Skip to content
Permalink
Browse files

[processing] filter items in toolbox using translated and original na…

…mes (fix #13764)
  • Loading branch information
alexbruy committed Apr 11, 2016
1 parent 16d8da3 commit abda90fe0dfc680273fd0db7ee865e67faeaa83b
@@ -36,8 +36,8 @@
class OpenViewerAction(ToolboxAction):

def __init__(self):
self.name = self.tr('Open Fusion LAS viewer')
self.group = self.tr('Visualization')
self.name, self.i18n_name = self.trAction('Open Fusion LAS viewer')
self.group, self.i18n_group = self.trAction('Visualization')

def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../../../images/tool.png')
@@ -52,7 +52,7 @@ def __init__(self):
AlgorithmProvider.__init__(self)
self.activate = False
self.actions.append(CreateNewScriptAction(
self.tr('Create new R script'), CreateNewScriptAction.SCRIPT_R))
'Create new R script', CreateNewScriptAction.SCRIPT_R))
self.actions.append(GetRScriptsAction())
self.contextMenuActions = \
[EditScriptAction(EditScriptAction.SCRIPT_R),
@@ -74,3 +74,7 @@ def getDisplayNameEn(alg):

def getDisplayName(alg):
return alg.i18n_name or alg.name


def getDisplayNames(alg):
return alg.name, alg.i18n_name
@@ -41,8 +41,9 @@ class CreateNewScriptAction(ToolboxAction):
SCRIPT_R = 1

def __init__(self, actionName, scriptType):
self.name = actionName
self.group = self.tr('Tools', 'CreateNewScriptAction')
self.name, self.i18n_name = self.trAction(actionName)
self.group, self.i18n_group = self.trAction('Tools')

self.scriptType = scriptType

def getIcon(self):
@@ -55,8 +55,8 @@
class GetScriptsAction(ToolboxAction):

def __init__(self):
self.name = self.tr('Get scripts from on-line scripts collection', 'GetScriptsAction')
self.group = self.tr('Tools', 'GetScriptsAction')
self.name, self.i18n_name = self.trAction('Get scripts from on-line scripts collection')
self.group, self.i18n_group = self.trAction('Tools')

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'script.png'))
@@ -71,8 +71,8 @@ def execute(self):
class GetRScriptsAction(ToolboxAction):

def __init__(self):
self.name = self.tr('Get R scripts from on-line scripts collection', 'GetRScriptsAction')
self.group = self.tr('Tools', 'GetRScriptsAction')
self.name, self.i18n_name = self.trAction('Get R scripts from on-line scripts collection')
self.group, self.i18n_group = self.trAction('Tools')

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'r.svg'))
@@ -87,8 +87,8 @@ def execute(self):
class GetModelsAction(ToolboxAction):

def __init__(self):
self.name = self.tr('Get models from on-line scripts collection', 'GetModelsAction')
self.group = self.tr('Tools', 'GetModelsAction')
self.name, self.i18n_name = self.trAction('Get models from on-line scripts collection')
self.group, self.i18n_group = self.trAction('Tools')

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'model.png'))
@@ -133,7 +133,8 @@ 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 (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()])
if isinstance(item, TreeAlgorithmItem):
hide = hide and (text not in item.alg.commandLineName())
item.setHidden(hide)
@@ -327,19 +328,21 @@ def __init__(self, alg):
QTreeWidgetItem.__init__(self)
self.alg = alg
icon = alg.getIcon()
name = AlgorithmClassification.getDisplayName(alg)
nameEn, name = AlgorithmClassification.getDisplayNames(alg)
self.setIcon(0, icon)
self.setToolTip(0, name)
self.setText(0, name)
self.setData(0, Qt.UserRole, nameEn)


class TreeActionItem(QTreeWidgetItem):

def __init__(self, action):
QTreeWidgetItem.__init__(self)
self.action = action
self.setText(0, action.name)
self.setText(0, action.i18n_name)
self.setIcon(0, action.getIcon())
self.setData(0, Qt.UserRole, action.name)


class TreeProviderItem(QTreeWidgetItem):
@@ -42,3 +42,8 @@ def tr(self, string, context=''):
if context == '':
context = self.__class__.__name__
return QCoreApplication.translate(context, string)

def trAction(self, string, context=''):
if context == '':
context = self.__class__.__name__
return string, QCoreApplication.translate(context, string)
@@ -41,8 +41,8 @@
class AddModelFromFileAction(ToolboxAction):

def __init__(self):
self.name = self.tr('Add model from file', 'AddModelFromFileAction')
self.group = self.tr('Tools', 'AddModelFromFileAction')
self.name, self.i18n_name = self.trAction('Add model from file')
self.group, self.i18n_group = self.trAction('Tools')

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'model.png'))
@@ -36,8 +36,8 @@
class CreateNewModelAction(ToolboxAction):

def __init__(self):
self.name = self.tr('Create new model', 'CreateNewModelAction')
self.group = self.tr('Tools', 'CreateNewModelAction')
self.name, self.i18n_name = self.trAction('Create new model')
self.group, self.i18n_group = self.trAction('Tools')

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'model.png'))
@@ -42,8 +42,8 @@
class AddScriptFromFileAction(ToolboxAction):

def __init__(self):
self.name = self.tr('Add script from file', 'AddScriptFromFileAction')
self.group = self.tr('Tools', 'AddScriptFromFileAction')
self.name, self.i18n_name = self.trAction('Add script from file')
self.group, self.i18n_group = self.trAction('Tools')

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'script.png'))
@@ -45,7 +45,7 @@ class ScriptAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.actions.extend([CreateNewScriptAction(self.tr('Create new script', 'ScriptAlgorithmProvider'),
self.actions.extend([CreateNewScriptAction('Create new script',
CreateNewScriptAction.SCRIPT_PYTHON),
AddScriptFromFileAction(),
GetScriptsAction()])

0 comments on commit abda90f

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