src/eric7/Plugins/VcsPlugins/vcsMercurial/HgGraftDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 class HgGraftDialog(QDialog, Ui_HgGraftDialog): 16 class HgGraftDialog(QDialog, Ui_HgGraftDialog):
17 """ 17 """
18 Class implementing a dialog to enter the data for a graft session. 18 Class implementing a dialog to enter the data for a graft session.
19 """ 19 """
20
20 def __init__(self, vcs, revs=None, parent=None): 21 def __init__(self, vcs, revs=None, parent=None):
21 """ 22 """
22 Constructor 23 Constructor
23 24
24 @param vcs reference to the VCS object 25 @param vcs reference to the VCS object
25 @type Hg 26 @type Hg
26 @param revs list of revisions to show in the revisions pane 27 @param revs list of revisions to show in the revisions pane
27 @type list of str 28 @type list of str
28 @param parent reference to the parent widget 29 @param parent reference to the parent widget
29 @type QWidget 30 @type QWidget
30 """ 31 """
31 super().__init__(parent) 32 super().__init__(parent)
32 self.setupUi(self) 33 self.setupUi(self)
33 34
34 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime()) 35 self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
35 36
36 if revs: 37 if revs:
37 self.revisionsEdit.setPlainText("\n".join(sorted(revs))) 38 self.revisionsEdit.setPlainText("\n".join(sorted(revs)))
38 39
39 self.noCommitCheckBox.setEnabled(vcs.version >= (4, 7, 0)) 40 self.noCommitCheckBox.setEnabled(vcs.version >= (4, 7, 0))
40 41
41 self.__updateOk() 42 self.__updateOk()
42 43
43 def __updateOk(self): 44 def __updateOk(self):
44 """ 45 """
45 Private slot to update the state of the OK button. 46 Private slot to update the state of the OK button.
46 """ 47 """
47 enable = self.revisionsEdit.toPlainText() != "" 48 enable = self.revisionsEdit.toPlainText() != ""
48 if self.userGroup.isChecked(): 49 if self.userGroup.isChecked():
49 enable = ( 50 enable = enable and (
50 enable and 51 self.currentUserCheckBox.isChecked() or self.userEdit.text() != ""
51 (self.currentUserCheckBox.isChecked() or
52 self.userEdit.text() != "")
53 ) 52 )
54 53
55 self.buttonBox.button( 54 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
56 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) 55
57
58 @pyqtSlot() 56 @pyqtSlot()
59 def on_revisionsEdit_textChanged(self): 57 def on_revisionsEdit_textChanged(self):
60 """ 58 """
61 Private slot to react upon changes of revisions. 59 Private slot to react upon changes of revisions.
62 """ 60 """
63 self.__updateOk() 61 self.__updateOk()
64 62
65 @pyqtSlot(bool) 63 @pyqtSlot(bool)
66 def on_userGroup_toggled(self, checked): 64 def on_userGroup_toggled(self, checked):
67 """ 65 """
68 Private slot to handle changes of the user group state. 66 Private slot to handle changes of the user group state.
69 67
70 @param checked flag giving the checked state 68 @param checked flag giving the checked state
71 @type bool 69 @type bool
72 """ 70 """
73 self.__updateOk() 71 self.__updateOk()
74 72
75 @pyqtSlot(bool) 73 @pyqtSlot(bool)
76 def on_currentUserCheckBox_toggled(self, checked): 74 def on_currentUserCheckBox_toggled(self, checked):
77 """ 75 """
78 Private slot to handle changes of the current user state. 76 Private slot to handle changes of the current user state.
79 77
80 @param checked flag giving the checked state 78 @param checked flag giving the checked state
81 @type bool 79 @type bool
82 """ 80 """
83 self.__updateOk() 81 self.__updateOk()
84 82
85 @pyqtSlot(str) 83 @pyqtSlot(str)
86 def on_userEdit_textChanged(self, txt): 84 def on_userEdit_textChanged(self, txt):
87 """ 85 """
88 Private slot to handle changes of the user name. 86 Private slot to handle changes of the user name.
89 87
90 @param txt text of the edit (string) 88 @param txt text of the edit (string)
91 """ 89 """
92 self.__updateOk() 90 self.__updateOk()
93 91
94 def getData(self): 92 def getData(self):
95 """ 93 """
96 Public method to retrieve the entered data. 94 Public method to retrieve the entered data.
97 95
98 @return tuple with list of revisions, a tuple giving a 96 @return tuple with list of revisions, a tuple giving a
99 flag indicating to set the user, a flag indicating to use the 97 flag indicating to set the user, a flag indicating to use the
100 current user and the user name, another tuple giving a flag 98 current user and the user name, another tuple giving a flag
101 indicating to set the date, a flag indicating to use the 99 indicating to set the date, a flag indicating to use the
102 current date and the date, a flag indicating to append graft info 100 current date and the date, a flag indicating to append graft info
108 userData = ( 106 userData = (
109 self.userGroup.isChecked(), 107 self.userGroup.isChecked(),
110 self.currentUserCheckBox.isChecked(), 108 self.currentUserCheckBox.isChecked(),
111 self.userEdit.text(), 109 self.userEdit.text(),
112 ) 110 )
113 111
114 dateData = ( 112 dateData = (
115 self.dateGroup.isChecked(), 113 self.dateGroup.isChecked(),
116 self.currentDateCheckBox.isChecked(), 114 self.currentDateCheckBox.isChecked(),
117 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm"), 115 self.dateTimeEdit.dateTime().toString("yyyy-MM-dd hh:mm"),
118 ) 116 )
119 117
120 return ( 118 return (
121 self.revisionsEdit.toPlainText().strip().splitlines(), 119 self.revisionsEdit.toPlainText().strip().splitlines(),
122 userData, 120 userData,
123 dateData, 121 dateData,
124 self.logCheckBox.isChecked(), 122 self.logCheckBox.isChecked(),

eric ide

mercurial