eric6/WebBrowser/Bookmarks/BookmarkPropertiesDialog.py

Wed, 25 Sep 2019 18:48:22 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 25 Sep 2019 18:48:22 +0200
changeset 7268
a28338eaf694
parent 7229
53054eb5b15a
child 7360
9190402e4505
permissions
-rw-r--r--

Continued to resolve code style issue M841.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2012 - 2019 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
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
10
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
11 from PyQt5.QtWidgets import QDialog
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
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 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
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
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 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
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 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
19 """
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 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
21 """
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 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
23
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2403
diff changeset
24 @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
25 @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
26 """
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
27 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
28 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
29
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
30 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
31 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
32 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
33 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
34 self.addressEdit.hide()
5015
ca1d44f0f6b2 Enhanced the new web browser by adding a visit count to the bookmarks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
35 self.visitedLabel.hide()
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
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)
5015
ca1d44f0f6b2 Enhanced the new web browser by adding a visit count to the bookmarks.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4732
diff changeset
40 self.visitedLabel.setText(self.tr(
5707
1273cd92a8f4 Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
41 "Visited <b>{0}</b> times. Last visit on <b>{1}</b>.").format(
1273cd92a8f4 Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
42 self.__node.visitCount,
1273cd92a8f4 Web Browser (NG):
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
43 self.__node.visited.toString("yyyy-MM-dd hh:mm")))
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
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 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
46 """
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 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
48 """
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
49 from .BookmarkNode import BookmarkNode
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
50
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
51 if (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
52 (self.__node.type() == BookmarkNode.Bookmark and
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
53 not self.addressEdit.text()) or
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
54 not self.nameEdit.text()
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
55 ):
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
56 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
57 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
58
4732
5ac4fc1dfc20 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
59 import WebBrowser.WebBrowserWindow
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
60 bookmarksManager = (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
61 WebBrowser.WebBrowserWindow.WebBrowserWindow.bookmarksManager()
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
62 )
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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74
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
75 super(BookmarkPropertiesDialog, self).accept()

eric ide

mercurial