src/eric7/Plugins/VcsPlugins/vcsMercurial/StripExtension/HgStripDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 class HgStripDialog(QDialog, Ui_HgStripDialog): 16 class HgStripDialog(QDialog, Ui_HgStripDialog):
17 """ 17 """
18 Class implementing a dialog to enter the data to strip changesets. 18 Class implementing a dialog to enter the data to strip changesets.
19 """ 19 """
20 def __init__(self, tagsList, branchesList, bookmarksList=None, rev="", 20
21 parent=None): 21 def __init__(self, tagsList, branchesList, bookmarksList=None, rev="", parent=None):
22 """ 22 """
23 Constructor 23 Constructor
24 24
25 @param tagsList list of tags 25 @param tagsList list of tags
26 @type list of str 26 @type list of str
27 @param branchesList list of branches 27 @param branchesList list of branches
28 @type list of str 28 @type list of str
29 @param bookmarksList list of bookmarks 29 @param bookmarksList list of bookmarks
33 @param parent reference to the parent widget 33 @param parent reference to the parent widget
34 @type QWidget 34 @type QWidget
35 """ 35 """
36 super().__init__(parent) 36 super().__init__(parent)
37 self.setupUi(self) 37 self.setupUi(self)
38 38
39 self.tagCombo.addItems(sorted(tagsList)) 39 self.tagCombo.addItems(sorted(tagsList))
40 self.branchCombo.addItems(["default"] + sorted(branchesList)) 40 self.branchCombo.addItems(["default"] + sorted(branchesList))
41 if bookmarksList is not None: 41 if bookmarksList is not None:
42 self.bookmarkCombo.addItems([""] + sorted(bookmarksList)) 42 self.bookmarkCombo.addItems([""] + sorted(bookmarksList))
43 self.idEdit.setText(rev) 43 self.idEdit.setText(rev)
44 44
45 # connect various radio buttons and input fields 45 # connect various radio buttons and input fields
46 self.numberButton.toggled.connect(self.__updateOK) 46 self.numberButton.toggled.connect(self.__updateOK)
47 self.idButton.toggled.connect(self.__updateOK) 47 self.idButton.toggled.connect(self.__updateOK)
48 self.tagButton.toggled.connect(self.__updateOK) 48 self.tagButton.toggled.connect(self.__updateOK)
49 self.branchButton.toggled.connect(self.__updateOK) 49 self.branchButton.toggled.connect(self.__updateOK)
50 self.expressionButton.toggled.connect(self.__updateOK) 50 self.expressionButton.toggled.connect(self.__updateOK)
51 51
52 self.numberSpinBox.valueChanged.connect(self.__updateOK) 52 self.numberSpinBox.valueChanged.connect(self.__updateOK)
53 53
54 self.idEdit.textChanged.connect(self.__updateOK) 54 self.idEdit.textChanged.connect(self.__updateOK)
55 self.expressionEdit.textChanged.connect(self.__updateOK) 55 self.expressionEdit.textChanged.connect(self.__updateOK)
56 56
57 self.tagCombo.editTextChanged.connect(self.__updateOK) 57 self.tagCombo.editTextChanged.connect(self.__updateOK)
58 self.branchCombo.editTextChanged.connect(self.__updateOK) 58 self.branchCombo.editTextChanged.connect(self.__updateOK)
59 59
60 msh = self.minimumSizeHint() 60 msh = self.minimumSizeHint()
61 self.resize(max(self.width(), msh.width()), msh.height()) 61 self.resize(max(self.width(), msh.width()), msh.height())
62 62
63 self.__updateOK() 63 self.__updateOK()
64 64
65 self.idEdit.setFocus() 65 self.idEdit.setFocus()
66 66
67 @pyqtSlot() 67 @pyqtSlot()
68 def __updateOK(self): 68 def __updateOK(self):
69 """ 69 """
70 Private slot to update the OK button. 70 Private slot to update the OK button.
71 """ 71 """
78 enabled = enabled and bool(self.tagCombo.currentText()) 78 enabled = enabled and bool(self.tagCombo.currentText())
79 elif self.branchButton.isChecked(): 79 elif self.branchButton.isChecked():
80 enabled = enabled and bool(self.branchCombo.currentText()) 80 enabled = enabled and bool(self.branchCombo.currentText())
81 elif self.expressionButton.isChecked(): 81 elif self.expressionButton.isChecked():
82 enabled = enabled and bool(self.expressionEdit.text()) 82 enabled = enabled and bool(self.expressionEdit.text())
83 83
84 self.buttonBox.button( 84 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
85 QDialogButtonBox.StandardButton.Ok).setEnabled(enabled) 85
86
87 def __getRevision(self): 86 def __getRevision(self):
88 """ 87 """
89 Private method to generate the revision. 88 Private method to generate the revision.
90 89
91 @return revision 90 @return revision
92 @rtype str 91 @rtype str
93 """ 92 """
94 if self.numberButton.isChecked(): 93 if self.numberButton.isChecked():
95 return "rev({0})".format(self.numberSpinBox.value()) 94 return "rev({0})".format(self.numberSpinBox.value())
102 elif self.expressionButton.isChecked(): 101 elif self.expressionButton.isChecked():
103 return self.expressionEdit.text() 102 return self.expressionEdit.text()
104 else: 103 else:
105 # should not happen 104 # should not happen
106 return "" 105 return ""
107 106
108 def getData(self): 107 def getData(self):
109 """ 108 """
110 Public method to retrieve the data for the strip action. 109 Public method to retrieve the data for the strip action.
111 110
112 @return tuple with the revision, a bookmark name, a flag indicating 111 @return tuple with the revision, a bookmark name, a flag indicating
113 to enforce the strip action, a flag indicating to omit the creation 112 to enforce the strip action, a flag indicating to omit the creation
114 of backup bundles and a flag indicating to not modify the working 113 of backup bundles and a flag indicating to not modify the working
115 directory 114 directory
116 @rtype tuple (str, str, bool, bool, bool) 115 @rtype tuple (str, str, bool, bool, bool)

eric ide

mercurial