eric7/Plugins/VcsPlugins/vcsMercurial/ShelveExtension/HgShelvesSelectionDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to select multiple shelve names.
8 """
9
10 from PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_HgShelvesSelectionDialog import Ui_HgShelvesSelectionDialog
14
15
16 class HgShelvesSelectionDialog(QDialog, Ui_HgShelvesSelectionDialog):
17 """
18 Class implementing a dialog to select multiple shelve names.
19 """
20 def __init__(self, message, shelveNames, parent=None):
21 """
22 Constructor
23
24 @param message message to be shown (string)
25 @param shelveNames list of shelve names (list of string)
26 @param parent reference to the parent widget (QWidget)
27 """
28 super().__init__(parent)
29 self.setupUi(self)
30
31 self.message.setText(message)
32 self.shelvesList.addItems(shelveNames)
33
34 self.buttonBox.button(
35 QDialogButtonBox.StandardButton.Ok).setEnabled(False)
36
37 @pyqtSlot()
38 def on_shelvesList_itemSelectionChanged(self):
39 """
40 Private slot to enabled the OK button if items have been selected.
41 """
42 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
43 len(self.shelvesList.selectedItems()) > 0)
44
45 def getSelectedShelves(self):
46 """
47 Public method to retrieve the selected shelve names.
48
49 @return selected shelve names (list of string)
50 """
51 names = []
52 for itm in self.shelvesList.selectedItems():
53 names.append(itm.text())
54
55 return names

eric ide

mercurial