7 Module implementing a dialog showing signed changesets. |
7 Module implementing a dialog showing signed changesets. |
8 """ |
8 """ |
9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, Qt, QRegExp, QCoreApplication |
12 from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, Qt, QRegExp, \ |
13 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem, \ |
13 QCoreApplication |
14 QLineEdit |
14 from PyQt4.QtGui import QDialog, QDialogButtonBox, QHeaderView, \ |
|
15 QTreeWidgetItem, QLineEdit |
15 |
16 |
16 from E5Gui import E5MessageBox |
17 from E5Gui import E5MessageBox |
17 |
18 |
18 from .Ui_HgGpgSignaturesDialog import Ui_HgGpgSignaturesDialog |
19 from .Ui_HgGpgSignaturesDialog import Ui_HgGpgSignaturesDialog |
19 |
20 |
122 self.inputGroup.setEnabled(True) |
123 self.inputGroup.setEnabled(True) |
123 self.inputGroup.show() |
124 self.inputGroup.show() |
124 |
125 |
125 def __finish(self): |
126 def __finish(self): |
126 """ |
127 """ |
127 Private slot called when the process finished or the user pressed the button. |
128 Private slot called when the process finished or the user pressed |
|
129 the button. |
128 """ |
130 """ |
129 if self.process is not None and \ |
131 if self.process is not None and \ |
130 self.process.state() != QProcess.NotRunning: |
132 self.process.state() != QProcess.NotRunning: |
131 self.process.terminate() |
133 self.process.terminate() |
132 QTimer.singleShot(2000, self.process.kill) |
134 QTimer.singleShot(2000, self.process.kill) |
136 self.inputGroup.hide() |
138 self.inputGroup.hide() |
137 |
139 |
138 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
140 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
139 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
141 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
140 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
142 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
141 self.buttonBox.button(QDialogButtonBox.Close).setFocus(Qt.OtherFocusReason) |
143 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
144 Qt.OtherFocusReason) |
142 |
145 |
143 self.process = None |
146 self.process = None |
144 |
147 |
145 if self.signaturesList.topLevelItemCount() == 0: |
148 if self.signaturesList.topLevelItemCount() == 0: |
146 # no patches present |
149 # no patches present |
180 |
183 |
181 def __resizeColumns(self): |
184 def __resizeColumns(self): |
182 """ |
185 """ |
183 Private method to resize the list columns. |
186 Private method to resize the list columns. |
184 """ |
187 """ |
185 self.signaturesList.header().resizeSections(QHeaderView.ResizeToContents) |
188 self.signaturesList.header().resizeSections( |
|
189 QHeaderView.ResizeToContents) |
186 self.signaturesList.header().setStretchLastSection(True) |
190 self.signaturesList.header().setStretchLastSection(True) |
187 |
191 |
188 def __generateItem(self, revision, changeset, signature): |
192 def __generateItem(self, revision, changeset, signature): |
189 """ |
193 """ |
190 Private method to generate a patch item in the list of patches. |
194 Private method to generate a patch item in the list of patches. |
195 """ |
199 """ |
196 if revision == "" and changeset == "": |
200 if revision == "" and changeset == "": |
197 QTreeWidgetItem(self.signaturesList, [signature]) |
201 QTreeWidgetItem(self.signaturesList, [signature]) |
198 else: |
202 else: |
199 revString = "{0:>7}:{1}".format(revision, changeset) |
203 revString = "{0:>7}:{1}".format(revision, changeset) |
200 topItems = self.signaturesList.findItems(revString, Qt.MatchExactly) |
204 topItems = self.signaturesList.findItems( |
|
205 revString, Qt.MatchExactly) |
201 if len(topItems) == 0: |
206 if len(topItems) == 0: |
202 # first signature for this changeset |
207 # first signature for this changeset |
203 topItm = QTreeWidgetItem(self.signaturesList, [ |
208 topItm = QTreeWidgetItem(self.signaturesList, [ |
204 "{0:>7}:{1}".format(revision, changeset)]) |
209 "{0:>7}:{1}".format(revision, changeset)]) |
205 topItm.setExpanded(True) |
210 topItm.setExpanded(True) |
277 @pyqtSlot() |
282 @pyqtSlot() |
278 def on_verifyButton_clicked(self): |
283 def on_verifyButton_clicked(self): |
279 """ |
284 """ |
280 Private slot to verify the signatures of the selected revision. |
285 Private slot to verify the signatures of the selected revision. |
281 """ |
286 """ |
282 rev = self.signaturesList.selectedItems()[0].text(0).split(":")[0].strip() |
287 rev = self.signaturesList.selectedItems()[0].text(0)\ |
|
288 .split(":")[0].strip() |
283 self.vcs.getExtensionObject("gpg")\ |
289 self.vcs.getExtensionObject("gpg")\ |
284 .hgGpgVerifySignatures(self.__path, rev) |
290 .hgGpgVerifySignatures(self.__path, rev) |
285 |
291 |
286 @pyqtSlot(str) |
292 @pyqtSlot(str) |
287 def on_categoryCombo_activated(self, txt): |
293 def on_categoryCombo_activated(self, txt): |
306 Private method to filter the log entries. |
312 Private method to filter the log entries. |
307 """ |
313 """ |
308 searchRxText = self.rxEdit.text() |
314 searchRxText = self.rxEdit.text() |
309 filterTop = self.categoryCombo.currentText() == self.trUtf8("Revision") |
315 filterTop = self.categoryCombo.currentText() == self.trUtf8("Revision") |
310 if filterTop and searchRxText.startswith("^"): |
316 if filterTop and searchRxText.startswith("^"): |
311 searchRx = QRegExp("^\s*{0}".format(searchRxText[1:]), Qt.CaseInsensitive) |
317 searchRx = QRegExp( |
|
318 "^\s*{0}".format(searchRxText[1:]), Qt.CaseInsensitive) |
312 else: |
319 else: |
313 searchRx = QRegExp(searchRxText, Qt.CaseInsensitive) |
320 searchRx = QRegExp(searchRxText, Qt.CaseInsensitive) |
314 for topIndex in range(self.signaturesList.topLevelItemCount()): |
321 for topIndex in range(self.signaturesList.topLevelItemCount()): |
315 topLevelItem = self.signaturesList.topLevelItem(topIndex) |
322 topLevelItem = self.signaturesList.topLevelItem(topIndex) |
316 if filterTop: |
323 if filterTop: |
317 topLevelItem.setHidden(searchRx.indexIn(topLevelItem.text(0)) == -1) |
324 topLevelItem.setHidden( |
|
325 searchRx.indexIn(topLevelItem.text(0)) == -1) |
318 else: |
326 else: |
319 visibleChildren = topLevelItem.childCount() |
327 visibleChildren = topLevelItem.childCount() |
320 for childIndex in range(topLevelItem.childCount()): |
328 for childIndex in range(topLevelItem.childCount()): |
321 childItem = topLevelItem.child(childIndex) |
329 childItem = topLevelItem.child(childIndex) |
322 if searchRx.indexIn(childItem.text(0)) == -1: |
330 if searchRx.indexIn(childItem.text(0)) == -1: |