Read about our upcoming Code of Conduct on this issue

Commit 790f8868 authored by Adrian Buehlmann's avatar Adrian Buehlmann
Browse files

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)
parent b5dc923712d7
...@@ -95,6 +95,8 @@ class RepoTreeView(QTreeView): ...@@ -95,6 +95,8 @@ class RepoTreeView(QTreeView):
def _action_defs(self): def _action_defs(self):
a = [("open", _("Open"), None, a = [("open", _("Open"), None,
_("Open the repository in a new tab"), None,, _("Open the repository in a new tab"), None,,
("openAll", _("Open All"), None,
_("Open all repositories in new tabs"), None, self.openAll),
("newGroup", _("New Group"), None, ("newGroup", _("New Group"), None,
_("Create a new group"), None, self.newGroup), _("Create a new group"), None, self.newGroup),
("rename", _("Rename"), None, ("rename", _("Rename"), None,
...@@ -152,6 +154,11 @@ class RepoTreeView(QTreeView): ...@@ -152,6 +154,11 @@ class RepoTreeView(QTreeView):
return return
self.selitem.internalPointer().open() self.selitem.internalPointer().open()
def openAll(self):
if not self.selitem:
def showFirstTabOrOpen(self): def showFirstTabOrOpen(self):
if not self.selitem: if not self.selitem:
return return
...@@ -210,7 +217,7 @@ class RepoTreeView(QTreeView): ...@@ -210,7 +217,7 @@ class RepoTreeView(QTreeView):
class RepoRegistryView(QDockWidget): class RepoRegistryView(QDockWidget):
openRepoSignal = pyqtSignal(QString) openRepoSignal = pyqtSignal(QString, bool)
visibilityChanged = pyqtSignal(bool) visibilityChanged = pyqtSignal(bool)
def __init__(self, workbench): def __init__(self, workbench):
...@@ -248,8 +255,8 @@ class RepoRegistryView(QDockWidget): ...@@ -248,8 +255,8 @@ class RepoRegistryView(QDockWidget):
if m.getRepoItem(reporoot) == None: if m.getRepoItem(reporoot) == None:
m.addRepo(None, reporoot) m.addRepo(None, reporoot)
def openrepo(self, path): def openrepo(self, path, reuse=False):
self.openRepoSignal.emit(hglib.tounicode(path)) self.openRepoSignal.emit(hglib.tounicode(path), reuse)
def showPaths(self, show): def showPaths(self, show):
self.tview.setColumnHidden(1, not show) self.tview.setColumnHidden(1, not show)
...@@ -121,7 +121,10 @@ class RepoTreeItem(object): ...@@ -121,7 +121,10 @@ class RepoTreeItem(object):
self.dump(xw) self.dump(xw)
xw.writeEndElement() xw.writeEndElement()
def open(self): def open(self, reuse=False):
def openAll(self):
pass pass
def showFirstTabOrOpen(self, workbench=None): def showFirstTabOrOpen(self, workbench=None):
...@@ -184,8 +187,8 @@ class RepoItem(RepoTreeItem): ...@@ -184,8 +187,8 @@ class RepoItem(RepoTreeItem):
self._root = hglib.fromunicode(a.value('', 'root').toString()) self._root = hglib.fromunicode(a.value('', 'root').toString())
RepoTreeItem.undump(self, xr) RepoTreeItem.undump(self, xr)
def open(self): def open(self, reuse=False):
self.model.openrepofunc(self._root) self.model.openrepofunc(self._root, reuse)
def showFirstTabOrOpen(self, workbench=None): def showFirstTabOrOpen(self, workbench=None):
workbench.showRepo(hglib.tounicode(self._root)) workbench.showRepo(hglib.tounicode(self._root))
...@@ -232,12 +235,16 @@ class RepoGroupItem(RepoTreeItem): ...@@ -232,12 +235,16 @@ class RepoGroupItem(RepoTreeItem):
return False return False
def menulist(self): def menulist(self):
return ['add', None, 'newGroup', None, 'rename', 'remove'] return ['openAll', 'add', None, 'newGroup', None, 'rename', 'remove']
def flags(self): def flags(self):
return (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDropEnabled return (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDropEnabled
| Qt.ItemIsEditable) | Qt.ItemIsEditable)
def openAll(self):
for c in self.childs:
def dump(self, xw): def dump(self, xw):
xw.writeAttribute('name', xw.writeAttribute('name',
RepoTreeItem.dump(self, xw) RepoTreeItem.dump(self, xw)
...@@ -333,11 +333,11 @@ class Workbench(QMainWindow): ...@@ -333,11 +333,11 @@ class Workbench(QMainWindow):
else: else:
rw.switchToNamedTaskTab(str( rw.switchToNamedTaskTab(str(
def openRepo(self, repopath): def openRepo(self, repopath, reuse=False):
""" Open repo by openRepoSignal from reporegistry """ """ Open repo by openRepoSignal from reporegistry """
if isinstance(repopath, (unicode, QString)): # as Qt slot if isinstance(repopath, (unicode, QString)): # as Qt slot
repopath = hglib.fromunicode(repopath) repopath = hglib.fromunicode(repopath)
self._openRepo(path=repopath) self._openRepo(path=repopath, reuse=reuse)
@pyqtSlot(unicode) @pyqtSlot(unicode)
def showRepo(self, path): def showRepo(self, path):
...@@ -548,8 +548,11 @@ class Workbench(QMainWindow): ...@@ -548,8 +548,11 @@ class Workbench(QMainWindow):
options=FD.ShowDirsOnly | FD.ReadOnly) options=FD.ShowDirsOnly | FD.ReadOnly)
self._openRepo(path=hglib.fromunicode(path)) self._openRepo(path=hglib.fromunicode(path))
def _openRepo(self, path): def _openRepo(self, path, reuse=False):
if path: if path:
if reuse:
for rw in self._findrepowidget(path):
try: try:
repo = thgrepo.repository(path=path) repo = thgrepo.repository(path=path)
self.addRepoTab(repo) self.addRepoTab(repo)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment