Skip to content
Permalink
Browse files

Merge pull request #3731 from nyalldawson/alg_tags

[processing] Allow algorithms to specify tags
  • Loading branch information
volaya committed Nov 8, 2016
2 parents 0189609 + 3550cc9 commit db35b38bdb32e22fd9c4239c0ee236ab04321691
@@ -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')))
@@ -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]))
@@ -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
@@ -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)
@@ -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):
@@ -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(' ', '_')
@@ -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:

0 comments on commit db35b38

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