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