src/eric7/Plugins/VcsPlugins/vcsGit/GitRevisionsSelectionDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
16 class GitRevisionsSelectionDialog(QDialog, Ui_GitRevisionsSelectionDialog): 16 class GitRevisionsSelectionDialog(QDialog, Ui_GitRevisionsSelectionDialog):
17 """ 17 """
18 Class implementing a dialog to enter the revisions for the git diff 18 Class implementing a dialog to enter the revisions for the git diff
19 command. 19 command.
20 """ 20 """
21
21 def __init__(self, tagsList, branchesList, parent=None): 22 def __init__(self, tagsList, branchesList, parent=None):
22 """ 23 """
23 Constructor 24 Constructor
24 25
25 @param tagsList list of tags (list of strings) 26 @param tagsList list of tags (list of strings)
26 @param branchesList list of branches (list of strings) 27 @param branchesList list of branches (list of strings)
27 @param parent parent widget of the dialog (QWidget) 28 @param parent parent widget of the dialog (QWidget)
28 """ 29 """
29 super().__init__(parent) 30 super().__init__(parent)
30 self.setupUi(self) 31 self.setupUi(self)
31 32
32 self.buttonBox.button( 33 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
33 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 34
34
35 self.tag1Combo.addItems(sorted(tagsList)) 35 self.tag1Combo.addItems(sorted(tagsList))
36 self.tag2Combo.addItems(sorted(tagsList)) 36 self.tag2Combo.addItems(sorted(tagsList))
37 self.branch1Combo.addItems(["master"] + sorted(branchesList)) 37 self.branch1Combo.addItems(["master"] + sorted(branchesList))
38 self.branch2Combo.addItems(["master"] + sorted(branchesList)) 38 self.branch2Combo.addItems(["master"] + sorted(branchesList))
39 39
40 msh = self.minimumSizeHint() 40 msh = self.minimumSizeHint()
41 self.resize(max(self.width(), msh.width()), msh.height()) 41 self.resize(max(self.width(), msh.width()), msh.height())
42 42
43 def __updateOK(self): 43 def __updateOK(self):
44 """ 44 """
45 Private slot to update the OK button. 45 Private slot to update the OK button.
46 """ 46 """
47 enabled = True 47 enabled = True
49 enabled = enabled and self.rev1Edit.text() != "" 49 enabled = enabled and self.rev1Edit.text() != ""
50 elif self.tag1Button.isChecked(): 50 elif self.tag1Button.isChecked():
51 enabled = enabled and self.tag1Combo.currentText() != "" 51 enabled = enabled and self.tag1Combo.currentText() != ""
52 elif self.branch1Button.isChecked(): 52 elif self.branch1Button.isChecked():
53 enabled = enabled and self.branch1Combo.currentText() != "" 53 enabled = enabled and self.branch1Combo.currentText() != ""
54 54
55 if self.rev2Button.isChecked(): 55 if self.rev2Button.isChecked():
56 enabled = enabled and self.rev2Edit.text() != "" 56 enabled = enabled and self.rev2Edit.text() != ""
57 elif self.tag2Button.isChecked(): 57 elif self.tag2Button.isChecked():
58 enabled = enabled and self.tag2Combo.currentText() != "" 58 enabled = enabled and self.tag2Combo.currentText() != ""
59 elif self.branch2Button.isChecked(): 59 elif self.branch2Button.isChecked():
60 enabled = enabled and self.branch2Combo.currentText() != "" 60 enabled = enabled and self.branch2Combo.currentText() != ""
61 61
62 self.buttonBox.button( 62 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
63 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) 63
64
65 @pyqtSlot(bool) 64 @pyqtSlot(bool)
66 def on_rev1Button_toggled(self, checked): 65 def on_rev1Button_toggled(self, checked):
67 """ 66 """
68 Private slot to handle changes of the rev1 select button. 67 Private slot to handle changes of the rev1 select button.
69 68
70 @param checked state of the button (boolean) 69 @param checked state of the button (boolean)
71 """ 70 """
72 self.__updateOK() 71 self.__updateOK()
73 72
74 @pyqtSlot(bool) 73 @pyqtSlot(bool)
75 def on_rev2Button_toggled(self, checked): 74 def on_rev2Button_toggled(self, checked):
76 """ 75 """
77 Private slot to handle changes of the rev2 select button. 76 Private slot to handle changes of the rev2 select button.
78 77
79 @param checked state of the button (boolean) 78 @param checked state of the button (boolean)
80 """ 79 """
81 self.__updateOK() 80 self.__updateOK()
82 81
83 @pyqtSlot(bool) 82 @pyqtSlot(bool)
84 def on_tag1Button_toggled(self, checked): 83 def on_tag1Button_toggled(self, checked):
85 """ 84 """
86 Private slot to handle changes of the Tag1 select button. 85 Private slot to handle changes of the Tag1 select button.
87 86
88 @param checked state of the button (boolean) 87 @param checked state of the button (boolean)
89 """ 88 """
90 self.__updateOK() 89 self.__updateOK()
91 90
92 @pyqtSlot(bool) 91 @pyqtSlot(bool)
93 def on_tag2Button_toggled(self, checked): 92 def on_tag2Button_toggled(self, checked):
94 """ 93 """
95 Private slot to handle changes of the Tag2 select button. 94 Private slot to handle changes of the Tag2 select button.
96 95
97 @param checked state of the button (boolean) 96 @param checked state of the button (boolean)
98 """ 97 """
99 self.__updateOK() 98 self.__updateOK()
100 99
101 @pyqtSlot(bool) 100 @pyqtSlot(bool)
102 def on_branch1Button_toggled(self, checked): 101 def on_branch1Button_toggled(self, checked):
103 """ 102 """
104 Private slot to handle changes of the Branch1 select button. 103 Private slot to handle changes of the Branch1 select button.
105 104
106 @param checked state of the button (boolean) 105 @param checked state of the button (boolean)
107 """ 106 """
108 self.__updateOK() 107 self.__updateOK()
109 108
110 @pyqtSlot(bool) 109 @pyqtSlot(bool)
111 def on_branch2Button_toggled(self, checked): 110 def on_branch2Button_toggled(self, checked):
112 """ 111 """
113 Private slot to handle changes of the Branch2 select button. 112 Private slot to handle changes of the Branch2 select button.
114 113
115 @param checked state of the button (boolean) 114 @param checked state of the button (boolean)
116 """ 115 """
117 self.__updateOK() 116 self.__updateOK()
118 117
119 @pyqtSlot(str) 118 @pyqtSlot(str)
120 def on_rev1Edit_textChanged(self, txt): 119 def on_rev1Edit_textChanged(self, txt):
121 """ 120 """
122 Private slot to handle changes of the rev1 edit. 121 Private slot to handle changes of the rev1 edit.
123 122
124 @param txt text of the edit (string) 123 @param txt text of the edit (string)
125 """ 124 """
126 self.__updateOK() 125 self.__updateOK()
127 126
128 @pyqtSlot(str) 127 @pyqtSlot(str)
129 def on_rev2Edit_textChanged(self, txt): 128 def on_rev2Edit_textChanged(self, txt):
130 """ 129 """
131 Private slot to handle changes of the rev2 edit. 130 Private slot to handle changes of the rev2 edit.
132 131
133 @param txt text of the edit (string) 132 @param txt text of the edit (string)
134 """ 133 """
135 self.__updateOK() 134 self.__updateOK()
136 135
137 @pyqtSlot(str) 136 @pyqtSlot(str)
138 def on_tag1Combo_editTextChanged(self, txt): 137 def on_tag1Combo_editTextChanged(self, txt):
139 """ 138 """
140 Private slot to handle changes of the Tag1 combo. 139 Private slot to handle changes of the Tag1 combo.
141 140
142 @param txt text of the combo (string) 141 @param txt text of the combo (string)
143 """ 142 """
144 self.__updateOK() 143 self.__updateOK()
145 144
146 @pyqtSlot(str) 145 @pyqtSlot(str)
147 def on_tag2Combo_editTextChanged(self, txt): 146 def on_tag2Combo_editTextChanged(self, txt):
148 """ 147 """
149 Private slot to handle changes of the Tag2 combo. 148 Private slot to handle changes of the Tag2 combo.
150 149
151 @param txt text of the combo (string) 150 @param txt text of the combo (string)
152 """ 151 """
153 self.__updateOK() 152 self.__updateOK()
154 153
155 @pyqtSlot(str) 154 @pyqtSlot(str)
156 def on_branch1Combo_editTextChanged(self, txt): 155 def on_branch1Combo_editTextChanged(self, txt):
157 """ 156 """
158 Private slot to handle changes of the Branch1 combo. 157 Private slot to handle changes of the Branch1 combo.
159 158
160 @param txt text of the combo (string) 159 @param txt text of the combo (string)
161 """ 160 """
162 self.__updateOK() 161 self.__updateOK()
163 162
164 @pyqtSlot(str) 163 @pyqtSlot(str)
165 def on_branch2Combo_editTextChanged(self, txt): 164 def on_branch2Combo_editTextChanged(self, txt):
166 """ 165 """
167 Private slot to handle changes of the Branch2 combo. 166 Private slot to handle changes of the Branch2 combo.
168 167
169 @param txt text of the combo (string) 168 @param txt text of the combo (string)
170 """ 169 """
171 self.__updateOK() 170 self.__updateOK()
172 171
173 def __getRevision(self, no): 172 def __getRevision(self, no):
174 """ 173 """
175 Private method to generate the revision. 174 Private method to generate the revision.
176 175
177 @param no revision number to generate (1 or 2) 176 @param no revision number to generate (1 or 2)
178 @return revision (string) 177 @return revision (string)
179 """ 178 """
180 if no == 1: 179 if no == 1:
181 revButton = self.rev1Button 180 revButton = self.rev1Button
195 branchButton = self.branch2Button 194 branchButton = self.branch2Button
196 branchCombo = self.branch2Combo 195 branchCombo = self.branch2Combo
197 tipButton = self.tip2Button 196 tipButton = self.tip2Button
198 prevButton = self.prev2Button 197 prevButton = self.prev2Button
199 noneButton = self.none2Button 198 noneButton = self.none2Button
200 199
201 if revButton.isChecked(): 200 if revButton.isChecked():
202 return revEdit.text() 201 return revEdit.text()
203 elif tagButton.isChecked(): 202 elif tagButton.isChecked():
204 return tagCombo.currentText() 203 return tagCombo.currentText()
205 elif branchButton.isChecked(): 204 elif branchButton.isChecked():
208 return "HEAD" 207 return "HEAD"
209 elif prevButton.isChecked(): 208 elif prevButton.isChecked():
210 return "HEAD^" 209 return "HEAD^"
211 elif noneButton.isChecked(): 210 elif noneButton.isChecked():
212 return "" 211 return ""
213 212
214 return "" 213 return ""
215 214
216 def getRevisions(self): 215 def getRevisions(self):
217 """ 216 """
218 Public method to get the revisions. 217 Public method to get the revisions.
219 218
220 @return list of two revisions (list of strings) 219 @return list of two revisions (list of strings)
221 """ 220 """
222 rev1 = self.__getRevision(1) 221 rev1 = self.__getRevision(1)
223 rev2 = self.__getRevision(2) 222 rev2 = self.__getRevision(2)
224 223
225 return [rev1, rev2] 224 return [rev1, rev2]

eric ide

mercurial