117 @param engine reference to the help engine |
117 @param engine reference to the help engine |
118 @type QHelpEngine |
118 @type QHelpEngine |
119 @param parent reference to the parent object |
119 @param parent reference to the parent object |
120 @type QObject |
120 @type QObject |
121 """ |
121 """ |
122 super(QtHelpSchemeReply, self).__init__(parent) |
122 super().__init__(parent) |
123 |
123 |
124 self.__job = job |
124 self.__job = job |
125 self.__engine = engine |
125 self.__engine = engine |
126 self.__mutex = QMutex() |
126 self.__mutex = QMutex() |
127 |
127 |
134 # For some reason the url to load maybe wrong (passed from web engine) |
134 # For some reason the url to load maybe wrong (passed from web engine) |
135 # though the css file and the references inside should work that way. |
135 # though the css file and the references inside should work that way. |
136 # One possible problem might be that the css is loaded at the same |
136 # One possible problem might be that the css is loaded at the same |
137 # level as the html, thus a path inside the css like |
137 # level as the html, thus a path inside the css like |
138 # (../images/foo.png) might cd out of the virtual folder |
138 # (../images/foo.png) might cd out of the virtual folder |
139 if not self.__engine.findFile(url).isValid(): |
139 if ( |
140 if strUrl.startswith(QtDocPath): |
140 not self.__engine.findFile(url).isValid() and |
141 newUrl = self.__job.requestUrl() |
141 strUrl.startswith(QtDocPath) |
142 if not newUrl.path().startswith("/qdoc/"): |
142 ): |
143 newUrl.setPath("/qdoc" + newUrl.path()) |
143 newUrl = self.__job.requestUrl() |
144 url = newUrl |
144 if not newUrl.path().startswith("/qdoc/"): |
145 strUrl = url.toString() |
145 newUrl.setPath("/qdoc" + newUrl.path()) |
|
146 url = newUrl |
|
147 strUrl = url.toString() |
146 |
148 |
147 self.__mimeType = mimetypes.guess_type(strUrl)[0] |
149 self.__mimeType = mimetypes.guess_type(strUrl)[0] |
148 if self.__mimeType is None: |
150 if self.__mimeType is None: |
149 # do our own (limited) guessing |
151 # do our own (limited) guessing |
150 self.__mimeType = self.__mimeFromUrl(url) |
152 self.__mimeType = self.__mimeFromUrl(url) |
156 Private method to load the requested QtHelp page. |
158 Private method to load the requested QtHelp page. |
157 |
159 |
158 @param url URL of the requested page |
160 @param url URL of the requested page |
159 @type QUrl |
161 @type QUrl |
160 """ |
162 """ |
161 if self.__engine.findFile(url).isValid(): |
163 data = ( |
162 data = self.__engine.fileData(url) |
164 self.__engine.fileData(url) |
163 else: |
165 if self.__engine.findFile(url).isValid() else |
164 data = QByteArray(self.tr( |
166 QByteArray(self.tr( |
165 """<html>""" |
167 """<html>""" |
166 """<head><title>Error 404...</title></head>""" |
168 """<head><title>Error 404...</title></head>""" |
167 """<body><div align="center"><br><br>""" |
169 """<body><div align="center"><br><br>""" |
168 """<h1>The page could not be found</h1><br>""" |
170 """<h1>The page could not be found</h1><br>""" |
169 """<h3>'{0}'</h3></div></body>""" |
171 """<h3>'{0}'</h3></div></body>""" |
170 """</html>""").format(url.toString()) |
172 """</html>""").format(url.toString()) |
171 .encode("utf-8")) |
173 .encode("utf-8")) |
|
174 ) |
172 |
175 |
173 with E5MutexLocker(self.__mutex): |
176 with E5MutexLocker(self.__mutex): |
174 self.__buffer.setData(data) |
177 self.__buffer.setData(data) |
175 self.__buffer.open(QIODevice.OpenModeFlag.ReadOnly) |
178 self.__buffer.open(QIODevice.OpenModeFlag.ReadOnly) |
176 self.open(QIODevice.OpenModeFlag.ReadOnly) |
179 self.open(QIODevice.OpenModeFlag.ReadOnly) |