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_HgBookmarksListDialog import Ui_HgBookmarksListDialog |
24 from .Ui_HgBookmarksListDialog import Ui_HgBookmarksListDialog |
25 |
25 |
46 self.process = QProcess() |
46 self.process = QProcess() |
47 self.vcs = vcs |
47 self.vcs = vcs |
48 self.__bookmarksList = None |
48 self.__bookmarksList = None |
49 self.__hgClient = vcs.getClient() |
49 self.__hgClient = vcs.getClient() |
50 |
50 |
51 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "") |
51 self.bookmarksList.headerItem().setText( |
|
52 self.bookmarksList.columnCount(), "") |
52 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
53 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
53 |
54 |
54 self.process.finished.connect(self.__procFinished) |
55 self.process.finished.connect(self.__procFinished) |
55 self.process.readyReadStandardOutput.connect(self.__readStdout) |
56 self.process.readyReadStandardOutput.connect(self.__readStdout) |
56 self.process.readyReadStandardError.connect(self.__readStderr) |
57 self.process.readyReadStandardError.connect(self.__readStderr) |
134 self.inputGroup.setEnabled(True) |
135 self.inputGroup.setEnabled(True) |
135 self.inputGroup.show() |
136 self.inputGroup.show() |
136 |
137 |
137 def __finish(self): |
138 def __finish(self): |
138 """ |
139 """ |
139 Private slot called when the process finished or the user pressed the button. |
140 Private slot called when the process finished or the user pressed |
|
141 the button. |
140 """ |
142 """ |
141 if self.process is not None and \ |
143 if self.process is not None and \ |
142 self.process.state() != QProcess.NotRunning: |
144 self.process.state() != QProcess.NotRunning: |
143 self.process.terminate() |
145 self.process.terminate() |
144 QTimer.singleShot(2000, self.process.kill) |
146 QTimer.singleShot(2000, self.process.kill) |
148 self.inputGroup.hide() |
150 self.inputGroup.hide() |
149 |
151 |
150 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
152 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
151 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
153 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
152 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
154 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
153 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
155 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
156 Qt.OtherFocusReason) |
154 |
157 |
155 self.process = None |
158 self.process = None |
156 |
159 |
157 if self.bookmarksList.topLevelItemCount() == 0: |
160 if self.bookmarksList.topLevelItemCount() == 0: |
158 # no bookmarks defined |
161 # no bookmarks defined |
159 self.__generateItem(self.trUtf8("no bookmarks defined"), "", "", "") |
162 self.__generateItem( |
|
163 self.trUtf8("no bookmarks defined"), "", "", "") |
160 self.__resizeColumns() |
164 self.__resizeColumns() |
161 self.__resort() |
165 self.__resort() |
162 |
166 |
163 def on_buttonBox_clicked(self, button): |
167 def on_buttonBox_clicked(self, button): |
164 """ |
168 """ |
192 |
196 |
193 def __resizeColumns(self): |
197 def __resizeColumns(self): |
194 """ |
198 """ |
195 Private method to resize the list columns. |
199 Private method to resize the list columns. |
196 """ |
200 """ |
197 self.bookmarksList.header().resizeSections(QHeaderView.ResizeToContents) |
201 self.bookmarksList.header().resizeSections( |
|
202 QHeaderView.ResizeToContents) |
198 self.bookmarksList.header().setStretchLastSection(True) |
203 self.bookmarksList.header().setStretchLastSection(True) |
199 |
204 |
200 def __generateItem(self, revision, changeset, status, name): |
205 def __generateItem(self, revision, changeset, status, name): |
201 """ |
206 """ |
202 Private method to generate a bookmark item in the bookmarks list. |
207 Private method to generate a bookmark item in the bookmarks list. |