Skip to content
Permalink
Browse files

[processing] show layers sorted only for single selection widget and use

legend order for multiple selection
  • Loading branch information
alexbruy committed Oct 4, 2014
1 parent ec64e1d commit e0fc515af0fb9692eb596c43edf23d41b2ec513f
Showing with 18 additions and 9 deletions.
  1. +3 −3 python/plugins/processing/gui/ParametersPanel.py
  2. +15 −6 python/plugins/processing/tools/dataobjects.py
@@ -297,11 +297,11 @@ def getWidgetFromParameter(self, param):
item = MultipleFileInputPanel()
else:
if param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = dataobjects.getRasterLayers()
options = dataobjects.getRasterLayers(sorting=False)
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = dataobjects.getVectorLayers()
options = dataobjects.getVectorLayers(sorting=False)
else:
options = dataobjects.getVectorLayers([param.datatype])
options = dataobjects.getVectorLayers([param.datatype], sorting=False)
opts = []
for opt in options:
opts.append(self.getExtendedLayerName(opt))
@@ -68,18 +68,21 @@ def getSupportedOutputTableExtensions():
return exts


def getRasterLayers():
def getRasterLayers(sorting=True):
layers = QgsMapLayerRegistry.instance().mapLayers().values()
raster = []

for layer in layers:
if layer.type() == layer.RasterLayer:
if layer.providerType() == 'gdal': # only gdal file-based layers
raster.append(layer)
return sorted(raster, key=lambda layer: layer.name().lower())
if sorting:
return sorted(raster, key=lambda layer: layer.name().lower())
else:
return raster


def getVectorLayers(shapetype=[-1]):
def getVectorLayers(shapetype=[-1], sorting=True):
layers = QgsMapLayerRegistry.instance().mapLayers().values()
vector = []
for layer in layers:
@@ -88,7 +91,10 @@ def getVectorLayers(shapetype=[-1]):
uri = unicode(layer.source())
if not uri.lower().endswith('csv') and not uri.lower().endswith('dbf'):
vector.append(layer)
return sorted(vector, key=lambda layer: layer.name().lower())
if sorting:
return sorted(vector, key=lambda layer: layer.name().lower())
else:
return vector


def getAllLayers():
@@ -98,13 +104,16 @@ def getAllLayers():
return sorted(layers, key=lambda layer: layer.name().lower())


def getTables():
def getTables(sorting=True):
layers = QgsMapLayerRegistry.instance().mapLayers().values()
tables = list()
for layer in layers:
if layer.type() == layer.VectorLayer:
tables.append(layer)
return sorted(tables, key=lambda table: table.name().lower())
if sorting:
return sorted(tables, key=lambda table: table.name().lower())
else:
return tables


def extent(layers):

0 comments on commit e0fc515

Please sign in to comment.
You can’t perform that action at this time.