eric7/EricWidgets/EricListSelectionDialog.py

branch
eric7
changeset 8670
12e7fbf2445a
parent 8358
144a6b854f70
child 8881
54e42bc2437a
equal deleted inserted replaced
8669:c26ecdb00a8b 8670:12e7fbf2445a
20 Class implementing a dialog to select from a list of strings. 20 Class implementing a dialog to select from a list of strings.
21 """ 21 """
22 def __init__(self, entries, 22 def __init__(self, entries,
23 selectionMode=QAbstractItemView.SelectionMode 23 selectionMode=QAbstractItemView.SelectionMode
24 .ExtendedSelection, 24 .ExtendedSelection,
25 title="", message="", checkBoxSelection=False, parent=None): 25 title="", message="", checkBoxSelection=False,
26 doubleClickOk=False, parent=None):
26 """ 27 """
27 Constructor 28 Constructor
28 29
29 @param entries list of entries to select from 30 @param entries list of entries to select from
30 @type list of str 31 @type list of str
34 @type str 35 @type str
35 @param message message to be show in the dialog 36 @param message message to be show in the dialog
36 @type str 37 @type str
37 @param checkBoxSelection flag indicating to select items via their 38 @param checkBoxSelection flag indicating to select items via their
38 checkbox 39 checkbox
40 @type bool
41 @param doubleClickOk flag indicating to accept the dialog upon a
42 double click of an item (single selection only)
39 @type bool 43 @type bool
40 @param parent reference to the parent widget 44 @param parent reference to the parent widget
41 @type QWidget 45 @type QWidget
42 """ 46 """
43 super().__init__(parent) 47 super().__init__(parent)
90 self.__checkCount -= 1 94 self.__checkCount -= 1
91 self.buttonBox.button( 95 self.buttonBox.button(
92 QDialogButtonBox.StandardButton.Ok).setEnabled( 96 QDialogButtonBox.StandardButton.Ok).setEnabled(
93 self.__checkCount > 0) 97 self.__checkCount > 0)
94 98
99 @pyqtSlot(QListWidgetItem)
100 def on_selectionList_itemDoubleClicked(self, item):
101 """
102 Private slot handling double clicking an item.
103
104 @param item double clicked item
105 @type QListWidgetItem
106 """
107 if (
108 not self.__isCheckBoxSelection and
109 self.selectionList.selectionMode() ==
110 QAbstractItemView.SelectionMode.SingleSelection
111 ):
112 self.accept()
113
95 def getSelection(self): 114 def getSelection(self):
96 """ 115 """
97 Public method to retrieve the selected items. 116 Public method to retrieve the selected items.
98 117
99 @return selected entries 118 @return selected entries

eric ide

mercurial