eric7/EricWidgets/EricListSelectionDialog.py

branch
eric7
changeset 8670
12e7fbf2445a
parent 8358
144a6b854f70
child 8881
54e42bc2437a
--- a/eric7/EricWidgets/EricListSelectionDialog.py	Tue Oct 05 19:36:02 2021 +0200
+++ b/eric7/EricWidgets/EricListSelectionDialog.py	Tue Oct 05 19:47:03 2021 +0200
@@ -22,7 +22,8 @@
     def __init__(self, entries,
                  selectionMode=QAbstractItemView.SelectionMode
                  .ExtendedSelection,
-                 title="", message="", checkBoxSelection=False, parent=None):
+                 title="", message="", checkBoxSelection=False,
+                 doubleClickOk=False, parent=None):
         """
         Constructor
         
@@ -37,6 +38,9 @@
         @param checkBoxSelection flag indicating to select items via their
             checkbox
         @type bool
+        @param doubleClickOk flag indicating to accept the dialog upon a
+            double click of an item (single selection only)
+        @type bool
         @param parent reference to the parent widget
         @type QWidget
         """
@@ -92,6 +96,21 @@
                 QDialogButtonBox.StandardButton.Ok).setEnabled(
                 self.__checkCount > 0)
     
+    @pyqtSlot(QListWidgetItem)
+    def on_selectionList_itemDoubleClicked(self, item):
+        """
+        Private slot handling double clicking an item.
+        
+        @param item double clicked item
+        @type QListWidgetItem
+        """
+        if (
+            not self.__isCheckBoxSelection and
+            self.selectionList.selectionMode() ==
+            QAbstractItemView.SelectionMode.SingleSelection
+        ):
+            self.accept()
+    
     def getSelection(self):
         """
         Public method to retrieve the selected items.

eric ide

mercurial