Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelvesSelectionDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3359
6b6c224d67d6
child 3656
441956d8fce5
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
1 # -*- coding: utf-8 -*-
2
3 """
4 Module implementing a dialog to select multiple shelve names.
5 """
6
7 from __future__ import unicode_literals
8
9 from PyQt4.QtCore import pyqtSlot
10 from PyQt4.QtGui import QDialog, QDialogButtonBox
11
12 from .Ui_HgShelvesSelectionDialog import Ui_HgShelvesSelectionDialog
13
14
15 class HgShelvesSelectionDialog(QDialog, Ui_HgShelvesSelectionDialog):
16 """
17 Class implementing a dialog to select multiple shelve names.
18 """
19 def __init__(self, message, shelveNames, parent=None):
20 """
21 Constructor
22
23 @param message message to be shown (string)
24 @param shelveNames list of shelve names (list of string)
25 @param parent reference to the parent widget (QWidget)
26 """
27 super(HgShelvesSelectionDialog, self).__init__(parent)
28 self.setupUi(self)
29
30 self.message.setText(message)
31 self.shelvesList.addItems(shelveNames)
32
33 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
34
35 @pyqtSlot()
36 def on_shelvesList_itemSelectionChanged(self):
37 """
38 Private slot to enabled the OK button if items have been selected.
39 """
40 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
41 len(self.shelvesList.selectedItems()) > 0)
42
43 def getSelectedShelves(self):
44 """
45 Public method to retrieve the selected shelve names.
46
47 @return selected shelve names (list of string)
48 """
49 names = []
50 for itm in self.shelvesList.selectedItems():
51 names.append(itm.text())
52
53 return names

eric ide

mercurial