Helpviewer/HelpDocsInstaller.py

changeset 2298
fa4f79c34e0c
parent 1509
c0b5e693b0eb
child 2302
f29e9405c851
equal deleted inserted replaced
2297:e8a46f81517c 2298:fa4f79c34e0c
6 """ 6 """
7 Module implementing a thread class populating and updating the QtHelp 7 Module implementing a thread class populating and updating the QtHelp
8 documentation database. 8 documentation database.
9 """ 9 """
10 10
11 from PyQt4.QtCore import pyqtSignal, QThread, qVersion, Qt, QMutex, QDateTime, QDir, \ 11 from PyQt4.QtCore import pyqtSignal, QThread, Qt, QMutex, QDateTime, QDir, \
12 QLibraryInfo, QFileInfo 12 QLibraryInfo, QFileInfo
13 from PyQt4.QtHelp import QHelpEngineCore 13 from PyQt4.QtHelp import QHelpEngineCore
14 14
15 from eric5config import getConfig 15 from eric5config import getConfig
16 16
63 """ 63 """
64 engine = QHelpEngineCore(self.__collection) 64 engine = QHelpEngineCore(self.__collection)
65 engine.setupData() 65 engine.setupData()
66 changes = False 66 changes = False
67 67
68 qtDocs = ["designer", "linguist", "qt"] 68 qt4Docs = ["designer", "linguist", "qt"]
69 for doc in qtDocs: 69 qt5Docs = ["activeqt", "qtconcurrent", "qtcore", "qtdbus", "qtdesigner", "qtdoc",
70 changes |= self.__installQtDoc(doc, engine) 70 "qtgraphicaleffects", "qtgui", "qthelp", "qtimageformats", "qtlinguist",
71 self.__mutex.lock() 71 "qtmultimedia", "qtnetwork", "qtopengl", "qtprintsupport", "qtqml", "qtquick",
72 if self.__abort: 72 "qtscript", "qtsql", "qtsvg", "qttestlib", "qtuitools", "qtwebkit",
73 engine = None 73 "qtwebkitexamples", "qtwidgets", "qtxml", "qtxmlpatterns"]
74 for qtDocs, version in [(qt4Docs, 4), (qt5Docs, 5)]:
75 for doc in qtDocs:
76 changes |= self.__installQtDoc(doc, version, engine)
77 self.__mutex.lock()
78 if self.__abort:
79 engine = None
80 self.__mutex.unlock()
81 return
74 self.__mutex.unlock() 82 self.__mutex.unlock()
75 return
76 self.__mutex.unlock()
77 83
78 changes |= self.__installEric5Doc(engine) 84 changes |= self.__installEric5Doc(engine)
79 engine = None 85 engine = None
80 del engine 86 del engine
81 self.docsInstalled.emit(changes) 87 self.docsInstalled.emit(changes)
82 88
83 def __installQtDoc(self, name, engine): 89 def __installQtDoc(self, name, version, engine):
84 """ 90 """
85 Private method to install/update a Qt help document. 91 Private method to install/update a Qt help document.
86 92
87 @param name name of the Qt help document (string) 93 @param name name of the Qt help document (string)
94 @param version Qt version of the help documens (integer)
88 @param engine reference to the help engine (QHelpEngineCore) 95 @param engine reference to the help engine (QHelpEngineCore)
89 @return flag indicating success (boolean) 96 @return flag indicating success (boolean)
90 """ 97 """
91 versionKey = "qt_version_{0}@@{1}".format(qVersion(), name) 98 versionKey = "qt_version_{0}@@{1}".format(version, name)
92 info = engine.customValue(versionKey, "") 99 info = engine.customValue(versionKey, "")
93 lst = info.split('|') 100 lst = info.split('|')
94 101
95 dt = QDateTime() 102 dt = QDateTime()
96 if len(lst) and lst[0]: 103 if len(lst) and lst[0]:
98 105
99 qchFile = "" 106 qchFile = ""
100 if len(lst) == 2: 107 if len(lst) == 2:
101 qchFile = lst[1] 108 qchFile = lst[1]
102 109
103 docsPath = QDir(QLibraryInfo.location(QLibraryInfo.DocumentationPath) + \ 110 if version == 4:
104 QDir.separator() + "qch") 111 docsPath = QDir(QLibraryInfo.location(QLibraryInfo.DocumentationPath) + \
112 QDir.separator() + "qch")
113 elif version == 5:
114 docsPath = QDir(QLibraryInfo.location(QLibraryInfo.DocumentationPath))
115 else:
116 # unsupported Qt version
117 return False
105 118
106 files = docsPath.entryList(["*.qch"]) 119 files = docsPath.entryList(["*.qch"])
107 if not files: 120 if not files:
108 engine.setCustomValue(versionKey, 121 engine.setCustomValue(versionKey,
109 QDateTime().toString(Qt.ISODate) + '|') 122 QDateTime().toString(Qt.ISODate) + '|')

eric ide

mercurial