src/eric7/Plugins/VcsPlugins/vcsMercurial/ShelveBuiltin/HgShelvesSelectionDialog.py

branch
eric7
changeset 11068
15f0385e0471
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/ShelveBuiltin/HgShelvesSelectionDialog.py	Sun Dec 01 18:17:51 2024 +0100
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2014 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing a dialog to select multiple shelve names.
+"""
+
+from PyQt6.QtCore import pyqtSlot
+from PyQt6.QtWidgets import QDialog, QDialogButtonBox
+
+from .Ui_HgShelvesSelectionDialog import Ui_HgShelvesSelectionDialog
+
+
+class HgShelvesSelectionDialog(QDialog, Ui_HgShelvesSelectionDialog):
+    """
+    Class implementing a dialog to select multiple shelve names.
+    """
+
+    def __init__(self, message, shelveNames, parent=None):
+        """
+        Constructor
+
+        @param message message to be shown
+        @type str
+        @param shelveNames list of shelve names
+        @type list of str
+        @param parent reference to the parent widget
+        @type QWidget
+        """
+        super().__init__(parent)
+        self.setupUi(self)
+
+        self.message.setText(message)
+        self.shelvesList.addItems(shelveNames)
+
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
+
+    @pyqtSlot()
+    def on_shelvesList_itemSelectionChanged(self):
+        """
+        Private slot to enabled the OK button if items have been selected.
+        """
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
+            len(self.shelvesList.selectedItems()) > 0
+        )
+
+    def getSelectedShelves(self):
+        """
+        Public method to retrieve the selected shelve names.
+
+        @return selected shelve names
+        @rtype list of str
+        """
+        names = []
+        for itm in self.shelvesList.selectedItems():
+            names.append(itm.text())
+
+        return names

eric ide

mercurial