Skip to content

Commit

Permalink
[processing] When searching in toolbox, ignore order of words
Browse files Browse the repository at this point in the history
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 1a4f8f5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions python/plugins/processing/gui/ProcessingToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 1a4f8f5

Please sign in to comment.