41 self.setupUi(self) |
43 self.setupUi(self) |
42 |
44 |
43 self.showButton = self.buttonBox.addButton(\ |
45 self.showButton = self.buttonBox.addButton(\ |
44 self.trUtf8("Show"), QDialogButtonBox.ActionRole) |
46 self.trUtf8("Show"), QDialogButtonBox.ActionRole) |
45 self.showButton.setToolTip(\ |
47 self.showButton.setToolTip(\ |
46 self.trUtf8("Press to show all files containing a syntax error")) |
48 self.trUtf8("Press to show all files containing an issue")) |
47 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
49 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
48 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
50 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
49 |
51 |
50 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
52 self.resultList.headerItem().setText(self.resultList.columnCount(), "") |
51 self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) |
53 self.resultList.header().setSortIndicator(0, Qt.AscendingOrder) |
52 |
54 |
53 self.noResults = True |
55 self.noResults = True |
54 self.cancelled = False |
56 self.cancelled = False |
|
57 self.__lastFileItem = None |
55 |
58 |
56 def __resort(self): |
59 def __resort(self): |
57 """ |
60 """ |
58 Private method to resort the tree. |
61 Private method to resort the tree. |
59 """ |
62 """ |
68 @param line linenumber of faulty source (integer or string) |
71 @param line linenumber of faulty source (integer or string) |
69 @param error error text (string) |
72 @param error error text (string) |
70 @param sourcecode faulty line of code (string) |
73 @param sourcecode faulty line of code (string) |
71 @param isWarning flag indicating a warning message (boolean) |
74 @param isWarning flag indicating a warning message (boolean) |
72 """ |
75 """ |
73 itm = QTreeWidgetItem(self.resultList, |
76 if self.__lastFileItem is None: |
74 [os.path.basename(file), str(line), error, sourcecode]) |
77 # It's a new file |
75 itm.setTextAlignment(1, Qt.AlignRight) |
78 self.__lastFileItem = QTreeWidgetItem(self.resultList, [file]) |
|
79 self.__lastFileItem.setFirstColumnSpanned(True) |
|
80 self.__lastFileItem.setExpanded(True) |
|
81 self.__lastFileItem.setData(0, self.filenameRole, file) |
|
82 |
|
83 itm = QTreeWidgetItem(self.__lastFileItem, |
|
84 [str(line), error, sourcecode]) |
76 if isWarning: |
85 if isWarning: |
77 itm.setIcon(0, UI.PixmapCache.getIcon("warning.png")) |
86 itm.setIcon(0, UI.PixmapCache.getIcon("warning.png")) |
78 else: |
87 else: |
79 itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError.png")) |
88 itm.setIcon(0, UI.PixmapCache.getIcon("syntaxError.png")) |
80 itm.setToolTip(0, file) |
89 ## itm.setToolTip(0, file) |
81 itm.setData(0, self.filenameRole, file) |
90 itm.setData(0, self.filenameRole, file) |
|
91 itm.setData(0, self.lineRole, line) |
|
92 itm.setData(0, self.errorRole, error) |
82 itm.setData(0, self.warningRole, isWarning) |
93 itm.setData(0, self.warningRole, isWarning) |
83 |
94 |
84 def start(self, fn, codestring = ""): |
95 def start(self, fn, codestring = ""): |
85 """ |
96 """ |
86 Public slot to start the syntax check. |
97 Public slot to start the syntax check. |
156 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
169 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
157 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
170 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
158 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
171 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
159 |
172 |
160 if self.noResults: |
173 if self.noResults: |
161 self.__createResultItem(self.trUtf8('No syntax errors found.'), "", "", "") |
174 QTreeWidgetItem(self.resultList, [self.trUtf8('No issues found.')]) |
162 QApplication.processEvents() |
175 QApplication.processEvents() |
163 self.showButton.setEnabled(False) |
176 self.showButton.setEnabled(False) |
164 self.__clearErrors() |
177 self.__clearErrors() |
165 else: |
178 else: |
166 self.showButton.setEnabled(True) |
179 self.showButton.setEnabled(True) |
187 @param itm reference to the activated item (QTreeWidgetItem) |
200 @param itm reference to the activated item (QTreeWidgetItem) |
188 @param col column the item was activated in (integer) |
201 @param col column the item was activated in (integer) |
189 """ |
202 """ |
190 if self.noResults: |
203 if self.noResults: |
191 return |
204 return |
|
205 |
|
206 if itm.parent(): |
|
207 fn = Utilities.normabspath(itm.data(0, self.filenameRole)) |
|
208 lineno = itm.data(0, self.lineRole) |
|
209 error = itm.data(0, self.errorRole) |
192 |
210 |
193 fn = Utilities.normabspath(itm.data(0, self.filenameRole)) |
211 vm = e5App().getObject("ViewManager") |
194 lineno = int(itm.text(1)) |
212 vm.openSourceFile(fn, lineno) |
195 error = itm.text(2) |
213 editor = vm.getOpenEditor(fn) |
196 |
214 |
197 vm = e5App().getObject("ViewManager") |
215 if itm.data(0, self.warningRole): |
198 vm.openSourceFile(fn, lineno) |
216 editor.toggleFlakesWarning(lineno, True, error) |
199 editor = vm.getOpenEditor(fn) |
217 else: |
200 if itm.data(0, self.warningRole): |
218 editor.toggleSyntaxError(lineno, True, error) |
201 editor.toggleFlakesWarning(lineno, True, error) |
|
202 else: |
|
203 editor.toggleSyntaxError(lineno, True, error) |
|
204 |
219 |
205 @pyqtSlot() |
220 @pyqtSlot() |
206 def on_showButton_clicked(self): |
221 def on_showButton_clicked(self): |
207 """ |
222 """ |
208 Private slot to handle the "Show" button press. |
223 Private slot to handle the "Show" button press. |
209 """ |
224 """ |
|
225 vm = e5App().getObject("ViewManager") |
|
226 |
210 for index in range(self.resultList.topLevelItemCount()): |
227 for index in range(self.resultList.topLevelItemCount()): |
211 itm = self.resultList.topLevelItem(index) |
228 itm = self.resultList.topLevelItem(index) |
212 self.on_resultList_itemActivated(itm, 0) |
229 fn = Utilities.normabspath(itm.data(0, self.filenameRole)) |
213 |
230 vm.openSourceFile(fn, 1) |
214 # go through the list again to clear syntax error markers |
231 |
215 # for files, that are ok |
232 # go through the list again to clear syntax error and |
216 vm = e5App().getObject("ViewManager") |
233 # py3flakes warning markers for files, that are ok |
217 openFiles = vm.getOpenFilenames() |
234 openFiles = vm.getOpenFilenames() |
218 errorFiles = [] |
235 errorFiles = [] |
219 for index in range(self.resultList.topLevelItemCount()): |
236 for index in range(self.resultList.topLevelItemCount()): |
220 itm = self.resultList.topLevelItem(index) |
237 itm = self.resultList.topLevelItem(index) |
221 errorFiles.append(Utilities.normabspath(itm.text(0))) |
238 errorFiles.append(Utilities.normabspath(itm.data(0, self.filenameRole))) |
222 for file in openFiles: |
239 for file in openFiles: |
223 if not file in errorFiles: |
240 if not file in errorFiles: |
224 editor = vm.getOpenEditor(file) |
241 editor = vm.getOpenEditor(file) |
225 editor.clearSyntaxError() |
242 editor.clearSyntaxError() |
|
243 editor.clearFlakesWarnings() |
226 |
244 |
227 def __clearErrors(self): |
245 def __clearErrors(self): |
228 """ |
246 """ |
229 Private method to clear all error markers of open editors. |
247 Private method to clear all error markers of open editors. |
230 """ |
248 """ |
231 vm = e5App().getObject("ViewManager") |
249 vm = e5App().getObject("ViewManager") |
232 openFiles = vm.getOpenFilenames() |
250 openFiles = vm.getOpenFilenames() |
233 for file in openFiles: |
251 for file in openFiles: |
234 editor = vm.getOpenEditor(file) |
252 editor = vm.getOpenEditor(file) |
235 editor.clearSyntaxError() |
253 editor.clearSyntaxError() |
|
254 editor.clearFlakesWarnings() |