Project/ProjectSourcesBrowser.py

changeset 500
c3abc7895a01
parent 476
121633976eca
child 501
5c615a85241a
equal deleted inserted replaced
499:622ab17a68d5 500:c3abc7895a01
40 @signal closeSourceWindow(string) emitted after a file has been removed/deleted 40 @signal closeSourceWindow(string) emitted after a file has been removed/deleted
41 from the project 41 from the project
42 @signal showMenu(string, QMenu) emitted when a menu is about to be shown. The name 42 @signal showMenu(string, QMenu) emitted when a menu is about to be shown. The name
43 of the menu and a reference to the menu are given. 43 of the menu and a reference to the menu are given.
44 """ 44 """
45 closeSourceWindow = pyqtSignal(str)
46 showMenu = pyqtSignal(str, QMenu)
45 sourceFile = pyqtSignal((str, ), (str, int), (str, int, str)) 47 sourceFile = pyqtSignal((str, ), (str, int), (str, int, str))
46 48
47 def __init__(self, project, parent = None): 49 def __init__(self, project, parent = None):
48 """ 50 """
49 Constructor 51 Constructor
62 """<b>Project Sources Browser</b>""" 64 """<b>Project Sources Browser</b>"""
63 """<p>This allows to easily see all sources contained in the current""" 65 """<p>This allows to easily see all sources contained in the current"""
64 """ project. Several actions can be executed via the context menu.</p>""" 66 """ project. Several actions can be executed via the context menu.</p>"""
65 )) 67 ))
66 68
67 self.connect(project, SIGNAL("prepareRepopulateItem"), 69 project.prepareRepopulateItem.connect(self._prepareRepopulateItem)
68 self._prepareRepopulateItem) 70 project.completeRepopulateItem.connect(self._completeRepopulateItem)
69 self.connect(project, SIGNAL("completeRepopulateItem"),
70 self._completeRepopulateItem)
71 71
72 self.codemetrics = None 72 self.codemetrics = None
73 self.codecoverage = None 73 self.codecoverage = None
74 self.profiledata = None 74 self.profiledata = None
75 self.classDiagram = None 75 self.classDiagram = None
113 Privat method to generate the popup menus for a Python project. 113 Privat method to generate the popup menus for a Python project.
114 """ 114 """
115 self.checksMenu = QMenu(self.trUtf8('Check')) 115 self.checksMenu = QMenu(self.trUtf8('Check'))
116 self.checksMenu.aboutToShow.connect(self.__showContextMenuCheck) 116 self.checksMenu.aboutToShow.connect(self.__showContextMenuCheck)
117 117
118 self.showMenu = QMenu(self.trUtf8('Show')) 118 self.menuShow = QMenu(self.trUtf8('Show'))
119 self.showMenu.addAction(self.trUtf8('Code metrics...'), self.__showCodeMetrics) 119 self.menuShow.addAction(self.trUtf8('Code metrics...'), self.__showCodeMetrics)
120 self.coverageMenuAction = self.showMenu.addAction(\ 120 self.coverageMenuAction = self.menuShow.addAction(\
121 self.trUtf8('Code coverage...'), self.__showCodeCoverage) 121 self.trUtf8('Code coverage...'), self.__showCodeCoverage)
122 self.profileMenuAction = self.showMenu.addAction(\ 122 self.profileMenuAction = self.menuShow.addAction(\
123 self.trUtf8('Profile data...'), self.__showProfileData) 123 self.trUtf8('Profile data...'), self.__showProfileData)
124 self.showMenu.aboutToShow.connect(self.__showContextMenuShow) 124 self.menuShow.aboutToShow.connect(self.__showContextMenuShow)
125 125
126 self.graphicsMenu = QMenu(self.trUtf8('Diagrams')) 126 self.graphicsMenu = QMenu(self.trUtf8('Diagrams'))
127 self.classDiagramAction = self.graphicsMenu.addAction(\ 127 self.classDiagramAction = self.graphicsMenu.addAction(\
128 self.trUtf8("Class Diagram..."), self.__showClassDiagram) 128 self.trUtf8("Class Diagram..."), self.__showClassDiagram)
129 self.graphicsMenu.addAction(\ 129 self.graphicsMenu.addAction(\
155 act = self.sourceMenu.addMenu(self.graphicsMenu) 155 act = self.sourceMenu.addMenu(self.graphicsMenu)
156 self.sourceMenu.addSeparator() 156 self.sourceMenu.addSeparator()
157 self.sourceMenu.addMenu(self.checksMenu) 157 self.sourceMenu.addMenu(self.checksMenu)
158 self.sourceMenu.addSeparator() 158 self.sourceMenu.addSeparator()
159 self.sourceMenuActions["Show"] = \ 159 self.sourceMenuActions["Show"] = \
160 self.sourceMenu.addMenu(self.showMenu) 160 self.sourceMenu.addMenu(self.menuShow)
161 self.sourceMenu.addSeparator() 161 self.sourceMenu.addSeparator()
162 self.sourceMenu.addAction(self.trUtf8('Copy Path to Clipboard'), 162 self.sourceMenu.addAction(self.trUtf8('Copy Path to Clipboard'),
163 self._copyToClipboard) 163 self._copyToClipboard)
164 self.sourceMenu.addSeparator() 164 self.sourceMenu.addSeparator()
165 self.sourceMenu.addAction(self.trUtf8('Expand all directories'), 165 self.sourceMenu.addAction(self.trUtf8('Expand all directories'),
440 """ 440 """
441 Private slot called by the sourceMenu aboutToShow signal. 441 Private slot called by the sourceMenu aboutToShow signal.
442 """ 442 """
443 ProjectBaseBrowser._showContextMenu(self, self.sourceMenu) 443 ProjectBaseBrowser._showContextMenu(self, self.sourceMenu)
444 444
445 self.emit(SIGNAL("showMenu"), "Main", self.sourceMenu) 445 self.showMenu.emit("Main", self.sourceMenu)
446 446
447 def __showContextMenuMulti(self): 447 def __showContextMenuMulti(self):
448 """ 448 """
449 Private slot called by the multiMenu aboutToShow signal. 449 Private slot called by the multiMenu aboutToShow signal.
450 """ 450 """
451 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu) 451 ProjectBaseBrowser._showContextMenuMulti(self, self.multiMenu)
452 452
453 self.emit(SIGNAL("showMenu"), "MainMulti", self.multiMenu) 453 self.showMenu.emit("MainMulti", self.multiMenu)
454 454
455 def __showContextMenuDir(self): 455 def __showContextMenuDir(self):
456 """ 456 """
457 Private slot called by the dirMenu aboutToShow signal. 457 Private slot called by the dirMenu aboutToShow signal.
458 """ 458 """
459 ProjectBaseBrowser._showContextMenuDir(self, self.dirMenu) 459 ProjectBaseBrowser._showContextMenuDir(self, self.dirMenu)
460 460
461 self.emit(SIGNAL("showMenu"), "MainDir", self.dirMenu) 461 self.showMenu.emit("MainDir", self.dirMenu)
462 462
463 def __showContextMenuDirMulti(self): 463 def __showContextMenuDirMulti(self):
464 """ 464 """
465 Private slot called by the dirMultiMenu aboutToShow signal. 465 Private slot called by the dirMultiMenu aboutToShow signal.
466 """ 466 """
467 ProjectBaseBrowser._showContextMenuDirMulti(self, self.dirMultiMenu) 467 ProjectBaseBrowser._showContextMenuDirMulti(self, self.dirMultiMenu)
468 468
469 self.emit(SIGNAL("showMenu"), "MainDirMulti", self.dirMultiMenu) 469 self.showMenu.emit("MainDirMulti", self.dirMultiMenu)
470 470
471 def __showContextMenuBack(self): 471 def __showContextMenuBack(self):
472 """ 472 """
473 Private slot called by the backMenu aboutToShow signal. 473 Private slot called by the backMenu aboutToShow signal.
474 """ 474 """
475 ProjectBaseBrowser._showContextMenuBack(self, self.backMenu) 475 ProjectBaseBrowser._showContextMenuBack(self, self.backMenu)
476 476
477 self.emit(SIGNAL("showMenu"), "MainBack", self.backMenu) 477 self.showMenu.emit("MainBack", self.backMenu)
478 478
479 def __showContextMenuShow(self): 479 def __showContextMenuShow(self):
480 """ 480 """
481 Private slot called before the show menu is shown. 481 Private slot called before the show menu is shown.
482 """ 482 """
508 os.path.isfile("{0}.coverage".format(basename)) 508 os.path.isfile("{0}.coverage".format(basename))
509 509
510 self.profileMenuAction.setEnabled(prEnable) 510 self.profileMenuAction.setEnabled(prEnable)
511 self.coverageMenuAction.setEnabled(coEnable) 511 self.coverageMenuAction.setEnabled(coEnable)
512 512
513 self.emit(SIGNAL("showMenu"), "Show", self.showMenu) 513 self.showMenu.emit("Show", self.menuShow)
514 514
515 def _openItem(self): 515 def _openItem(self):
516 """ 516 """
517 Protected slot to handle the open popup menu entry. 517 Protected slot to handle the open popup menu entry.
518 """ 518 """
650 self.trUtf8("Do you really want to delete these files from the project?"), 650 self.trUtf8("Do you really want to delete these files from the project?"),
651 files) 651 files)
652 652
653 if dlg.exec_() == QDialog.Accepted: 653 if dlg.exec_() == QDialog.Accepted:
654 for fn2, fn in zip(fullNames, files): 654 for fn2, fn in zip(fullNames, files):
655 self.emit(SIGNAL('closeSourceWindow'), fn2) 655 self.closeSourceWindow.emit(fn2)
656 self.project.deleteFile(fn) 656 self.project.deleteFile(fn)
657 657
658 ############################################################################ 658 ############################################################################
659 ## Methods for the Checks submenu 659 ## Methods for the Checks submenu
660 ############################################################################ 660 ############################################################################
661 661
662 def __showContextMenuCheck(self): 662 def __showContextMenuCheck(self):
663 """ 663 """
664 Private slot called before the checks menu is shown. 664 Private slot called before the checks menu is shown.
665 """ 665 """
666 self.emit(SIGNAL("showMenu"), "Checks", self.checksMenu) 666 self.showMenu.emit("Checks", self.checksMenu)
667 667
668 ############################################################################ 668 ############################################################################
669 ## Methods for the Show submenu 669 ## Methods for the Show submenu
670 ############################################################################ 670 ############################################################################
671 671
792 792
793 def __showContextMenuGraphics(self): 793 def __showContextMenuGraphics(self):
794 """ 794 """
795 Private slot called before the checks menu is shown. 795 Private slot called before the checks menu is shown.
796 """ 796 """
797 self.emit(SIGNAL("showMenu"), "Graphics", self.graphicsMenu) 797 self.showMenu.emit("Graphics", self.graphicsMenu)
798 798
799 def __showClassDiagram(self): 799 def __showClassDiagram(self):
800 """ 800 """
801 Private method to handle the class diagram context menu action. 801 Private method to handle the class diagram context menu action.
802 """ 802 """

eric ide

mercurial