E5Gui/E5StringListEditWidget.py

changeset 5858
7afdb26fcabc
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5857:a4cf5c1c8d2b 5858:7afdb26fcabc
6 """ 6 """
7 Module implementing a dialog to edit a list of strings. 7 Module implementing a dialog to edit a list of strings.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 from PyQt5.QtCore import pyqtSlot, Qt, QSortFilterProxyModel, QStringListModel 11 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QSortFilterProxyModel, \
12 QStringListModel
12 from PyQt5.QtWidgets import QWidget, QInputDialog, QLineEdit 13 from PyQt5.QtWidgets import QWidget, QInputDialog, QLineEdit
13 14
14 from .Ui_E5StringListEditWidget import Ui_E5StringListEditWidget 15 from .Ui_E5StringListEditWidget import Ui_E5StringListEditWidget
15 16
16 17
17 class E5StringListEditWidget(QWidget, Ui_E5StringListEditWidget): 18 class E5StringListEditWidget(QWidget, Ui_E5StringListEditWidget):
18 """ 19 """
19 Class implementing a dialog to edit a list of strings. 20 Class implementing a dialog to edit a list of strings.
21
22 @signal setToDefault() emitted to request the default list of values
20 """ 23 """
24 setToDefault = pyqtSignal()
25
21 def __init__(self, parent=None): 26 def __init__(self, parent=None):
22 """ 27 """
23 Constructor 28 Constructor
24 29
25 @param parent reference to the parent widget (QWidget) 30 @param parent reference to the parent widget (QWidget)
31 self.__proxyModel = QSortFilterProxyModel(self) 36 self.__proxyModel = QSortFilterProxyModel(self)
32 self.__proxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive) 37 self.__proxyModel.setFilterCaseSensitivity(Qt.CaseInsensitive)
33 self.__proxyModel.setSourceModel(self.__model) 38 self.__proxyModel.setSourceModel(self.__model)
34 self.stringList.setModel(self.__proxyModel) 39 self.stringList.setModel(self.__proxyModel)
35 40
41 self.defaultButton.hide()
42
36 self.searchEdit.textChanged.connect( 43 self.searchEdit.textChanged.connect(
37 self.__proxyModel.setFilterFixedString) 44 self.__proxyModel.setFilterFixedString)
38 45
39 self.removeButton.clicked.connect(self.stringList.removeSelected) 46 self.removeButton.clicked.connect(self.stringList.removeSelected)
40 self.removeAllButton.clicked.connect(self.stringList.removeAll) 47 self.removeAllButton.clicked.connect(self.stringList.removeAll)
48 self.defaultButton.clicked.connect(self.setToDefault)
41 49
42 def setList(self, stringList): 50 def setList(self, stringList):
43 """ 51 """
44 Public method to set the list of strings to be edited. 52 Public method to set the list of strings to be edited.
45 53
62 70
63 @param txt help text to be set (string) 71 @param txt help text to be set (string)
64 """ 72 """
65 self.stringList.setWhatsThis(txt) 73 self.stringList.setWhatsThis(txt)
66 74
75 def setDefaultVisible(self, visible):
76 """
77 Public method to show or hide the default button.
78
79 @param visible flag indicating the visibility of the default button
80 @type bool
81 """
82 self.defaultButton.setVisible(visible)
83
67 @pyqtSlot() 84 @pyqtSlot()
68 def on_addButton_clicked(self): 85 def on_addButton_clicked(self):
69 """ 86 """
70 Private slot to add an entry to the list. 87 Private slot to add an entry to the list.
71 """ 88 """

eric ide

mercurial