Skip to content

Commit bb0fecc

Browse files
alexbruynyalldawson
authored andcommittedMay 11, 2018
[processing] use another icon for clear button and add confirmation
1 parent 3ec2dfa commit bb0fecc

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
 

‎python/plugins/processing/gui/enummodelerwidget.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from qgis.PyQt import uic
3131
from qgis.PyQt.QtCore import Qt
3232
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem
33+
from qgis.PyQt.QtWidgets import QMessageBox
3334

3435
from qgis.core import QgsApplication
3536

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

4748
self.btnAdd.setIcon(QgsApplication.getThemeIcon('/symbologyAdd.svg'))
4849
self.btnRemove.setIcon(QgsApplication.getThemeIcon('/symbologyRemove.svg'))
49-
self.btnClear.setIcon(QgsApplication.getThemeIcon('/mIconClearText.svg'))
50+
self.btnClear.setIcon(QgsApplication.getThemeIcon('console/iconClearConsole.svg'))
5051

5152
self.btnAdd.clicked.connect(self.addItem)
5253
self.btnRemove.clicked.connect(lambda: self.removeItems())
@@ -87,7 +88,9 @@ def addItem(self):
8788

8889
def removeItems(self, removeAll=False):
8990
if removeAll:
90-
self.lstItems.model().clear()
91+
res = QMessageBox.question(self, self.tr('Clear?'), self.tr('Are you sure you want to delete all items?'))
92+
if res == QMessageBox.Yes:
93+
self.lstItems.model().clear()
9194
else:
9295
self.lstItems.setUpdatesEnabled(False)
9396
indexes = sorted(self.lstItems.selectionModel().selectedIndexes())

‎python/plugins/processing/gui/matrixmodelerwidget.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from qgis.PyQt import uic
3131
from qgis.PyQt.QtCore import Qt
3232
from qgis.PyQt.QtGui import QStandardItemModel, QStandardItem
33-
from qgis.PyQt.QtWidgets import QInputDialog
33+
from qgis.PyQt.QtWidgets import QInputDialog, QMessageBox
3434

3535
from qgis.core import QgsApplication
3636

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

5454
self.btnAddColumn.clicked.connect(self.addColumn)
5555
self.btnRemoveColumn.clicked.connect(self.removeColumns)
@@ -86,7 +86,9 @@ def removeRows(self):
8686
self.tblView.setUpdatesEnabled(True)
8787

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.