[processing] Update Processing toolbox when a provider is added or removed

This commit is contained in:
Rado Guzinski 2014-05-26 18:36:12 +02:00
parent aa43059d5a
commit 2ef7dcf6b9
2 changed files with 11 additions and 3 deletions

View File

@ -67,6 +67,8 @@ class Processing:
listeners = []
providers = []
toolbox = None
# A dictionary of algorithms. Keys are names of providers
# and values are list with all algorithms from that provider
algs = {}
@ -79,6 +81,10 @@ class Processing:
modeler = ModelerAlgorithmProvider()
@staticmethod
def setToolbox(toolbox):
Processing.toolbox = toolbox
@staticmethod
def addProvider(provider, updateList=False):
"""Use this method to add algorithms from external providers.
@ -91,8 +97,8 @@ class Processing:
provider.initializeSettings()
Processing.providers.append(provider)
ProcessingConfig.readSettings()
if updateList:
Processing.updateAlgsList()
if updateList and Processing.toolbox:
Processing.toolbox.updateTree()
except:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load provider:'
@ -111,7 +117,8 @@ class Processing:
provider.unload()
Processing.providers.remove(provider)
ProcessingConfig.readSettings()
Processing.updateAlgsList()
if Processing.toolbox:
Processing.toolbox.updateTree()
except:
# This try catch block is here to avoid problems if the
# plugin with a provider is unloaded after the Processing

View File

@ -72,6 +72,7 @@ class ProcessingToolbox(QDockWidget, Ui_ProcessingToolbox):
if hasattr(self.searchBox, 'setPlaceholderText'):
self.searchBox.setPlaceholderText(self.tr('Search...'))
Processing.setToolbox(self)
self.fillTree()
def textChanged(self):