Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py

changeset 1011
0b118aefae5b
parent 1005
6986db425aa2
child 1034
8a7fa049e9d3
--- a/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Sun May 01 19:01:24 2011 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/ProjectHelper.py	Mon May 02 19:59:41 2011 +0200
@@ -16,6 +16,8 @@
 
 from VCS.ProjectHelper import VcsProjectHelper
 
+from .BookmarksExtension.ProjectHelper import BookmarksProjectHelper
+
 from E5Gui.E5Action import E5Action
 
 import UI.PixmapCache
@@ -36,6 +38,24 @@
         @param name name of this object (string)
         """
         VcsProjectHelper.__init__(self, vcsObject, projectObject, parent, name)
+        
+        # instantiate the extensions
+        self.__extensions = {
+            "bookmarks" : BookmarksProjectHelper(),
+        }
+    
+    def setObjects(self, vcsObject, projectObject):
+        """
+        Public method to set references to the vcs and project objects.
+        
+        @param vcsObject reference to the vcs object
+        @param projectObject reference to the project object
+        """
+        self.vcs = vcsObject
+        self.project = projectObject
+        
+        for extension in self.__extensions.values():
+            extension.setObjects(vcsObject, projectObject)
     
     def getActions(self):
         """
@@ -43,7 +63,10 @@
         
         @return list of all actions (list of E5Action)
         """
-        return self.actions[:]
+        actions = self.actions[:]
+        for extension in self.__extensions.values():
+            actions.extend(extension.getActions())
+        return actions
     
     def initActions(self):
         """
@@ -829,6 +852,13 @@
         bisectMenu.addAction(self.hgBisectSkipAct)
         bisectMenu.addAction(self.hgBisectResetAct)
         
+        extensionsMenu = QMenu(self.trUtf8("Extensions"), menu)
+        extensionsMenu.aboutToShow.connect(self.__showExtensionMenu)
+        self.extensionMenus = {}
+        for extensionName in self.__extensions:
+            self.extensionMenus[extensionName] = extensionsMenu.addMenu(
+                self.__extensions[extensionName].initMenu(extensionsMenu))
+        
         act = menu.addAction(
             UI.PixmapCache.getIcon(
                 os.path.join("VcsPlugins", "vcsMercurial", "icons", "mercurial.png")),
@@ -848,6 +878,8 @@
         menu.addSeparator()
         menu.addMenu(bundleMenu)
         menu.addSeparator()
+        menu.addMenu(extensionsMenu)
+        menu.addSeparator()
         menu.addAction(self.vcsNewAct)
         menu.addAction(self.vcsExportAct)
         menu.addSeparator()
@@ -890,6 +922,14 @@
         menu.addSeparator()
         menu.addAction(self.hgConfigAct)
     
+    def __showExtensionMenu(self):
+        """
+        Private slot showing the extensions menu.
+        """
+        for extensionName in self.extensionMenus:
+            self.extensionMenus[extensionName].setEnabled(
+                self.vcs.isExtensionActive(extensionName))
+    
     def __hgExtendedDiff(self):
         """
         Private slot used to perform a hg diff with the selection of revisions.

eric ide

mercurial