RefactoringRope/MatchesDialog.py

changeset 21
46236998ad5f
parent 20
83b71483e198
child 35
79e19b499675
equal deleted inserted replaced
20:83b71483e198 21:46236998ad5f
18 18
19 class MatchesDialog(QDialog, Ui_MatchesDialog): 19 class MatchesDialog(QDialog, Ui_MatchesDialog):
20 """ 20 """
21 Class implementing a dialog to show matching references/definitions. 21 Class implementing a dialog to show matching references/definitions.
22 """ 22 """
23 FilePathRole = Qt.UserRole
24
23 def __init__(self, ui, showConfidence, parent=None, name=None): 25 def __init__(self, ui, showConfidence, parent=None, name=None):
24 """ 26 """
25 Constructor 27 Constructor
26 28
27 @param ui reference to the UI object 29 @param ui reference to the UI object
37 39
38 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 40 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
39 41
40 self.ui = ui 42 self.ui = ui
41 self.__showConfidence = showConfidence 43 self.__showConfidence = showConfidence
44 self.__e5project = e5App().getObject("Project")
42 45
43 if not self.__showConfidence: 46 if not self.__showConfidence:
44 self.matchesList.setColumnHidden(2, True) 47 self.matchesList.setColumnHidden(2, True)
45 self.matchesList.header().setSortIndicator(0, Qt.AscendingOrder) 48 self.matchesList.header().setSortIndicator(0, Qt.AscendingOrder)
46 49
62 def on_matchesList_itemActivated(self, item, column): 65 def on_matchesList_itemActivated(self, item, column):
63 """ 66 """
64 Private slot to handle the itemActivated signal of the list. 67 Private slot to handle the itemActivated signal of the list.
65 """ 68 """
66 lineno = int(item.text(1)) 69 lineno = int(item.text(1))
67 fn = item.text(0) 70 fn = item.data(0, MatchesDialog.FilePathRole)
68 e5App().getObject("ViewManager").openSourceFile(fn, lineno) 71 e5App().getObject("ViewManager").openSourceFile(fn, lineno)
69 72
70 def addEntry(self, resource, lineno, unsure=False): 73 def addEntry(self, resource, lineno, unsure=False):
71 """ 74 """
72 Public slot to add an entry to the list. 75 Public slot to add an entry to the list.
79 if unsure: 82 if unsure:
80 conf = 50 83 conf = 50
81 else: 84 else:
82 conf = 100 85 conf = 100
83 itm = QTreeWidgetItem(self.matchesList, 86 itm = QTreeWidgetItem(self.matchesList,
84 [resource.real_path, 87 [self.__e5project.getRelativePath(resource.real_path),
85 " {0:5d}".format(lineno), 88 " {0:5d}".format(lineno),
86 " {0:5d}%".format(conf)]) 89 " {0:5d}%".format(conf)])
90 itm.setData(0, MatchesDialog.FilePathRole, resource.real_path)
87 itm.setTextAlignment(1, Qt.AlignRight) 91 itm.setTextAlignment(1, Qt.AlignRight)
88 itm.setTextAlignment(2, Qt.AlignRight) 92 itm.setTextAlignment(2, Qt.AlignRight)
89 self.__resort() 93 self.__resort()
90 self.__resizeColumns() 94 self.__resizeColumns()

eric ide

mercurial