1. Yuya Nishihara
  2. thg-qt-mq

Source

thg-qt-mq / mani-dlg-filter.diff

# HG changeset patch
# Parent 575e16f1bc55e75792929eb738b2d1a43329361d

diff --git a/tortoisehg/hgqt/manifestdialog.py b/tortoisehg/hgqt/manifestdialog.py
--- a/tortoisehg/hgqt/manifestdialog.py
+++ b/tortoisehg/hgqt/manifestdialog.py
@@ -182,6 +182,14 @@ class ManifestWidget(QWidget, qtlib.Task
         qs.setValue(prefix+'/revpanel.expanded', self.revpanel.is_expanded())
 
     def _initactions(self):
+        self._namefilter = le = QLineEdit()
+        if hasattr(le, 'setPlaceholderText'): # Qt >= 4.7
+            le.setPlaceholderText(_('### filter text ###'))
+        else:
+            lbl = QLabel(_('Filter:'))
+            self._toolbar.addWidget(lbl)
+        self._toolbar.addWidget(le)
+
         self._statusfilter = status.StatusFilterButton(
           statustext='MASC', text=_('Status'))
         self._toolbar.addWidget(self._statusfilter)
@@ -384,6 +392,7 @@ class ManifestWidget(QWidget, qtlib.Task
         self._treemodel = ManifestModel(self._repo, self._rev,
                                         statusfilter=self._statusfilter.status(),
                                         parent=self)
+        self._treemodel.setNameFilter(self._namefilter.text())
         oldmodel = self._treeview.model()
         oldselmodel = self._treeview.selectionModel()
         self._treeview.setModel(self._treemodel)
@@ -396,6 +405,8 @@ class ManifestWidget(QWidget, qtlib.Task
         selmodel.currentChanged.connect(self._updatecontent)
         selmodel.currentChanged.connect(self._emitPathChanged)
 
+        self._namefilter.textChanged.connect(self._treemodel.setNameFilter)
+        self._namefilter.textChanged.connect(self._autoexpandtree)
         self._statusfilter.statusChanged.connect(self._treemodel.setStatusFilter)
         self._statusfilter.statusChanged.connect(self._autoexpandtree)
         self._autoexpandtree()
@@ -403,7 +414,7 @@ class ManifestWidget(QWidget, qtlib.Task
     @pyqtSlot()
     def _autoexpandtree(self):
         """expand file tree if the number of the items isn't large"""
-        if 'C' not in self._statusfilter.status():
+        if 'C' not in self._statusfilter.status() or self._namefilter.text():
             self._treeview.expandAll()
 
     def reload(self):