aboutsummaryrefslogtreecommitdiffstats
path: root/gui.py
diff options
context:
space:
mode:
authorNao Pross <np@0hm.ch>2020-11-09 11:48:44 +0100
committerNao Pross <np@0hm.ch>2020-11-09 11:48:44 +0100
commit684bcd9d36d19308ec8d02ae6e92df6b4e71dcb9 (patch)
treeafe75b48fad81ee034bb7c9d3f721e175bc637a1 /gui.py
parentImplement download path selection (diff)
downloadMuddle-684bcd9d36d19308ec8d02ae6e92df6b4e71dcb9.tar.gz
Muddle-684bcd9d36d19308ec8d02ae6e92df6b4e71dcb9.zip
Improve search
- Add clear button - Fix minor some behavior bugs - Expand tree items
Diffstat (limited to '')
-rw-r--r--gui.py13
1 files changed, 10 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):