14 from PyQt4.QtCore import pyqtSignal |
14 from PyQt4.QtCore import pyqtSignal |
15 from PyQt4.QtGui import QDialog, QInputDialog, QMenu |
15 from PyQt4.QtGui import QDialog, QInputDialog, QMenu |
16 |
16 |
17 from E5Gui import E5MessageBox |
17 from E5Gui import E5MessageBox |
18 |
18 |
19 from UI.BrowserModel import BrowserFileItem, BrowserClassItem, BrowserMethodItem, \ |
19 from UI.BrowserModel import BrowserFileItem, BrowserClassItem, \ |
20 BrowserClassAttributeItem |
20 BrowserMethodItem, BrowserClassAttributeItem |
21 |
21 |
22 from .ProjectBrowserModel import ProjectBrowserFileItem, \ |
22 from .ProjectBrowserModel import ProjectBrowserFileItem, \ |
23 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \ |
23 ProjectBrowserSimpleDirectoryItem, ProjectBrowserDirectoryItem, \ |
24 ProjectBrowserSourceType |
24 ProjectBrowserSourceType |
25 from .ProjectBaseBrowser import ProjectBaseBrowser |
25 from .ProjectBaseBrowser import ProjectBaseBrowser |
30 |
30 |
31 class ProjectSourcesBrowser(ProjectBaseBrowser): |
31 class ProjectSourcesBrowser(ProjectBaseBrowser): |
32 """ |
32 """ |
33 A class used to display the Sources part of the project. |
33 A class used to display the Sources part of the project. |
34 |
34 |
35 @signal closeSourceWindow(str) emitted after a file has been removed/deleted |
35 @signal closeSourceWindow(str) emitted after a file has been |
36 from the project |
36 removed/deleted from the project |
37 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The name |
37 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. |
38 of the menu and a reference to the menu are given. |
38 The name of the menu and a reference to the menu are given. |
39 @signal sourceFile(str) emitted to open the given file. |
39 @signal sourceFile(str) emitted to open the given file. |
40 @signal sourceFile(str, int) emitted to open the given file at the given line. |
40 @signal sourceFile(str, int) emitted to open the given file at the given |
41 @signal sourceFile(str, int, str) emitted to open the given file as the given type |
41 line. |
42 at the given line. |
42 @signal sourceFile(str, int, str) emitted to open the given file as the |
|
43 given type at the given line. |
43 """ |
44 """ |
44 showMenu = pyqtSignal(str, QMenu) |
45 showMenu = pyqtSignal(str, QMenu) |
45 |
46 |
46 def __init__(self, project, parent=None): |
47 def __init__(self, project, parent=None): |
47 """ |
48 """ |
48 Constructor |
49 Constructor |
49 |
50 |
50 @param project reference to the project object |
51 @param project reference to the project object |
51 @param parent parent widget of this browser (QWidget) |
52 @param parent parent widget of this browser (QWidget) |
52 """ |
53 """ |
53 ProjectBaseBrowser.__init__(self, project, ProjectBrowserSourceType, parent) |
54 ProjectBaseBrowser.__init__(self, project, ProjectBrowserSourceType, |
|
55 parent) |
54 |
56 |
55 self.selectedItemsFilter = \ |
57 self.selectedItemsFilter = \ |
56 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem] |
58 [ProjectBrowserFileItem, ProjectBrowserSimpleDirectoryItem] |
57 |
59 |
58 self.setWindowTitle(self.trUtf8('Sources')) |
60 self.setWindowTitle(self.trUtf8('Sources')) |
59 |
61 |
60 self.setWhatsThis(self.trUtf8( |
62 self.setWhatsThis(self.trUtf8( |
61 """<b>Project Sources Browser</b>""" |
63 """<b>Project Sources Browser</b>""" |
62 """<p>This allows to easily see all sources contained in the current""" |
64 """<p>This allows to easily see all sources contained in the""" |
63 """ project. Several actions can be executed via the context menu.</p>""" |
65 """ current project. Several actions can be executed via the""" |
|
66 """ context menu.</p>""" |
64 )) |
67 )) |
65 |
68 |
66 project.prepareRepopulateItem.connect(self._prepareRepopulateItem) |
69 project.prepareRepopulateItem.connect(self._prepareRepopulateItem) |
67 project.completeRepopulateItem.connect(self._completeRepopulateItem) |
70 project.completeRepopulateItem.connect(self._completeRepopulateItem) |
68 |
71 |
100 Protected overloaded method to generate the popup menu. |
103 Protected overloaded method to generate the popup menu. |
101 """ |
104 """ |
102 ProjectBaseBrowser._createPopupMenus(self) |
105 ProjectBaseBrowser._createPopupMenus(self) |
103 self.sourceMenuActions = {} |
106 self.sourceMenuActions = {} |
104 |
107 |
105 if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2", "Python3"]: |
108 if self.project.pdata["PROGLANGUAGE"][0] in \ |
|
109 ["Python", "Python2", "Python3"]: |
106 self.__createPythonPopupMenus() |
110 self.__createPythonPopupMenus() |
107 elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": |
111 elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": |
108 self.__createRubyPopupMenus() |
112 self.__createRubyPopupMenus() |
109 |
113 |
110 def __createPythonPopupMenus(self): |
114 def __createPythonPopupMenus(self): |
113 """ |
117 """ |
114 self.checksMenu = QMenu(self.trUtf8('Check')) |
118 self.checksMenu = QMenu(self.trUtf8('Check')) |
115 self.checksMenu.aboutToShow.connect(self.__showContextMenuCheck) |
119 self.checksMenu.aboutToShow.connect(self.__showContextMenuCheck) |
116 |
120 |
117 self.menuShow = QMenu(self.trUtf8('Show')) |
121 self.menuShow = QMenu(self.trUtf8('Show')) |
118 self.menuShow.addAction(self.trUtf8('Code metrics...'), self.__showCodeMetrics) |
122 self.menuShow.addAction( |
|
123 self.trUtf8('Code metrics...'), self.__showCodeMetrics) |
119 self.coverageMenuAction = self.menuShow.addAction( |
124 self.coverageMenuAction = self.menuShow.addAction( |
120 self.trUtf8('Code coverage...'), self.__showCodeCoverage) |
125 self.trUtf8('Code coverage...'), self.__showCodeCoverage) |
121 self.profileMenuAction = self.menuShow.addAction( |
126 self.profileMenuAction = self.menuShow.addAction( |
122 self.trUtf8('Profile data...'), self.__showProfileData) |
127 self.trUtf8('Profile data...'), self.__showProfileData) |
123 self.menuShow.aboutToShow.connect(self.__showContextMenuShow) |
128 self.menuShow.aboutToShow.connect(self.__showContextMenuShow) |
128 self.graphicsMenu.addAction( |
133 self.graphicsMenu.addAction( |
129 self.trUtf8("Package Diagram..."), self.__showPackageDiagram) |
134 self.trUtf8("Package Diagram..."), self.__showPackageDiagram) |
130 self.importsDiagramAction = self.graphicsMenu.addAction( |
135 self.importsDiagramAction = self.graphicsMenu.addAction( |
131 self.trUtf8("Imports Diagram..."), self.__showImportsDiagram) |
136 self.trUtf8("Imports Diagram..."), self.__showImportsDiagram) |
132 self.graphicsMenu.addAction( |
137 self.graphicsMenu.addAction( |
133 self.trUtf8("Application Diagram..."), self.__showApplicationDiagram) |
138 self.trUtf8("Application Diagram..."), |
|
139 self.__showApplicationDiagram) |
134 self.graphicsMenu.addSeparator() |
140 self.graphicsMenu.addSeparator() |
135 self.graphicsMenu.addAction(UI.PixmapCache.getIcon("open.png"), |
141 self.graphicsMenu.addAction(UI.PixmapCache.getIcon("open.png"), |
136 self.trUtf8("Load Diagram..."), self.__loadDiagram) |
142 self.trUtf8("Load Diagram..."), self.__loadDiagram) |
137 self.graphicsMenu.aboutToShow.connect(self.__showContextMenuGraphics) |
143 self.graphicsMenu.aboutToShow.connect(self.__showContextMenuGraphics) |
138 |
144 |
139 self.unittestAction = self.sourceMenu.addAction( |
145 self.unittestAction = self.sourceMenu.addAction( |
140 self.trUtf8('Run unittest...'), self.handleUnittest) |
146 self.trUtf8('Run unittest...'), self.handleUnittest) |
141 self.sourceMenu.addSeparator() |
147 self.sourceMenu.addSeparator() |
142 act = self.sourceMenu.addAction(self.trUtf8('Rename file'), self._renameFile) |
148 act = self.sourceMenu.addAction( |
|
149 self.trUtf8('Rename file'), self._renameFile) |
143 self.menuActions.append(act) |
150 self.menuActions.append(act) |
144 act = self.sourceMenu.addAction(self.trUtf8('Remove from project'), |
151 act = self.sourceMenu.addAction(self.trUtf8('Remove from project'), |
145 self._removeFile) |
152 self._removeFile) |
146 self.menuActions.append(act) |
153 self.menuActions.append(act) |
147 act = self.sourceMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) |
154 act = self.sourceMenu.addAction( |
|
155 self.trUtf8('Delete'), self.__deleteFile) |
148 self.menuActions.append(act) |
156 self.menuActions.append(act) |
149 self.sourceMenu.addSeparator() |
157 self.sourceMenu.addSeparator() |
150 self.sourceMenu.addAction(self.trUtf8('New package...'), |
158 self.sourceMenu.addAction(self.trUtf8('New package...'), |
151 self.__addNewPackage) |
159 self.__addNewPackage) |
152 self.sourceMenu.addAction(self.trUtf8('Add source files...'), |
160 self.sourceMenu.addAction(self.trUtf8('Add source files...'), |
204 self.attributeMenu.addAction(self.trUtf8('Expand all directories'), |
212 self.attributeMenu.addAction(self.trUtf8('Expand all directories'), |
205 self._expandAllDirs) |
213 self._expandAllDirs) |
206 self.attributeMenu.addAction(self.trUtf8('Collapse all directories'), |
214 self.attributeMenu.addAction(self.trUtf8('Collapse all directories'), |
207 self._collapseAllDirs) |
215 self._collapseAllDirs) |
208 self.attributeMenu.addSeparator() |
216 self.attributeMenu.addSeparator() |
209 self.attributeMenu.addAction(self.trUtf8('Configure...'), self._configure) |
217 self.attributeMenu.addAction( |
|
218 self.trUtf8('Configure...'), self._configure) |
210 |
219 |
211 self.backMenu = QMenu(self) |
220 self.backMenu = QMenu(self) |
212 self.backMenu.addAction(self.trUtf8('New package...'), |
221 self.backMenu.addAction(self.trUtf8('New package...'), |
213 self.__addNewPackage) |
222 self.__addNewPackage) |
214 self.backMenu.addAction(self.trUtf8('Add source files...'), |
223 self.backMenu.addAction(self.trUtf8('Add source files...'), |
226 |
235 |
227 self.multiMenu.addSeparator() |
236 self.multiMenu.addSeparator() |
228 act = self.multiMenu.addAction(self.trUtf8('Remove from project'), |
237 act = self.multiMenu.addAction(self.trUtf8('Remove from project'), |
229 self._removeFile) |
238 self._removeFile) |
230 self.multiMenuActions.append(act) |
239 self.multiMenuActions.append(act) |
231 act = self.multiMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) |
240 act = self.multiMenu.addAction( |
|
241 self.trUtf8('Delete'), self.__deleteFile) |
232 self.multiMenuActions.append(act) |
242 self.multiMenuActions.append(act) |
233 self.multiMenu.addSeparator() |
243 self.multiMenu.addSeparator() |
234 self.multiMenu.addAction(self.trUtf8('Expand all directories'), |
244 self.multiMenu.addAction(self.trUtf8('Expand all directories'), |
235 self._expandAllDirs) |
245 self._expandAllDirs) |
236 self.multiMenu.addAction(self.trUtf8('Collapse all directories'), |
246 self.multiMenu.addAction(self.trUtf8('Collapse all directories'), |
237 self._collapseAllDirs) |
247 self._collapseAllDirs) |
238 self.multiMenu.addSeparator() |
248 self.multiMenu.addSeparator() |
239 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure) |
249 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure) |
240 |
250 |
241 self.dirMenu = QMenu(self) |
251 self.dirMenu = QMenu(self) |
242 act = self.dirMenu.addAction(self.trUtf8('Remove from project'), self._removeDir) |
252 act = self.dirMenu.addAction( |
|
253 self.trUtf8('Remove from project'), self._removeDir) |
243 self.dirMenuActions.append(act) |
254 self.dirMenuActions.append(act) |
244 act = self.dirMenu.addAction(self.trUtf8('Delete'), self._deleteDirectory) |
255 act = self.dirMenu.addAction( |
|
256 self.trUtf8('Delete'), self._deleteDirectory) |
245 self.dirMenuActions.append(act) |
257 self.dirMenuActions.append(act) |
246 self.dirMenu.addSeparator() |
258 self.dirMenu.addSeparator() |
247 self.dirMenu.addAction(self.trUtf8('New package...'), self.__addNewPackage) |
259 self.dirMenu.addAction( |
248 self.dirMenu.addAction(self.trUtf8('Add source files...'), self.__addSourceFiles) |
260 self.trUtf8('New package...'), self.__addNewPackage) |
|
261 self.dirMenu.addAction( |
|
262 self.trUtf8('Add source files...'), self.__addSourceFiles) |
249 self.dirMenu.addAction(self.trUtf8('Add source directory...'), |
263 self.dirMenu.addAction(self.trUtf8('Add source directory...'), |
250 self.__addSourceDirectory) |
264 self.__addSourceDirectory) |
251 self.dirMenu.addSeparator() |
265 self.dirMenu.addSeparator() |
252 act = self.dirMenu.addMenu(self.graphicsMenu) |
266 act = self.dirMenu.addMenu(self.graphicsMenu) |
253 self.dirMenu.addSeparator() |
267 self.dirMenu.addSeparator() |
267 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'), |
281 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'), |
268 self._expandAllDirs) |
282 self._expandAllDirs) |
269 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'), |
283 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'), |
270 self._collapseAllDirs) |
284 self._collapseAllDirs) |
271 self.dirMultiMenu.addSeparator() |
285 self.dirMultiMenu.addSeparator() |
272 self.dirMultiMenu.addAction(self.trUtf8('Configure...'), self._configure) |
286 self.dirMultiMenu.addAction( |
|
287 self.trUtf8('Configure...'), self._configure) |
273 |
288 |
274 self.sourceMenu.aboutToShow.connect(self.__showContextMenu) |
289 self.sourceMenu.aboutToShow.connect(self.__showContextMenu) |
275 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) |
290 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) |
276 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir) |
291 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir) |
277 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti) |
292 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti) |
292 self.graphicsMenu.addSeparator() |
307 self.graphicsMenu.addSeparator() |
293 self.graphicsMenu.addAction(UI.PixmapCache.getIcon("fileOpen.png"), |
308 self.graphicsMenu.addAction(UI.PixmapCache.getIcon("fileOpen.png"), |
294 self.trUtf8("Load Diagram..."), self.__loadDiagram) |
309 self.trUtf8("Load Diagram..."), self.__loadDiagram) |
295 |
310 |
296 self.sourceMenu.addSeparator() |
311 self.sourceMenu.addSeparator() |
297 act = self.sourceMenu.addAction(self.trUtf8('Rename file'), self._renameFile) |
312 act = self.sourceMenu.addAction( |
|
313 self.trUtf8('Rename file'), self._renameFile) |
298 self.menuActions.append(act) |
314 self.menuActions.append(act) |
299 act = self.sourceMenu.addAction(self.trUtf8('Remove from project'), |
315 act = self.sourceMenu.addAction(self.trUtf8('Remove from project'), |
300 self._removeFile) |
316 self._removeFile) |
301 self.menuActions.append(act) |
317 self.menuActions.append(act) |
302 act = self.sourceMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) |
318 act = self.sourceMenu.addAction( |
|
319 self.trUtf8('Delete'), self.__deleteFile) |
303 self.menuActions.append(act) |
320 self.menuActions.append(act) |
304 self.sourceMenu.addSeparator() |
321 self.sourceMenu.addSeparator() |
305 self.sourceMenu.addAction(self.trUtf8('Add source files...'), |
322 self.sourceMenu.addAction(self.trUtf8('Add source files...'), |
306 self.__addSourceFiles) |
323 self.__addSourceFiles) |
307 self.sourceMenu.addAction(self.trUtf8('Add source directory...'), |
324 self.sourceMenu.addAction(self.trUtf8('Add source directory...'), |
315 self._collapseAllDirs) |
332 self._collapseAllDirs) |
316 self.sourceMenu.addSeparator() |
333 self.sourceMenu.addSeparator() |
317 self.sourceMenu.addAction(self.trUtf8('Configure...'), self._configure) |
334 self.sourceMenu.addAction(self.trUtf8('Configure...'), self._configure) |
318 |
335 |
319 self.menu.addSeparator() |
336 self.menu.addSeparator() |
320 self.menu.addAction(self.trUtf8('Add source files...'), self.__addSourceFiles) |
337 self.menu.addAction( |
|
338 self.trUtf8('Add source files...'), self.__addSourceFiles) |
321 self.menu.addAction(self.trUtf8('Add source directory...'), |
339 self.menu.addAction(self.trUtf8('Add source directory...'), |
322 self.__addSourceDirectory) |
340 self.__addSourceDirectory) |
323 self.menu.addSeparator() |
341 self.menu.addSeparator() |
324 self.menu.addAction(self.trUtf8('Expand all directories'), |
342 self.menu.addAction(self.trUtf8('Expand all directories'), |
325 self._expandAllDirs) |
343 self._expandAllDirs) |
346 self.attributeMenu.addAction(self.trUtf8('Expand all directories'), |
364 self.attributeMenu.addAction(self.trUtf8('Expand all directories'), |
347 self._expandAllDirs) |
365 self._expandAllDirs) |
348 self.attributeMenu.addAction(self.trUtf8('Collapse all directories'), |
366 self.attributeMenu.addAction(self.trUtf8('Collapse all directories'), |
349 self._collapseAllDirs) |
367 self._collapseAllDirs) |
350 self.attributeMenu.addSeparator() |
368 self.attributeMenu.addSeparator() |
351 self.attributeMenu.addAction(self.trUtf8('Configure...'), self._configure) |
369 self.attributeMenu.addAction( |
|
370 self.trUtf8('Configure...'), self._configure) |
352 |
371 |
353 self.backMenu = QMenu(self) |
372 self.backMenu = QMenu(self) |
354 self.backMenu.addAction(self.trUtf8('Add source files...'), |
373 self.backMenu.addAction(self.trUtf8('Add source files...'), |
355 self.project.addSourceFiles) |
374 self.project.addSourceFiles) |
356 self.backMenu.addAction(self.trUtf8('Add source directory...'), |
375 self.backMenu.addAction(self.trUtf8('Add source directory...'), |
366 |
385 |
367 self.multiMenu.addSeparator() |
386 self.multiMenu.addSeparator() |
368 act = self.multiMenu.addAction(self.trUtf8('Remove from project'), |
387 act = self.multiMenu.addAction(self.trUtf8('Remove from project'), |
369 self._removeFile) |
388 self._removeFile) |
370 self.multiMenuActions.append(act) |
389 self.multiMenuActions.append(act) |
371 act = self.multiMenu.addAction(self.trUtf8('Delete'), self.__deleteFile) |
390 act = self.multiMenu.addAction( |
|
391 self.trUtf8('Delete'), self.__deleteFile) |
372 self.multiMenuActions.append(act) |
392 self.multiMenuActions.append(act) |
373 self.multiMenu.addSeparator() |
393 self.multiMenu.addSeparator() |
374 self.multiMenu.addAction(self.trUtf8('Expand all directories'), |
394 self.multiMenu.addAction(self.trUtf8('Expand all directories'), |
375 self._expandAllDirs) |
395 self._expandAllDirs) |
376 self.multiMenu.addAction(self.trUtf8('Collapse all directories'), |
396 self.multiMenu.addAction(self.trUtf8('Collapse all directories'), |
377 self._collapseAllDirs) |
397 self._collapseAllDirs) |
378 self.multiMenu.addSeparator() |
398 self.multiMenu.addSeparator() |
379 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure) |
399 self.multiMenu.addAction(self.trUtf8('Configure...'), self._configure) |
380 |
400 |
381 self.dirMenu = QMenu(self) |
401 self.dirMenu = QMenu(self) |
382 act = self.dirMenu.addAction(self.trUtf8('Remove from project'), self._removeDir) |
402 act = self.dirMenu.addAction( |
|
403 self.trUtf8('Remove from project'), self._removeDir) |
383 self.dirMenuActions.append(act) |
404 self.dirMenuActions.append(act) |
384 self.dirMenu.addSeparator() |
405 self.dirMenu.addSeparator() |
385 self.dirMenu.addAction(self.trUtf8('Add source files...'), self.__addSourceFiles) |
406 self.dirMenu.addAction( |
|
407 self.trUtf8('Add source files...'), self.__addSourceFiles) |
386 self.dirMenu.addAction(self.trUtf8('Add source directory...'), |
408 self.dirMenu.addAction(self.trUtf8('Add source directory...'), |
387 self.__addSourceDirectory) |
409 self.__addSourceDirectory) |
388 self.dirMenu.addSeparator() |
410 self.dirMenu.addSeparator() |
389 act = self.dirMenu.addMenu(self.graphicsMenu) |
411 act = self.dirMenu.addMenu(self.graphicsMenu) |
390 self.dirMenu.addSeparator() |
412 self.dirMenu.addSeparator() |
399 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'), |
421 self.dirMultiMenu.addAction(self.trUtf8('Expand all directories'), |
400 self._expandAllDirs) |
422 self._expandAllDirs) |
401 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'), |
423 self.dirMultiMenu.addAction(self.trUtf8('Collapse all directories'), |
402 self._collapseAllDirs) |
424 self._collapseAllDirs) |
403 self.dirMultiMenu.addSeparator() |
425 self.dirMultiMenu.addSeparator() |
404 self.dirMultiMenu.addAction(self.trUtf8('Configure...'), self._configure) |
426 self.dirMultiMenu.addAction( |
|
427 self.trUtf8('Configure...'), self._configure) |
405 |
428 |
406 self.sourceMenu.aboutToShow.connect(self.__showContextMenu) |
429 self.sourceMenu.aboutToShow.connect(self.__showContextMenu) |
407 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) |
430 self.multiMenu.aboutToShow.connect(self.__showContextMenuMulti) |
408 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir) |
431 self.dirMenu.aboutToShow.connect(self.__showContextMenuDir) |
409 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti) |
432 self.dirMultiMenu.aboutToShow.connect(self.__showContextMenuDirMulti) |
452 if isinstance(itm, ProjectBrowserFileItem): |
475 if isinstance(itm, ProjectBrowserFileItem): |
453 fn = itm.fileName() |
476 fn = itm.fileName() |
454 if self.project.pdata["PROGLANGUAGE"][0] in \ |
477 if self.project.pdata["PROGLANGUAGE"][0] in \ |
455 ["Python", "Python2", "Python3"]: |
478 ["Python", "Python2", "Python3"]: |
456 if fn.endswith('.ptl'): |
479 if fn.endswith('.ptl'): |
457 for act in list(self.sourceMenuActions.values()): |
480 for act in self.sourceMenuActions.values(): |
458 act.setEnabled(False) |
481 act.setEnabled(False) |
459 self.classDiagramAction.setEnabled(True) |
482 self.classDiagramAction.setEnabled(True) |
460 self.importsDiagramAction.setEnabled(True) |
483 self.importsDiagramAction.setEnabled(True) |
461 self.unittestAction.setEnabled(False) |
484 self.unittestAction.setEnabled(False) |
462 self.checksMenu.menuAction().setEnabled(False) |
485 self.checksMenu.menuAction().setEnabled( |
463 elif fn.endswith('.rb'): # entry for mixed mode programs |
486 False) |
464 for act in list(self.sourceMenuActions.values()): |
487 elif fn.endswith('.rb'): # entry for mixed |
|
488 # mode programs |
|
489 for act in self.sourceMenuActions.values(): |
465 act.setEnabled(False) |
490 act.setEnabled(False) |
466 self.classDiagramAction.setEnabled(True) |
491 self.classDiagramAction.setEnabled(True) |
467 self.importsDiagramAction.setEnabled(False) |
492 self.importsDiagramAction.setEnabled(False) |
468 self.unittestAction.setEnabled(False) |
493 self.unittestAction.setEnabled(False) |
469 self.checksMenu.menuAction().setEnabled(False) |
494 self.checksMenu.menuAction().setEnabled( |
470 else: # assume the source file is a Python file |
495 False) |
471 for act in list(self.sourceMenuActions.values()): |
496 else: # assume the source file is a |
|
497 # Python file |
|
498 for act in self.sourceMenuActions.values(): |
472 act.setEnabled(True) |
499 act.setEnabled(True) |
473 self.classDiagramAction.setEnabled(True) |
500 self.classDiagramAction.setEnabled(True) |
474 self.importsDiagramAction.setEnabled(True) |
501 self.importsDiagramAction.setEnabled(True) |
475 self.unittestAction.setEnabled(True) |
502 self.unittestAction.setEnabled(True) |
476 self.checksMenu.menuAction().setEnabled(True) |
503 self.checksMenu.menuAction().setEnabled( |
|
504 True) |
477 self.sourceMenu.popup(self.mapToGlobal(coord)) |
505 self.sourceMenu.popup(self.mapToGlobal(coord)) |
478 elif isinstance(itm, BrowserClassItem) or \ |
506 elif isinstance(itm, BrowserClassItem) or \ |
479 isinstance(itm, BrowserMethodItem): |
507 isinstance(itm, BrowserMethodItem): |
480 self.menu.popup(self.mapToGlobal(coord)) |
508 self.menu.popup(self.mapToGlobal(coord)) |
481 elif isinstance(itm, BrowserClassAttributeItem): |
509 elif isinstance(itm, BrowserClassAttributeItem): |
583 if itm.isPython2File(): |
611 if itm.isPython2File(): |
584 self.sourceFile[str].emit(itm.fileName()) |
612 self.sourceFile[str].emit(itm.fileName()) |
585 elif itm.isPython3File(): |
613 elif itm.isPython3File(): |
586 self.sourceFile[str].emit(itm.fileName()) |
614 self.sourceFile[str].emit(itm.fileName()) |
587 elif itm.isRubyFile(): |
615 elif itm.isRubyFile(): |
588 self.sourceFile[str, int, str].emit(itm.fileName(), -1, "Ruby") |
616 self.sourceFile[str, int, str].emit( |
|
617 itm.fileName(), -1, "Ruby") |
589 elif itm.isDFile(): |
618 elif itm.isDFile(): |
590 self.sourceFile[str, int, str].emit(itm.fileName(), -1, "D") |
619 self.sourceFile[str, int, str].emit( |
|
620 itm.fileName(), -1, "D") |
591 else: |
621 else: |
592 self.sourceFile[str].emit(itm.fileName()) |
622 self.sourceFile[str].emit(itm.fileName()) |
593 elif isinstance(itm, BrowserClassItem): |
623 elif isinstance(itm, BrowserClassItem): |
594 self.sourceFile[str, int].emit(itm.fileName(), itm.classObject().lineno) |
624 self.sourceFile[str, int].emit( |
|
625 itm.fileName(), itm.classObject().lineno) |
595 elif isinstance(itm, BrowserMethodItem): |
626 elif isinstance(itm, BrowserMethodItem): |
596 self.sourceFile[str, int].emit( |
627 self.sourceFile[str, int].emit( |
597 itm.fileName(), itm.functionObject().lineno) |
628 itm.fileName(), itm.functionObject().lineno) |
598 elif isinstance(itm, BrowserClassAttributeItem): |
629 elif isinstance(itm, BrowserClassAttributeItem): |
599 self.sourceFile[str, int].emit( |
630 self.sourceFile[str, int].emit( |
630 try: |
661 try: |
631 os.mkdir(packagePath) |
662 os.mkdir(packagePath) |
632 except OSError as err: |
663 except OSError as err: |
633 E5MessageBox.critical(self, |
664 E5MessageBox.critical(self, |
634 self.trUtf8("Add new Python package"), |
665 self.trUtf8("Add new Python package"), |
635 self.trUtf8("""<p>The package directory <b>{0}</b> could""" |
666 self.trUtf8( |
636 """ not be created. Aborting...</p>""" |
667 """<p>The package directory <b>{0}</b> could""" |
637 """<p>Reason: {1}</p>""")\ |
668 """ not be created. Aborting...</p>""" |
|
669 """<p>Reason: {1}</p>""")\ |
638 .format(packagePath, str(err))) |
670 .format(packagePath, str(err))) |
639 return |
671 return |
640 packageFile = os.path.join(packagePath, "__init__.py") |
672 packageFile = os.path.join(packagePath, "__init__.py") |
641 if not os.path.exists(packageFile): |
673 if not os.path.exists(packageFile): |
642 try: |
674 try: |
643 f = open(packageFile, "w", encoding="utf-8") |
675 f = open(packageFile, "w", encoding="utf-8") |
644 f.close() |
676 f.close() |
645 except IOError as err: |
677 except IOError as err: |
646 E5MessageBox.critical(self, |
678 E5MessageBox.critical(self, |
647 self.trUtf8("Add new Python package"), |
679 self.trUtf8("Add new Python package"), |
648 self.trUtf8("""<p>The package file <b>{0}</b> could""" |
680 self.trUtf8( |
649 """ not be created. Aborting...</p>""" |
681 """<p>The package file <b>{0}</b> could""" |
650 """<p>Reason: {1}</p>""")\ |
682 """ not be created. Aborting...</p>""" |
|
683 """<p>Reason: {1}</p>""")\ |
651 .format(packageFile, str(err))) |
684 .format(packageFile, str(err))) |
652 return |
685 return |
653 self.project.appendFile(packageFile) |
686 self.project.appendFile(packageFile) |
654 if packageFile: |
687 if packageFile: |
655 self.sourceFile[str].emit(packageFile) |
688 self.sourceFile[str].emit(packageFile) |
698 fn2 = itm.fileName() |
731 fn2 = itm.fileName() |
699 fullNames.append(fn2) |
732 fullNames.append(fn2) |
700 fn = self.project.getRelativePath(fn2) |
733 fn = self.project.getRelativePath(fn2) |
701 files.append(fn) |
734 files.append(fn) |
702 |
735 |
703 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
736 from UI.DeleteFilesConfirmationDialog import \ |
|
737 DeleteFilesConfirmationDialog |
704 dlg = DeleteFilesConfirmationDialog(self.parent(), |
738 dlg = DeleteFilesConfirmationDialog(self.parent(), |
705 self.trUtf8("Delete files"), |
739 self.trUtf8("Delete files"), |
706 self.trUtf8("Do you really want to delete these files from the project?"), |
740 self.trUtf8( |
|
741 "Do you really want to delete these files from the project?"), |
707 files) |
742 files) |
708 |
743 |
709 if dlg.exec_() == QDialog.Accepted: |
744 if dlg.exec_() == QDialog.Accepted: |
710 for fn2, fn in zip(fullNames, files): |
745 for fn2, fn in zip(fullNames, files): |
711 self.closeSourceWindow.emit(fn2) |
746 self.closeSourceWindow.emit(fn2) |
712 self.project.deleteFile(fn) |
747 self.project.deleteFile(fn) |
713 |
748 |
714 ############################################################################ |
749 ########################################################################### |
715 ## Methods for the Checks submenu |
750 ## Methods for the Checks submenu |
716 ############################################################################ |
751 ########################################################################### |
717 |
752 |
718 def __showContextMenuCheck(self): |
753 def __showContextMenuCheck(self): |
719 """ |
754 """ |
720 Private slot called before the checks menu is shown. |
755 Private slot called before the checks menu is shown. |
721 """ |
756 """ |
722 self.showMenu.emit("Checks", self.checksMenu) |
757 self.showMenu.emit("Checks", self.checksMenu) |
723 |
758 |
724 ############################################################################ |
759 ########################################################################### |
725 ## Methods for the Show submenu |
760 ## Methods for the Show submenu |
726 ############################################################################ |
761 ########################################################################### |
727 |
762 |
728 def __showCodeMetrics(self): |
763 def __showCodeMetrics(self): |
729 """ |
764 """ |
730 Private method to handle the code metrics context menu action. |
765 Private method to handle the code metrics context menu action. |
731 """ |
766 """ |
843 from DataViews.PyProfileDialog import PyProfileDialog |
878 from DataViews.PyProfileDialog import PyProfileDialog |
844 self.profiledata = PyProfileDialog() |
879 self.profiledata = PyProfileDialog() |
845 self.profiledata.show() |
880 self.profiledata.show() |
846 self.profiledata.start(pfn, fn) |
881 self.profiledata.start(pfn, fn) |
847 |
882 |
848 ############################################################################ |
883 ########################################################################### |
849 ## Methods for the Graphics submenu |
884 ## Methods for the Graphics submenu |
850 ############################################################################ |
885 ########################################################################### |
851 |
886 |
852 def __showContextMenuGraphics(self): |
887 def __showContextMenuGraphics(self): |
853 """ |
888 """ |
854 Private slot called before the checks menu is shown. |
889 Private slot called before the checks menu is shown. |
855 """ |
890 """ |
885 package = os.path.isdir(fn) and fn or os.path.dirname(fn) |
920 package = os.path.isdir(fn) and fn or os.path.dirname(fn) |
886 res = E5MessageBox.yesNo(self, |
921 res = E5MessageBox.yesNo(self, |
887 self.trUtf8("Imports Diagram"), |
922 self.trUtf8("Imports Diagram"), |
888 self.trUtf8("""Include imports from external modules?""")) |
923 self.trUtf8("""Include imports from external modules?""")) |
889 from Graphics.UMLDialog import UMLDialog |
924 from Graphics.UMLDialog import UMLDialog |
890 self.importsDiagram = UMLDialog(UMLDialog.ImportsDiagram, self.project, package, |
925 self.importsDiagram = UMLDialog( |
891 self, showExternalImports=res) |
926 UMLDialog.ImportsDiagram, self.project, package, |
|
927 self, showExternalImports=res) |
892 self.importsDiagram.show() |
928 self.importsDiagram.show() |
893 |
929 |
894 def __showPackageDiagram(self): |
930 def __showPackageDiagram(self): |
895 """ |
931 """ |
896 Private method to handle the package diagram context menu action. |
932 Private method to handle the package diagram context menu action. |
904 res = E5MessageBox.yesNo(self, |
940 res = E5MessageBox.yesNo(self, |
905 self.trUtf8("Package Diagram"), |
941 self.trUtf8("Package Diagram"), |
906 self.trUtf8("""Include class attributes?"""), |
942 self.trUtf8("""Include class attributes?"""), |
907 yesDefault=True) |
943 yesDefault=True) |
908 from Graphics.UMLDialog import UMLDialog |
944 from Graphics.UMLDialog import UMLDialog |
909 self.packageDiagram = UMLDialog(UMLDialog.PackageDiagram, self.project, package, |
945 self.packageDiagram = UMLDialog( |
910 self, noAttrs=not res) |
946 UMLDialog.PackageDiagram, self.project, package, |
|
947 self, noAttrs=not res) |
911 self.packageDiagram.show() |
948 self.packageDiagram.show() |
912 |
949 |
913 def __showApplicationDiagram(self): |
950 def __showApplicationDiagram(self): |
914 """ |
951 """ |
915 Private method to handle the application diagram context menu action. |
952 Private method to handle the application diagram context menu action. |
917 res = E5MessageBox.yesNo(self, |
954 res = E5MessageBox.yesNo(self, |
918 self.trUtf8("Application Diagram"), |
955 self.trUtf8("Application Diagram"), |
919 self.trUtf8("""Include module names?"""), |
956 self.trUtf8("""Include module names?"""), |
920 yesDefault=True) |
957 yesDefault=True) |
921 from Graphics.UMLDialog import UMLDialog |
958 from Graphics.UMLDialog import UMLDialog |
922 self.applicationDiagram = UMLDialog(UMLDialog.ApplicationDiagram, self.project, |
959 self.applicationDiagram = UMLDialog( |
923 self, noModules=not res) |
960 UMLDialog.ApplicationDiagram, self.project, |
|
961 self, noModules=not res) |
924 self.applicationDiagram.show() |
962 self.applicationDiagram.show() |
925 |
963 |
926 def __loadDiagram(self): |
964 def __loadDiagram(self): |
927 """ |
965 """ |
928 Private slot to load a diagram from file. |
966 Private slot to load a diagram from file. |
929 """ |
967 """ |
930 from Graphics.UMLDialog import UMLDialog |
968 from Graphics.UMLDialog import UMLDialog |
931 self.loadedDiagram = None |
969 self.loadedDiagram = None |
932 loadedDiagram = UMLDialog(UMLDialog.NoDiagram, self.project, parent=self) |
970 loadedDiagram = UMLDialog( |
|
971 UMLDialog.NoDiagram, self.project, parent=self) |
933 if loadedDiagram.load(): |
972 if loadedDiagram.load(): |
934 self.loadedDiagram = loadedDiagram |
973 self.loadedDiagram = loadedDiagram |
935 self.loadedDiagram.show(fromFile=True) |
974 self.loadedDiagram.show(fromFile=True) |