Plugins/VcsPlugins/vcsMercurial/HgGraftDialog.py

changeset 1655
d2b583fdde1c
child 1990
7fee3661c4f9
equal deleted inserted replaced
1654:08264848be08 1655:d2b583fdde1c
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 the data for a graft session.
8 """
9
10 from PyQt4.QtCore import pyqtSlot, QDateTime
11 from PyQt4.QtGui import QDialog, QDialogButtonBox
12
13 from .Ui_HgGraftDialog import Ui_HgGraftDialog
14
15
16 class HgGraftDialog(QDialog, Ui_HgGraftDialog):
17 """
18 Class implementing a dialog to enter the data for a graft session.
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.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
30
31 self.__updateOk()
32
33 def __updateOk(self):
34 """
35 Private slot to update the state of the OK button.
36 """
37 enable = self.revisionsEdit.toPlainText() != ""
38 if self.userGroup.isChecked():
39 enable = enable and \
40 (self.currentUserCheckBox.isChecked() or \
41 self.userEdit.text() != "")
42
43 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
44
45 @pyqtSlot()
46 def on_revisionsEdit_textChanged(self):
47 """
48 Private slot to react upon changes of revisions.
49 """
50 self.__updateOk()
51
52 @pyqtSlot(bool)
53 def on_userGroup_toggled(self, checked):
54 """
55 Private slot to handle changes of the user group state.
56
57 @param checked flag giving the checked state (boolean)
58 """
59 self.__updateOk()
60
61 @pyqtSlot(bool)
62 def on_currentUserCheckBox_toggled(self, checked):
63 """
64 Private slot to handle changes of the currentuser state.
65
66 @param checked flag giving the checked state (boolean)
67 """
68 self.__updateOk()
69
70 @pyqtSlot(str)
71 def on_userEdit_textChanged(self, txt):
72 """
73 Private slot to handle changes of the user name.
74
75 @param txt text of the edit (string)
76 """
77 self.__updateOk()
78
79 def getData(self):
80 """
81 Public method to retrieve the entered data.
82
83 @return tuple with list of revisions, a tuple giving a
84 flag indicating to set the user, a flag indicating to use the
85 current user and the user name and another tuple giving a flag
86 indicating to set the date, a flag indicating to use the
87 current date and the date (list of strings, (boolean, boolean, string),
88 (boolean, boolean, string))
89 """
90 userData = (self.userGroup.isChecked(),
91 self.currentUserCheckBox.isChecked(),
92 self.userEdit.text())
93 dateData = (self.dateGroup.isChecked(),
94 self.currentDateCheckBox.isChecked(),
95 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm"))
96 return (self.revisionsEdit.toPlainText().strip().splitlines(),
97 userData, dateData)

eric ide

mercurial