[processing] add icon caching for other providers

This commit is contained in:
Alexander Bruy 2016-10-04 19:53:21 +03:00
parent d03d2069b9
commit cc62c52269
5 changed files with 26 additions and 5 deletions

View File

@ -41,8 +41,14 @@ pluginPath = os.path.normpath(os.path.join(
class GdalAlgorithm(GeoAlgorithm):
def __init__(self):
GeoAlgorithm.__init__(self)
self._icon = None
def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))
return self._icon
def getCustomParametersDialog(self):
return GdalAlgorithmDialog(self)

View File

@ -67,6 +67,7 @@ class OTBAlgorithm(GeoAlgorithm):
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
self.hasROI = None
self._icon = None
def __str__(self):
return("Algo : " + self.name + " from app : " + self.cliName + " in : " + self.group)
@ -77,7 +78,9 @@ class OTBAlgorithm(GeoAlgorithm):
return newone
def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
return self._icon
def help(self):
version = OTBUtils.getInstalledVersion()

View File

@ -61,6 +61,9 @@ from processing.tools.system import isWindows
from processing.script.WrongScriptException import WrongScriptException
from .RUtils import RUtils
pluginPath = os.path.normpath(os.path.join(
os.path.split(os.path.dirname(__file__))[0], os.pardir))
class RAlgorithm(GeoAlgorithm):
@ -80,9 +83,12 @@ class RAlgorithm(GeoAlgorithm):
self.defineCharacteristicsFromScript()
if descriptionFile is not None:
self.defineCharacteristicsFromFile()
self._icon = None
def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../../images/r.svg')
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'r.svg'))
return self._icon
def defineCharacteristicsFromScript(self):
lines = self.script.split('\n')

View File

@ -72,6 +72,7 @@ class SagaAlgorithm212(GeoAlgorithm):
self.allowUnmatchingGridExtents = False
self.descriptionFile = descriptionfile
self.defineCharacteristicsFromFile()
self._icon = None
def getCopy(self):
newone = SagaAlgorithm212(self.descriptionFile)
@ -79,7 +80,9 @@ class SagaAlgorithm212(GeoAlgorithm):
return newone
def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'saga.png'))
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'saga.png'))
return self._icon
def defineCharacteristicsFromFile(self):
lines = open(self.descriptionFile)

View File

@ -59,6 +59,7 @@ class TauDEMAlgorithm(GeoAlgorithm):
GeoAlgorithm.__init__(self)
self.descriptionFile = descriptionfile
self.defineCharacteristicsFromFile()
self._icon = None
def getCopy(self):
newone = TauDEMAlgorithm(self.descriptionFile)
@ -66,7 +67,9 @@ class TauDEMAlgorithm(GeoAlgorithm):
return newone
def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'taudem.svg'))
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'taudem.svg'))
return self._icon
def defineCharacteristicsFromFile(self):
with codecs.open(self.descriptionFile, encoding='utf-8') as f: