Commit b9ec3781 authored by Steve Borho's avatar Steve Borho
Browse files

repofilter: add a filter checkbutton

Toggles the display of revision sets as a filtered list or as part of the
whole revision graph.  Filters and branch selections now survive reloads
parent a3d329cf076d
......@@ -36,7 +36,7 @@ class FileRevModel(HgRepoListModel):
"""
data is a HgHLRepo instance
"""
HgRepoListModel.__init__(self, repo, parent=parent)
HgRepoListModel.__init__(self, repo, '', [], False, parent)
self.setFilename(filename)
def setRepo(self, repo, branch='', fromhead=None, follow=False):
......
......@@ -17,6 +17,7 @@ class RepoFilterBar(QToolBar):
revisionSet = pyqtSignal(object)
clearSet = pyqtSignal()
filterToggled = pyqtSignal(bool)
showMessage = pyqtSignal(QString)
progress = pyqtSignal(QString, object, QString, QString, object)
......@@ -48,13 +49,18 @@ class RepoFilterBar(QToolBar):
self.revsetle = le = QLineEdit()
le.setCompleter(QCompleter(self.revsethist))
le.returnPressed.connect(self.returnPressed)
# Requires Qt 4.7
#self.revsetle.setPlaceholderText('### revision set query ###')
if hasattr(self.revsetle, 'setPlaceholderText'): # Qt >= 4.7
self.revsetle.setPlaceholderText('### revision set query ###')
self.addWidget(le)
self.clear.clicked.connect(le.clear)
self.clear.clicked.connect(self.clearSet)
self.filtercb = f = QCheckBox(_('filter'))
f.setChecked(s.value('revset-filter').toBool())
f.toggled.connect(self.filterToggled)
self.addWidget(f)
self.store = store = QPushButton(_('store'))
store.clicked.connect(self.saveQuery)
le.textChanged.connect(lambda t: store.setEnabled(False))
......@@ -95,6 +101,7 @@ class RepoFilterBar(QToolBar):
def storeConfigs(self, s):
s.setValue('revset/geom', self.entrydlg.saveGeometry())
s.setValue('revset-queries', self.revsethist)
s.setValue('revset-filter', self.filtercb.isChecked())
def _initbranchfilter(self):
self._branchLabel = QToolButton(
......
......@@ -85,7 +85,7 @@ class HgRepoListModel(QAbstractTableModel):
_columns = ('Graph', 'ID', 'Branch', 'Log', 'Author', 'Age', 'Tags',)
_stretchs = {'Log': 1, }
def __init__(self, repo, branch='', parent=None):
def __init__(self, repo, branch, revset, rfilter, parent):
"""
repo is a hg repo instance
"""
......@@ -97,7 +97,8 @@ class HgRepoListModel(QAbstractTableModel):
self.rowheight = 20
self.rowcount = 0
self.repo = repo
self.revset = ()
self.revset = revset
self.filterbyrevset = rfilter
self.reloadConfig()
self.updateColumns()
self.setBranch(branch)
......@@ -126,7 +127,7 @@ class HgRepoListModel(QAbstractTableModel):
def setBranch(self, branch=None, allparents=True):
self.filterbranch = branch
self.datacache = {}
if self.revset: # TODO: and self.filterbyrevset
if self.revset and self.filterbyrevset:
grapher = revision_grapher(self.repo, revset=self.revset)
self.graph = Graph(self.repo, grapher, include_mq=False)
else:
......
......@@ -54,6 +54,9 @@ class RepoWidget(QWidget):
repo.repositoryDestroyed.connect(self.repositoryDestroyed)
repo.configChanged.connect(self.configChanged)
self.workbench = workbench
self.revsetfilter = False
self.branch = ''
self.revset = set()
self._reload_rev = '.' # select working parent at startup
self.currentMessage = ''
......@@ -78,8 +81,11 @@ class RepoWidget(QWidget):
self.filterbar.showMessage.connect(self.showMessage)
self.filterbar.revisionSet.connect(self.setRevisionSet)
self.filterbar.clearSet.connect(self.clearSet)
self.filterbar.filterToggled.connect(self.filterToggled)
self.layout().addWidget(self.filterbar)
self.revsetfilter = self.filterbar.filtercb.isChecked()
self.layout().addWidget(self.repotabs_splitter)
self.repoview = view = HgRepoView(self.workbench, self.repo)
......@@ -148,7 +154,7 @@ class RepoWidget(QWidget):
def createCommitWidget(self):
cw = self.getCommitWidget()
if cw:
cw.commitComplete.connect(self.reload)
cw.commitComplete.connect(self.reload) # todo: redundant?
return SharedWidget(cw)
pats = {}
......@@ -207,12 +213,27 @@ class RepoWidget(QWidget):
return SharedWidget(sw)
def clearSet(self):
self.repomodel.revset = set()
self.refresh()
self.revset = []
if self.revsetfilter:
self.reload()
else:
self.repomodel.revset = []
self.refresh()
def setRevisionSet(self, nodes):
self.repomodel.revset = [self.repo[n].node() for n in nodes]
self.refresh()
self.revset = [self.repo[n].node() for n in nodes]
if self.revsetfilter:
self.reload()
else:
self.repomodel.revset = self.revset
self.refresh()
@pyqtSlot(bool)
def filterToggled(self, checked):
self.revsetfilter = checked
if self.revset:
self.repomodel.filterbyrevset = checked
self.reload()
def setOutgoingNodes(self, nodes):
self.filterbar.revsetle.setText('outgoing()')
......@@ -312,7 +333,6 @@ class RepoWidget(QWidget):
def thgimport(self, paths=None):
dlg = thgimport.ImportDialog(repo=self.repo, parent=self)
dlg.repoInvalidated.connect(self.reload)
dlg.finished.connect(dlg.deleteLater)
if paths:
dlg.setfilepaths(paths)
......@@ -367,11 +387,14 @@ class RepoWidget(QWidget):
'by this rollback, leaving uncommitted changes.\n '
'Continue?' % rev)):
return
saved = self.repo.ui.quiet
self.repo.ui.quiet = True
self.repo.rollback()
self.repo.ui.quiet = saved
self.reload()
self.repo.incrementBusyCount()
try:
saved = self.repo.ui.quiet
self.repo.ui.quiet = True
self.repo.rollback()
self.repo.ui.quiet = saved
finally:
self.repo.decrementBusyCount()
QTimer.singleShot(500, lambda: shlib.shell_notify([self.repo.root]))
def purge(self):
......@@ -400,14 +423,12 @@ class RepoWidget(QWidget):
self.taskTabsWidget.setCurrentIndex(self.grepTabIndex)
self.grepDemand.setSearch(pattern, **opts)
def create_models(self):
self.repomodel = HgRepoListModel(self.repo, parent=self)
def setupModels(self):
self.repomodel = HgRepoListModel(self.repo, self.branch, self.revset,
self.revsetfilter, self)
self.repomodel.filled.connect(self.modelFilled)
self.repomodel.loaded.connect(self.modelLoaded)
self.repomodel.showMessage.connect(self.showMessage)
def setupModels(self):
self.create_models()
self.repoview.setModel(self.repomodel)
self.revDetailsWidget.setupModels(self.repomodel)
......@@ -519,6 +540,7 @@ class RepoWidget(QWidget):
@pyqtSlot(unicode, bool)
def setBranch(self, branch, allparents=True):
'Change the branch filter'
self.branch = branch
self.repomodel.setBranch(branch=branch, allparents=allparents)
self.titleChanged.emit(self.title())
......
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