14 pass |
14 pass |
15 |
15 |
16 import os |
16 import os |
17 |
17 |
18 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer, QCoreApplication |
18 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer, QCoreApplication |
19 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, \ |
19 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, \ |
20 QLineEdit |
20 QTreeWidgetItem, QLineEdit |
21 |
21 |
22 from E5Gui import E5MessageBox |
22 from E5Gui import E5MessageBox |
23 |
23 |
24 from .Ui_HgBookmarksInOutDialog import Ui_HgBookmarksInOutDialog |
24 from .Ui_HgBookmarksInOutDialog import Ui_HgBookmarksInOutDialog |
25 |
25 |
26 import Preferences |
26 import Preferences |
27 |
27 |
28 |
28 |
29 class HgBookmarksInOutDialog(QDialog, Ui_HgBookmarksInOutDialog): |
29 class HgBookmarksInOutDialog(QDialog, Ui_HgBookmarksInOutDialog): |
30 """ |
30 """ |
31 Class implementing a dialog to show a list of incoming or outgoing bookmarks. |
31 Class implementing a dialog to show a list of incoming or outgoing |
|
32 bookmarks. |
32 """ |
33 """ |
33 INCOMING = 0 |
34 INCOMING = 0 |
34 OUTGOING = 1 |
35 OUTGOING = 1 |
35 |
36 |
36 def __init__(self, vcs, mode, parent=None): |
37 def __init__(self, vcs, mode, parent=None): |
39 |
40 |
40 @param vcs reference to the vcs object |
41 @param vcs reference to the vcs object |
41 @param mode mode of the dialog (HgBookmarksInOutDialog.INCOMING, |
42 @param mode mode of the dialog (HgBookmarksInOutDialog.INCOMING, |
42 HgBookmarksInOutDialog.OUTGOING) |
43 HgBookmarksInOutDialog.OUTGOING) |
43 @param parent reference to the parent widget (QWidget) |
44 @param parent reference to the parent widget (QWidget) |
|
45 @exception ValueError raised to indicate an invalid dialog mode |
44 """ |
46 """ |
45 super(HgBookmarksInOutDialog, self).__init__(parent) |
47 super(HgBookmarksInOutDialog, self).__init__(parent) |
46 self.setupUi(self) |
48 self.setupUi(self) |
47 |
49 |
48 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
50 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
58 self.process = QProcess() |
60 self.process = QProcess() |
59 self.vcs = vcs |
61 self.vcs = vcs |
60 self.mode = mode |
62 self.mode = mode |
61 self.__hgClient = vcs.getClient() |
63 self.__hgClient = vcs.getClient() |
62 |
64 |
63 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "") |
65 self.bookmarksList.headerItem().setText( |
|
66 self.bookmarksList.columnCount(), "") |
64 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
67 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
65 |
68 |
66 self.process.finished.connect(self.__procFinished) |
69 self.process.finished.connect(self.__procFinished) |
67 self.process.readyReadStandardOutput.connect(self.__readStdout) |
70 self.process.readyReadStandardOutput.connect(self.__readStdout) |
68 self.process.readyReadStandardError.connect(self.__readStderr) |
71 self.process.readyReadStandardError.connect(self.__readStderr) |
91 def start(self, path): |
94 def start(self, path): |
92 """ |
95 """ |
93 Public slot to start the bookmarks command. |
96 Public slot to start the bookmarks command. |
94 |
97 |
95 @param path name of directory to be listed (string) |
98 @param path name of directory to be listed (string) |
|
99 @exception ValueError raised to indicate an invalid dialog mode |
96 """ |
100 """ |
97 self.errorGroup.hide() |
101 self.errorGroup.hide() |
98 |
102 |
99 self.intercept = False |
103 self.intercept = False |
100 self.activateWindow() |
104 self.activateWindow() |
149 self.inputGroup.setEnabled(True) |
153 self.inputGroup.setEnabled(True) |
150 self.inputGroup.show() |
154 self.inputGroup.show() |
151 |
155 |
152 def __finish(self): |
156 def __finish(self): |
153 """ |
157 """ |
154 Private slot called when the process finished or the user pressed the button. |
158 Private slot called when the process finished or the user pressed |
|
159 the button. |
155 """ |
160 """ |
156 if self.process is not None and \ |
161 if self.process is not None and \ |
157 self.process.state() != QProcess.NotRunning: |
162 self.process.state() != QProcess.NotRunning: |
158 self.process.terminate() |
163 self.process.terminate() |
159 QTimer.singleShot(2000, self.process.kill) |
164 QTimer.singleShot(2000, self.process.kill) |
163 self.inputGroup.hide() |
168 self.inputGroup.hide() |
164 |
169 |
165 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
170 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
166 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
171 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
167 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
172 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
168 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
173 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
174 Qt.OtherFocusReason) |
169 |
175 |
170 self.process = None |
176 self.process = None |
171 |
177 |
172 if self.bookmarksList.topLevelItemCount() == 0: |
178 if self.bookmarksList.topLevelItemCount() == 0: |
173 # no bookmarks defined |
179 # no bookmarks defined |
207 |
213 |
208 def __resizeColumns(self): |
214 def __resizeColumns(self): |
209 """ |
215 """ |
210 Private method to resize the list columns. |
216 Private method to resize the list columns. |
211 """ |
217 """ |
212 self.bookmarksList.header().resizeSections(QHeaderView.ResizeToContents) |
218 self.bookmarksList.header().resizeSections( |
|
219 QHeaderView.ResizeToContents) |
213 self.bookmarksList.header().setStretchLastSection(True) |
220 self.bookmarksList.header().setStretchLastSection(True) |
214 |
221 |
215 def __generateItem(self, changeset, name): |
222 def __generateItem(self, changeset, name): |
216 """ |
223 """ |
217 Private method to generate a bookmark item in the bookmarks list. |
224 Private method to generate a bookmark item in the bookmarks list. |