Helpviewer/Bookmarks/BookmarkPropertiesDialog.py

Sat, 14 Dec 2013 23:44:25 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 14 Dec 2013 23:44:25 +0100
branch
Py2 comp.
changeset 3145
a9de05d4a22f
parent 3060
5883ce99ee12
child 3161
06f57a834adf
permissions
-rw-r--r--

# __IGNORE_WARNING__ added/ removed.

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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2403
diff changeset
11
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
12 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
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 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
15
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 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
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 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
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 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
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 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
24
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
25 @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
26 @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
27 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2403
diff changeset
28 super(BookmarkPropertiesDialog, self).__init__(parent)
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.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
30
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
31 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
32 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
33 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
34 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
35 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
36
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.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
38 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
39 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
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 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
42 """
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
43 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
44 """
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
45 from .BookmarkNode import BookmarkNode
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
46
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2954
diff changeset
47 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
48 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
49 not self.nameEdit.text():
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2403
diff changeset
50 super(BookmarkPropertiesDialog, self).accept()
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 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
52
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2403
diff changeset
67 super(BookmarkPropertiesDialog, self).accept()

eric ide

mercurial