7 Module implementing a dialog to manage the list of messages to be ignored. |
7 Module implementing a dialog to manage the list of messages to be ignored. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSlot, Qt, QSortFilterProxyModel, QStringListModel |
12 from PyQt5.QtWidgets import QDialog |
13 from PyQt5.QtWidgets import QDialog, QInputDialog, QLineEdit |
|
14 |
13 |
15 from .Ui_E5ErrorMessageFilterDialog import Ui_E5ErrorMessageFilterDialog |
14 from .Ui_E5ErrorMessageFilterDialog import Ui_E5ErrorMessageFilterDialog |
16 |
15 |
17 |
16 |
18 class E5ErrorMessageFilterDialog(QDialog, Ui_E5ErrorMessageFilterDialog): |
17 class E5ErrorMessageFilterDialog(QDialog, Ui_E5ErrorMessageFilterDialog): |
28 @param parent reference to the parent widget (QWidget) |
27 @param parent reference to the parent widget (QWidget) |
29 """ |
28 """ |
30 super(E5ErrorMessageFilterDialog, self).__init__(parent) |
29 super(E5ErrorMessageFilterDialog, self).__init__(parent) |
31 self.setupUi(self) |
30 self.setupUi(self) |
32 |
31 |
33 self.__model = QStringListModel(messageFilters, self) |
32 self.filtersEditWidget.setList(messageFilters) |
34 self.__model.sort(0) |
33 self.filtersEditWidget.setListWhatsThis(self.tr( |
35 self.__proxyModel = QSortFilterProxyModel(self) |
34 "<b>Error Message Filter</b>" |
36 self.__proxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive) |
35 "<p>This list shows the configured message filters used to" |
37 self.__proxyModel.setSourceModel(self.__model) |
36 " suppress error messages from within Qt.</p>" |
38 self.filterList.setModel(self.__proxyModel) |
37 )) |
39 |
|
40 self.searchEdit.textChanged.connect( |
|
41 self.__proxyModel.setFilterFixedString) |
|
42 |
|
43 self.removeButton.clicked.connect(self.filterList.removeSelected) |
|
44 self.removeAllButton.clicked.connect(self.filterList.removeAll) |
|
45 |
|
46 @pyqtSlot() |
|
47 def on_addButton_clicked(self): |
|
48 """ |
|
49 Private slot to add an entry to the list. |
|
50 """ |
|
51 filter, ok = QInputDialog.getText( |
|
52 self, |
|
53 self.tr("Error Messages Filter"), |
|
54 self.tr("Enter message filter to add to the list:"), |
|
55 QLineEdit.Normal) |
|
56 if ok and filter != "" and filter not in self.__model.stringList(): |
|
57 self.__model.insertRow(self.__model.rowCount()) |
|
58 self.__model.setData( |
|
59 self.__model.index(self.__model.rowCount() - 1), filter) |
|
60 self.__model.sort(0) |
|
61 |
38 |
62 def getFilters(self): |
39 def getFilters(self): |
63 """ |
40 """ |
64 Public method to get the list of message filters. |
41 Public method to get the list of message filters. |
65 |
42 |
66 @return error message filters (list of strings) |
43 @return error message filters (list of strings) |
67 """ |
44 """ |
68 return self.__model.stringList()[:] |
45 return self.filtersEditWidget.getList() |