Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesNewPatchDialog.py

changeset 1034
8a7fa049e9d3
child 1035
2cd7817ac659
equal deleted inserted replaced
1033:bfc17ed5ab1a 1034:8a7fa049e9d3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to get the data for a new patch.
8 """
9
10 from PyQt4.QtCore import pyqtSlot, QDate
11 from PyQt4.QtGui import QDialog, QDialogButtonBox
12
13 from .Ui_HgQueuesNewPatchDialog import Ui_HgQueuesNewPatchDialog
14
15
16 class HgQueuesNewPatchDialog(QDialog, Ui_HgQueuesNewPatchDialog):
17 """
18 Class implementing a dialog to get the data for a new patch.
19 """
20 def __init__(self, parent=None):
21 """
22 Constructor
23
24 @param parent reference to the parent widget (QWidget)
25 """
26 QDialog.__init__(self, parent)
27 self.setupUi(self)
28
29 self.dateEdit.setDate(QDate.currentDate())
30
31 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
32
33 def __updateUI(self):
34 """
35 Private slot to update the UI.
36 """
37 enable = self.nameEdit.text() != "" and \
38 self.messageEdit.toPlainText() != ""
39 if self.userGroup.isChecked():
40 enable = enable and \
41 (self.currentUserCheckBox.isChecked() or \
42 self.userEdit.text() != "")
43
44 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
45
46 @pyqtSlot(str)
47 def on_nameEdit_textChanged(self, txt):
48 """
49 Private slot to handle changes of the patch name.
50
51 @param txt text of the edit (string)
52 """
53 self.__updateUI()
54
55 @pyqtSlot()
56 def on_messageEdit_textChanged(self):
57 """
58 Private slot to handle changes of the patch message.
59
60 @param txt text of the edit (string)
61 """
62 self.__updateUI()
63
64 def getData(self):
65 """
66 Public method to retrieve the entered data.
67
68 @return tuple giving the patch name and message, a tuple giving a
69 flag indicating to set the user, a flag indicating to use the
70 current user and the user name and another tuple giving a flag
71 indicating to set the date, a flag indicating to use the
72 current date and the date (string, string, (boolean, boolean, string),
73 (boolean, boolean, string))
74 """
75 userData = (self.userGroup.isChecked(),
76 self.currentUserCheckBox.isChecked(),
77 self.userEdit.text())
78 dateData = (self.dateGroup.isChecked(),
79 self.currentDateCheckBox.isChecked(),
80 self.dateEdit.date().toString("yyyy-MM-dd"))
81 return (self.nameEdit.text(), self.messageEdit.toPlainText(),
82 userData, dateData)

eric ide

mercurial