|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter data for the Mercurial Phase operation. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_HgPhaseDialog import Ui_HgPhaseDialog |
|
14 |
|
15 |
|
16 class HgPhaseDialog(QDialog, Ui_HgPhaseDialog): |
|
17 """ |
|
18 Class dimplementing a dialog to enter data for the Mercurial Phase operation. |
|
19 """ |
|
20 def __init__(self, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param parent reference to the parent widget (QWidget) |
|
25 """ |
|
26 super().__init__(parent) |
|
27 self.setupUi(self) |
|
28 |
|
29 self.phaseCombo.addItem("", "") |
|
30 self.phaseCombo.addItem(self.trUtf8("Public"), "p") |
|
31 self.phaseCombo.addItem(self.trUtf8("Draft"), "d") |
|
32 self.phaseCombo.addItem(self.trUtf8("Secret"), "s") |
|
33 |
|
34 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
35 |
|
36 def __updateOk(self): |
|
37 """ |
|
38 Private slot to update the state of the OK button. |
|
39 """ |
|
40 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
|
41 self.revisionsEdit.toPlainText().strip() != "" and |
|
42 self.phaseCombo.currentText().strip() != "") |
|
43 |
|
44 @pyqtSlot() |
|
45 def on_revisionsEdit_textChanged(self): |
|
46 """ |
|
47 Private slot to react upon changes of revisions. |
|
48 """ |
|
49 self.__updateOk() |
|
50 |
|
51 @pyqtSlot(str) |
|
52 def on_phaseCombo_activated(self, txt): |
|
53 """ |
|
54 Private slot to react upon changes of the phase. |
|
55 """ |
|
56 self.__updateOk() |
|
57 |
|
58 def getData(self): |
|
59 """ |
|
60 Public method to retrieve the entered data. |
|
61 |
|
62 @return tuple with list of revisions, phase and a flag indicating |
|
63 a forced operation (list of strings, string, boolean) |
|
64 """ |
|
65 return ( |
|
66 self.revisionsEdit.toPlainText().strip().splitlines(), |
|
67 self.phaseCombo.itemData(self.phaseCombo.currentIndex()), |
|
68 self.forceCheckBox.isChecked() |
|
69 ) |