Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksInOutDialog.py

Sat, 07 May 2011 20:31:28 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 07 May 2011 20:31:28 +0200
changeset 1018
949812411ab8
child 1131
7781e396c903
permissions
-rw-r--r--

Continued with Mercurial bookmark support.

1018
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show a list of incoming or outgoing bookmarks.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, \
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 QLineEdit
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui import E5MessageBox
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .Ui_HgBookmarksInOutDialog import Ui_HgBookmarksInOutDialog
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import Preferences
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 class HgBookmarksInOutDialog(QDialog, Ui_HgBookmarksInOutDialog):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Class implementing a dialog to show a list of incoming or outgoing bookmarks.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 INCOMING = 0
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 OUTGOING = 1
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 def __init__(self, vcs, mode, parent=None):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 Constructor
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 @param vcs reference to the vcs object
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param mode mode of the dialog (HgBookmarksInOutDialog.INCOMING,
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 HgBookmarksInOutDialog.OUTGOING)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param parent reference to the parent widget (QWidget)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 QDialog.__init__(self, parent)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.setupUi(self)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 if mode not in [self.INCOMING, self.OUTGOING]:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 raise ValueError("Bad value for mode")
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 if mode == self.INCOMING:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.setWindowTitle(self.trUtf8("Mercurial Incoming Bookmarks"))
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 elif mode == self.OUTGOING:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 self.setWindowTitle(self.trUtf8("Mercurial Outgoing Bookmarks"))
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.process = QProcess()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.vcs = vcs
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.mode = mode
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "")
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 self.process.finished.connect(self.__procFinished)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.process.readyReadStandardOutput.connect(self.__readStdout)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.process.readyReadStandardError.connect(self.__readStderr)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 def closeEvent(self, e):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 Private slot implementing a close event handler.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @param e close event (QCloseEvent)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 if self.process is not None and \
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.process.state() != QProcess.NotRunning:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.process.terminate()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 QTimer.singleShot(2000, self.process.kill)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.process.waitForFinished(3000)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 e.accept()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def start(self, path):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Public slot to start the bookmarks command.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @param path name of directory to be listed (string)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self.errorGroup.hide()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.intercept = False
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.activateWindow()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 dname, fname = self.vcs.splitPath(path)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 # find the root of the repo
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 repodir = dname
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 while not os.path.isdir(os.path.join(repodir, self.vcs.adminDir)):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 repodir = os.path.dirname(repodir)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 if repodir == os.sep:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 return
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 args = []
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 if self.mode == self.INCOMING:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 args.append('incoming')
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 elif self.mode == self.OUTGOING:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 args.append('outgoing')
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 else:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 raise ValueError("Bad value for mode")
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 args.append('--bookmarks')
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.process.kill()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.process.setWorkingDirectory(repodir)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.process.start('hg', args)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 procStarted = self.process.waitForStarted()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 if not procStarted:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.inputGroup.setEnabled(False)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.inputGroup.hide()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 E5MessageBox.critical(self,
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.trUtf8('Process Generation Error'),
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.trUtf8(
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 'The process {0} could not be started. '
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 'Ensure, that it is in the search path.'
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 ).format('hg'))
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 else:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.inputGroup.setEnabled(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.inputGroup.show()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 def __finish(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 Private slot called when the process finished or the user pressed the button.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 if self.process is not None and \
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.process.state() != QProcess.NotRunning:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.process.terminate()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 QTimer.singleShot(2000, self.process.kill)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.process.waitForFinished(3000)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.inputGroup.setEnabled(False)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.inputGroup.hide()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.process = None
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if self.bookmarksList.topLevelItemCount() == 0:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 # no bookmarks defined
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.__generateItem(self.trUtf8("no bookmarks found"), "")
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 self.bookmarksList.doItemsLayout()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.__resizeColumns()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 self.__resort()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 def on_buttonBox_clicked(self, button):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 Private slot called by a button of the button box clicked.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @param button button that was clicked (QAbstractButton)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 if button == self.buttonBox.button(QDialogButtonBox.Close):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 self.close()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.__finish()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 def __procFinished(self, exitCode, exitStatus):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 Private slot connected to the finished signal.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 @param exitCode exit code of the process (integer)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @param exitStatus exit status of the process (QProcess.ExitStatus)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 self.__finish()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 def __resort(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 Private method to resort the tree.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.bookmarksList.sortItems(self.bookmarksList.sortColumn(),
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 self.bookmarksList.header().sortIndicatorOrder())
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 def __resizeColumns(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 Private method to resize the list columns.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 self.bookmarksList.header().resizeSections(QHeaderView.ResizeToContents)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 self.bookmarksList.header().setStretchLastSection(True)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 def __generateItem(self, changeset, name):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 Private method to generate a bookmark item in the bookmarks list.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 @param changeset changeset of the bookmark (string)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 @param name name of the bookmark (string)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 itm = QTreeWidgetItem(self.bookmarksList, [
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 name,
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 changeset])
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 itm.setTextAlignment(1, Qt.AlignRight)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 def __readStdout(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 Private slot to handle the readyReadStdout signal.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 It reads the output of the process, formats it and inserts it into
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 the contents pane.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.process.setReadChannel(QProcess.StandardOutput)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 while self.process.canReadLine():
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 s = str(self.process.readLine(),
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 Preferences.getSystem("IOEncoding"),
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 'replace')
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 if s.startswith(" "):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 l = s.strip().split()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 changeset = l[-1]
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 del l[-1]
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 name = " ".join(l)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.__generateItem(changeset, name)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 def __readStderr(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 Private slot to handle the readyReadStderr signal.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 It reads the error output of the process and inserts it into the
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 error pane.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 if self.process is not None:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.errorGroup.show()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 s = str(self.process.readAllStandardError(),
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 Preferences.getSystem("IOEncoding"),
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 'replace')
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 self.errors.insertPlainText(s)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.errors.ensureCursorVisible()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 def on_passwordCheckBox_toggled(self, isOn):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 Private slot to handle the password checkbox toggled.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 @param isOn flag indicating the status of the check box (boolean)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 if isOn:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 self.input.setEchoMode(QLineEdit.Password)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 else:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 self.input.setEchoMode(QLineEdit.Normal)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 @pyqtSlot()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 def on_sendButton_clicked(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 Private slot to send the input to the subversion process.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 input = self.input.text()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 input += os.linesep
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 if self.passwordCheckBox.isChecked():
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 self.errors.insertPlainText(os.linesep)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.errors.ensureCursorVisible()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 else:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 self.errors.insertPlainText(input)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 self.errors.ensureCursorVisible()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 self.process.write(input)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 self.passwordCheckBox.setChecked(False)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 self.input.clear()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 def on_input_returnPressed(self):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 Private slot to handle the press of the return key in the input field.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 self.intercept = True
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 self.on_sendButton_clicked()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 def keyPressEvent(self, evt):
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 Protected slot to handle a key press event.
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 @param evt the key press event (QKeyEvent)
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 """
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 if self.intercept:
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 self.intercept = False
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 evt.accept()
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 return
949812411ab8 Continued with Mercurial bookmark support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 QDialog.keyPressEvent(self, evt)

eric ide

mercurial