5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to select a revision. |
7 Module implementing a dialog to select a revision. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt4.QtGui import QDialog |
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog, QDialogButtonBox |
11 |
12 |
12 from .Ui_HgRevisionSelectionDialog import Ui_HgRevisionSelectionDialog |
13 from .Ui_HgRevisionSelectionDialog import Ui_HgRevisionSelectionDialog |
13 |
14 |
14 |
15 |
15 class HgRevisionSelectionDialog(QDialog, Ui_HgRevisionSelectionDialog): |
16 class HgRevisionSelectionDialog(QDialog, Ui_HgRevisionSelectionDialog): |
16 """ |
17 """ |
17 Class implementing a dialog to select a revision. |
18 Class implementing a dialog to select a revision. |
18 """ |
19 """ |
19 def __init__(self, tagsList, branchesList, showNone=False, parent=None): |
20 def __init__(self, tagsList, branchesList, bookmarksList=None, showNone=False, |
|
21 parent=None): |
20 """ |
22 """ |
21 Constructor |
23 Constructor |
22 |
24 |
23 @param tagsList list of tags (list of strings) |
25 @param tagsList list of tags (list of strings) |
24 @param branchesList list of branches (list of strings) |
26 @param branchesList list of branches (list of strings) |
|
27 @param bookmarksList list of bookmarks (list of strings) |
25 @param showNone flag influencing the label of the 'None' selection (boolean) |
28 @param showNone flag influencing the label of the 'None' selection (boolean) |
26 @param parent parent widget (QWidget) |
29 @param parent parent widget (QWidget) |
27 """ |
30 """ |
28 QDialog.__init__(self, parent) |
31 QDialog.__init__(self, parent) |
29 self.setupUi(self) |
32 self.setupUi(self) |
30 |
33 |
|
34 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
35 |
31 self.tagCombo.addItems(sorted(tagsList)) |
36 self.tagCombo.addItems(sorted(tagsList)) |
32 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
37 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
|
38 if bookmarksList is not None: |
|
39 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
|
40 else: |
|
41 self.bookmarkButton.setHidden(True) |
|
42 self.bookmarkCombo.setHidden(True) |
33 |
43 |
34 if showNone: |
44 if showNone: |
35 self.tipButton.setText(self.trUtf8("No revision selected")) |
45 self.tipButton.setText(self.trUtf8("No revision selected")) |
36 self.tipButton.setToolTip(self.trUtf8( |
46 self.tipButton.setToolTip(self.trUtf8( |
37 "Select to not specify a specific revision")) |
47 "Select to not specify a specific revision")) |
|
48 |
|
49 def __updateOK(self): |
|
50 """ |
|
51 Private slot to update the OK button. |
|
52 """ |
|
53 enabled = True |
|
54 if self.idButton.isChecked(): |
|
55 enabled = self.idEdit.text() != "" |
|
56 elif self.tagButton.isChecked(): |
|
57 enabled = self.tagCombo.currentText() != "" |
|
58 elif self.branchButton.isChecked(): |
|
59 enabled = self.branchCombo.currentText() != "" |
|
60 elif self.bookmarkButton.isChecked(): |
|
61 enabled = self.bookmarkCombo.currentText() != "" |
|
62 |
|
63 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
|
64 |
|
65 @pyqtSlot(bool) |
|
66 def on_idButton_toggled(self, checked): |
|
67 """ |
|
68 Private slot to handle changes of the ID select button. |
|
69 |
|
70 @param checked state of the button (boolean) |
|
71 """ |
|
72 self.__updateOK() |
|
73 |
|
74 @pyqtSlot(bool) |
|
75 def on_tagButton_toggled(self, checked): |
|
76 """ |
|
77 Private slot to handle changes of the Tag select button. |
|
78 |
|
79 @param checked state of the button (boolean) |
|
80 """ |
|
81 self.__updateOK() |
|
82 |
|
83 @pyqtSlot(bool) |
|
84 def on_branchButton_toggled(self, checked): |
|
85 """ |
|
86 Private slot to handle changes of the Branch select button. |
|
87 |
|
88 @param checked state of the button (boolean) |
|
89 """ |
|
90 self.__updateOK() |
|
91 |
|
92 @pyqtSlot(bool) |
|
93 def on_bookmarkButton_toggled(self, checked): |
|
94 """ |
|
95 Private slot to handle changes of the Bookmark select button. |
|
96 |
|
97 @param checked state of the button (boolean) |
|
98 """ |
|
99 self.__updateOK() |
|
100 |
|
101 @pyqtSlot(str) |
|
102 def on_idEdit_textChanged(self, txt): |
|
103 """ |
|
104 Private slot to handle changes of the ID edit. |
|
105 |
|
106 @param txt text of the edit (string) |
|
107 """ |
|
108 self.__updateOK() |
|
109 |
|
110 @pyqtSlot(str) |
|
111 def on_tagCombo_editTextChanged(self, txt): |
|
112 """ |
|
113 Private slot to handle changes of the Tag combo. |
|
114 |
|
115 @param txt text of the combo (string) |
|
116 """ |
|
117 self.__updateOK() |
|
118 |
|
119 @pyqtSlot(str) |
|
120 def on_branchCombo_editTextChanged(self, txt): |
|
121 """ |
|
122 Private slot to handle changes of the Branch combo. |
|
123 |
|
124 @param txt text of the combo (string) |
|
125 """ |
|
126 self.__updateOK() |
|
127 |
|
128 @pyqtSlot(str) |
|
129 def on_bookmarkCombo_editTextChanged(self, txt): |
|
130 """ |
|
131 Private slot to handle changes of the Bookmark combo. |
|
132 |
|
133 @param txt text of the combo (string) |
|
134 """ |
|
135 self.__updateOK() |
38 |
136 |
39 def getRevision(self): |
137 def getRevision(self): |
40 """ |
138 """ |
41 Public method to retrieve the selected revision. |
139 Public method to retrieve the selected revision. |
42 |
140 |