Skip to content

Commit

Permalink
[processing] Update Processing toolbox when a provider is added or re…
Browse files Browse the repository at this point in the history
…moved
  • Loading branch information
Rado Guzinski committed May 26, 2014
1 parent aa43059 commit 2ef7dcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions python/plugins/processing/core/Processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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.
Expand All @@ -91,8 +97,8 @@ def addProvider(provider, updateList=False):
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:'
Expand All @@ -111,7 +117,8 @@ def removeProvider(provider):
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
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/gui/ProcessingToolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(self):
if hasattr(self.searchBox, 'setPlaceholderText'):
self.searchBox.setPlaceholderText(self.tr('Search...'))

Processing.setToolbox(self)
self.fillTree()

def textChanged(self):
Expand Down

0 comments on commit 2ef7dcf

Please sign in to comment.