Skip to content

Commit

Permalink
Move algorithm icon handling to QgsProcessingAlgorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 3, 2017
1 parent 28e7573 commit faa8a65
Show file tree
Hide file tree
Showing 193 changed files with 899 additions and 193 deletions.
2 changes: 2 additions & 0 deletions python/core/processing/qgsprocessingalgorithm.sip
Expand Up @@ -9,5 +9,7 @@ class QgsProcessingAlgorithm
QgsProcessingAlgorithm();
virtual ~QgsProcessingAlgorithm();
virtual QStringList tags() const;
virtual QIcon icon() const;
virtual QString svgIconPath() const;
};

2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/AssignProjection.py
Expand Up @@ -46,7 +46,7 @@ class AssignProjection(GdalAlgorithm):
CRS = 'CRS'
OUTPUT = 'OUTPUT'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'projection-add.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/ClipByExtent.py
Expand Up @@ -53,7 +53,7 @@ class ClipByExtent(GdalAlgorithm):
RTYPE = 'RTYPE'
TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-clip.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/ClipByMask.py
Expand Up @@ -62,7 +62,7 @@ class ClipByMask(GdalAlgorithm):
RTYPE = 'RTYPE'
TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-clip.png'))

def defineCharacteristics(self):
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/algs/gdal/GdalAlgorithm.py
Expand Up @@ -46,12 +46,12 @@ class GdalAlgorithm(GeoAlgorithm):

def __init__(self):
GeoAlgorithm.__init__(self)
self._icon = None

def getIcon(self):
if self._icon is None:
self._icon = QgsApplication.getThemeIcon("/providerGdal.svg")
return self._icon
def icon(self):
return QgsApplication.getThemeIcon("/providerGdal.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerGdal.svg")

def getCustomParametersDialog(self):
return GdalAlgorithmDialog(self)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridAverage.py
Expand Up @@ -56,7 +56,7 @@ class GridAverage(GdalAlgorithm):

TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridDataMetrics.py
Expand Up @@ -61,7 +61,7 @@ class GridDataMetrics(GdalAlgorithm):
DATA_METRICS = ['Minimum', 'Maximum', 'Range', 'Count', 'Average distance',
'Average distance between points']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridInvDist.py
Expand Up @@ -60,7 +60,7 @@ class GridInvDist(GdalAlgorithm):

TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/GridNearest.py
Expand Up @@ -56,7 +56,7 @@ class GridNearest(GdalAlgorithm):

TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'grid.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/buildvrt.py
Expand Up @@ -51,7 +51,7 @@ class buildvrt(GdalAlgorithm):

RESOLUTION_OPTIONS = ['average', 'highest', 'lowest']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'vrt.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/contour.py
Expand Up @@ -51,7 +51,7 @@ class contour(GdalAlgorithm):
FIELD_NAME = 'FIELD_NAME'
EXTRA = 'EXTRA'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'contour.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/extractprojection.py
Expand Up @@ -44,7 +44,7 @@ class ExtractProjection(GdalAlgorithm):
INPUT = 'INPUT'
PRJ_FILE = 'PRJ_FILE'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'projection-export.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/gdaladdo.py
Expand Up @@ -63,7 +63,7 @@ class gdaladdo(GdalAlgorithm):
FORMATS = ['Internal (if possible)', 'External (GTiff .ovr)',
'External (ERDAS Imagine .aux)']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-overview.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/gdaltindex.py
Expand Up @@ -48,7 +48,7 @@ class gdaltindex(GdalAlgorithm):
FIELD_NAME = 'FIELD_NAME'
PROJ_DIFFERENCE = 'PROJ_DIFFERENCE'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'tiles.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/information.py
Expand Up @@ -46,7 +46,7 @@ class information(GdalAlgorithm):
NOGCP = 'NOGCP'
NOMETADATA = 'NOMETADATA'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'raster-info.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/merge.py
Expand Up @@ -54,7 +54,7 @@ class merge(GdalAlgorithm):

TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'merge.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/nearblack.py
Expand Up @@ -47,7 +47,7 @@ class nearblack(GdalAlgorithm):
NEAR = 'NEAR'
WHITE = 'WHITE'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'nearblack.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/pct2rgb.py
Expand Up @@ -47,7 +47,7 @@ class pct2rgb(GdalAlgorithm):
OUTPUT = 'OUTPUT'
NBAND = 'NBAND'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', '8-to-24-bits.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/polygonize.py
Expand Up @@ -46,7 +46,7 @@ class polygonize(GdalAlgorithm):
OUTPUT = 'OUTPUT'
FIELD = 'FIELD'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'polygonize.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/proximity.py
Expand Up @@ -57,7 +57,7 @@ class proximity(GdalAlgorithm):

DISTUNITS = ['GEO', 'PIXEL']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'proximity.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/rasterize.py
Expand Up @@ -62,7 +62,7 @@ class rasterize(GdalAlgorithm):

RAST_EXT = 'RAST_EXT'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/rasterize_over.py
Expand Up @@ -49,7 +49,7 @@ class rasterize_over(GdalAlgorithm):
INPUT_RASTER = 'INPUT_RASTER'
FIELD = 'FIELD'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'rasterize.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/rgb2pct.py
Expand Up @@ -47,7 +47,7 @@ class rgb2pct(GdalAlgorithm):
OUTPUT = 'OUTPUT'
NCOLORS = 'NCOLORS'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', '24-to-8-bits.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/sieve.py
Expand Up @@ -53,7 +53,7 @@ class sieve(GdalAlgorithm):

PIXEL_CONNECTIONS = ['4', '8']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'sieve.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/translate.py
Expand Up @@ -60,7 +60,7 @@ class translate(GdalAlgorithm):
OPTIONS = 'OPTIONS'
TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'translate.png'))

def commandLineName(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/warp.py
Expand Up @@ -60,7 +60,7 @@ class warp(GdalAlgorithm):
METHOD_OPTIONS = ['near', 'bilinear', 'cubic', 'cubicspline', 'lanczos']
TYPE = ['Byte', 'Int16', 'UInt16', 'UInt32', 'Int32', 'Float32', 'Float64']

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'gdaltools', 'warp.png'))

def tags(self):
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -84,7 +84,6 @@ def __init__(self, descriptionfile):
self.descriptionFile = descriptionfile
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
self._icon = None
self.uniqueSuffix = str(uuid.uuid4()).replace('-', '')

# Use the ext mechanism
Expand All @@ -99,10 +98,11 @@ def getCopy(self):
newone.provider = self.provider
return newone

def getIcon(self):
if self._icon is None:
self._icon = QgsApplication.getThemeIcon("/providerGrass.svg")
return self._icon
def icon(self):
return QgsApplication.getThemeIcon("/providerGrass.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerGrass.svg")

def help(self):
helpPath = Grass7Utils.grassHelpPath()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/nviz7.py
Expand Up @@ -59,7 +59,7 @@ def __init__(self):
GeoAlgorithm.__init__(self)
self.showInModeler = False

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'grass.png'))

def defineCharacteristics(self):
Expand Down
10 changes: 9 additions & 1 deletion python/plugins/processing/algs/qgis/AddTableField.py
Expand Up @@ -26,7 +26,9 @@
__revision__ = '$Format:%H$'

from qgis.PyQt.QtCore import QVariant
from qgis.core import QgsField, QgsFeature
from qgis.core import (QgsField,
QgsFeature,
QgsApplication)
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterString
Expand All @@ -47,6 +49,12 @@ class AddTableField(GeoAlgorithm):

TYPES = [QVariant.Int, QVariant.Double, QVariant.String]

def icon(self):
return QgsApplication.getThemeIcon("/providerQgis.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerQgis.svg")

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Add field to attributes table')
self.group, self.i18n_group = self.trAlgorithm('Vector table tools')
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Aspect.py
Expand Up @@ -46,7 +46,7 @@ class Aspect(GeoAlgorithm):
Z_FACTOR = 'Z_FACTOR'
OUTPUT_LAYER = 'OUTPUT_LAYER'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'dem.png'))

def defineCharacteristics(self):
Expand Down
10 changes: 9 additions & 1 deletion python/plugins/processing/algs/qgis/AutoincrementalField.py
Expand Up @@ -26,7 +26,9 @@
__revision__ = '$Format:%H$'

from qgis.PyQt.QtCore import QVariant
from qgis.core import QgsField, QgsFeature
from qgis.core import (QgsField,
QgsFeature,
QgsApplication)
from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.parameters import ParameterVector
from processing.core.outputs import OutputVector
Expand All @@ -38,6 +40,12 @@ class AutoincrementalField(GeoAlgorithm):
INPUT = 'INPUT'
OUTPUT = 'OUTPUT'

def icon(self):
return QgsApplication.getThemeIcon("/providerQgis.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerQgis.svg")

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Add autoincremental field')
self.group, self.i18n_group = self.trAlgorithm('Vector table tools')
Expand Down
7 changes: 7 additions & 0 deletions python/plugins/processing/algs/qgis/BarPlot.py
Expand Up @@ -29,6 +29,7 @@
import plotly.graph_objs as go
import numpy as np

from qgis.core import (QgsApplication)
from processing.core.parameters import ParameterTable
from processing.core.parameters import ParameterTableField
from processing.core.GeoAlgorithm import GeoAlgorithm
Expand All @@ -44,6 +45,12 @@ class BarPlot(GeoAlgorithm):
NAME_FIELD = 'NAME_FIELD'
VALUE_FIELD = 'VALUE_FIELD'

def icon(self):
return QgsApplication.getThemeIcon("/providerQgis.svg")

def svgIconPath(self):
return QgsApplication.iconPath("providerQgis.svg")

def defineCharacteristics(self):
self.name, self.i18n_name = self.trAlgorithm('Bar plot')
self.group, self.i18n_group = self.trAlgorithm('Graphics')
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BasicStatistics.py
Expand Up @@ -74,7 +74,7 @@ class BasicStatisticsForField(GeoAlgorithm):
THIRDQUARTILE = 'THIRDQUARTILE'
IQR = 'IQR'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'basic_statistics.png'))

def tags(self):
Expand Down
Expand Up @@ -73,7 +73,7 @@ def __init__(self):
# this algorithm is deprecated - use BasicStatistics instead
self.showInToolbox = False

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'basic_statistics.png'))

def tags(self):
Expand Down
Expand Up @@ -65,7 +65,7 @@ def __init__(self):
# this algorithm is deprecated - use BasicStatistics instead
self.showInToolbox = False

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'basic_statistics.png'))

def tags(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Boundary.py
Expand Up @@ -45,7 +45,7 @@ class Boundary(GeoAlgorithm):
INPUT_LAYER = 'INPUT_LAYER'
OUTPUT_LAYER = 'OUTPUT_LAYER'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'convex_hull.png'))

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BoundingBox.py
Expand Up @@ -45,7 +45,7 @@ class BoundingBox(GeoAlgorithm):
INPUT_LAYER = 'INPUT_LAYER'
OUTPUT_LAYER = 'OUTPUT_LAYER'

def getIcon(self):
def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'matrix.png'))

def defineCharacteristics(self):
Expand Down

0 comments on commit faa8a65

Please sign in to comment.