Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesNewPatchDialog.py

changeset 1035
2cd7817ac659
parent 1034
8a7fa049e9d3
child 1061
3e21869872e3
equal deleted inserted replaced
1034:8a7fa049e9d3 1035:2cd7817ac659
5 5
6 """ 6 """
7 Module implementing a dialog to get the data for a new patch. 7 Module implementing a dialog to get the data for a new patch.
8 """ 8 """
9 9
10 from PyQt4.QtCore import pyqtSlot, QDate 10 from PyQt4.QtCore import pyqtSlot, QDateTime
11 from PyQt4.QtGui import QDialog, QDialogButtonBox 11 from PyQt4.QtGui import QDialog, QDialogButtonBox
12 12
13 from .Ui_HgQueuesNewPatchDialog import Ui_HgQueuesNewPatchDialog 13 from .Ui_HgQueuesNewPatchDialog import Ui_HgQueuesNewPatchDialog
14 14
15 15
16 class HgQueuesNewPatchDialog(QDialog, Ui_HgQueuesNewPatchDialog): 16 class HgQueuesNewPatchDialog(QDialog, Ui_HgQueuesNewPatchDialog):
17 """ 17 """
18 Class implementing a dialog to get the data for a new patch. 18 Class implementing a dialog to get the data for a new patch.
19 """ 19 """
20 def __init__(self, parent=None): 20 NEW_MODE = 0
21 REFRESH_MODE = 1
22
23 def __init__(self, mode, message="", parent=None):
21 """ 24 """
22 Constructor 25 Constructor
23 26
27 @param mode mode of the dialog (HgQueuesNewPatchDialog.NEW_MODE,
28 HgQueuesNewPatchDialog.REFRESH_MODE)
29 @param message text to set as the commit message (string)
24 @param parent reference to the parent widget (QWidget) 30 @param parent reference to the parent widget (QWidget)
25 """ 31 """
26 QDialog.__init__(self, parent) 32 QDialog.__init__(self, parent)
27 self.setupUi(self) 33 self.setupUi(self)
28 34
29 self.dateEdit.setDate(QDate.currentDate()) 35 self.__mode = mode
36 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE:
37 self.nameLabel.hide()
38 self.nameEdit.hide()
39 elif self.__mode == HgQueuesNewPatchDialog.NEW_MODE:
40 # nothing special here
41 pass
42 else:
43 raise ValueError("invalid value for mode")
30 44
31 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) 45 if message:
46 self.messageEdit.setPlainText(message)
47
48 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
49
50 self.__updateUI()
32 51
33 def __updateUI(self): 52 def __updateUI(self):
34 """ 53 """
35 Private slot to update the UI. 54 Private slot to update the UI.
36 """ 55 """
37 enable = self.nameEdit.text() != "" and \ 56 if self.__mode == HgQueuesNewPatchDialog.REFRESH_MODE:
38 self.messageEdit.toPlainText() != "" 57 enable = self.messageEdit.toPlainText() != ""
58 else:
59 enable = self.nameEdit.text() != "" and \
60 self.messageEdit.toPlainText() != ""
39 if self.userGroup.isChecked(): 61 if self.userGroup.isChecked():
40 enable = enable and \ 62 enable = enable and \
41 (self.currentUserCheckBox.isChecked() or \ 63 (self.currentUserCheckBox.isChecked() or \
42 self.userEdit.text() != "") 64 self.userEdit.text() != "")
43 65
59 81
60 @param txt text of the edit (string) 82 @param txt text of the edit (string)
61 """ 83 """
62 self.__updateUI() 84 self.__updateUI()
63 85
86 @pyqtSlot(bool)
87 def on_userGroup_toggled(self, checked):
88 """
89 Private slot to handle changes of the user group state.
90
91 @param checked flag giving the checked state (boolean)
92 """
93 self.__updateUI()
94
95 @pyqtSlot(bool)
96 def on_currentUserCheckBox_toggled(self, checked):
97 """
98 Private slot to handle changes of the currentuser state.
99
100 @param checked flag giving the checked state (boolean)
101 """
102 self.__updateUI()
103
104 @pyqtSlot(str)
105 def on_userEdit_textChanged(self, txt):
106 """
107 Private slot to handle changes of the user name.
108
109 @param txt text of the edit (string)
110 """
111 self.__updateUI()
112
64 def getData(self): 113 def getData(self):
65 """ 114 """
66 Public method to retrieve the entered data. 115 Public method to retrieve the entered data.
67 116
68 @return tuple giving the patch name and message, a tuple giving a 117 @return tuple giving the patch name and message, a tuple giving a
75 userData = (self.userGroup.isChecked(), 124 userData = (self.userGroup.isChecked(),
76 self.currentUserCheckBox.isChecked(), 125 self.currentUserCheckBox.isChecked(),
77 self.userEdit.text()) 126 self.userEdit.text())
78 dateData = (self.dateGroup.isChecked(), 127 dateData = (self.dateGroup.isChecked(),
79 self.currentDateCheckBox.isChecked(), 128 self.currentDateCheckBox.isChecked(),
80 self.dateEdit.date().toString("yyyy-MM-dd")) 129 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm"))
81 return (self.nameEdit.text(), self.messageEdit.toPlainText(), 130 return (self.nameEdit.text(), self.messageEdit.toPlainText(),
82 userData, dateData) 131 userData, dateData)

eric ide

mercurial