8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer, QCoreApplication |
12 from PyQt4.QtCore import pyqtSlot, QProcess, Qt, QTimer, QCoreApplication |
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, \ |
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, \ |
14 QLineEdit |
14 QTreeWidgetItem, QLineEdit |
15 |
15 |
16 from E5Gui import E5MessageBox |
16 from E5Gui import E5MessageBox |
17 |
17 |
18 from .Ui_HgBookmarksListDialog import Ui_HgBookmarksListDialog |
18 from .Ui_HgBookmarksListDialog import Ui_HgBookmarksListDialog |
19 |
19 |
40 self.process = QProcess() |
40 self.process = QProcess() |
41 self.vcs = vcs |
41 self.vcs = vcs |
42 self.__bookmarksList = None |
42 self.__bookmarksList = None |
43 self.__hgClient = vcs.getClient() |
43 self.__hgClient = vcs.getClient() |
44 |
44 |
45 self.bookmarksList.headerItem().setText(self.bookmarksList.columnCount(), "") |
45 self.bookmarksList.headerItem().setText( |
|
46 self.bookmarksList.columnCount(), "") |
46 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
47 self.bookmarksList.header().setSortIndicator(3, Qt.AscendingOrder) |
47 |
48 |
48 self.process.finished.connect(self.__procFinished) |
49 self.process.finished.connect(self.__procFinished) |
49 self.process.readyReadStandardOutput.connect(self.__readStdout) |
50 self.process.readyReadStandardOutput.connect(self.__readStdout) |
50 self.process.readyReadStandardError.connect(self.__readStderr) |
51 self.process.readyReadStandardError.connect(self.__readStderr) |
128 self.inputGroup.setEnabled(True) |
129 self.inputGroup.setEnabled(True) |
129 self.inputGroup.show() |
130 self.inputGroup.show() |
130 |
131 |
131 def __finish(self): |
132 def __finish(self): |
132 """ |
133 """ |
133 Private slot called when the process finished or the user pressed the button. |
134 Private slot called when the process finished or the user pressed |
|
135 the button. |
134 """ |
136 """ |
135 if self.process is not None and \ |
137 if self.process is not None and \ |
136 self.process.state() != QProcess.NotRunning: |
138 self.process.state() != QProcess.NotRunning: |
137 self.process.terminate() |
139 self.process.terminate() |
138 QTimer.singleShot(2000, self.process.kill) |
140 QTimer.singleShot(2000, self.process.kill) |
142 self.inputGroup.hide() |
144 self.inputGroup.hide() |
143 |
145 |
144 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
146 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
145 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
147 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
146 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
148 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
147 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
149 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
150 Qt.OtherFocusReason) |
148 |
151 |
149 self.process = None |
152 self.process = None |
150 |
153 |
151 if self.bookmarksList.topLevelItemCount() == 0: |
154 if self.bookmarksList.topLevelItemCount() == 0: |
152 # no bookmarks defined |
155 # no bookmarks defined |
153 self.__generateItem(self.trUtf8("no bookmarks defined"), "", "", "") |
156 self.__generateItem( |
|
157 self.trUtf8("no bookmarks defined"), "", "", "") |
154 self.__resizeColumns() |
158 self.__resizeColumns() |
155 self.__resort() |
159 self.__resort() |
156 |
160 |
157 def on_buttonBox_clicked(self, button): |
161 def on_buttonBox_clicked(self, button): |
158 """ |
162 """ |
186 |
190 |
187 def __resizeColumns(self): |
191 def __resizeColumns(self): |
188 """ |
192 """ |
189 Private method to resize the list columns. |
193 Private method to resize the list columns. |
190 """ |
194 """ |
191 self.bookmarksList.header().resizeSections(QHeaderView.ResizeToContents) |
195 self.bookmarksList.header().resizeSections( |
|
196 QHeaderView.ResizeToContents) |
192 self.bookmarksList.header().setStretchLastSection(True) |
197 self.bookmarksList.header().setStretchLastSection(True) |
193 |
198 |
194 def __generateItem(self, revision, changeset, status, name): |
199 def __generateItem(self, revision, changeset, status, name): |
195 """ |
200 """ |
196 Private method to generate a bookmark item in the bookmarks list. |
201 Private method to generate a bookmark item in the bookmarks list. |