Helpviewer/SiteInfo/SiteInfoDialog.py

Fri, 11 May 2012 18:48:10 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 11 May 2012 18:48:10 +0200
changeset 1857
baf039cc2d9a
parent 1780
f42757fd021b
child 2078
9f4a45741622
permissions
-rw-r--r--

Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.

1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
1509
c0b5e693b0eb Updated copyright for 2012.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1474
diff changeset
3 # Copyright (c) 2011 - 2012 Detlev Offenbach <detlev@die-offenbachs.de>
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show some information about a site.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QFile
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from PyQt4.QtGui import QDialog, QTreeWidgetItem, QPixmap, QGraphicsScene, QMenu, \
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
14 QCursor, QApplication, QListWidgetItem
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from PyQt4.QtWebKit import QWebSettings
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from E5Gui import E5MessageBox, E5FileDialog
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
1857
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
19 try:
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
20 from .Ui_SiteInfoDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
21 SSL = True
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
22 except ImportError:
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
23 from .Ui_SiteInfoNoSslDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
24 SSL = False
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from ..Download.DownloadUtilities import dataString
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import Helpviewer.HelpWindow
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import UI.PixmapCache
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 class SiteInfoDialog(QDialog, Ui_SiteInfoDialog):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 Class implementing a dialog to show some information about a site.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 okStyle = "QLabel { color : white; background-color : green; }"
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 nokStyle = "QLabel { color : white; background-color : red; }"
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 def __init__(self, browser, parent=None):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Constructor
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @param browser reference to the browser window (HelpBrowser)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @param parent reference to the parent widget (QWidget)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 super().__init__(parent)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.setupUi(self)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 # put icons
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 self.tabWidget.setTabIcon(0, UI.PixmapCache.getIcon("siteinfo-general.png"))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.tabWidget.setTabIcon(1, UI.PixmapCache.getIcon("siteinfo-media.png"))
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
53 self.tabWidget.setTabIcon(2, UI.PixmapCache.getIcon("siteinfo-databases.png"))
1857
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
54 if SSL:
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
55 self.tabWidget.setTabIcon(3, UI.PixmapCache.getIcon("siteinfo-security.png"))
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
57 self.__mainFrame = browser.page().mainFrame()
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 title = browser.title()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 sslInfo = browser.page().getSslInfo()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 # populate General tab
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.heading.setText("<b>{0}</b>".format(title))
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
63 self.siteAddressLabel.setText(self.__mainFrame.baseUrl().toString())
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.sizeLabel.setText(dataString(browser.page().totalBytes()))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 encoding = ""
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 # populate Meta tags
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
68 meta = self.__mainFrame.findAllElements("meta")
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 for element in meta:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 content = element.attribute("content")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 name = element.attribute("name")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 if not name:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 name = element.attribute("http-equiv")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 if element.attribute("charset"):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 encoding = element.attribute("charset")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if "charset=" in content:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 encoding = content[content.index("charset=") + 8:]
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 if not content or not name:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 continue
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 QTreeWidgetItem(self.tagsTree, [name, content])
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 for col in range(self.tagsTree.columnCount()):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.tagsTree.resizeColumnToContents(col)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 if not encoding:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 encoding = QWebSettings.globalSettings().defaultTextEncoding()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.encodingLabel.setText(encoding)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 # populate the Security info and the Security tab
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 if sslInfo is not None and sslInfo.isValid():
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.securityLabel.setStyleSheet(SiteInfoDialog.okStyle)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.securityLabel.setText('<b>Connection is encrypted.</b>')
1857
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
94 if SSL:
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
95 self.sslWidget.showCertificate(sslInfo)
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
96 self.securityDetailsButton.setEnabled(True)
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
97 else:
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
98 self.securityDetailsButton.setEnabled(False)
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.securityLabel.setText('<b>Connection is not encrypted.</b>')
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.securityDetailsButton.setEnabled(False)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 # populate Media tab
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
105 images = self.__mainFrame.findAllElements("img")
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 for element in images:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 src = element.attribute("src")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 alt = element.attribute("alt")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 if src and src.startswith("data:"):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 continue
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 if not alt:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 if src.find("/") == -1:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 alt = src
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 pos = src.find("/")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 alt = src[pos + 1:]
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 if not src or not alt:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 continue
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 QTreeWidgetItem(self.imagesTree, [alt, src])
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 for col in range(self.imagesTree.columnCount()):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 self.imagesTree.resizeColumnToContents(col)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 if self.imagesTree.columnWidth(0) > 300:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.imagesTree.setColumnWidth(0, 300)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.imagesTree.setCurrentItem(self.imagesTree.topLevelItem(0))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.imagesTree.setContextMenuPolicy(Qt.CustomContextMenu)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.imagesTree.customContextMenuRequested.connect(
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.__imagesTreeContextMenuRequested)
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
130
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
131 # populate the Databases tab
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
132 databases = self.__mainFrame.securityOrigin().databases()
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
133 counter = 0
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
134 for database in databases:
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
135 itm = QListWidgetItem(self.databasesList)
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
136 itm.setText(database.displayName())
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
137 itm.setData(Qt.UserRole, counter)
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
138 counter += 1
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
139
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
140 if counter == 0:
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
141 itm = QListWidgetItem(self.databasesList)
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
142 itm.setText(self.trUtf8("No databases are used by this page."))
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
143 itm.setFlags(itm.flags() & Qt.ItemIsSelectable)
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 @pyqtSlot()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 def on_securityDetailsButton_clicked(self):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 Private slot to show security details.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.tabWidget.setCurrentIndex(2)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 def on_imagesTree_currentItemChanged(self, current, previous):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 Private slot to show a preview of the selected image.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 @param current current image entry (QTreeWidgetItem)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 @param previous old current entry (QTreeWidgetItem)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 if current is None:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 imageUrl = QUrl(current.text(1))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 if not imageUrl.host():
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 imageUrl.setHost(QUrl(self.siteAddressLabel.text()).host())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 imageUrl.setScheme(QUrl(self.siteAddressLabel.text()).scheme())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache()
1433
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
169 if cache:
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
170 cacheData = cache.data(imageUrl)
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
171 else:
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
172 cacheData = None
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 pixmap = QPixmap()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 invalidPixmap = False
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 scene = QGraphicsScene(self.imagePreview)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 if not cacheData:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 invalidPixmap = True
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 pixmap.loadFromData(cacheData.readAll())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 if pixmap.isNull():
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 invalidPixmap = True
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 if invalidPixmap:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 scene.addText(self.trUtf8("Preview not available."))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 scene.addPixmap(pixmap)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 self.imagePreview.setScene(scene)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 def __imagesTreeContextMenuRequested(self, pos):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 Private slot to show a context menu for the images list.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 @param pos position for the menu (QPoint)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 itm = self.imagesTree.itemAt(pos)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 if itm is None:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 menu = QMenu()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 act = menu.addAction(self.trUtf8("Copy Image Location to Clipboard"),
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 self.__copyAction)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 act.setData(itm.text(1))
1474
1eaec11a0078 Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1433
diff changeset
202 act = menu.addAction(self.trUtf8("Copy Image Name to Clipboard"),
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 self.__copyAction)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 act.setData(itm.text(0))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 menu.addSeparator()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 act = menu.addAction(self.trUtf8("Save Image"), self.__saveImage)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 act.setData(self.imagesTree.indexOfTopLevelItem(itm))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 menu.exec_(QCursor.pos())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def __copyAction(self):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Private slot to copy the image URL or the image name to the clipboard.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 act = self.sender()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 QApplication.clipboard().setText(act.data())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 def __saveImage(self):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 Private slot to save the selected image to disk.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 act = self.sender()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 index = act.data()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 itm = self.imagesTree.topLevelItem(index)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 if itm is None:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 imageUrl = QUrl(itm.text(1))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 if not imageUrl.host():
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 imageUrl.setHost(QUrl(self.siteAddressLabel.text()).host())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 imageUrl.setScheme(QUrl(self.siteAddressLabel.text()).scheme())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache()
1433
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
233 if cache:
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
234 cacheData = cache.data(imageUrl)
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
235 else:
cb6507f68b16 Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1427
diff changeset
236 cacheData = None
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 if not cacheData:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 E5MessageBox.critical(self,
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 self.trUtf8("Save Image"),
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 self.trUtf8("""This image is not available."""))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 downloadDirectory = Helpviewer.HelpWindow.HelpWindow\
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 .downloadManager().downloadDirectory()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 fn = os.path.join(downloadDirectory, os.path.basename(itm.text(1)))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 filename = E5FileDialog.getSaveFileName(
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 self,
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.trUtf8("Save Image"),
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 fn,
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 self.trUtf8("All Files (*)"),
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
251 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 if not filename:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 f = QFile(filename)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 if not f.open(QFile.WriteOnly):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 E5MessageBox.critical(self,
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 self.trUtf8("Save Image"),
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 self.trUtf8(
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 """<p>Cannot write to file <b>{0}</b>.</p>""".format(filename)))
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 f.write(cacheData.readAll())
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 f.close()
1780
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
265
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
266 @pyqtSlot(QListWidgetItem, QListWidgetItem)
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
267 def on_databasesList_currentItemChanged(self, current, previous):
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
268 """
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
269 Private slot to show data about the selected database.
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
270
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
271 @param current current database entry (QTreeWidgetItem)
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
272 @param previous old current entry (QTreeWidgetItem)
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
273 """
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
274 if current is None:
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
275 return
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
276
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
277 id = current.data(Qt.UserRole)
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
278 databases = self.__mainFrame.securityOrigin().databases()
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
279
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
280 if id >= len(databases):
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
281 return
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
282
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
283 db = databases[id]
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
284 self.databaseName.setText("{0} ({1})".format(db.displayName(), db.name()))
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
285 self.databasePath.setText(db.fileName())
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
286 self.databaseSize.setText(dataString(db.size()))

eric ide

mercurial