Skip to content

Commit

Permalink
Merge pull request #3731 from nyalldawson/alg_tags
Browse files Browse the repository at this point in the history
[processing] Allow algorithms to specify tags
  • Loading branch information
volaya committed Nov 8, 2016
2 parents 0189609 + 3550cc9 commit db35b38
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/ExtentFromLayer.py
Expand Up @@ -54,6 +54,7 @@ def getIcon(self):
def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Polygon from layer extent')
self.group, self.i18n_group = self.trAlgorithm('Vector general tools')
self.tags = self.tr('extent,envelope,bounds,bounding,boundary,layer')

self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer')))
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/algs/qgis/MergeLines.py
Expand Up @@ -51,6 +51,7 @@ def getIcon(self):
def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Merge lines')
self.group, self.i18n_group = self.trAlgorithm('Vector geometry tools')
self.tags = self.tr('line,merge,join,parts')

self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [dataobjects.TYPE_VECTOR_LINE]))
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -64,6 +64,9 @@ def __init__(self):
self.name, self.i18n_name = '', ''
self.group, self.i18n_group = '', ''

# Tags
self.tags = ''

# The crs taken from input layers (if possible), and used when
# loading output layers
self.crs = None
Expand Down
2 changes: 2 additions & 0 deletions python/plugins/processing/gui/ProcessingToolbox.py
Expand Up @@ -141,6 +141,7 @@ def _filterItem(self, item, text):
item_text = [item.text(0).lower(), item.data(0, Qt.UserRole).lower()]
if isinstance(item, TreeAlgorithmItem):
item_text.append(item.alg.commandLineName())
item_text.extend(item.data(0, Qt.UserRole + 1))

hide = bool(text) and not all(
any(part in t for t in item_text)
Expand Down Expand Up @@ -355,6 +356,7 @@ def __init__(self, alg):
self.setToolTip(0, name)
self.setText(0, name)
self.setData(0, Qt.UserRole, nameEn)
self.setData(0, Qt.UserRole + 1, alg.tags.split(','))


class TreeActionItem(QTreeWidgetItem):
Expand Down
11 changes: 10 additions & 1 deletion python/plugins/processing/modeler/ModelerDialog.py
Expand Up @@ -472,6 +472,7 @@ def fillAlgorithmTree(self):
def fillAlgorithmTreeUsingProviders(self):
self.algorithmTree.clear()
text = str(self.searchBox.text())
search_strings = text.split(' ')
allAlgs = algList.algs
for providerName in list(allAlgs.keys()):
name = 'ACTIVATE_' + providerName.upper().replace(' ', '_')
Expand All @@ -486,7 +487,15 @@ def fillAlgorithmTreeUsingProviders(self):
continue
if alg.commandLineName() == self.alg.commandLineName():
continue
if text == '' or text.lower() in alg.name.lower():

item_text = [alg.name.lower()]
item_text.extend(alg.tags.split(','))

show = not search_strings or all(
any(part in t for t in item_text)
for part in search_strings)

if show:
if alg.group in groups:
groupItem = groups[alg.group]
else:
Expand Down

0 comments on commit db35b38

Please sign in to comment.