|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to get the data to rename a bookmark. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog, QDialogButtonBox |
|
12 |
|
13 from .Ui_HgBookmarkRenameDialog import Ui_HgBookmarkRenameDialog |
|
14 |
|
15 |
|
16 class HgBookmarkRenameDialog(QDialog, Ui_HgBookmarkRenameDialog): |
|
17 """ |
|
18 Class implementing a dialog to get the data to rename a bookmark. |
|
19 """ |
|
20 def __init__(self, bookmarksList, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param bookmarksList list of bookmarks (list of strings) |
|
25 @param parent reference to the parent widget (QWidget) |
|
26 """ |
|
27 QDialog.__init__(self, parent) |
|
28 self.setupUi(self) |
|
29 |
|
30 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False) |
|
31 |
|
32 self.bookmarkCombo.addItems(sorted(bookmarksList)) |
|
33 |
|
34 def __updateUI(self): |
|
35 """ |
|
36 Private slot to update the UI. |
|
37 """ |
|
38 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
|
39 self.nameEdit.text() != "" and \ |
|
40 self.bookmarkCombo.currentText() != "" |
|
41 ) |
|
42 |
|
43 @pyqtSlot(str) |
|
44 def on_nameEdit_textChanged(self, txt): |
|
45 """ |
|
46 Private slot to handle changes of the bookmark name. |
|
47 |
|
48 @param txt text of the edit (string) |
|
49 """ |
|
50 self.__updateUI() |
|
51 |
|
52 @pyqtSlot(str) |
|
53 def on_bookmarkCombo_editTextChanged(self, txt): |
|
54 """ |
|
55 Private slot to handle changes of the selected bookmark. |
|
56 |
|
57 @param txt name of the selected bookmark (string) |
|
58 """ |
|
59 self.__updateUI() |
|
60 |
|
61 def getData(self): |
|
62 """ |
|
63 Public method to retrieve the entered data. |
|
64 |
|
65 @return tuple naming the new and old bookmark names |
|
66 (string, string) |
|
67 """ |
|
68 return self.nameEdit.text(), self.bookmarkCombo.currentText() |