15 |
15 |
16 class HgBookmarkDialog(QDialog, Ui_HgBookmarkDialog): |
16 class HgBookmarkDialog(QDialog, Ui_HgBookmarkDialog): |
17 """ |
17 """ |
18 Class mplementing the bookmark dialog. |
18 Class mplementing the bookmark dialog. |
19 """ |
19 """ |
20 def __init__(self, tagsList, branchesList, bookmarksList, parent=None): |
20 DEFINE_MODE = 0 |
|
21 MOVE_MODE = 1 |
|
22 |
|
23 def __init__(self, mode, tagsList, branchesList, bookmarksList, parent=None): |
21 """ |
24 """ |
22 Constructor |
25 Constructor |
23 |
26 |
|
27 @param mode of the dialog (integer) |
24 @param tagsList list of tags (list of strings) |
28 @param tagsList list of tags (list of strings) |
25 @param branchesList list of branches (list of strings) |
29 @param branchesList list of branches (list of strings) |
26 @param bookmarksList list of bookmarks (list of strings) |
30 @param bookmarksList list of bookmarks (list of strings) |
27 @param parent reference to the parent widget (QWidget) |
31 @param parent reference to the parent widget (QWidget) |
28 """ |
32 """ |
29 QDialog.__init__(self, parent) |
33 QDialog.__init__(self, parent) |
30 self.setupUi(self) |
34 self.setupUi(self) |
31 |
35 |
32 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
36 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
33 |
37 |
|
38 self.__mode = mode |
|
39 if mode == self.MOVE_MODE: |
|
40 self.nameEdit.hide() |
|
41 self.nameCombo.addItems([""] + sorted(bookmarksList)) |
|
42 else: |
|
43 self.nameCombo.hide() |
|
44 |
|
45 self.__bookmarksList = bookmarksList[:] |
|
46 |
34 self.tagCombo.addItems(sorted(tagsList)) |
47 self.tagCombo.addItems(sorted(tagsList)) |
35 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
48 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
36 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
49 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
37 |
50 |
|
51 def __updateOK(self): |
|
52 """ |
|
53 Private slot to update the OK button. |
|
54 """ |
|
55 if self.__mode == self.MOVE_MODE: |
|
56 enabled = self.nameCombo.currentText() != "" |
|
57 else: |
|
58 enabled = self.nameEdit.text() != "" |
|
59 if self.idButton.isChecked(): |
|
60 enabled = enabled and self.idEdit.text() != "" |
|
61 elif self.tagButton.isChecked(): |
|
62 enabled = enabled and self.tagCombo.currentText() != "" |
|
63 elif self.branchButton.isChecked(): |
|
64 enabled = enabled and self.branchCombo.currentText() != "" |
|
65 elif self.bookmarkButton.isChecked(): |
|
66 enabled = enabled and self.bookmarkCombo.currentText() != "" |
|
67 |
|
68 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
|
69 |
|
70 def __updateBookmarksCombo(self): |
|
71 """ |
|
72 Private slot to update the bookmarks combo. |
|
73 """ |
|
74 if self.__mode == self.MOVE_MODE: |
|
75 bookmark = self.nameCombo.currentText() |
|
76 selectedBookmark = self.bookmarkCombo.currentText() |
|
77 self.bookmarkCombo.clearEditText() |
|
78 self.bookmarkCombo.clear() |
|
79 self.bookmarkCombo.addItems(sorted(self.__bookmarksList)) |
|
80 index = self.bookmarkCombo.findText(bookmark) |
|
81 if index > -1: |
|
82 self.bookmarkCombo.removeItem(index) |
|
83 if selectedBookmark: |
|
84 index = self.bookmarkCombo.findText(selectedBookmark) |
|
85 if index > -1: |
|
86 self.bookmarkCombo.setCurrentIndex(index) |
|
87 |
|
88 @pyqtSlot(str) |
|
89 def on_nameCombo_activated(self, txt): |
|
90 """ |
|
91 Private slot to handle changes of the selected bookmark name. |
|
92 """ |
|
93 self.__updateOK() |
|
94 self.__updateBookmarksCombo() |
|
95 |
38 @pyqtSlot(str) |
96 @pyqtSlot(str) |
39 def on_nameEdit_textChanged(self, txt): |
97 def on_nameEdit_textChanged(self, txt): |
40 """ |
98 """ |
41 Private slot to handle changes of the bookmark name. |
99 Private slot to handle changes of the bookmark name. |
42 |
100 |
43 @param txt text of the edit (string) |
101 @param txt text of the edit (string) |
44 """ |
102 """ |
45 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(txt != "") |
103 self.__updateOK() |
|
104 |
|
105 @pyqtSlot(bool) |
|
106 def on_idButton_toggled(self, checked): |
|
107 """ |
|
108 Private slot to handle changes of the ID select button. |
|
109 |
|
110 @param checked state of the button (boolean) |
|
111 """ |
|
112 self.__updateOK() |
|
113 |
|
114 @pyqtSlot(bool) |
|
115 def on_tagButton_toggled(self, checked): |
|
116 """ |
|
117 Private slot to handle changes of the Tag select button. |
|
118 |
|
119 @param checked state of the button (boolean) |
|
120 """ |
|
121 self.__updateOK() |
|
122 |
|
123 @pyqtSlot(bool) |
|
124 def on_branchButton_toggled(self, checked): |
|
125 """ |
|
126 Private slot to handle changes of the Branch select button. |
|
127 |
|
128 @param checked state of the button (boolean) |
|
129 """ |
|
130 self.__updateOK() |
|
131 |
|
132 @pyqtSlot(bool) |
|
133 def on_bookmarkButton_toggled(self, checked): |
|
134 """ |
|
135 Private slot to handle changes of the Bookmark select button. |
|
136 |
|
137 @param checked state of the button (boolean) |
|
138 """ |
|
139 self.__updateOK() |
|
140 |
|
141 @pyqtSlot(str) |
|
142 def on_idEdit_textChanged(self, txt): |
|
143 """ |
|
144 Private slot to handle changes of the ID edit. |
|
145 |
|
146 @param txt text of the edit (string) |
|
147 """ |
|
148 self.__updateOK() |
|
149 |
|
150 @pyqtSlot(str) |
|
151 def on_tagCombo_editTextChanged(self, txt): |
|
152 """ |
|
153 Private slot to handle changes of the Tag combo. |
|
154 |
|
155 @param txt text of the combo (string) |
|
156 """ |
|
157 self.__updateOK() |
|
158 |
|
159 @pyqtSlot(str) |
|
160 def on_branchCombo_editTextChanged(self, txt): |
|
161 """ |
|
162 Private slot to handle changes of the Branch combo. |
|
163 |
|
164 @param txt text of the combo (string) |
|
165 """ |
|
166 self.__updateOK() |
|
167 |
|
168 @pyqtSlot(str) |
|
169 def on_bookmarkCombo_editTextChanged(self, txt): |
|
170 """ |
|
171 Private slot to handle changes of the Bookmark combo. |
|
172 |
|
173 @param txt text of the combo (string) |
|
174 """ |
|
175 self.__updateOK() |
46 |
176 |
47 def getData(self): |
177 def getData(self): |
48 """ |
178 """ |
49 Public method to retrieve the entered data. |
179 Public method to retrieve the entered data. |
50 |
180 |