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

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to select multiple shelve names.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.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