aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gui.py13
-rw-r--r--muddle.ui3
2 files changed, 13 insertions, 3 deletions
diff --git a/gui.py b/gui.py
index 3cb1474..1edf4c9 100644
--- a/gui.py
+++ b/gui.py
@@ -23,6 +23,7 @@ from PyQt5.QtCore import (
pyqtSlot,
pyqtSignal,
QObject,
+ QRegularExpression,
QSortFilterProxyModel,
)
@@ -276,7 +277,7 @@ class MuddleWindow(QMainWindow):
logging.getLogger("muddle").addHandler(self.loghandler)
# set up proxymodel for moodle treeview
- moodleTreeWidget = MoodleTreeWidget(None)
+ moodleTreeWidget = MoodleTreeWidget(None) # TODO: refractor into model
self.filter = MoodleTreeFilterModel()
self.filter.setRecursiveFilteringEnabled(True)
@@ -292,6 +293,7 @@ class MuddleWindow(QMainWindow):
# searchbar
searchBar = self.findChild(QLineEdit, "searchBar")
searchBar.textChanged.connect(self.onSearchBarTextChanged)
+ searchBar.textEdited.connect(self.onSearchBarTextChanged)
# local filesystem view
self.downloadPath = QDir.homePath()
@@ -317,9 +319,14 @@ class MuddleWindow(QMainWindow):
@pyqtSlot(str)
def onSearchBarTextChanged(self, text):
if not text:
- self.filter.invalidateFilter()
+ self.filter.setFilterRegularExpression(".*")
else:
- self.filter.setFilterRegExp(text)
+ regexp = QRegularExpression(text)
+ if regexp.isValid():
+ self.filter.setFilterRegularExpression(regexp)
+ self.findChild(QTreeView, "moodleTree").expandAll()
+ else:
+ log.debug("invalid search regular expression, not searching")
@pyqtSlot(str)
def onNewLogMessage(self, msg):
diff --git a/muddle.ui b/muddle.ui
index b9b0414..02dbae5 100644
--- a/muddle.ui
+++ b/muddle.ui
@@ -65,6 +65,9 @@
<property name="placeholderText">
<string>Search (regexp)</string>
</property>
+ <property name="clearButtonEnabled">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="5" column="0" colspan="2">