17 from .Ui_TabnannyDialog import Ui_TabnannyDialog |
18 from .Ui_TabnannyDialog import Ui_TabnannyDialog |
18 |
19 |
19 from . import Tabnanny |
20 from . import Tabnanny |
20 import Utilities |
21 import Utilities |
21 import Preferences |
22 import Preferences |
|
23 import UI.PixmapCache |
22 |
24 |
23 class TabnannyDialog(QDialog, Ui_TabnannyDialog): |
25 class TabnannyDialog(QDialog, Ui_TabnannyDialog): |
24 """ |
26 """ |
25 Class implementing a dialog to show the results of the tabnanny check run. |
27 Class implementing a dialog to show the results of the tabnanny check run. |
26 """ |
28 """ |
40 self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) |
42 self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) |
41 |
43 |
42 self.noResults = True |
44 self.noResults = True |
43 self.cancelled = False |
45 self.cancelled = False |
44 |
46 |
|
47 self.__fileList = [] |
|
48 self.__project = None |
|
49 self.clearButton.setIcon(UI.PixmapCache.getIcon("clearLeft.png")) |
|
50 self.filterFrame.setVisible(False) |
|
51 |
45 def __resort(self): |
52 def __resort(self): |
46 """ |
53 """ |
47 Private method to resort the tree. |
54 Private method to resort the tree. |
48 """ |
55 """ |
49 self.resultList.sortItems(self.resultList.sortColumn(), |
56 self.resultList.sortItems(self.resultList.sortColumn(), |
58 @param sourcecode faulty line of code (string) |
65 @param sourcecode faulty line of code (string) |
59 """ |
66 """ |
60 itm = QTreeWidgetItem(self.resultList, [file, str(line), sourcecode]) |
67 itm = QTreeWidgetItem(self.resultList, [file, str(line), sourcecode]) |
61 itm.setTextAlignment(1, Qt.AlignRight) |
68 itm.setTextAlignment(1, Qt.AlignRight) |
62 |
69 |
|
70 def prepare(self, fileList, project): |
|
71 """ |
|
72 Public method to prepare the dialog with a list of filenames. |
|
73 |
|
74 @param fileList list of filenames (list of strings) |
|
75 @param project reference to the project object (Project) |
|
76 """ |
|
77 self.__fileList = fileList[:] |
|
78 self.__project = project |
|
79 |
|
80 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
|
81 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
|
82 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
|
83 |
|
84 self.filterFrame.setVisible(True) |
|
85 |
|
86 self.__data = self.__project.getData("CHECKERSPARMS", "Tabnanny") |
|
87 if self.__data is None or "ExcludeFiles" not in self.__data: |
|
88 self.__data = {"ExcludeFiles" : ""} |
|
89 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
|
90 |
63 def start(self, fn): |
91 def start(self, fn): |
64 """ |
92 """ |
65 Public slot to start the tabnanny check. |
93 Public slot to start the tabnanny check. |
66 |
94 |
67 @param fn File or list of files or directory to be checked |
95 @param fn File or list of files or directory to be checked |
68 (string or list of strings) |
96 (string or list of strings) |
69 """ |
97 """ |
|
98 self.cancelled = False |
|
99 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
|
100 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
|
101 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
|
102 QApplication.processEvents() |
|
103 |
70 if isinstance(fn, list): |
104 if isinstance(fn, list): |
71 files = fn |
105 files = fn |
72 elif os.path.isdir(fn): |
106 elif os.path.isdir(fn): |
73 files = [] |
107 files = [] |
74 for ext in Preferences.getPython("Python3Extensions"): |
108 for ext in Preferences.getPython("Python3Extensions"): |
125 if button == self.buttonBox.button(QDialogButtonBox.Close): |
159 if button == self.buttonBox.button(QDialogButtonBox.Close): |
126 self.close() |
160 self.close() |
127 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
161 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
128 self.__finish() |
162 self.__finish() |
129 |
163 |
|
164 @pyqtSlot() |
|
165 def on_startButton_clicked(self): |
|
166 """ |
|
167 Private slot to start a code metrics run. |
|
168 """ |
|
169 fileList = self.__fileList[:] |
|
170 |
|
171 filterString = self.excludeFilesEdit.text() |
|
172 if "ExcludeFiles" not in self.__data or \ |
|
173 filterString != self.__data["ExcludeFiles"]: |
|
174 self.__data["ExcludeFiles"] = filterString |
|
175 self.__project.setData("CHECKERSPARMS", "Tabnanny", self.__data) |
|
176 filterList = filterString.split(",") |
|
177 if filterList: |
|
178 for filter in filterList: |
|
179 fileList = \ |
|
180 [f for f in fileList if not fnmatch.fnmatch(f, filter.strip())] |
|
181 |
|
182 self.resultList.clear() |
|
183 self.start(fileList) |
|
184 |
130 def on_resultList_itemActivated(self, itm, col): |
185 def on_resultList_itemActivated(self, itm, col): |
131 """ |
186 """ |
132 Private slot to handle the activation of an item. |
187 Private slot to handle the activation of an item. |
133 |
188 |
134 @param itm reference to the activated item (QTreeWidgetItem) |
189 @param itm reference to the activated item (QTreeWidgetItem) |