Skip to content
Permalink
Browse files
[processing] Default to current layer in layer selection combos
Makes things easier for large projects and avoids scrolling through
a large list of layers
  • Loading branch information
nyalldawson committed Mar 21, 2017
1 parent c412596 commit ce7180ca64f89f9bd31aae47fac654466750b05a
Showing with 19 additions and 1 deletion.
  1. +19 −1 python/plugins/processing/gui/wrappers.py
@@ -39,7 +39,8 @@
QgsMapLayerProxyModel,
QgsWkbTypes,
QgsSettings,
QgsProject
QgsProject,
QgsMapLayer
)
from qgis.PyQt.QtWidgets import (
QCheckBox,
@@ -63,6 +64,7 @@
QgsProjectionSelectionWidget,
)
from qgis.PyQt.QtCore import pyqtSignal, QObject, QVariant
from qgis.utils import iface

from processing.gui.NumberInputPanel import NumberInputPanel, ModellerNumberInputPanel
from processing.modeler.MultilineTextPanel import MultilineTextPanel
@@ -628,6 +630,11 @@ def createWidget(self):

self.combo.setFilters(QgsMapLayerProxyModel.RasterLayer)
self.combo.setExcludedProviders(['grass'])
try:
if iface.activeLayer().type() == QgsMapLayer.RasterLayer:
self.combo.setLayer(iface.activeLayer())
except:
pass

self.combo.currentIndexChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
self.combo.currentTextChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
@@ -755,6 +762,12 @@ def createWidget(self):
if QgsWkbTypes.PolygonGeometry in self.param.datatype:
filters |= QgsMapLayerProxyModel.PolygonLayer

try:
if iface.activeLayer().type() == QgsMapLayer.VectorLayer:
self.combo.setLayer(iface.activeLayer())
except:
pass

if self.param.optional:
self.combo.setAllowEmptyLayer(True)
if ProcessingConfig.getSetting(ProcessingConfig.SHOW_CRS_DEF):
@@ -989,6 +1002,11 @@ def createWidget(self):

self.combo.setFilters(QgsMapLayerProxyModel.VectorLayer)
self.combo.setExcludedProviders(['grass'])
try:
if iface.activeLayer().type() == QgsMapLayer.VectorLayer:
self.combo.setLayer(iface.activeLayer())
except:
pass

self.combo.currentIndexChanged.connect(lambda: self.widgetValueHasChanged.emit(self))
self.combo.currentTextChanged.connect(lambda: self.widgetValueHasChanged.emit(self))

0 comments on commit ce7180c

Please sign in to comment.