Skip to content

Commit

Permalink
[processing] use another icon for clear button and add confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and nyalldawson committed May 11, 2018
1 parent 3ec2dfa commit bb0fecc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions python/plugins/processing/gui/enummodelerwidget.py
Expand Up @@ -30,6 +30,7 @@
from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem
from qgis.PyQt.QtWidgets import QMessageBox

from qgis.core import QgsApplication

Expand All @@ -46,7 +47,7 @@ def __init__(self, parent=None):

self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg'))
self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg'))
self.btnClear.setIcon(QgsApplication.getThemeIcon('/mIconClearText.svg'))
self.btnClear.setIcon(QgsApplication.getThemeIcon('console/iconClearConsole.svg'))

self.btnAdd.clicked.connect(self.addItem)
self.btnRemove.clicked.connect(lambda: self.removeItems())
Expand Down Expand Up @@ -87,7 +88,9 @@ def addItem(self):

def removeItems(self, removeAll=False):
if removeAll:
self.lstItems.model().clear()
res = QMessageBox.question(self, self.tr('Clear?'), self.tr('Are you sure you want to delete all items?'))
if res == QMessageBox.Yes:
self.lstItems.model().clear()
else:
self.lstItems.setUpdatesEnabled(False)
indexes = sorted(self.lstItems.selectionModel().selectedIndexes())
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/processing/gui/matrixmodelerwidget.py
Expand Up @@ -30,7 +30,7 @@
from qgis.PyQt import uic
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem
from qgis.PyQt.QtWidgets import QInputDialog
from qgis.PyQt.QtWidgets import QInputDialog, QMessageBox

from qgis.core import QgsApplication

Expand All @@ -49,7 +49,7 @@ def __init__(self, parent=None):
self.btnRemoveColumn.setIcon(QgsApplication.getThemeIcon('/mActionDeleteAttribute.svg'))
self.btnAddRow.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg'))
self.btnRemoveRow.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg'))
self.btnClear.setIcon(QgsApplication.getThemeIcon('/mIconClearText.svg'))
self.btnClear.setIcon(QgsApplication.getThemeIcon('console/iconClearConsole.svg'))

self.btnAddColumn.clicked.connect(self.addColumn)
self.btnRemoveColumn.clicked.connect(self.removeColumns)
Expand Down Expand Up @@ -86,7 +86,9 @@ def removeRows(self):
self.tblView.setUpdatesEnabled(True)

def clearTable(self, removeAll=False):
self.tblView.model().clear()
res = QMessageBox.question(self, self.tr('Clear?'), self.tr('Are you sure you want to clear table?'))
if res == QMessageBox.Yes:
self.tblView.model().clear()

def changeHeader(self, index):
txt, ok = QInputDialog.getText(self, self.tr("Enter column name"), self.tr("Column name"))
Expand Down

0 comments on commit bb0fecc

Please sign in to comment.