Skip to content
Permalink
Browse files

Allow selecting multiple items in processing multi layer input dialog

And selecting/deselecting only these items. Otherwise it can be quite
cumbersome to manually select complex sets of items (e.g. try needing
to select ~50% of the layers in a large project - there's currently
no quick way to do this.) With this change you can at least
ctrl/shift click to create selections quicker.
  • Loading branch information
nyalldawson committed Aug 16, 2017
1 parent 1f2ea02 commit 0a7bb4869b0df3d2bea8db3aef78258163b7b841
Showing with 13 additions and 6 deletions.
  1. +13 −6 python/plugins/processing/gui/MultipleInputDialog.py
@@ -87,6 +87,7 @@ def __init__(self, options, selectedoptions=None, datatype=None):
self.settings = QgsSettings()
self.restoreGeometry(self.settings.value("/Processing/multipleInputDialogGeometry", QByteArray()))

self.lstLayers.setSelectionMode(QAbstractItemView.ExtendedSelection)
self.populateList()
self.finished.connect(self.saveWindowGeometry)

@@ -125,16 +126,22 @@ def reject(self):
self.selectedoptions = None
QDialog.reject(self)

def getItemsToModify(self):
items = []
if len(self.lstLayers.selectedIndexes()) > 1:
for i in self.lstLayers.selectedIndexes():
items.append(self.model.itemFromIndex(i))
else:
for i in range(self.model.rowCount()):
items.append(self.model.item(i))
return items

def selectAll(self, value):
model = self.lstLayers.model()
for i in range(model.rowCount()):
item = model.item(i)
for item in self.getItemsToModify():
item.setCheckState(Qt.Checked if value else Qt.Unchecked)

def toggleSelection(self):
model = self.lstLayers.model()
for i in range(model.rowCount()):
item = model.item(i)
for item in self.getItemsToModify():
checked = item.checkState() == Qt.Checked
item.setCheckState(Qt.Unchecked if checked else Qt.Checked)

0 comments on commit 0a7bb48

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