Sun, 10 Feb 2013 18:31:31 +0100
Continued implementing the delayed import.
1736
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
2302
f29e9405c851
Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1736
diff
changeset
|
3 | # Copyright (c) 2012 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> |
1736
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to show and edit bookmark properties. |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from PyQt4.QtGui import QDialog |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | from .Ui_BookmarkPropertiesDialog import Ui_BookmarkPropertiesDialog |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | class BookmarkPropertiesDialog(QDialog, Ui_BookmarkPropertiesDialog): |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | """ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | Class implementing a dialog to show and edit bookmark properties. |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | def __init__(self, node, parent=None): |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | Constructor |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | @param parent reference to the parent widget (QWidget) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | super().__init__(parent) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | self.setupUi(self) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
28 | from .BookmarkNode import BookmarkNode |
1736
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | self.__node = node |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | if self.__node.type() == BookmarkNode.Folder: |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | self.addressLabel.hide() |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.addressEdit.hide() |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | self.nameEdit.setText(self.__node.title) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | self.descriptionEdit.setPlainText(self.__node.desc) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | self.addressEdit.setText(self.__node.url) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | def accept(self): |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | """ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | Public slot handling the acceptance of the dialog. |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | """ |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
42 | from .BookmarkNode import BookmarkNode |
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
43 | |
1736
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | if (self.__node.type() == BookmarkNode.Bookmark and \ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | not self.addressEdit.text()) or \ |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | not self.nameEdit.text(): |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | super().accept() |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | return |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
50 | import Helpviewer.HelpWindow |
1736
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | bookmarksManager = Helpviewer.HelpWindow.HelpWindow.bookmarksManager() |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | title = self.nameEdit.text() |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | if title != self.__node.title: |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | bookmarksManager.setTitle(self.__node, title) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | if self.__node.type() == BookmarkNode.Bookmark: |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | url = self.addressEdit.text() |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | if url != self.__node.url: |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | bookmarksManager.setUrl(self.__node, url) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | description = self.descriptionEdit.toPlainText() |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | if description != self.__node.desc: |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | self.__node.desc = description |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | bookmarksManager.setNodeChanged(self.__node) |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | |
8b80cd598ebe
Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | super().accept() |