Skip to content

Commit

Permalink
Allow selecting multiple items in processing multi layer input dialog
Browse files Browse the repository at this point in the history
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 0a7bb48
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions python/plugins/processing/gui/MultipleInputDialog.py
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0a7bb48

Please sign in to comment.