Skip to content
Permalink
Browse files

[processing] When searching in toolbox, ignore order of words

Eg, allows you to search "line merge" and find the "Merge lines"
algorithm. Should make it easier for users who don't know the
exact name to find algorithms.
  • Loading branch information
nyalldawson committed Nov 7, 2016
1 parent 35a29d8 commit 1a4f8f59f1b26fc88e0686b51646723a4243f9ba
Showing with 9 additions and 4 deletions.
  1. +9 −4 python/plugins/processing/gui/ProcessingToolbox.py
@@ -108,7 +108,7 @@ def textChanged(self):
text = self.searchBox.text().strip(' ').lower()
for item in list(self.disabledProviderItems.values()):
item.setHidden(True)
self._filterItem(self.algorithmTree.invisibleRootItem(), text)
self._filterItem(self.algorithmTree.invisibleRootItem(), [t for t in text.split(' ') if t])
if text:
self.algorithmTree.expandAll()
self.disabledWithMatchingAlgs = []
@@ -137,10 +137,15 @@ def _filterItem(self, item, text):
item.setHidden(not show)
return show
elif isinstance(item, (TreeAlgorithmItem, TreeActionItem)):
# hide = bool(text) and (text not in item.text(0).lower())
hide = bool(text) and not any(text in t for t in [item.text(0).lower(), item.data(0, Qt.UserRole).lower()])
# hide if every part of text is not contained somewhere in either the item text or item user role
item_text = [item.text(0).lower(), item.data(0, Qt.UserRole).lower()]
if isinstance(item, TreeAlgorithmItem):
hide = hide and (text not in item.alg.commandLineName())
item_text.append(item.alg.commandLineName())

hide = bool(text) and not all(
any(part in t for t in item_text)
for part in text)

item.setHidden(hide)
return not hide
else:

0 comments on commit 1a4f8f5

Please sign in to comment.
You can’t perform that action at this time.