88 itm.setData(0, self.filenameRole, file) |
94 itm.setData(0, self.filenameRole, file) |
89 itm.setData(0, self.lineRole, int(line)) |
95 itm.setData(0, self.lineRole, int(line)) |
90 itm.setData(0, self.errorRole, error) |
96 itm.setData(0, self.errorRole, error) |
91 itm.setData(0, self.warningRole, isWarning) |
97 itm.setData(0, self.warningRole, isWarning) |
92 |
98 |
|
99 def prepare(self, fileList, project): |
|
100 """ |
|
101 Public method to prepare the dialog with a list of filenames. |
|
102 |
|
103 @param fileList list of filenames (list of strings) |
|
104 @param project reference to the project object (Project) |
|
105 """ |
|
106 self.__fileList = fileList[:] |
|
107 self.__project = project |
|
108 |
|
109 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
|
110 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
|
111 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
|
112 |
|
113 self.filterFrame.setVisible(True) |
|
114 |
|
115 self.__data = self.__project.getData("CHECKERSPARMS", "SyntaxChecker") |
|
116 if self.__data is None or "ExcludeFiles" not in self.__data: |
|
117 self.__data = {"ExcludeFiles" : ""} |
|
118 self.excludeFilesEdit.setText(self.__data["ExcludeFiles"]) |
|
119 |
93 def start(self, fn, codestring = ""): |
120 def start(self, fn, codestring = ""): |
94 """ |
121 """ |
95 Public slot to start the syntax check. |
122 Public slot to start the syntax check. |
96 |
123 |
97 @param fn file or list of files or directory to be checked |
124 @param fn file or list of files or directory to be checked |
98 (string or list of strings) |
125 (string or list of strings) |
99 @param codestring string containing the code to be checked (string). |
126 @param codestring string containing the code to be checked (string). |
100 If this is given, file must be a single file name. |
127 If this is given, file must be a single file name. |
101 """ |
128 """ |
|
129 self.cancelled = False |
|
130 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
|
131 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
|
132 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
|
133 QApplication.processEvents() |
|
134 |
102 if isinstance(fn, list): |
135 if isinstance(fn, list): |
103 files = fn |
136 files = fn |
104 elif os.path.isdir(fn): |
137 elif os.path.isdir(fn): |
105 files = [] |
138 files = [] |
106 for ext in Preferences.getPython("Python3Extensions"): |
139 for ext in Preferences.getPython("Python3Extensions"): |
196 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
229 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
197 self.__finish() |
230 self.__finish() |
198 elif button == self.showButton: |
231 elif button == self.showButton: |
199 self.on_showButton_clicked() |
232 self.on_showButton_clicked() |
200 |
233 |
|
234 @pyqtSlot() |
|
235 def on_startButton_clicked(self): |
|
236 """ |
|
237 Private slot to start a code metrics run. |
|
238 """ |
|
239 fileList = self.__fileList[:] |
|
240 |
|
241 filterString = self.excludeFilesEdit.text() |
|
242 if "ExcludeFiles" not in self.__data or \ |
|
243 filterString != self.__data["ExcludeFiles"]: |
|
244 self.__data["ExcludeFiles"] = filterString |
|
245 self.__project.setData("CHECKERSPARMS", "SyntaxChecker", self.__data) |
|
246 filterList = filterString.split(",") |
|
247 if filterList: |
|
248 for filter in filterList: |
|
249 fileList = \ |
|
250 [f for f in fileList if not fnmatch.fnmatch(f, filter.strip())] |
|
251 |
|
252 self.resultList.clear() |
|
253 self.start(fileList) |
|
254 |
201 def on_resultList_itemActivated(self, itm, col): |
255 def on_resultList_itemActivated(self, itm, col): |
202 """ |
256 """ |
203 Private slot to handle the activation of an item. |
257 Private slot to handle the activation of an item. |
204 |
258 |
205 @param itm reference to the activated item (QTreeWidgetItem) |
259 @param itm reference to the activated item (QTreeWidgetItem) |