Skip to content
Permalink
Browse files
Remove processing algList
All functionality has been moved to QgsProcessingRegistry
  • Loading branch information
nyalldawson committed Apr 7, 2017
1 parent 4970bb4 commit fb1cf1e18519780f2cd8396ce840dfb6c1e6e94a
@@ -2169,6 +2169,7 @@ need to update their use of the progress argument to utilize the QgsProcessingFe
- Similarly, Python processing scripts no longer have access to a progress variable for reporting their progress. Instead they have a feedback
object of type QgsProcessingFeedback, and will need to adapt their use of progress reporting to the QgsProcessingFeedback API.
- SilentProgress was removed. Use the base QgsProcessingFeedback class instead.
- algList was removed. Use QgsApplication.processingRegistry() instead.
- Processing.algs was removed. QgsApplication.processingRegistry().algorithms() instead.

Triangulation {#qgis_api_break_3_0_Triangulation}
@@ -9,7 +9,7 @@



class QgsProcessingProvider
class QgsProcessingProvider : QObject
{
%Docstring
Abstract base class for processing providers. An algorithm provider is a set of
@@ -24,7 +24,7 @@ class QgsProcessingProvider

public:

QgsProcessingProvider();
QgsProcessingProvider( QObject* parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsProcessingProvider.
%End
@@ -129,6 +129,15 @@ class QgsProcessingProvider
\see algorithms()
%End

signals:

void algorithmsLoaded();
%Docstring
Emitted when the provider has loaded (or refreshed) its list of available
algorithms.
\see refreshAlgorithms()
%End

protected:

virtual void loadAlgorithms() = 0;
@@ -42,7 +42,8 @@ class QgsProcessingRegistry : QObject

bool addProvider( QgsProcessingProvider *provider /Transfer/ );
%Docstring
Add a processing provider to the registry. Ownership of the provider is transferred to the registry.
Add a processing provider to the registry. Ownership of the provider is transferred to the registry,
and the provider's parent will be set to the registry.
Returns false if the provider could not be added (eg if a provider with a duplicate ID already exists
in the registry).
\see removeProvider()
@@ -73,7 +74,7 @@ class QgsProcessingRegistry : QObject
\see algorithmById()
%End

QgsProcessingAlgorithm * algorithmById( const QString& id ) const;
QgsProcessingAlgorithm *algorithmById( const QString &id ) const;
%Docstring
Finds an algorithm by its ID. If no matching algorithm is found, a nullptr
is returned.
@@ -46,7 +46,6 @@
from processing.modeler.ModelerDialog import ModelerDialog
from processing.tools.system import tempFolder
from processing.gui.menus import removeMenus, initializeMenus, createMenus
from processing.core.alglist import algList
from processing.core.ProcessingResults import resultsList

cmd_folder = os.path.split(inspect.getfile(inspect.currentframe()))[0]
@@ -185,7 +184,8 @@ def openModeler(self):
dlg.show()

def updateModel(self):
algList.reloadProvider('model')
model_provider = QgsApplication.processingRegistry().providerById('model')
model_provider.refreshAlgorithms()

def openResults(self):
if self.resultsDock.isVisible():
@@ -51,7 +51,6 @@
from processing.gui.Postprocessing import handleAlgorithmResults
from processing.gui.AlgorithmExecutor import execute
from processing.tools import dataobjects
from processing.core.alglist import algList

from processing.modeler.ModelerAlgorithmProvider import ModelerAlgorithmProvider # NOQA
from processing.algs.qgis.QGISAlgorithmProvider import QGISAlgorithmProvider # NOQA
@@ -67,7 +66,6 @@

class Processing(object):

# Same structure as algs in algList
actions = {}

# All the registered context menu actions for the toolbox
@@ -115,7 +113,9 @@ def activateProvider(providerOrName, activate=True):
provider_id = providerOrName.id() if isinstance(providerOrName, AlgorithmProvider) else providerOrName
name = 'ACTIVATE_' + provider_id.upper().replace(' ', '_')
ProcessingConfig.setSettingValue(name, activate)
algList.providerUpdated.emit(provider_id)
provider = QgsApplication.processingRegistry().providerById(provider_id)
if provider:
provider.refreshAlgorithms()

@staticmethod
def initialize():
@@ -128,7 +128,6 @@ def initialize():
ProcessingConfig.initialize()
ProcessingConfig.readSettings()
RenderingStyles.loadStyles()
Processing.updateAlgsList()

@staticmethod
def addScripts(folder):
@@ -142,7 +141,7 @@ def addScripts(folder):
script._icon = provider._icon
script.provider = provider
provider.externalAlgs.extend(scripts)
Processing.reloadProvider("qgis")
provider.refreshAlgorithms()

@staticmethod
def removeScripts(folder):
@@ -151,23 +150,7 @@ def removeScripts(folder):
path = os.path.dirname(alg.descriptionFile)
if path == folder:
provider.externalAlgs.remove(alg)
Processing.reloadProvider("qgis")

@staticmethod
def updateAlgsList():
"""Call this method when there has been any change that
requires the list of algorithms to be created again from
algorithm providers. Use reloadProvider() for a more fine-grained
update.
"""
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
for p in QgsApplication.processingRegistry().providers():
Processing.reloadProvider(p.id())
QApplication.restoreOverrideCursor()

@staticmethod
def reloadProvider(provider_id):
algList.reloadProvider(provider_id)
provider.refreshAlgorithms()


@staticmethod

This file was deleted.

@@ -40,10 +40,12 @@
QToolButton,
QHBoxLayout,
QComboBox,
QPushButton)
QPushButton,
QApplication)
from qgis.PyQt.QtGui import (QIcon,
QStandardItemModel,
QStandardItem)
QStandardItem,
QCursor)

from qgis.gui import (QgsDoubleSpinBox,
QgsSpinBox,
@@ -288,7 +290,11 @@ def accept(self):
return
setting.save(qsettings)

Processing.updateAlgsList()
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
for p in QgsApplication.processingRegistry().providers():
p.refreshAlgorithms()
QApplication.restoreOverrideCursor()

settingsWatcher.settingsChanged.emit()

def itemExpanded(self, idx):
@@ -29,11 +29,12 @@

from qgis.PyQt.QtWidgets import QMessageBox

from qgis.core import QgsApplication

from processing.gui.ContextAction import ContextAction

from processing.algs.r.RAlgorithm import RAlgorithm
from processing.script.ScriptAlgorithm import ScriptAlgorithm
from processing.core.alglist import algList


class DeleteScriptAction(ContextAction):
@@ -61,6 +62,6 @@ def execute(self):
if reply == QMessageBox.Yes:
os.remove(self.itemData.descriptionFile)
if self.scriptType == self.SCRIPT_PYTHON:
algList.reloadProvider('script')
QgsApplication.processingRegistry().providerById('script').refreshAlgorithms()
elif self.scriptType == self.SCRIPT_R:
algList.reloadProvider('r')
QgsApplication.processingRegistry().providerById('r').refreshAlgorithms()
@@ -44,7 +44,6 @@
QgsApplication)
from qgis.gui import QgsMessageBar

from processing.core.alglist import algList
from processing.core.ProcessingConfig import ProcessingConfig
from processing.gui.ToolboxAction import ToolboxAction
from processing.gui import Help2Html
@@ -77,7 +76,7 @@ def execute(self):
dlg = GetScriptsAndModelsDialog(GetScriptsAndModelsDialog.SCRIPTS)
dlg.exec_()
if dlg.updateProvider:
algList.reloadProvider('script')
QgsApplication.processingRegistry().providerById('script').refreshAlgorithms()


class GetRScriptsAction(ToolboxAction):
@@ -123,7 +122,7 @@ def execute(self):
dlg = GetScriptsAndModelsDialog(GetScriptsAndModelsDialog.MODELS)
dlg.exec_()
if dlg.updateProvider:
algList.reloadProvider('model')
QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()


class GetScriptsAndModelsDialog(BASE, WIDGET):
@@ -47,7 +47,6 @@
from processing.gui.ConfigDialog import ConfigDialog
from processing.gui.MessageBarProgress import MessageBarProgress
from processing.gui.AlgorithmExecutor import execute
from processing.core.alglist import algList

pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
@@ -85,7 +84,6 @@ def openSettings(url):

QgsApplication.processingRegistry().providerRemoved.connect(self.removeProvider)
QgsApplication.processingRegistry().providerAdded.connect(self.addProvider)
algList.providerUpdated.connect(self.updateProvider)
settingsWatcher.settingsChanged.connect(self.fillTree)

def showDisabled(self):
@@ -165,8 +163,9 @@ def activateProvider(self, id):
QMessageBox.warning(self, "Activate provider",
"The provider has been activated, but it might need additional configuration.")

def updateProvider(self, provider_id):
item = self._providerItem(provider_id)
def updateProvider(self):
provider = self.sender()
item = self._providerItem(provider.id())
if item is not None:
item.refresh()
item.sortChildren(0, Qt.AscendingOrder)
@@ -329,6 +328,7 @@ def addProvider(self, provider_id):
if child.text(0) > providerItem.text(0):
break
self.algorithmTree.insertTopLevelItem(i, providerItem)
provider.algorithmsLoaded.connect(self.updateProvider)

def fillTreeUsingProviders(self):
self.algorithmTree.clear()
@@ -46,7 +46,6 @@
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(
@@ -178,9 +177,9 @@ def closeEvent(self, evt):
def updateProviders(self):
if self.update:
if self.algType == self.SCRIPT_PYTHON:
algList.reloadProvider('script')
QgsApplication.processingRegistry().providerById('script').refreshAlgorithms()
elif self.algType == self.SCRIPT_R:
algList.reloadProvider('r')
QgsApplication.processingRegistry().providerById('r').refreshAlgorithms()

def editHelp(self):
if self.alg is None:
@@ -36,7 +36,6 @@
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
from processing.modeler.WrongModelException import WrongModelException
from processing.modeler.ModelerUtils import ModelerUtils
from processing.core.alglist import algList

pluginPath = os.path.split(os.path.dirname(__file__))[0]

@@ -75,4 +74,4 @@ def execute(self):
return
destFilename = os.path.join(ModelerUtils.modelsFolders()[0], os.path.basename(filename))
shutil.copyfile(filename, destFilename)
algList.reloadProvider('model')
QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()
@@ -31,7 +31,6 @@

from processing.gui.ToolboxAction import ToolboxAction
from processing.modeler.ModelerDialog import ModelerDialog
from processing.core.alglist import algList

pluginPath = os.path.split(os.path.dirname(__file__))[0]

@@ -51,4 +50,4 @@ def execute(self):
dlg.show()

def updateModel(self):
algList.reloadProvider('model')
QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()
@@ -26,10 +26,10 @@
__revision__ = '$Format:%H$'

import os
from qgis.core import QgsApplication
from qgis.PyQt.QtWidgets import QMessageBox
from processing.gui.ContextAction import ContextAction
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
from processing.core.alglist import algList


class DeleteModelAction(ContextAction):
@@ -49,4 +49,4 @@ def execute(self):
QMessageBox.No)
if reply == QMessageBox.Yes:
os.remove(self.itemData.descriptionFile)
algList.reloadProvider('model')
QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()
@@ -25,10 +25,10 @@

__revision__ = '$Format:%H$'

from qgis.core import QgsApplication
from processing.gui.ContextAction import ContextAction
from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
from processing.modeler.ModelerDialog import ModelerDialog
from processing.core.alglist import algList


class EditModelAction(ContextAction):
@@ -45,4 +45,4 @@ def execute(self):
dlg.show()

def updateModel(self):
algList.reloadProvider('model')
QgsApplication.processingRegistry().providerById('model').refreshAlgorithms()
Loading

0 comments on commit fb1cf1e

Please sign in to comment.