Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelvesSelectionDialog.py

changeset 3297
7b7e8124fb51
child 3359
6b6c224d67d6
diff -r 3aabaf28817b -r 7b7e8124fb51 Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelvesSelectionDialog.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelvesSelectionDialog.py	Sat Feb 22 19:57:46 2014 +0100
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+"""
+Module implementing a dialog to select multiple shelve names.
+"""
+
+from PyQt4.QtCore import pyqtSlot
+from PyQt4.QtGui 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 parent reference to the parent widget (QWidget)
+        """
+        super().__init__(parent)
+        self.setupUi(self)
+        
+        self.message.setText(message)
+        self.shelvesList.addItems(shelveNames)
+        
+        self.buttonBox.button(QDialogButtonBox.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.Ok).setEnabled(
+            len(self.shelvesList.selectedItems()) > 0)
+    
+    def getSelectedShelves(self):
+        """
+        Public method to retrieve the selected shelve names.
+        
+        @return selected shelve names (list of string)
+        """
+        names = []
+        for itm in self.shelvesList.selectedItems():
+            names.append(itm.text())
+        
+        return names

eric ide

mercurial