5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to show matching references/definitions. |
7 Module implementing a dialog to show matching references/definitions. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt5.QtCore import pyqtSlot, Qt |
10 from PyQt6.QtCore import pyqtSlot, Qt |
11 from PyQt5.QtWidgets import ( |
11 from PyQt6.QtWidgets import ( |
12 QDialog, QTreeWidgetItem, QDialogButtonBox, QHeaderView |
12 QDialog, QTreeWidgetItem, QDialogButtonBox, QHeaderView |
13 ) |
13 ) |
14 |
14 |
15 from E5Gui.E5Application import e5App |
15 from EricWidgets.EricApplication import ericApp |
16 |
16 |
17 from .Ui_MatchesDialog import Ui_MatchesDialog |
17 from .Ui_MatchesDialog import Ui_MatchesDialog |
18 |
18 |
19 |
19 |
20 class MatchesDialog(QDialog, Ui_MatchesDialog): |
20 class MatchesDialog(QDialog, Ui_MatchesDialog): |
21 """ |
21 """ |
22 Class implementing a dialog to show matching references/definitions. |
22 Class implementing a dialog to show matching references/definitions. |
23 """ |
23 """ |
24 FilePathRole = Qt.UserRole |
24 FilePathRole = Qt.ItemDataRole.UserRole |
25 |
25 |
26 def __init__(self, ui, showConfidence, parent=None, name=None): |
26 def __init__(self, ui, showConfidence, parent=None, name=None): |
27 """ |
27 """ |
28 Constructor |
28 Constructor |
29 |
29 |
40 QDialog.__init__(self, parent) |
40 QDialog.__init__(self, parent) |
41 if name: |
41 if name: |
42 self.setObjectName(name) |
42 self.setObjectName(name) |
43 self.setupUi(self) |
43 self.setupUi(self) |
44 |
44 |
45 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
45 self.buttonBox.button( |
|
46 QDialogButtonBox.StandardButton.Close).setDefault(True) |
46 |
47 |
47 self.ui = ui |
48 self.ui = ui |
48 self.__showConfidence = showConfidence |
49 self.__showConfidence = showConfidence |
49 self.__e5project = e5App().getObject("Project") |
50 self.__e5project = ericApp().getObject("Project") |
50 |
51 |
51 if not self.__showConfidence: |
52 if not self.__showConfidence: |
52 self.matchesList.setColumnHidden(2, True) |
53 self.matchesList.setColumnHidden(2, True) |
53 self.matchesList.header().setSortIndicator(0, Qt.AscendingOrder) |
54 self.matchesList.header().setSortIndicator( |
|
55 0, Qt.SortOrder.AscendingOrder) |
54 |
56 |
55 def __resort(self): |
57 def __resort(self): |
56 """ |
58 """ |
57 Private method to resort the tree. |
59 Private method to resort the tree. |
58 """ |
60 """ |
62 |
64 |
63 def __resizeColumns(self): |
65 def __resizeColumns(self): |
64 """ |
66 """ |
65 Private method to resize the list columns. |
67 Private method to resize the list columns. |
66 """ |
68 """ |
67 self.matchesList.header().resizeSections(QHeaderView.ResizeToContents) |
69 self.matchesList.header().resizeSections( |
|
70 QHeaderView.ResizeMode.ResizeToContents) |
68 self.matchesList.header().setStretchLastSection(True) |
71 self.matchesList.header().setStretchLastSection(True) |
69 |
72 |
70 @pyqtSlot(QTreeWidgetItem, int) |
73 @pyqtSlot(QTreeWidgetItem, int) |
71 def on_matchesList_itemActivated(self, item, column): |
74 def on_matchesList_itemActivated(self, item, column): |
72 """ |
75 """ |
77 @param column column the item was activated in |
80 @param column column the item was activated in |
78 @type int |
81 @type int |
79 """ |
82 """ |
80 lineno = int(item.text(1)) |
83 lineno = int(item.text(1)) |
81 fn = item.data(0, MatchesDialog.FilePathRole) |
84 fn = item.data(0, MatchesDialog.FilePathRole) |
82 e5App().getObject("ViewManager").openSourceFile(fn, lineno) |
85 ericApp().getObject("ViewManager").openSourceFile(fn, lineno) |
83 |
86 |
84 def addEntry(self, filename, lineno, unsure=False): |
87 def addEntry(self, filename, lineno, unsure=False): |
85 """ |
88 """ |
86 Public slot to add an entry to the list. |
89 Public slot to add an entry to the list. |
87 |
90 |
97 self.matchesList, |
100 self.matchesList, |
98 [self.__e5project.getRelativePath(filename), |
101 [self.__e5project.getRelativePath(filename), |
99 " {0:5d}".format(lineno), |
102 " {0:5d}".format(lineno), |
100 " {0:5d}%".format(conf)]) |
103 " {0:5d}%".format(conf)]) |
101 itm.setData(0, MatchesDialog.FilePathRole, filename) |
104 itm.setData(0, MatchesDialog.FilePathRole, filename) |
102 itm.setTextAlignment(1, Qt.AlignRight) |
105 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight) |
103 itm.setTextAlignment(2, Qt.AlignRight) |
106 itm.setTextAlignment(2, Qt.AlignmentFlag.AlignRight) |
104 self.__resort() |
107 self.__resort() |
105 self.__resizeColumns() |
108 self.__resizeColumns() |