mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Merge pull request #4206 from volaya/fix_processing_provider_update
[processing] fixed update of toolbox after editing script providers
This commit is contained in:
commit
e5ebcd170f
@ -172,11 +172,12 @@ class Processing(object):
|
||||
def updateAlgsList():
|
||||
"""Call this method when there has been any change that
|
||||
requires the list of algorithms to be created again from
|
||||
algorithm providers.
|
||||
algorithm providers. Use reloadProvider() for a more fine-grained
|
||||
update.
|
||||
"""
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
for p in Processing.providers:
|
||||
Processing.reloadProvider(p)
|
||||
Processing.reloadProvider(p.id())
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
@staticmethod
|
||||
|
@ -38,8 +38,6 @@ class AlgorithmList(QObject):
|
||||
# and values are list with all algorithms from that provider
|
||||
algs = {}
|
||||
|
||||
providers = []
|
||||
|
||||
def removeProvider(self, provider_id):
|
||||
if provider_id in self.algs:
|
||||
del self.algs[provider_id]
|
||||
@ -47,7 +45,7 @@ class AlgorithmList(QObject):
|
||||
QgsApplication.processingRegistry().removeProvider(provider_id)
|
||||
|
||||
def reloadProvider(self, provider_id):
|
||||
for p in self.providers:
|
||||
for p in QgsApplication.processingRegistry().providers():
|
||||
if p.id() == provider_id:
|
||||
p.loadAlgorithms()
|
||||
self.algs[p.id()] = {a.commandLineName(): a for a in p.algs}
|
||||
|
@ -62,8 +62,3 @@ class CreateNewScriptAction(ToolboxAction):
|
||||
if self.scriptType == self.SCRIPT_R:
|
||||
dlg = ScriptEditorDialog(ScriptEditorDialog.SCRIPT_R, None)
|
||||
dlg.show()
|
||||
if dlg.update:
|
||||
if self.scriptType == self.SCRIPT_PYTHON:
|
||||
algList.reloadProvider('script')
|
||||
elif self.scriptType == self.SCRIPT_R:
|
||||
algList.reloadProvider('r')
|
||||
|
@ -50,9 +50,3 @@ class EditScriptAction(ContextAction):
|
||||
def execute(self):
|
||||
dlg = ScriptEditorDialog(self.scriptType, self.itemData)
|
||||
dlg.show()
|
||||
dlg.exec_()
|
||||
if dlg.update:
|
||||
if self.scriptType == ScriptEditorDialog.SCRIPT_PYTHON:
|
||||
algList.reloadProvider('script')
|
||||
elif self.scriptType == ScriptEditorDialog.SCRIPT_R:
|
||||
algList.reloadProvider('r')
|
||||
|
@ -385,7 +385,7 @@ class TreeProviderItem(QTreeWidgetItem):
|
||||
|
||||
def refresh(self):
|
||||
self.takeChildren()
|
||||
Processing.updateAlgsList()
|
||||
#Processing.updateAlgsList()
|
||||
self.populate()
|
||||
|
||||
def populate(self):
|
||||
|
@ -49,6 +49,7 @@ from processing.algs.r.RAlgorithm import RAlgorithm
|
||||
from processing.algs.r.RUtils import RUtils
|
||||
from processing.script.ScriptAlgorithm import ScriptAlgorithm
|
||||
from processing.script.ScriptUtils import ScriptUtils
|
||||
from processing.core.alglist import algList
|
||||
|
||||
pluginPath = os.path.split(os.path.dirname(__file__))[0]
|
||||
WIDGET, BASE = uic.loadUiType(
|
||||
@ -169,12 +170,21 @@ class ScriptEditorDialog(BASE, WIDGET):
|
||||
QMessageBox.Yes | QMessageBox.No, QMessageBox.No
|
||||
)
|
||||
if ret == QMessageBox.Yes:
|
||||
self.updateProviders()
|
||||
evt.accept()
|
||||
else:
|
||||
evt.ignore()
|
||||
else:
|
||||
self.updateProviders()
|
||||
evt.accept()
|
||||
|
||||
def updateProviders(self):
|
||||
if self.update:
|
||||
if self.algType == self.SCRIPT_PYTHON:
|
||||
algList.reloadProvider('script')
|
||||
elif self.algType == self.SCRIPT_R:
|
||||
algList.reloadProvider('r')
|
||||
|
||||
def editHelp(self):
|
||||
if self.alg is None:
|
||||
if self.algType == self.SCRIPT_PYTHON:
|
||||
|
Loading…
x
Reference in New Issue
Block a user