Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesGuardsSelectionDialog.py

changeset 1047
b41a36b201e4
child 1131
7781e396c903
equal deleted inserted replaced
1046:5dd14be5d6a1 1047:b41a36b201e4
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to select a list of guards.
8 """
9
10 from PyQt4.QtGui import QDialog, QDialogButtonBox, QListWidgetItem, QAbstractItemView
11
12 from .Ui_HgQueuesGuardsSelectionDialog import Ui_HgQueuesGuardsSelectionDialog
13
14
15 class HgQueuesGuardsSelectionDialog(QDialog, Ui_HgQueuesGuardsSelectionDialog):
16 """
17 Class implementing a dialog to select a list of guards.
18 """
19 def __init__(self, guards, activeGuards=None, listOnly=False, parent=None):
20 """
21 Constructor
22
23 @param guards list of guards to select from (list of strings)
24 @keyparam activeGuards list of active guards (list of strings)
25 @param listOnly flag indicating to only list the guards (boolean)
26 @param parent reference to the parent widget (QWidget)
27 """
28 QDialog.__init__(self, parent)
29 self.setupUi(self)
30
31 for guard in guards:
32 itm = QListWidgetItem(guard, self.guardsList)
33 if activeGuards is not None and guard in activeGuards:
34 font = itm.font()
35 font.setBold(True)
36 itm.setFont(font)
37 self.guardsList.sortItems()
38
39 if listOnly:
40 self.buttonBox.button(QDialogButtonBox.Cancel).hide()
41 self.guardsList.setSelectionMode(QAbstractItemView.NoSelection)
42 self.setWindowTitle(self.trUtf8("Active Guards"))
43
44 def getData(self):
45 """
46 Public method to retrieve the data.
47
48 @return list of selected guards (list of strings)
49 """
50 guardsList = []
51
52 for itm in self.guardsList.selectedItems():
53 guardsList.append(itm.text())
54
55 return guardsList

eric ide

mercurial