Adrian Buehlmann avatar Adrian Buehlmann committed f1dd5c4

reporegistry: add new "Open All" cmenu command for group items

opens all repos in the group (if they aren't already open in a tab)

Comments (0)

Files changed (3)

tortoisehg/hgqt/reporegistry.py

     def _action_defs(self):
         a = [("open", _("Open"), None,
                 _("Open the repository in a new tab"), None, self.open),
+             ("openAll", _("Open All"), None,
+                _("Open all repositories in new tabs"), None, self.openAll),
              ("newGroup", _("New Group"), None,
                 _("Create a new group"), None, self.newGroup),
              ("rename", _("Rename"), None,
             return
         self.selitem.internalPointer().open()
 
+    def openAll(self):
+        if not self.selitem:
+            return
+        self.selitem.internalPointer().openAll()
+
     def showFirstTabOrOpen(self):
         if not self.selitem:
             return
 
 class RepoRegistryView(QDockWidget):
 
-    openRepoSignal = pyqtSignal(QString)
+    openRepoSignal = pyqtSignal(QString, bool)
     visibilityChanged = pyqtSignal(bool)
 
     def __init__(self, workbench):
         if m.getRepoItem(reporoot) == None:
             m.addRepo(None, reporoot)
 
-    def openrepo(self, path):
-        self.openRepoSignal.emit(hglib.tounicode(path))
+    def openrepo(self, path, reuse=False):
+        self.openRepoSignal.emit(hglib.tounicode(path), reuse)
 
     def showPaths(self, show):
         self.tview.setColumnHidden(1, not show)

tortoisehg/hgqt/repotreeitem.py

         self.dump(xw)
         xw.writeEndElement()
 
-    def open(self):
+    def open(self, reuse=False):
+        pass
+
+    def openAll(self):
         pass
 
     def showFirstTabOrOpen(self, workbench=None):
         self._root = hglib.fromunicode(a.value('', 'root').toString())
         RepoTreeItem.undump(self, xr)
 
-    def open(self):
-        self.model.openrepofunc(self._root)
+    def open(self, reuse=False):
+        self.model.openrepofunc(self._root, reuse)
 
     def showFirstTabOrOpen(self, workbench=None):
         workbench.showRepo(hglib.tounicode(self._root))
         return False
 
     def menulist(self):
-        return ['add', None, 'newGroup', None, 'rename', 'remove']
+        return ['openAll', 'add', None, 'newGroup', None, 'rename', 'remove']
 
     def flags(self):
         return (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDropEnabled
             | Qt.ItemIsEditable)
 
+    def openAll(self):
+        for c in self.childs:
+            c.open(reuse=True)
+
     def dump(self, xw):
         xw.writeAttribute('name', self.name)
         RepoTreeItem.dump(self, xw)

tortoisehg/hgqt/workbench.py

         else:
             rw.switchToNamedTaskTab(str(action.data().toString()))
 
-    def openRepo(self, repopath):
+    def openRepo(self, repopath, reuse=False):
         """ Open repo by openRepoSignal from reporegistry """
         if isinstance(repopath, (unicode, QString)):  # as Qt slot
             repopath = hglib.fromunicode(repopath)
-        self._openRepo(path=repopath)
+        self._openRepo(path=repopath, reuse=reuse)
 
     @pyqtSlot(unicode)
     def showRepo(self, path):
             options=FD.ShowDirsOnly | FD.ReadOnly)
         self._openRepo(path=hglib.fromunicode(path))
 
-    def _openRepo(self, path):
+    def _openRepo(self, path, reuse=False):
         if path:
+            if reuse:
+                for rw in self._findrepowidget(path):
+                    return
             try:
                 repo = thgrepo.repository(path=path)
                 self.addRepoTab(repo)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.