6 """ |
6 """ |
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 import re |
12 from PyQt5.QtCore import pyqtSlot, Qt, QRegExp, QCoreApplication |
12 |
|
13 from PyQt5.QtCore import pyqtSlot, Qt, QCoreApplication |
13 from PyQt5.QtWidgets import ( |
14 from PyQt5.QtWidgets import ( |
14 QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem |
15 QDialog, QDialogButtonBox, QHeaderView, QTreeWidgetItem |
15 ) |
16 ) |
16 |
17 |
17 from .Ui_HgGpgSignaturesDialog import Ui_HgGpgSignaturesDialog |
18 from .Ui_HgGpgSignaturesDialog import Ui_HgGpgSignaturesDialog |
228 Private method to filter the log entries. |
229 Private method to filter the log entries. |
229 """ |
230 """ |
230 searchRxText = self.rxEdit.text() |
231 searchRxText = self.rxEdit.text() |
231 filterTop = self.categoryCombo.currentText() == self.tr("Revision") |
232 filterTop = self.categoryCombo.currentText() == self.tr("Revision") |
232 if filterTop and searchRxText.startswith("^"): |
233 if filterTop and searchRxText.startswith("^"): |
233 searchRx = QRegExp( |
234 searchRx = re.compile( |
234 r"^\s*{0}".format(searchRxText[1:]), Qt.CaseInsensitive) |
235 r"^\s*{0}".format(searchRxText[1:]), re.IGNORECASE) |
235 else: |
236 else: |
236 searchRx = QRegExp(searchRxText, Qt.CaseInsensitive) |
237 searchRx = re.compile(searchRxText, re.IGNORECASE) |
237 for topIndex in range(self.signaturesList.topLevelItemCount()): |
238 for topIndex in range(self.signaturesList.topLevelItemCount()): |
238 topLevelItem = self.signaturesList.topLevelItem(topIndex) |
239 topLevelItem = self.signaturesList.topLevelItem(topIndex) |
239 if filterTop: |
240 if filterTop: |
240 topLevelItem.setHidden( |
241 topLevelItem.setHidden( |
241 searchRx.indexIn(topLevelItem.text(0)) == -1) |
242 searchRx.search(topLevelItem.text(0)) is None) |
242 else: |
243 else: |
243 visibleChildren = topLevelItem.childCount() |
244 visibleChildren = topLevelItem.childCount() |
244 for childIndex in range(topLevelItem.childCount()): |
245 for childIndex in range(topLevelItem.childCount()): |
245 childItem = topLevelItem.child(childIndex) |
246 childItem = topLevelItem.child(childIndex) |
246 if searchRx.indexIn(childItem.text(0)) == -1: |
247 if searchRx.search(childItem.text(0)) is None: |
247 childItem.setHidden(True) |
248 childItem.setHidden(True) |
248 visibleChildren -= 1 |
249 visibleChildren -= 1 |
249 else: |
250 else: |
250 childItem.setHidden(False) |
251 childItem.setHidden(False) |
251 topLevelItem.setHidden(visibleChildren == 0) |
252 topLevelItem.setHidden(visibleChildren == 0) |