Helpviewer/Bookmarks/BookmarkPropertiesDialog.py

Wed, 01 Jan 2014 14:38:45 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2014 14:38:45 +0100
changeset 3160
209a07d7e401
parent 3034
7ce719013078
child 3178
f25fc1364c88
permissions
-rw-r--r--

Updated copyright for 2014.

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
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
3 # Copyright (c) 2012 - 2014 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
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
23 @param node reference to the bookmark (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
24 @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
25 """
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 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
27 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
28
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
29 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
30 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
31 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
32 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
33 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
34
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.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
36 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
37 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
38
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 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
40 """
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 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
42 """
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
43 from .BookmarkNode import BookmarkNode
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
44
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
45 if (self.__node.type() == BookmarkNode.Bookmark and
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
46 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
47 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
48 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
49 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
50
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64
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
65 super().accept()

eric ide

mercurial