eric6/WebBrowser/QtHelp/HelpDocsInstaller.py

Tue, 10 Sep 2019 19:30:07 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Sep 2019 19:30:07 +0200
changeset 7229
53054eb5b15a
parent 7195
6b53960ff598
child 7269
0c63ea7f94bd
permissions
-rw-r--r--

Removed obsolete "from __future__ import ..." statements.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6143
diff changeset
3 # Copyright (c) 2009 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a thread class populating and updating the QtHelp
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 documentation database.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
4622
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
12 import os
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
13
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
14 from PyQt5.QtCore import pyqtSignal, QThread, Qt, QMutex, QDateTime, QDir, \
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
15 QLibraryInfo, QFileInfo
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
16 from PyQt5.QtHelp import QHelpEngineCore
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
18 from eric6config import getConfig
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
20 from Globals import qVersionTuple
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
21
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
22
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 class HelpDocsInstaller(QThread):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 Class implementing the worker thread populating and updating the QtHelp
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 documentation database.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 487
diff changeset
28 @signal errorMessage(str) emitted, if an error occurred during
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 the installation of the documentation
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @signal docsInstalled(bool) emitted after the installation has finished
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
32 errorMessage = pyqtSignal(str)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
33 docsInstalled = pyqtSignal(bool)
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
34
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 def __init__(self, collection):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param collection full pathname of the collection file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
41 super(HelpDocsInstaller, self).__init__()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.__abort = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__collection = collection
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__mutex = QMutex()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def stop(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Public slot to stop the installation procedure.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 if not self.isRunning():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__mutex.lock()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.__abort = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.__mutex.unlock()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.wait()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def installDocs(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 Public method to start the installation procedure.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.start(QThread.LowPriority)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 def run(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
67 Public method executed by the thread.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 engine = QHelpEngineCore(self.__collection)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 changes = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
72 qt4Docs = ["designer", "linguist", "qt"]
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
73 qt5Docs = [
4622
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
74 "activeqt", "qdoc", "qmake", "qt3d", "qt3drenderer",
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
75 "qtandroidextras", "qtassistant", "qtbluetooth", "qtcanvas3d",
7195
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
76 "qtcharts", "qtconcurrent", "qtcore", "qtdatavisualization",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
77 "qtdbus", "qtdesigner", "qtdistancefieldgenerator", "qtdoc",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
78 "qtenginio", "qtenginiooverview", "qtenginoqml", "qtgamepad",
4622
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
79 "qtgraphicaleffects", "qtgui", "qthelp", "qtimageformats",
7195
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
80 "qtlabscalendar", "qtlabsplatform", "qtlabscontrols", "qtlinguist",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
81 "qtlocation", "qtlottieanimation", "qtmaxextras", "qtmultimedia",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
82 "qtmultimediawidgets", "qtnetwork", "qtnetworkauth", "qtnfc",
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
83 "qtopengl", "qtplatformheaders", "qtpositioning", "qtprintsupport",
7195
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
84 "qtpurchasing", "qtqml", "qtqmltest", "qtquick", "qtquickcontrols",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
85 "qtquickcontrols1", "qtquickdialogs", "qtquickextras",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
86 "qtquicklayouts", "qtremoteobjects", "qtscript", "qtscripttools",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
87 "qtscxml", "qtsensors", "qtserialbus", "qtserialport", "qtspeech",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
88 "qtsql", "qtsvg", "qttest", "qttestlib", "qtuitools",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
89 "qtvirtualkeyboard", "qtwaylandcompositor", "qtwebchannel",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
90 "qtwebengine", "qtwebenginewidgets", "qtwebkit",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
91 "qtwebkitexamples", "qtwebsockets", "qtwebview", "qtwidgets",
6b53960ff598 HelpDocsInstaller: updated the list of potential QtHelp files to be imported into the documentation database.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
92 "qtwinextras", "qtx11extras", "qtxml", "qtxmlpatterns"]
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
93 for qtDocs, version in [(qt4Docs, 4), (qt5Docs, 5)]:
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
94 for doc in qtDocs:
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
95 changes |= self.__installQtDoc(doc, version, engine)
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
96 self.__mutex.lock()
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
97 if self.__abort:
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
98 engine = None
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
99 self.__mutex.unlock()
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
100 return
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__mutex.unlock()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
103 changes |= self.__installEric6Doc(engine)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 engine = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 del engine
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
106 self.docsInstalled.emit(changes)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
108 def __installQtDoc(self, name, version, engine):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 Private method to install/update a Qt help document.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 @param name name of the Qt help document (string)
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
113 @param version Qt version of the help documens (integer)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @param engine reference to the help engine (QHelpEngineCore)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @return flag indicating success (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
117 versionKey = "qt_version_{0}@@{1}".format(version, name)
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
118 info = engine.customValue(versionKey, "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 lst = info.split('|')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 dt = QDateTime()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 if len(lst) and lst[0]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 dt = QDateTime.fromString(lst[0], Qt.ISODate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 qchFile = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 if len(lst) == 2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 qchFile = lst[1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
129 if version == 4:
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
130 docsPath = QDir(
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
131 QLibraryInfo.location(QLibraryInfo.DocumentationPath) +
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
132 QDir.separator() + "qch")
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
133 elif version == 5:
4622
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
134 docsPath = QLibraryInfo.location(QLibraryInfo.DocumentationPath)
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
135 if not os.path.isdir(docsPath) or \
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
136 len(QDir(docsPath).entryList(["*.qch"])) == 0:
4622
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
137 # Qt installer is a bit buggy; it's missing a symbolic link
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
138 docsPathList = QDir.fromNativeSeparators(docsPath).split("/")
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
139 docsPath = os.sep.join(
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
140 docsPathList[:-3] +
5736
000ea446ff4b Prepared the code for Qt > 5.9.99.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
141 ["Docs", "Qt-{0}.{1}".format(*qVersionTuple())])
4622
8800cbcbb496 Fix for detection of Qt documentation files (*.qch). The Qt installer is missing a symbolic link.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
142 docsPath = QDir(docsPath)
2298
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
143 else:
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
144 # unsupported Qt version
fa4f79c34e0c Added support for Qt5 documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
145 return False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 files = docsPath.entryList(["*.qch"])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 if not files:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
149 engine.setCustomValue(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
150 versionKey,
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
151 QDateTime().toString(Qt.ISODate) + '|')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 for f in files:
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
155 if f.startswith(name + "."):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f)
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
157 namespace = QHelpEngineCore.namespaceName(
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
158 fi.absoluteFilePath())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 if not namespace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 if dt.isValid() and \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 namespace in engine.registeredDocumentations() and \
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
164 fi.lastModified().toString(Qt.ISODate) == \
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
165 dt.toString(Qt.ISODate) and \
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 qchFile == fi.absoluteFilePath():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 if namespace in engine.registeredDocumentations():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 engine.unregisterDocumentation(namespace)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 if not engine.registerDocumentation(fi.absoluteFilePath()):
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
173 self.errorMessage.emit(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
174 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
175 """<p>The file <b>{0}</b> could not be"""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
176 """ registered. <br/>Reason: {1}</p>""")
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
177 .format(fi.absoluteFilePath, engine.error())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
181 engine.setCustomValue(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
182 versionKey,
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
183 fi.lastModified().toString(Qt.ISODate) + '|' +
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
184 fi.absoluteFilePath())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
189 def __installEric6Doc(self, engine):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
191 Private method to install/update the eric6 help documentation.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 @param engine reference to the help engine (QHelpEngineCore)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @return flag indicating success (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
196 versionKey = "eric6_ide"
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
197 info = engine.customValue(versionKey, "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 lst = info.split('|')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 dt = QDateTime()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 if len(lst) and lst[0]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 dt = QDateTime.fromString(lst[0], Qt.ISODate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 qchFile = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 if len(lst) == 2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 qchFile = lst[1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 docsPath = QDir(getConfig("ericDocDir") + QDir.separator() + "Help")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 files = docsPath.entryList(["*.qch"])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 if not files:
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
212 engine.setCustomValue(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
213 versionKey, QDateTime().toString(Qt.ISODate) + '|')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 for f in files:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 if f == "source.qch":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f)
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
219 namespace = QHelpEngineCore.namespaceName(
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
220 fi.absoluteFilePath())
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
221 if not namespace:
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
222 continue
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
223
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 if dt.isValid() and \
4875
4ee26909ac0d Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
225 namespace in engine.registeredDocumentations() and \
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
226 fi.lastModified().toString(Qt.ISODate) == \
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
227 dt.toString(Qt.ISODate) and \
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 qchFile == fi.absoluteFilePath():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 if namespace in engine.registeredDocumentations():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 engine.unregisterDocumentation(namespace)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 if not engine.registerDocumentation(fi.absoluteFilePath()):
487
4d41d03d3d00 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 168
diff changeset
235 self.errorMessage.emit(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
236 self.tr(
2999
28c75409a78f Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
237 """<p>The file <b>{0}</b> could not be"""
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
238 """ registered. <br/>Reason: {1}</p>""")
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
239 .format(fi.absoluteFilePath, engine.error())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 return False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
243 engine.setCustomValue(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2999
diff changeset
244 versionKey,
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
245 fi.lastModified().toString(Qt.ISODate) + '|' +
7
c679fb30c8f3 Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
246 fi.absoluteFilePath())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248
168
3383117f894b Fixed a few bugs in the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
249 return False

eric ide

mercurial