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

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 class GitRevisionSelectionDialog(QDialog, Ui_GitRevisionSelectionDialog): 16 class GitRevisionSelectionDialog(QDialog, Ui_GitRevisionSelectionDialog):
17 """ 17 """
18 Class implementing a dialog to select a revision. 18 Class implementing a dialog to select a revision.
19 """ 19 """
20 def __init__(self, tagsList, branchesList, trackingBranchesList=None, 20
21 noneLabel="", showBranches=True, showHead=True, parent=None): 21 def __init__(
22 self,
23 tagsList,
24 branchesList,
25 trackingBranchesList=None,
26 noneLabel="",
27 showBranches=True,
28 showHead=True,
29 parent=None,
30 ):
22 """ 31 """
23 Constructor 32 Constructor
24 33
25 @param tagsList list of tags (list of strings) 34 @param tagsList list of tags (list of strings)
26 @param branchesList list of branches (list of strings) 35 @param branchesList list of branches (list of strings)
27 @param trackingBranchesList list of remote branches (list of strings) 36 @param trackingBranchesList list of remote branches (list of strings)
28 @param noneLabel label text for "no revision selected" (string) 37 @param noneLabel label text for "no revision selected" (string)
29 @param showBranches flag indicating to show the branch selection 38 @param showBranches flag indicating to show the branch selection
31 @param showHead flag indicating to show the head selection (boolean) 40 @param showHead flag indicating to show the head selection (boolean)
32 @param parent parent widget (QWidget) 41 @param parent parent widget (QWidget)
33 """ 42 """
34 super().__init__(parent) 43 super().__init__(parent)
35 self.setupUi(self) 44 self.setupUi(self)
36 45
37 self.buttonBox.button( 46 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
38 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 47
39
40 self.tagCombo.addItems(sorted(tagsList)) 48 self.tagCombo.addItems(sorted(tagsList))
41 self.branchCombo.addItems(["master"] + sorted(branchesList)) 49 self.branchCombo.addItems(["master"] + sorted(branchesList))
42 50
43 self.tipButton.setVisible(showHead) 51 self.tipButton.setVisible(showHead)
44 self.branchButton.setVisible(showBranches) 52 self.branchButton.setVisible(showBranches)
45 self.branchCombo.setVisible(showBranches) 53 self.branchCombo.setVisible(showBranches)
46 54
47 if noneLabel: 55 if noneLabel:
48 self.noneButton.setText(noneLabel) 56 self.noneButton.setText(noneLabel)
49 57
50 if trackingBranchesList is not None: 58 if trackingBranchesList is not None:
51 self.remoteBranchCombo.addItems(sorted(trackingBranchesList)) 59 self.remoteBranchCombo.addItems(sorted(trackingBranchesList))
52 else: 60 else:
53 self.remoteBranchButton.setVisible(False) 61 self.remoteBranchButton.setVisible(False)
54 self.remoteBranchCombo.setVisible(False) 62 self.remoteBranchCombo.setVisible(False)
55 63
56 msh = self.minimumSizeHint() 64 msh = self.minimumSizeHint()
57 self.resize(max(self.width(), msh.width()), msh.height()) 65 self.resize(max(self.width(), msh.width()), msh.height())
58 66
59 def __updateOK(self): 67 def __updateOK(self):
60 """ 68 """
61 Private slot to update the OK button. 69 Private slot to update the OK button.
62 """ 70 """
63 enabled = True 71 enabled = True
67 enabled = self.tagCombo.currentText() != "" 75 enabled = self.tagCombo.currentText() != ""
68 elif self.branchButton.isChecked(): 76 elif self.branchButton.isChecked():
69 enabled = self.branchCombo.currentText() != "" 77 enabled = self.branchCombo.currentText() != ""
70 elif self.remoteBranchButton.isChecked(): 78 elif self.remoteBranchButton.isChecked():
71 enabled = self.remoteBranchCombo.currentText() != "" 79 enabled = self.remoteBranchCombo.currentText() != ""
72 80
73 self.buttonBox.button( 81 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
74 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) 82
75
76 @pyqtSlot(bool) 83 @pyqtSlot(bool)
77 def on_revButton_toggled(self, checked): 84 def on_revButton_toggled(self, checked):
78 """ 85 """
79 Private slot to handle changes of the rev select button. 86 Private slot to handle changes of the rev select button.
80 87
81 @param checked state of the button (boolean) 88 @param checked state of the button (boolean)
82 """ 89 """
83 self.__updateOK() 90 self.__updateOK()
84 91
85 @pyqtSlot(bool) 92 @pyqtSlot(bool)
86 def on_tagButton_toggled(self, checked): 93 def on_tagButton_toggled(self, checked):
87 """ 94 """
88 Private slot to handle changes of the Tag select button. 95 Private slot to handle changes of the Tag select button.
89 96
90 @param checked state of the button (boolean) 97 @param checked state of the button (boolean)
91 """ 98 """
92 self.__updateOK() 99 self.__updateOK()
93 100
94 @pyqtSlot(bool) 101 @pyqtSlot(bool)
95 def on_branchButton_toggled(self, checked): 102 def on_branchButton_toggled(self, checked):
96 """ 103 """
97 Private slot to handle changes of the Branch select button. 104 Private slot to handle changes of the Branch select button.
98 105
99 @param checked state of the button (boolean) 106 @param checked state of the button (boolean)
100 """ 107 """
101 self.__updateOK() 108 self.__updateOK()
102 109
103 @pyqtSlot(bool) 110 @pyqtSlot(bool)
104 def on_remoteBranchButton_toggled(self, checked): 111 def on_remoteBranchButton_toggled(self, checked):
105 """ 112 """
106 Private slot to handle changes of the Remote Branch select button. 113 Private slot to handle changes of the Remote Branch select button.
107 114
108 @param checked state of the button (boolean) 115 @param checked state of the button (boolean)
109 """ 116 """
110 self.__updateOK() 117 self.__updateOK()
111 118
112 @pyqtSlot(str) 119 @pyqtSlot(str)
113 def on_revEdit_textChanged(self, txt): 120 def on_revEdit_textChanged(self, txt):
114 """ 121 """
115 Private slot to handle changes of the rev edit. 122 Private slot to handle changes of the rev edit.
116 123
117 @param txt text of the edit (string) 124 @param txt text of the edit (string)
118 """ 125 """
119 self.__updateOK() 126 self.__updateOK()
120 127
121 @pyqtSlot(str) 128 @pyqtSlot(str)
122 def on_tagCombo_editTextChanged(self, txt): 129 def on_tagCombo_editTextChanged(self, txt):
123 """ 130 """
124 Private slot to handle changes of the Tag combo. 131 Private slot to handle changes of the Tag combo.
125 132
126 @param txt text of the combo (string) 133 @param txt text of the combo (string)
127 """ 134 """
128 self.__updateOK() 135 self.__updateOK()
129 136
130 @pyqtSlot(str) 137 @pyqtSlot(str)
131 def on_branchCombo_editTextChanged(self, txt): 138 def on_branchCombo_editTextChanged(self, txt):
132 """ 139 """
133 Private slot to handle changes of the Branch combo. 140 Private slot to handle changes of the Branch combo.
134 141
135 @param txt text of the combo (string) 142 @param txt text of the combo (string)
136 """ 143 """
137 self.__updateOK() 144 self.__updateOK()
138 145
139 @pyqtSlot(str) 146 @pyqtSlot(str)
140 def on_remoteBranchCombo_editTextChanged(self, txt): 147 def on_remoteBranchCombo_editTextChanged(self, txt):
141 """ 148 """
142 Private slot to handle changes of the Remote Branch combo. 149 Private slot to handle changes of the Remote Branch combo.
143 150
144 @param txt text of the combo (string) 151 @param txt text of the combo (string)
145 """ 152 """
146 self.__updateOK() 153 self.__updateOK()
147 154
148 def getRevision(self): 155 def getRevision(self):
149 """ 156 """
150 Public method to retrieve the selected revision. 157 Public method to retrieve the selected revision.
151 158
152 @return selected revision (string) 159 @return selected revision (string)
153 """ 160 """
154 if self.revButton.isChecked(): 161 if self.revButton.isChecked():
155 rev = self.revEdit.text() 162 rev = self.revEdit.text()
156 elif self.tagButton.isChecked(): 163 elif self.tagButton.isChecked():
161 rev = self.remoteBranchCombo.currentText() 168 rev = self.remoteBranchCombo.currentText()
162 elif self.tipButton.isChecked(): 169 elif self.tipButton.isChecked():
163 rev = "HEAD" 170 rev = "HEAD"
164 else: 171 else:
165 rev = "" 172 rev = ""
166 173
167 return rev 174 return rev

eric ide

mercurial