Plugins/VcsPlugins/vcsMercurial/HgBackoutDialog.py

changeset 1017
919147f2b518
parent 945
8cd4d08fa9f6
child 1131
7781e396c903
equal deleted inserted replaced
1016:72b6b0778e06 1017:919147f2b518
15 15
16 class HgBackoutDialog(QDialog, Ui_HgBackoutDialog): 16 class HgBackoutDialog(QDialog, Ui_HgBackoutDialog):
17 """ 17 """
18 Class implementing a dialog to enter the data for a backout operation. 18 Class implementing a dialog to enter the data for a backout operation.
19 """ 19 """
20 def __init__(self, tagsList, branchesList, parent=None): 20 def __init__(self, tagsList, branchesList, bookmarksList=None, parent=None):
21 """ 21 """
22 Constructor 22 Constructor
23 23
24 @param tagsList list of tags (list of strings) 24 @param tagsList list of tags (list of strings)
25 @param branchesList list of branches (list of strings) 25 @param branchesList list of branches (list of strings)
26 @param bookmarksList list of bookmarks (list of strings)
26 @param parent parent widget (QWidget) 27 @param parent parent widget (QWidget)
27 """ 28 """
28 QDialog.__init__(self, parent) 29 QDialog.__init__(self, parent)
29 self.setupUi(self) 30 self.setupUi(self)
30 31
32 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
33
31 self.tagCombo.addItems(sorted(tagsList)) 34 self.tagCombo.addItems(sorted(tagsList))
32 self.branchCombo.addItems(["default"] + sorted(branchesList)) 35 self.branchCombo.addItems(["default"] + sorted(branchesList))
33 36 if bookmarksList is not None:
34 self.okButton = self.buttonBox.button(QDialogButtonBox.Ok) 37 self.bookmarkCombo.addItems(sorted(bookmarksList))
35 self.okButton.setEnabled(False) 38 else:
39 self.bookmarkButton.setHidden(True)
40 self.bookmarkCombo.setHidden(True)
36 41
37 self.__initDateTime = QDateTime.currentDateTime() 42 self.__initDateTime = QDateTime.currentDateTime()
38 self.dateEdit.setDateTime(self.__initDateTime) 43 self.dateEdit.setDateTime(self.__initDateTime)
44
45 def __updateOK(self):
46 """
47 Private slot to update the OK button.
48 """
49 enabled = True
50 if self.noneButton.isChecked():
51 enabled = False
52 elif self.idButton.isChecked():
53 enabled = self.idEdit.text() != ""
54 elif self.tagButton.isChecked():
55 enabled = self.tagCombo.currentText() != ""
56 elif self.branchButton.isChecked():
57 enabled = self.branchCombo.currentText() != ""
58 elif self.bookmarkButton.isChecked():
59 enabled = self.bookmarkCombo.currentText() != ""
60
61 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
62
63 @pyqtSlot(bool)
64 def on_idButton_toggled(self, checked):
65 """
66 Private slot to handle changes of the ID select button.
67
68 @param checked state of the button (boolean)
69 """
70 self.__updateOK()
71
72 @pyqtSlot(bool)
73 def on_tagButton_toggled(self, checked):
74 """
75 Private slot to handle changes of the Tag select button.
76
77 @param checked state of the button (boolean)
78 """
79 self.__updateOK()
80
81 @pyqtSlot(bool)
82 def on_branchButton_toggled(self, checked):
83 """
84 Private slot to handle changes of the Branch select button.
85
86 @param checked state of the button (boolean)
87 """
88 self.__updateOK()
89
90 @pyqtSlot(bool)
91 def on_bookmarkButton_toggled(self, checked):
92 """
93 Private slot to handle changes of the Bookmark select button.
94
95 @param checked state of the button (boolean)
96 """
97 self.__updateOK()
39 98
40 @pyqtSlot(bool) 99 @pyqtSlot(bool)
41 def on_noneButton_toggled(self, checked): 100 def on_noneButton_toggled(self, checked):
42 """ 101 """
43 Private slot to handle the toggling of the None revision button. 102 Private slot to handle the toggling of the None revision button.
44 103
45 @param checked flag indicating the checked state (boolean) 104 @param checked flag indicating the checked state (boolean)
46 """ 105 """
47 self.okButton.setEnabled(not checked) 106 self.__updateOK()
107
108 @pyqtSlot(str)
109 def on_idEdit_textChanged(self, txt):
110 """
111 Private slot to handle changes of the ID edit.
112
113 @param txt text of the edit (string)
114 """
115 self.__updateOK()
116
117 @pyqtSlot(str)
118 def on_tagCombo_editTextChanged(self, txt):
119 """
120 Private slot to handle changes of the Tag combo.
121
122 @param txt text of the combo (string)
123 """
124 self.__updateOK()
125
126 @pyqtSlot(str)
127 def on_branchCombo_editTextChanged(self, txt):
128 """
129 Private slot to handle changes of the Branch combo.
130
131 @param txt text of the combo (string)
132 """
133 self.__updateOK()
134
135 @pyqtSlot(str)
136 def on_bookmarkCombo_editTextChanged(self, txt):
137 """
138 Private slot to handle changes of the Bookmark combo.
139
140 @param txt text of the combo (string)
141 """
142 self.__updateOK()
48 143
49 def getParameters(self): 144 def getParameters(self):
50 """ 145 """
51 Public method to retrieve the backout data. 146 Public method to retrieve the backout data.
52 147
60 rev = self.idEdit.text() 155 rev = self.idEdit.text()
61 elif self.tagButton.isChecked(): 156 elif self.tagButton.isChecked():
62 rev = self.tagCombo.currentText() 157 rev = self.tagCombo.currentText()
63 elif self.branchButton.isChecked(): 158 elif self.branchButton.isChecked():
64 rev = self.branchCombo.currentText() 159 rev = self.branchCombo.currentText()
160 elif self.bookmarkButton.isChecked():
161 rev = self.bookmarkCombo.currentText()
65 else: 162 else:
66 rev = "" 163 rev = ""
67 164
68 if self.dateEdit.dateTime() != self.__initDateTime: 165 if self.dateEdit.dateTime() != self.__initDateTime:
69 date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm") 166 date = self.dateEdit.dateTime().toString("yyyy-MM-dd hh:mm")

eric ide

mercurial