|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the bookmark dialog. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_HgBookmarkDialog import Ui_HgBookmarkDialog |
|
14 |
|
15 |
|
16 class HgBookmarkDialog(QDialog, Ui_HgBookmarkDialog): |
|
17 """ |
|
18 Class mplementing the bookmark dialog. |
|
19 """ |
|
20 def __init__(self, tagsList, branchesList, bookmarksList, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param tagsList list of tags (list of strings) |
|
25 @param branchesList list of branches (list of strings) |
|
26 @param bookmarksList list of bookmarks (list of strings) |
|
27 @param parent reference to the parent widget (QWidget) |
|
28 """ |
|
29 QDialog.__init__(self, parent) |
|
30 self.setupUi(self) |
|
31 |
|
32 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
33 |
|
34 self.tagCombo.addItems(sorted(tagsList)) |
|
35 self.branchCombo.addItems(["default"] + sorted(branchesList)) |
|
36 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
|
37 |
|
38 @pyqtSlot(str) |
|
39 def on_nameEdit_textChanged(self, txt): |
|
40 """ |
|
41 Private slot to handle changes of the bookmark name. |
|
42 |
|
43 @param txt text of the edit (string) |
|
44 """ |
|
45 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(txt != "") |
|
46 |
|
47 def getData(self): |
|
48 """ |
|
49 Public method to retrieve the entered data. |
|
50 |
|
51 @return tuple naming the revision and the bookmark name |
|
52 (string, string) |
|
53 """ |
|
54 if self.numberButton.isChecked(): |
|
55 rev = str(self.numberSpinBox.value()) |
|
56 elif self.idButton.isChecked(): |
|
57 rev = self.idEdit.text() |
|
58 elif self.tagButton.isChecked(): |
|
59 rev = self.tagCombo.currentText() |
|
60 elif self.branchButton.isChecked(): |
|
61 rev = self.branchCombo.currentText() |
|
62 elif self.bookmarkButton.isChecked(): |
|
63 rev = self.bookmarkCombo.currentText() |
|
64 else: |
|
65 rev = "" |
|
66 |
|
67 return rev, self.nameEdit.text() |