Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processing] separated alglist to its own module
- Loading branch information
Showing
24 changed files
with
172 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
*************************************************************************** | ||
Processing.py | ||
--------------------- | ||
Date : August 2012 | ||
Copyright : (C) 2012 by Victor Olaya | ||
Email : volayaf at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
*************************************************************************** | ||
""" | ||
|
||
__author__ = 'Victor Olaya' | ||
__date__ = 'August 2012' | ||
__copyright__ = '(C) 2012, Victor Olaya' | ||
|
||
# This will get replaced with a git SHA1 when you do a git archive | ||
|
||
__revision__ = '$Format:%H$' | ||
|
||
from qgis.PyQt.QtCore import QObject, pyqtSignal | ||
|
||
class AlgorithmList(QObject): | ||
|
||
providerAdded = pyqtSignal(str) | ||
providerRemoved = pyqtSignal(str) | ||
providerUpdated = pyqtSignal(str) | ||
|
||
# A dictionary of algorithms. Keys are names of providers | ||
# and values are list with all algorithms from that provider | ||
algs = {} | ||
|
||
providers = [] | ||
|
||
def removeProvider(self, providerName): | ||
for p in self.providers: | ||
if p.getName() == providerName: | ||
self.providers.remove(p) | ||
break | ||
self.algs.remove(providerName) | ||
self.providerRemoved.emit(providerName) | ||
|
||
def reloadProvider(self, providerName): | ||
for p in self.providers: | ||
if p.getName() == providerName: | ||
p.loadAlgorithms() | ||
self.algs[p.getName()] = {a.commandLineName(): a for a in p.algs} | ||
self.providerUpdated.emit(p.getName()) | ||
break | ||
|
||
def addProvider(self, provider): | ||
self.providers.append(provider) | ||
self.algs[provider.getName()] = {a.commandLineName(): a for a in provider.algs} | ||
self.providerAdded.emit(provider.getName()) | ||
|
||
def getProviderFromName(self, name): | ||
for provider in self.providers: | ||
if provider.getName() == name: | ||
return provider | ||
|
||
def getAlgorithm(self, name): | ||
for provider in self.algs.values(): | ||
if name in provider: | ||
return provider[name] | ||
|
||
def getAlgorithmFromFullName(self, name): | ||
for provider in self.algs.values(): | ||
for alg in provider.values(): | ||
if alg.name == name: | ||
return alg | ||
|
||
algList = AlgorithmList() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.