Helpviewer/Bookmarks/BookmarkPropertiesDialog.py

Sun, 25 Mar 2012 17:53:22 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 25 Mar 2012 17:53:22 +0200
changeset 1736
8b80cd598ebe
child 2302
f29e9405c851
permissions
-rw-r--r--

Added a dialog to edit bookmark properties and the description to the add bookmark dialog (forgot to add the new files).

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
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
3 # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de>
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 from .BookmarkNode import BookmarkNode
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 import Helpviewer.HelpWindow
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
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 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
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 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
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 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
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 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
26
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 @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
28 """
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 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
30 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
31
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 """
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 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
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
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()

eric ide

mercurial