Plugins/VcsPlugins/vcsMercurial/HgMultiRevisionSelectionDialog.py

changeset 1274
442c748018c5
child 1509
c0b5e693b0eb
equal deleted inserted replaced
1269:7b4d9f1d7c6c 1274:442c748018c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to select revisions.
8 """
9
10 from PyQt4.QtCore import pyqtSlot
11 from PyQt4.QtGui import QDialog, QDialogButtonBox
12
13 from .Ui_HgMultiRevisionSelectionDialog import Ui_HgMultiRevisionSelectionDialog
14
15
16 class HgMultiRevisionSelectionDialog(QDialog, Ui_HgMultiRevisionSelectionDialog):
17 """
18 Class implementing a dialog to select revisions.
19 """
20 def __init__(self, tagsList, branchesList, bookmarksList=None, emptyRevsOk=False,
21 showLimit=False, limitDefault=100, parent=None):
22 """
23 Constructor
24
25 @param tagsList list of tags (list of strings)
26 @param branchesList list of branches (list of strings)
27 @param bookmarksList list of bookmarks (list of strings)
28 @param emptyRevsOk flag indicating that it is ok to not enter revisions (boolean)
29 @param showLimit flag indicating to show the limit entry (boolean)
30 @param limitDefault default value for the limit (integer)
31 @param parent parent widget (QWidget)
32 """
33 super().__init__(parent)
34 self.setupUi(self)
35
36 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
37
38 self.__emptyRevsOk = emptyRevsOk
39
40 self.tagCombo.addItems(sorted(tagsList))
41 self.branchCombo.addItems(["default"] + sorted(branchesList))
42 if bookmarksList is not None:
43 self.bookmarkCombo.addItems(sorted(bookmarksList))
44 else:
45 self.bookmarkButton.setHidden(True)
46 self.bookmarkCombo.setHidden(True)
47
48 self.limitSpinBox.setValue(limitDefault)
49 self.limitGroup.setVisible(showLimit)
50
51 def __updateOK(self):
52 """
53 Private slot to update the OK button.
54 """
55 enabled = True
56 if self.changesetsButton.isChecked():
57 enabled = self.changesetsEdit.toPlainText() != ""
58 elif self.tagButton.isChecked():
59 enabled = self.tagCombo.currentText() != ""
60 elif self.branchButton.isChecked():
61 enabled = self.branchCombo.currentText() != ""
62 elif self.bookmarkButton.isChecked():
63 enabled = self.bookmarkCombo.currentText() != ""
64 if not enabled and self.__emptyRevsOk:
65 enabled = self.limitGroup.isChecked()
66
67 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
68
69 @pyqtSlot(bool)
70 def on_changesetsButton_toggled(self, checked):
71 """
72 Private slot to handle changes of the Changesets select button.
73
74 @param checked state of the button (boolean)
75 """
76 self.__updateOK()
77
78 @pyqtSlot(bool)
79 def on_tagButton_toggled(self, checked):
80 """
81 Private slot to handle changes of the Tag select button.
82
83 @param checked state of the button (boolean)
84 """
85 self.__updateOK()
86
87 @pyqtSlot(bool)
88 def on_branchButton_toggled(self, checked):
89 """
90 Private slot to handle changes of the Branch select button.
91
92 @param checked state of the button (boolean)
93 """
94 self.__updateOK()
95
96 @pyqtSlot(bool)
97 def on_bookmarkButton_toggled(self, checked):
98 """
99 Private slot to handle changes of the Bookmark select button.
100
101 @param checked state of the button (boolean)
102 """
103 self.__updateOK()
104
105 @pyqtSlot()
106 def on_changesetsEdit_textChanged(self):
107 """
108 Private slot to handle changes of the Changesets edit.
109
110 @param txt text of the edit (string)
111 """
112 self.__updateOK()
113
114 @pyqtSlot(str)
115 def on_tagCombo_editTextChanged(self, txt):
116 """
117 Private slot to handle changes of the Tag combo.
118
119 @param txt text of the combo (string)
120 """
121 self.__updateOK()
122
123 @pyqtSlot(str)
124 def on_branchCombo_editTextChanged(self, txt):
125 """
126 Private slot to handle changes of the Branch combo.
127
128 @param txt text of the combo (string)
129 """
130 self.__updateOK()
131
132 @pyqtSlot(str)
133 def on_bookmarkCombo_editTextChanged(self, txt):
134 """
135 Private slot to handle changes of the Bookmark combo.
136
137 @param txt text of the combo (string)
138 """
139 self.__updateOK()
140
141 @pyqtSlot(bool)
142 def on_limitGroup_toggled(self, checked):
143 """
144 Private slot to handle changes of the Limit Results group status.
145
146 @param checked state of the group (boolean)
147 """
148 self.__updateOK()
149
150 def getRevisions(self):
151 """
152 Public method to retrieve the selected revisions.
153
154 @return tuple of selected revisions (list of strings) and number
155 of entries to be shown (integer)
156 """
157 if self.changesetsButton.isChecked():
158 revs = self.changesetsEdit.toPlainText().strip().splitlines()
159 elif self.tagButton.isChecked():
160 revs = [self.tagCombo.currentText()]
161 elif self.branchButton.isChecked():
162 revs = [self.branchCombo.currentText()]
163 elif self.bookmarkButton.isChecked():
164 revs = [self.bookmarkCombo.currentText()]
165 else:
166 revs = []
167
168 if self.limitGroup.isChecked():
169 limit = self.limitSpinBox.value()
170 else:
171 limit = 0
172
173 return revs, limit

eric ide

mercurial