Merge lp:~mrqtros/ubuntu-docviewer-app/reboot-qsg-impress-support into lp:ubuntu-docviewer-app
- reboot-qsg-impress-support
- Merge into lo-viewer
Status: | Merged |
---|---|
Approved by: | Stefano Verzegnassi |
Approved revision: | 187 |
Merged at revision: | 186 |
Proposed branch: | lp:~mrqtros/ubuntu-docviewer-app/reboot-qsg-impress-support |
Merge into: | lp:ubuntu-docviewer-app |
Prerequisite: | lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-qsg-impress-support |
Diff against target: |
1256 lines (+329/-245) 19 files modified
po/com.ubuntu.docviewer.pot (+17/-17) src/app/qml/loView/LOViewDefaultHeader.qml (+36/-46) src/app/qml/loView/LOViewPage.qml (+3/-3) src/app/qml/loView/PartsView.qml (+8/-9) src/app/qml/ubuntu-docviewer-app.qml (+1/-1) src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp (+12/-24) src/plugin/libreofficetoolkit-qml-plugin/lodocument.h (+9/-4) src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.cpp (+20/-16) src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.h (+7/-2) src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.cpp (+45/-44) src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.h (+21/-10) src/plugin/libreofficetoolkit-qml-plugin/loview.cpp (+47/-19) src/plugin/libreofficetoolkit-qml-plugin/loview.h (+17/-7) src/plugin/libreofficetoolkit-qml-plugin/plugin.cpp (+1/-1) src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml (+2/-1) src/plugin/libreofficetoolkit-qml-plugin/renderengine.cpp (+39/-11) src/plugin/libreofficetoolkit-qml-plugin/renderengine.h (+38/-18) src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp (+5/-5) src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h (+1/-7) |
To merge this branch: | bzr merge lp:~mrqtros/ubuntu-docviewer-app/reboot-qsg-impress-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Stefano Verzegnassi | Approve | ||
Review via email: mp+273984@code.launchpad.net |
This proposal supersedes a proposal from 2015-10-08.
Commit message
RenderEngine - impress support.
Description of the change
RenderEngine - impress support.
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : Posted in a previous version of this proposal | # |
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
I've added lp:~verzegnassi-stefano/ubuntu-docviewer-app/reboot-qsg-impress-support as prerequisite branch, so that the diff is a bit shorter :)
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
FAILED: Continuous integration, rev:186
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
Overall it looks good to me! Excellent work! :)
Anyway there are a few things that require a fix (mostly some bad-looking piece of code I wrote, or deprecated stuff imported from PDF code).
Since I've already fixed six times the 'go to position' dialog in LibreOffice viewer (bzr conflicts), I'd prefer to push those fixes in this branch, and do the work just once.
It would be really appreciated if you could include the following changes in your branch:
https:/
Stefano Verzegnassi (verzegnassi-stefano) wrote : | # |
LGTM
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) : | # |
Preview Diff
1 | === modified file 'po/com.ubuntu.docviewer.pot' |
2 | --- po/com.ubuntu.docviewer.pot 2015-10-10 12:32:48 +0000 |
3 | +++ po/com.ubuntu.docviewer.pot 2015-10-11 19:35:30 +0000 |
4 | @@ -8,7 +8,7 @@ |
5 | msgstr "" |
6 | "Project-Id-Version: \n" |
7 | "Report-Msgid-Bugs-To: \n" |
8 | -"POT-Creation-Date: 2015-10-10 14:32+0200\n" |
9 | +"POT-Creation-Date: 2015-10-11 13:31+0200\n" |
10 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
11 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
12 | "Language-Team: LANGUAGE <LL@li.org>\n" |
13 | @@ -24,7 +24,7 @@ |
14 | msgstr "" |
15 | |
16 | #: ../src/app/qml/common/DetailsPage.qml:27 |
17 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:116 |
18 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:114 |
19 | #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:97 |
20 | #: ../src/app/qml/textView/TextViewDefaultHeader.qml:83 |
21 | msgid "Details" |
22 | @@ -63,7 +63,7 @@ |
23 | #: ../src/app/qml/common/RejectedImportDialog.qml:38 |
24 | #: ../src/app/qml/documentPage/DocumentPageSelectionModeHeader.qml:32 |
25 | #: ../src/app/qml/documentPage/SortSettingsDialog.qml:53 |
26 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:80 |
27 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:78 |
28 | #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:61 |
29 | #: ../src/app/qml/textView/TextViewDefaultHeader.qml:61 |
30 | msgid "Close" |
31 | @@ -254,7 +254,7 @@ |
32 | msgstr "" |
33 | |
34 | #: ../src/app/qml/documentPage/DocumentPageSearchHeader.qml:27 |
35 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:80 |
36 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:78 |
37 | #: ../src/app/qml/loView/LOViewPage.qml:191 |
38 | #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:61 |
39 | #: ../src/app/qml/textView/TextViewDefaultHeader.qml:61 |
40 | @@ -306,50 +306,50 @@ |
41 | msgid "Reverse order" |
42 | msgstr "" |
43 | |
44 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:57 |
45 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:55 |
46 | #: ../src/app/qml/textView/TextView.qml:42 |
47 | msgid "Loading..." |
48 | msgstr "" |
49 | |
50 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:59 |
51 | +msgid "LibreOffice text document" |
52 | +msgstr "" |
53 | + |
54 | #: ../src/app/qml/loView/LOViewDefaultHeader.qml:61 |
55 | -msgid "LibreOffice text document" |
56 | +msgid "LibreOffice spread sheet" |
57 | msgstr "" |
58 | |
59 | #: ../src/app/qml/loView/LOViewDefaultHeader.qml:63 |
60 | -msgid "LibreOffice spread sheet" |
61 | +msgid "LibreOffice presentation" |
62 | msgstr "" |
63 | |
64 | #: ../src/app/qml/loView/LOViewDefaultHeader.qml:65 |
65 | -msgid "LibreOffice presentation" |
66 | +msgid "LibreOffice Draw document" |
67 | msgstr "" |
68 | |
69 | #: ../src/app/qml/loView/LOViewDefaultHeader.qml:67 |
70 | -msgid "LibreOffice Draw document" |
71 | +msgid "Unknown LibreOffice document" |
72 | msgstr "" |
73 | |
74 | #: ../src/app/qml/loView/LOViewDefaultHeader.qml:69 |
75 | -msgid "Unknown LibreOffice document" |
76 | -msgstr "" |
77 | - |
78 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:71 |
79 | msgid "Unknown type document" |
80 | msgstr "" |
81 | |
82 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:96 |
83 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:94 |
84 | msgid "Show zoom controls" |
85 | msgstr "" |
86 | |
87 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:103 |
88 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:101 |
89 | msgid "Go to position..." |
90 | msgstr "" |
91 | |
92 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:110 |
93 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:108 |
94 | #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:91 |
95 | #: ../src/app/qml/textView/TextViewDefaultHeader.qml:77 |
96 | msgid "Disable night mode" |
97 | msgstr "" |
98 | |
99 | -#: ../src/app/qml/loView/LOViewDefaultHeader.qml:110 |
100 | +#: ../src/app/qml/loView/LOViewDefaultHeader.qml:108 |
101 | #: ../src/app/qml/pdfView/PdfViewDefaultHeader.qml:91 |
102 | #: ../src/app/qml/textView/TextViewDefaultHeader.qml:77 |
103 | msgid "Enable night mode" |
104 | |
105 | === modified file 'src/app/qml/loView/LOViewDefaultHeader.qml' |
106 | --- src/app/qml/loView/LOViewDefaultHeader.qml 2015-10-10 12:13:40 +0000 |
107 | +++ src/app/qml/loView/LOViewDefaultHeader.qml 2015-10-11 19:35:30 +0000 |
108 | @@ -16,7 +16,6 @@ |
109 | |
110 | import QtQuick 2.3 |
111 | import Ubuntu.Components 1.1 |
112 | -import QtQuick.Layouts 1.1 |
113 | import Ubuntu.Components.Popups 1.0 |
114 | import DocumentViewer.LibreOffice 1.0 as LibreOffice |
115 | |
116 | @@ -24,57 +23,48 @@ |
117 | id: rootItem |
118 | |
119 | property Page targetPage |
120 | - property alias activityRunning: activity.running |
121 | - |
122 | head: targetPage.head |
123 | |
124 | - contents: RowLayout { |
125 | - anchors.fill: parent |
126 | - spacing: units.gu(1) |
127 | - |
128 | - ActivityIndicator { id: activity } |
129 | - |
130 | - Column { |
131 | - id: layout |
132 | - Layout.fillWidth: true |
133 | - |
134 | - Label { |
135 | - width: parent.width |
136 | - //horizontalAlignment: Text.AlignHCenter |
137 | - elide: Text.ElideMiddle |
138 | - |
139 | - font.weight: Font.DemiBold |
140 | - text: targetPage.title |
141 | - } |
142 | - Label { |
143 | - width: parent.width |
144 | - //horizontalAlignment: Text.AlignHCenter |
145 | - elide: Text.ElideMiddle |
146 | - |
147 | - fontSize: "small" |
148 | - text: { |
149 | - if (!loPageContentLoader.item) |
150 | - return i18n.tr("Loading...") |
151 | - |
152 | - switch(loPageContentLoader.item.loDocument.documentType) { |
153 | - case 0: |
154 | - return i18n.tr("LibreOffice text document") |
155 | - case 1: |
156 | - return i18n.tr("LibreOffice spread sheet") |
157 | - case 2: |
158 | - return i18n.tr("LibreOffice presentation") |
159 | - case 3: |
160 | - return i18n.tr("LibreOffice Draw document") |
161 | - case 4: |
162 | - return i18n.tr("Unknown LibreOffice document") |
163 | - default: |
164 | - return i18n.tr("Unknown type document") |
165 | - } |
166 | + contents: Column { |
167 | + anchors { |
168 | + left: parent.left |
169 | + right: parent.right |
170 | + verticalCenter: parent.verticalCenter |
171 | + } |
172 | + |
173 | + Label { |
174 | + anchors { left: parent.left; right: parent.right } |
175 | + elide: Text.ElideMiddle |
176 | + font.weight: Font.DemiBold |
177 | + text: targetPage.title |
178 | + } |
179 | + Label { |
180 | + anchors { left: parent.left; right: parent.right } |
181 | + elide: Text.ElideMiddle |
182 | + fontSize: "small" |
183 | + text: { |
184 | + if (!loPageContentLoader.item) |
185 | + return i18n.tr("Loading...") |
186 | + |
187 | + switch(loPageContentLoader.item.loDocument.documentType) { |
188 | + case 0: |
189 | + return i18n.tr("LibreOffice text document") |
190 | + case 1: |
191 | + return i18n.tr("LibreOffice spread sheet") |
192 | + case 2: |
193 | + return i18n.tr("LibreOffice presentation") |
194 | + case 3: |
195 | + return i18n.tr("LibreOffice Draw document") |
196 | + case 4: |
197 | + return i18n.tr("Unknown LibreOffice document") |
198 | + default: |
199 | + return i18n.tr("Unknown type document") |
200 | } |
201 | } |
202 | } |
203 | } |
204 | |
205 | + |
206 | backAction: Action { |
207 | iconName: "back" |
208 | text: (pageStack.depth > 1) ? i18n.tr("Back") : i18n.tr("Close") |
209 | @@ -102,7 +92,7 @@ |
210 | iconName: "browser-tabs" |
211 | text: i18n.tr("Go to position...") |
212 | onTriggered: PopupUtils.open(Qt.resolvedUrl("LOViewGotoDialog.qml"), targetPage) |
213 | - visible: loDocument.documentType == LibreOffice.Document.TextDocument |
214 | + visible: loPageContentLoader.item.loDocument.documentType == LibreOffice.Document.TextDocument |
215 | }, |
216 | |
217 | Action { |
218 | |
219 | === modified file 'src/app/qml/loView/LOViewPage.qml' |
220 | --- src/app/qml/loView/LOViewPage.qml 2015-09-23 16:48:39 +0000 |
221 | +++ src/app/qml/loView/LOViewPage.qml 2015-10-11 19:35:30 +0000 |
222 | @@ -99,8 +99,8 @@ |
223 | left: parent.left |
224 | } |
225 | |
226 | - model: LO.PartsModel { document: loPageContent.loDocument } |
227 | - visible: model && loDocument.documentType == LO.Document.PresentationDocument |
228 | + model: loView.partsModel |
229 | + visible: loDocument.documentType == LO.Document.PresentationDocument |
230 | width: visible ? units.gu(40) : 0 |
231 | } |
232 | |
233 | @@ -198,7 +198,7 @@ |
234 | PartsView { |
235 | property bool belongsToNestedPage: true |
236 | anchors.fill: parent |
237 | - model: LO.PartsModel { document: loPageContent.loDocument } |
238 | + model: loView.partsModel |
239 | } |
240 | } |
241 | } |
242 | |
243 | === modified file 'src/app/qml/loView/PartsView.qml' |
244 | --- src/app/qml/loView/PartsView.qml 2015-09-23 16:48:39 +0000 |
245 | +++ src/app/qml/loView/PartsView.qml 2015-10-11 19:35:30 +0000 |
246 | @@ -28,7 +28,7 @@ |
247 | |
248 | property bool expanded: true |
249 | |
250 | - currentIndex: view.model ? view.model.document.currentPart : -1 |
251 | + currentIndex: view.model ? loView.document.currentPart : -1 |
252 | highlightMoveDuration: UbuntuAnimation.SnapDuration |
253 | |
254 | delegate: ListItemWithActions { |
255 | @@ -37,15 +37,15 @@ |
256 | width: parent.width |
257 | height: units.gu(16) |
258 | |
259 | - color: (view.model.document.currentPart === model.index) ? Theme.palette.selected.background |
260 | - : "transparent" |
261 | + color: (loView.document.currentPart === model.index) ? Theme.palette.selected.background |
262 | + : "transparent" |
263 | |
264 | AbstractButton { |
265 | objectName: "abstractbutton" |
266 | anchors.fill: parent |
267 | |
268 | onClicked: { |
269 | - view.model.document.currentPart = model.index |
270 | + loView.document.currentPart = model.index |
271 | |
272 | // Check if the view has been included in a nested page (e.g. |
273 | // bottomEdge). If so, close that page and return to the |
274 | @@ -65,22 +65,21 @@ |
275 | fillMode: Image.PreserveAspectFit |
276 | // Do not store a cache of the thumbnail, so that we don't show |
277 | // thumbnails of a previously loaded document. |
278 | - cache: false |
279 | - |
280 | - source: "image://lok/part/" + model.index |
281 | + cache: true // TODO PLAY WITH IT |
282 | + source: model.thumbnail |
283 | } |
284 | |
285 | Label { |
286 | Layout.fillWidth: true |
287 | wrapMode: Text.WordWrap |
288 | text: model.name |
289 | - color: (view.model.document.currentPart === model.index) ? UbuntuColors.orange |
290 | + color: (loView.document.currentPart === model.index) ? UbuntuColors.orange |
291 | : Theme.palette.selected.backgroundText |
292 | } |
293 | |
294 | Label { |
295 | text: model.index + 1 |
296 | - color: (view.model.document.currentPart === model.index) ? UbuntuColors.orange |
297 | + color: (loView.document.currentPart === model.index) ? UbuntuColors.orange |
298 | : Theme.palette.selected.backgroundText |
299 | } |
300 | } |
301 | |
302 | === modified file 'src/app/qml/ubuntu-docviewer-app.qml' |
303 | --- src/app/qml/ubuntu-docviewer-app.qml 2015-09-11 14:48:57 +0000 |
304 | +++ src/app/qml/ubuntu-docviewer-app.qml 2015-10-11 19:35:30 +0000 |
305 | @@ -37,7 +37,7 @@ |
306 | useDeprecatedToolbar: false |
307 | automaticOrientation: true |
308 | |
309 | - width: units.gu(50) |
310 | + width: units.gu(150) |
311 | height: units.gu(75) |
312 | |
313 | function openDocument(path) { |
314 | |
315 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp' |
316 | --- src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-10-04 12:38:48 +0000 |
317 | +++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-10-11 19:35:30 +0000 |
318 | @@ -110,6 +110,17 @@ |
319 | return m_docType; |
320 | } |
321 | |
322 | +int LODocument::documentPart() const |
323 | +{ |
324 | + return m_document->getPart(); |
325 | +} |
326 | + |
327 | +void LODocument::setDocumentPart(int p) |
328 | +{ |
329 | + if (documentPart() != p) |
330 | + m_document->setPart(p); |
331 | +} |
332 | + |
333 | // Return the size of the document, in TWIPs |
334 | QSize LODocument::documentSize() const |
335 | { |
336 | @@ -123,16 +134,11 @@ |
337 | return QSize(pWidth, pHeight); |
338 | } |
339 | |
340 | -// Paint a tile, with size=canvasSize, of the part of the document defined by |
341 | -// the rect tileSize. |
342 | QImage LODocument::paintTile(const QSize& canvasSize, const QRect& tileSize, const qreal &zoom) |
343 | { |
344 | if (!m_document) |
345 | return QImage(); |
346 | |
347 | - if (m_currentPart != m_document->getPart()) |
348 | - m_document->setPart(m_currentPart); |
349 | - |
350 | QImage result = QImage(canvasSize.width(), canvasSize.height(), QImage::Format_RGB32); |
351 | |
352 | #ifdef DEBUG_TILE_BENCHMARK |
353 | @@ -154,7 +160,7 @@ |
354 | return result.rgbSwapped(); |
355 | } |
356 | |
357 | -QImage LODocument::paintThumbnail(int part, qreal size) |
358 | +QImage LODocument::paintThumbnail(qreal size) |
359 | { |
360 | if (!m_document) |
361 | return QImage(); |
362 | @@ -164,14 +170,6 @@ |
363 | renderTimer.start(); |
364 | #endif |
365 | |
366 | - // This is used by LOPartsImageProvider to temporarily change the current part, |
367 | - // in order to generate thumbnails. |
368 | - |
369 | - // FIXME: Sometimes docviewer crashes at m_document->getPart() when a |
370 | - // document is being loaded. |
371 | - if (m_document->getPart() != part) |
372 | - m_document->setPart(part); |
373 | - |
374 | qreal tWidth = this->documentSize().width(); |
375 | qreal tHeight = this->documentSize().height(); |
376 | |
377 | @@ -189,10 +187,6 @@ |
378 | m_document->paintTile(result.bits(), resultSize.width(), resultSize.height(), |
379 | 0, 0, tWidth, tHeight); |
380 | |
381 | - // Restore the active part used for tile rendering. |
382 | - if (m_currentPart != part) |
383 | - m_document->setPart(m_currentPart); |
384 | - |
385 | #ifdef DEBUG_TILE_BENCHMARK |
386 | qDebug() << "Time to render the thumbnail:" << renderTimer.elapsed() << "ms"; |
387 | #endif |
388 | @@ -216,12 +210,6 @@ |
389 | return QString::fromUtf8(m_document->getPartName(index)); |
390 | } |
391 | |
392 | -/* Export the file in a given format: |
393 | - * - url is a mandatory argument. |
394 | - * - format is optional. If not specified, lok will try to get it from the file |
395 | - * extension given at the 'url' argument. |
396 | - * - filerOptions is also optional. |
397 | - */ |
398 | // TODO: Is there some documentation on safe formats or filterOptions that can |
399 | // be used? |
400 | bool LODocument::saveAs(QString url, QString format = QString(), QString filterOptions = QString()) |
401 | |
402 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.h' |
403 | --- src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2015-09-23 16:48:39 +0000 |
404 | +++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2015-10-11 19:35:30 +0000 |
405 | @@ -30,11 +30,12 @@ |
406 | Q_OBJECT |
407 | Q_DISABLE_COPY(LODocument) |
408 | |
409 | - Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) |
410 | - Q_PROPERTY(int currentPart READ currentPart WRITE setCurrentPart NOTIFY currentPartChanged) |
411 | + Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) |
412 | + Q_PROPERTY(int currentPart READ currentPart WRITE setCurrentPart NOTIFY currentPartChanged) |
413 | // Declare partsCount as constant at the moment, since LOK-plugin is just a viewer for now. |
414 | Q_PROPERTY(int partsCount READ partsCount CONSTANT) |
415 | - Q_PROPERTY(DocumentType documentType READ documentType NOTIFY documentTypeChanged) |
416 | + Q_PROPERTY(int documentPart READ documentPart WRITE setDocumentPart NOTIFY documentPartChanged) |
417 | + Q_PROPERTY(DocumentType documentType READ documentType NOTIFY documentTypeChanged) |
418 | Q_ENUMS(DocumentType) |
419 | |
420 | public: |
421 | @@ -57,10 +58,13 @@ |
422 | |
423 | DocumentType documentType() const; |
424 | |
425 | + int documentPart() const; |
426 | + void setDocumentPart(int p); |
427 | + |
428 | QSize documentSize() const; |
429 | |
430 | QImage paintTile(const QSize& canvasSize, const QRect& tileSize, const qreal& zoom = 1.0); |
431 | - QImage paintThumbnail(int part, qreal size); |
432 | + QImage paintThumbnail(qreal size); |
433 | |
434 | int partsCount(); |
435 | QString getPartName(int index) const; |
436 | @@ -72,6 +76,7 @@ |
437 | void pathChanged(); |
438 | void currentPartChanged(); |
439 | void documentTypeChanged(); |
440 | + void documentPartChanged(); |
441 | |
442 | private: |
443 | QString m_path; |
444 | |
445 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.cpp' |
446 | --- src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.cpp 2015-09-23 16:48:39 +0000 |
447 | +++ src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.cpp 2015-10-11 19:35:30 +0000 |
448 | @@ -18,9 +18,9 @@ |
449 | #include "lodocument.h" |
450 | #include "renderengine.h" |
451 | |
452 | -LOPartsImageProvider::LOPartsImageProvider(LODocument *document) |
453 | - : QQuickImageProvider(QQuickImageProvider::Image, QQuickImageProvider::ForceAsynchronousImageLoading) |
454 | - , m_document(document) |
455 | +LOPartsImageProvider::LOPartsImageProvider(const QSharedPointer<LODocument>& d) |
456 | + : QQuickImageProvider(QQuickImageProvider::Image), |
457 | + m_document(d) |
458 | { } |
459 | |
460 | QImage LOPartsImageProvider::requestImage(const QString & id, QSize * size, const QSize & requestedSize) |
461 | @@ -33,18 +33,22 @@ |
462 | m_document->documentType() != LODocument::PresentationDocument) |
463 | return QImage(); |
464 | |
465 | - // Wait for any in-progress rendering to be completed |
466 | - while (RenderEngine::instance()->activeTaskCount() != 0) { } |
467 | - |
468 | - // Lock the render engine |
469 | - RenderEngine::instance()->setEnabled(false); |
470 | - |
471 | - // Render the part to QImage |
472 | + // Get info from "id". |
473 | int partNumber = id.section("/", 1, 1).toInt(); |
474 | - QImage result = m_document->paintThumbnail(partNumber, 256.0); |
475 | - |
476 | - // Unlock the render engine |
477 | - RenderEngine::instance()->setEnabled(true); |
478 | - |
479 | - return result; |
480 | + int itemId = id.section("/", 2, 2).toInt(); |
481 | + |
482 | + // Once rendered images can be found in hash. |
483 | + if (m_images.contains(itemId)) |
484 | + return m_images[itemId]; |
485 | + |
486 | + const int defaultSize = 256; |
487 | + |
488 | + RenderEngine::instance()->enqueueTask(m_document, partNumber, defaultSize, itemId); |
489 | + |
490 | + // Return default image (empty). |
491 | + static QImage defaultImage; |
492 | + if (defaultImage.isNull()) |
493 | + defaultImage = QImage(defaultSize, defaultSize, QImage::Format_ARGB32); |
494 | + |
495 | + return defaultImage; |
496 | } |
497 | |
498 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.h' |
499 | --- src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.h 2015-09-15 18:20:00 +0000 |
500 | +++ src/plugin/libreofficetoolkit-qml-plugin/lopartsimageprovider.h 2015-10-11 19:35:30 +0000 |
501 | @@ -19,17 +19,22 @@ |
502 | #define LOPARTSIMAGEPROVIDER_H |
503 | |
504 | #include <QQuickImageProvider> |
505 | +#include <QSharedPointer> |
506 | +#include <QHash> |
507 | +#include <QDebug> |
508 | |
509 | class LODocument; |
510 | |
511 | class LOPartsImageProvider : public QQuickImageProvider |
512 | { |
513 | public: |
514 | - LOPartsImageProvider(LODocument *document); |
515 | + LOPartsImageProvider(const QSharedPointer<LODocument>& d); |
516 | QImage requestImage(const QString & id, QSize * size, const QSize & requestedSize); |
517 | |
518 | + QHash<int, QImage> m_images; |
519 | + |
520 | private: |
521 | - LODocument *m_document; |
522 | + QSharedPointer<LODocument> m_document; |
523 | }; |
524 | |
525 | #endif // LOPARTSIMAGEPROVIDER_H |
526 | |
527 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.cpp' |
528 | --- src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.cpp 2015-10-04 14:01:25 +0000 |
529 | +++ src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.cpp 2015-10-11 19:35:30 +0000 |
530 | @@ -19,32 +19,13 @@ |
531 | #include "lodocument.h" |
532 | #include "lopartsimageprovider.h" |
533 | |
534 | -#include <QQmlContext> |
535 | -#include <QQmlEngine> |
536 | #include <QDebug> |
537 | |
538 | -LOPartsModel::LOPartsModel(QAbstractListModel *parent): |
539 | +LOPartsModel::LOPartsModel(const QSharedPointer<LODocument>& document, QAbstractListModel *parent): |
540 | QAbstractListModel(parent) |
541 | { |
542 | - connect(this, SIGNAL(documentChanged()), this, SLOT(fillModel())); |
543 | -} |
544 | - |
545 | -void LOPartsModel::setDocument(LODocument *document) |
546 | -{ |
547 | - if (m_document == document) |
548 | - return; |
549 | - |
550 | m_document = document; |
551 | - Q_EMIT documentChanged(); |
552 | - |
553 | - QQmlEngine *engine = QQmlEngine::contextForObject(this)->engine(); |
554 | - QString imageProviderName = "lok"; |
555 | - |
556 | - if (engine->imageProvider(imageProviderName)) |
557 | - engine->removeImageProvider(imageProviderName); |
558 | - |
559 | - engine->addImageProvider(imageProviderName, new LOPartsImageProvider(m_document)); |
560 | - |
561 | + fillModel(); |
562 | } |
563 | |
564 | QHash<int, QByteArray> LOPartsModel::roleNames() const |
565 | @@ -52,6 +33,8 @@ |
566 | QHash<int, QByteArray> roles; |
567 | roles[IndexRole] = "index"; |
568 | roles[NameRole] = "name"; |
569 | + roles[IdRole] = "id"; |
570 | + roles[ThumbnailRole] = "thumbnail"; |
571 | |
572 | return roles; |
573 | } |
574 | @@ -74,6 +57,10 @@ |
575 | return part.index; |
576 | case NameRole: |
577 | return part.name; |
578 | + case IdRole: |
579 | + return part.id; |
580 | + case ThumbnailRole: |
581 | + return part.thumbnail; |
582 | |
583 | default: |
584 | return 0; |
585 | @@ -92,34 +79,48 @@ |
586 | QVariantMap map; |
587 | map["name"] = part.name; |
588 | map["index"] = part.index; |
589 | + map["id"] = part.id; |
590 | + map["thumbnail"] = part.thumbnail; |
591 | |
592 | return map; |
593 | } |
594 | |
595 | +void LOPartsModel::notifyAboutChanges(int id) |
596 | +{ |
597 | + for (int i = 0; i < m_entries.size(); i++) |
598 | + if (m_entries[i].id == id) { |
599 | + m_entries[i].thumbnail += "/cached"; |
600 | + Q_EMIT dataChanged(createIndex(i, 0), createIndex(i + 1, 0)); |
601 | + break; |
602 | + } |
603 | +} |
604 | + |
605 | void LOPartsModel::fillModel() { |
606 | - if (m_document) { |
607 | - if (!m_entries.isEmpty()) { |
608 | - beginRemoveRows(QModelIndex(), 0, rowCount()); |
609 | - m_entries.clear(); |
610 | - endRemoveRows(); |
611 | - } |
612 | - |
613 | - int partsCount = m_document->partsCount(); |
614 | - |
615 | - for (int i = 0; i < partsCount; i++) { |
616 | - LOPartEntry part; |
617 | - part.index = i; |
618 | - part.name = m_document->getPartName(i); |
619 | - |
620 | - beginInsertRows(QModelIndex(), rowCount(), rowCount()); |
621 | - m_entries.append(part); |
622 | - endInsertRows(); |
623 | - } |
624 | - |
625 | - Q_EMIT countChanged(); |
626 | - } |
627 | + if (!m_document) |
628 | + return; |
629 | + |
630 | + if (!m_entries.isEmpty()) { |
631 | + beginRemoveRows(QModelIndex(), 0, rowCount()); |
632 | + m_entries.clear(); |
633 | + endRemoveRows(); |
634 | + } |
635 | + |
636 | + int partsCount = m_document->partsCount(); |
637 | + beginInsertColumns(QModelIndex(), 0, qMax(partsCount - 1, 0)); |
638 | + for (int i = 0; i < partsCount; i++) { |
639 | + LOPartEntry part; |
640 | + |
641 | + part.index = i; |
642 | + part.name = m_document->getPartName(i); |
643 | + part.id = RenderEngine::getNextId(); |
644 | + part.thumbnail = QString("image://lok/part/%1/%2").arg(QString::number(part.index)).arg(QString::number(part.id)); |
645 | + |
646 | + m_entries.append(part); |
647 | + } |
648 | + endInsertColumns(); |
649 | + |
650 | + Q_EMIT countChanged(); |
651 | } |
652 | |
653 | LOPartsModel::~LOPartsModel() |
654 | -{ |
655 | -} |
656 | +{ } |
657 | |
658 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.h' |
659 | --- src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.h 2015-09-15 18:20:00 +0000 |
660 | +++ src/plugin/libreofficetoolkit-qml-plugin/lopartsmodel.h 2015-10-11 19:35:30 +0000 |
661 | @@ -19,35 +19,45 @@ |
662 | #define LOPARTSMODEL_H |
663 | |
664 | #include <QAbstractListModel> |
665 | +#include <QHash> |
666 | +#include <QSharedPointer> |
667 | + |
668 | +#include "renderengine.h" |
669 | |
670 | class LODocument; |
671 | |
672 | class LOPartEntry |
673 | { |
674 | public: |
675 | + LOPartEntry(): |
676 | + index(0) |
677 | + { |
678 | + id = RenderEngine::getNextId(); |
679 | + } |
680 | + |
681 | + int id; |
682 | QString name; |
683 | - int index = 0; |
684 | + int index; |
685 | + QString thumbnail; |
686 | }; |
687 | |
688 | class LOPartsModel : public QAbstractListModel |
689 | { |
690 | Q_OBJECT |
691 | Q_DISABLE_COPY(LOPartsModel) |
692 | - Q_PROPERTY(LODocument* document READ document WRITE setDocument NOTIFY documentChanged) |
693 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) |
694 | |
695 | public: |
696 | enum Roles { |
697 | - NameRole, |
698 | - IndexRole |
699 | + NameRole = Qt::UserRole + 1, |
700 | + IndexRole, |
701 | + IdRole, |
702 | + ThumbnailRole |
703 | }; |
704 | |
705 | - explicit LOPartsModel(QAbstractListModel *parent = 0); |
706 | + explicit LOPartsModel(const QSharedPointer<LODocument>& document, QAbstractListModel *parent = 0); |
707 | ~LOPartsModel(); |
708 | |
709 | - LODocument* document() { return m_document; } |
710 | - void setDocument(LODocument* document); |
711 | - |
712 | QHash<int, QByteArray> roleNames() const; |
713 | |
714 | int rowCount(const QModelIndex & parent = QModelIndex()) const; |
715 | @@ -55,15 +65,16 @@ |
716 | |
717 | Q_INVOKABLE QVariantMap get(int index) const; |
718 | |
719 | + void notifyAboutChanges(int id); |
720 | + |
721 | Q_SIGNALS: |
722 | - void documentChanged(); |
723 | void countChanged(); |
724 | |
725 | private slots: |
726 | void fillModel(); |
727 | |
728 | private: |
729 | - LODocument* m_document; |
730 | + QSharedPointer<LODocument> m_document; |
731 | QList<LOPartEntry> m_entries; |
732 | }; |
733 | |
734 | |
735 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp' |
736 | --- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-09-22 19:02:46 +0000 |
737 | +++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-10-11 19:35:30 +0000 |
738 | @@ -20,7 +20,6 @@ |
739 | #include "twips.h" |
740 | #include "config.h" |
741 | |
742 | -#include <QPainter> |
743 | #include <QImage> |
744 | #include <QTimer> |
745 | #include <QtCore/qmath.h> |
746 | @@ -36,6 +35,7 @@ |
747 | : QQuickItem(parent) |
748 | , m_parentFlickable(nullptr) |
749 | , m_document(nullptr) |
750 | + , m_partsModel(nullptr) |
751 | , m_zoomFactor(1.0) |
752 | , m_cacheBuffer(TILE_SIZE * 3) |
753 | , m_visibleArea(0, 0, 0, 0) |
754 | @@ -48,7 +48,11 @@ |
755 | connect(this, SIGNAL(parentFlickableChanged()), this, SLOT(updateVisibleRect())); |
756 | connect(this, SIGNAL(cacheBufferChanged()), this, SLOT(updateVisibleRect())); |
757 | connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateVisibleRect())); |
758 | - connect(RenderEngine::instance(), SIGNAL(renderFinished(int,QImage)), this, SLOT(renderResultReceived(int,QImage))); |
759 | + |
760 | + connect(RenderEngine::instance(), SIGNAL(renderFinished(int,QImage)), |
761 | + this, SLOT(slotTileRenderFinished(int,QImage))); |
762 | + connect(RenderEngine::instance(), SIGNAL(thumbnailRenderFinished(int,QImage)), |
763 | + this, SLOT(slotThumbnailRenderFinished(int,QImage))); |
764 | } |
765 | |
766 | // Returns the parent QML Flickable |
767 | @@ -79,12 +83,25 @@ |
768 | |
769 | void LOView::initializeDocument(const QString &path) |
770 | { |
771 | - if (m_document.data()) |
772 | - m_document.data()->disconnect(this); |
773 | + if (m_document) |
774 | + m_document->disconnect(this); |
775 | |
776 | m_document = QSharedPointer<LODocument>(new LODocument()); |
777 | m_document->setPath(path); |
778 | |
779 | + // TODO MOVE |
780 | + m_partsModel = new LOPartsModel(m_document); |
781 | + Q_EMIT partsModelChanged(); |
782 | + |
783 | + // -------------------------------------------------- |
784 | + QQmlEngine *engine = QQmlEngine::contextForObject(this)->engine(); |
785 | + if (engine->imageProvider("lok")) |
786 | + engine->removeImageProvider("lok"); |
787 | + |
788 | + m_imageProvider = new LOPartsImageProvider(m_document); |
789 | + engine->addImageProvider("lok", m_imageProvider); |
790 | + // -------------------------------------------------- |
791 | + |
792 | connect(m_document.data(), SIGNAL(currentPartChanged()), this, SLOT(invalidateAllTiles())); |
793 | |
794 | Q_EMIT documentChanged(); |
795 | @@ -96,6 +113,11 @@ |
796 | return m_document.data(); |
797 | } |
798 | |
799 | +LOPartsModel *LOView::partsModel() const |
800 | +{ |
801 | + return m_partsModel; |
802 | +} |
803 | + |
804 | qreal LOView::zoomFactor() const |
805 | { |
806 | return m_zoomFactor; |
807 | @@ -173,7 +195,6 @@ |
808 | return false; |
809 | } |
810 | |
811 | -// Update the size of LOView, according to the size of the loaded document. |
812 | void LOView::updateViewSize() |
813 | { |
814 | if (!m_document) |
815 | @@ -184,13 +205,9 @@ |
816 | this->setWidth(Twips::convertTwipsToPixels(docSize.width(), m_zoomFactor)); |
817 | this->setHeight(Twips::convertTwipsToPixels(docSize.height(), m_zoomFactor)); |
818 | |
819 | - // TODO: Consider to use connections to widthChanged and heightChanged |
820 | - this->updateVisibleRect(); |
821 | + updateVisibleRect(); |
822 | } |
823 | |
824 | -// Update the informations of the currently visible area of the parent |
825 | -// Flickable, then generate/delete all the required tiles, according to these |
826 | -// informations. |
827 | void LOView::updateVisibleRect() |
828 | { |
829 | if (!m_parentFlickable) |
830 | @@ -228,10 +245,10 @@ |
831 | m_parentFlickable->height()); |
832 | |
833 | // Update information about the buffer area |
834 | - m_bufferArea.setRect(qMax(0, m_visibleArea.x() - this->cacheBuffer()), |
835 | - qMax(0, m_visibleArea.y() - this->cacheBuffer()), |
836 | - qMin(int(this->width() - m_bufferArea.x()), m_visibleArea.width() + (this->cacheBuffer() * 2)), |
837 | - qMin(int(this->height() - m_bufferArea.y()), m_visibleArea.height() + (this->cacheBuffer() * 2))); |
838 | + m_bufferArea.setRect(qMax(0, m_visibleArea.x() - m_cacheBuffer), |
839 | + qMax(0, m_visibleArea.y() - m_cacheBuffer), |
840 | + qMin(int(this->width() - m_bufferArea.x()), m_visibleArea.width() + (m_cacheBuffer * 2)), |
841 | + qMin(int(this->height() - m_bufferArea.y()), m_visibleArea.height() + (m_cacheBuffer * 2))); |
842 | |
843 | // Delete tiles that are outside the loading area |
844 | if (!m_tiles.isEmpty()) { |
845 | @@ -300,7 +317,6 @@ |
846 | } |
847 | } |
848 | |
849 | -// FIXME: Just for the moment. In zoom branch we have all we need :) |
850 | void LOView::invalidateAllTiles() |
851 | { |
852 | clearView(); |
853 | @@ -314,9 +330,9 @@ |
854 | qDebug() << "Creating tile indexed as" << index; |
855 | #endif |
856 | |
857 | - auto tile = new SGTileItem(rect, m_zoomFactor, this); |
858 | + auto tile = new SGTileItem(rect, m_zoomFactor, RenderEngine::getNextId(), this); |
859 | m_tiles.insert(index, tile); |
860 | - RenderEngine::instance()->enqueueTask(m_document, rect, m_zoomFactor, tile->id()); |
861 | + RenderEngine::instance()->enqueueTask(m_document, m_document->currentPart(), rect, m_zoomFactor, tile->id()); |
862 | } |
863 | #ifdef DEBUG_VERBOSE |
864 | else { |
865 | @@ -331,7 +347,7 @@ |
866 | m_updateTimer.start(20); |
867 | } |
868 | |
869 | -void LOView::renderResultReceived(int id, QImage img) |
870 | +void LOView::slotTileRenderFinished(int id, QImage img) |
871 | { |
872 | for (auto i = m_tiles.begin(); i != m_tiles.end(); ++i) { |
873 | SGTileItem* sgtile = i.value(); |
874 | @@ -342,6 +358,13 @@ |
875 | } |
876 | } |
877 | |
878 | +void LOView::slotThumbnailRenderFinished(int id, QImage img) |
879 | +{ |
880 | + if (!m_imageProvider->m_images.contains(id)) |
881 | + m_imageProvider->m_images.insert(id, img); |
882 | + m_partsModel->notifyAboutChanges(id); |
883 | +} |
884 | + |
885 | void LOView::clearView() |
886 | { |
887 | for (auto i = m_tiles.begin(); i != m_tiles.end(); ++i) |
888 | @@ -352,7 +375,12 @@ |
889 | |
890 | LOView::~LOView() |
891 | { |
892 | - disconnect(RenderEngine::instance(), SIGNAL(renderFinished(int,QImage)), this, SLOT(renderResultReceived(int,QImage))); |
893 | + delete m_partsModel; |
894 | + |
895 | + disconnect(RenderEngine::instance(), SIGNAL(renderFinished(int,QImage)), |
896 | + this, SLOT(slotTileRenderFinished(int,QImage))); |
897 | + disconnect(RenderEngine::instance(), SIGNAL(thumbnailRenderFinished(int,QImage)), |
898 | + this, SLOT(slotThumbnailRenderFinished(int,QImage))); |
899 | |
900 | // Remove all tasks from rendering queue. |
901 | for (auto i = m_tiles.begin(); i != m_tiles.end(); ++i) |
902 | |
903 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.h' |
904 | --- src/plugin/libreofficetoolkit-qml-plugin/loview.h 2015-09-22 19:02:46 +0000 |
905 | +++ src/plugin/libreofficetoolkit-qml-plugin/loview.h 2015-10-11 19:35:30 +0000 |
906 | @@ -17,12 +17,15 @@ |
907 | #ifndef LOVIEW_H |
908 | #define LOVIEW_H |
909 | |
910 | -#include <QQuickPaintedItem> |
911 | #include <QQuickItem> |
912 | #include <QTimer> |
913 | #include <QSharedPointer> |
914 | +#include <QQmlContext> |
915 | +#include <QQmlEngine> |
916 | |
917 | #include "renderengine.h" |
918 | +#include "lopartsmodel.h" |
919 | +#include "lopartsimageprovider.h" |
920 | |
921 | class LODocument; |
922 | class SGTileItem; |
923 | @@ -31,11 +34,12 @@ |
924 | { |
925 | Q_OBJECT |
926 | Q_ENUMS(ZoomMode) |
927 | - Q_PROPERTY(QQuickItem* parentFlickable READ parentFlickable WRITE setParentFlickable NOTIFY parentFlickableChanged) |
928 | - Q_PROPERTY(LODocument* document READ document /*WRITE setDocument*/ NOTIFY documentChanged) |
929 | - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) |
930 | - Q_PROPERTY(ZoomMode zoomMode READ zoomMode NOTIFY zoomModeChanged) |
931 | - Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) |
932 | + Q_PROPERTY(QQuickItem* parentFlickable READ parentFlickable WRITE setParentFlickable NOTIFY parentFlickableChanged) |
933 | + Q_PROPERTY(LODocument* document READ document /*WRITE setDocument*/ NOTIFY documentChanged) |
934 | + Q_PROPERTY(LOPartsModel* partsModel READ partsModel NOTIFY partsModelChanged) |
935 | + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) |
936 | + Q_PROPERTY(ZoomMode zoomMode READ zoomMode NOTIFY zoomModeChanged) |
937 | + Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) |
938 | |
939 | public: |
940 | LOView(QQuickItem *parent = 0); |
941 | @@ -52,6 +56,7 @@ |
942 | Q_INVOKABLE void initializeDocument(const QString& path); |
943 | |
944 | LODocument* document() const; |
945 | + LOPartsModel* partsModel() const; |
946 | |
947 | qreal zoomFactor() const; |
948 | void setZoomFactor(const qreal zoom); |
949 | @@ -66,6 +71,7 @@ |
950 | Q_SIGNALS: |
951 | void parentFlickableChanged(); |
952 | void documentChanged(); |
953 | + void partsModelChanged(); |
954 | void zoomFactorChanged(); |
955 | void zoomModeChanged(); |
956 | void cacheBufferChanged(); |
957 | @@ -75,12 +81,16 @@ |
958 | void updateVisibleRect(); |
959 | void scheduleVisibleRectUpdate(); |
960 | void invalidateAllTiles(); |
961 | - void renderResultReceived(int id, QImage img); |
962 | + |
963 | + void slotTileRenderFinished(int id, QImage img); |
964 | + void slotThumbnailRenderFinished(int id, QImage img); |
965 | |
966 | private: |
967 | |
968 | QQuickItem* m_parentFlickable; |
969 | QSharedPointer<LODocument> m_document; |
970 | + LOPartsModel* m_partsModel; // TODO MB move to document. |
971 | + LOPartsImageProvider* m_imageProvider; // The QQmlEngine takes ownership of provider. |
972 | |
973 | qreal m_zoomFactor; |
974 | ZoomMode m_zoomMode; |
975 | |
976 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/plugin.cpp' |
977 | --- src/plugin/libreofficetoolkit-qml-plugin/plugin.cpp 2015-09-15 18:20:00 +0000 |
978 | +++ src/plugin/libreofficetoolkit-qml-plugin/plugin.cpp 2015-10-11 19:35:30 +0000 |
979 | @@ -30,7 +30,7 @@ |
980 | //@uri DocumentViewer.LibreOffice |
981 | qmlRegisterType<LODocument>(uri, 1, 0, "Document"); |
982 | qmlRegisterType<LOView>(uri, 1, 0, "View"); |
983 | - qmlRegisterType<LOPartsModel>(uri, 1, 0, "PartsModel"); |
984 | + qmlRegisterUncreatableType<LOPartsModel>(uri, 1, 0, "PartsModel", "You shouldn't create LOPartsModel in QML"); |
985 | } |
986 | |
987 | void LOPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
988 | |
989 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml' |
990 | --- src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml 2015-09-26 13:46:07 +0000 |
991 | +++ src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml 2015-10-11 19:35:30 +0000 |
992 | @@ -23,8 +23,9 @@ |
993 | property alias document: view.document |
994 | property alias zoomFactor: view.zoomFactor |
995 | property alias cacheBuffer: view.cacheBuffer |
996 | - |
997 | + property alias partsModel: view.partsModel |
998 | property alias zoomMode: view.zoomMode |
999 | + |
1000 | property string documentPath: "" |
1001 | |
1002 | function adjustZoomToWidth() |
1003 | |
1004 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/renderengine.cpp' |
1005 | --- src/plugin/libreofficetoolkit-qml-plugin/renderengine.cpp 2015-09-23 16:51:17 +0000 |
1006 | +++ src/plugin/libreofficetoolkit-qml-plugin/renderengine.cpp 2015-10-11 19:35:30 +0000 |
1007 | @@ -7,7 +7,8 @@ |
1008 | RenderEngine::RenderEngine(): |
1009 | QObject(nullptr), |
1010 | m_activeTaskCount(0), |
1011 | - m_enabled(true) |
1012 | + m_enabled(true), |
1013 | + m_lastPart(-1) |
1014 | { |
1015 | int itc = QThread::idealThreadCount(); |
1016 | m_idealThreadCount = itc == -1 ? DefaultIdealThreadCount : itc; |
1017 | @@ -15,11 +16,20 @@ |
1018 | connect(this, SIGNAL(enabledChanged()), this, SLOT(doNextTask())); |
1019 | } |
1020 | |
1021 | -void RenderEngine::enqueueTask(const QSharedPointer<LODocument>& doc, const QRect& area, const qreal &zoom, int id) |
1022 | -{ |
1023 | - Q_ASSERT(doc != nullptr); |
1024 | - |
1025 | - m_queue.enqueue(EngineTask(doc, area, zoom, id)); |
1026 | +void RenderEngine::enqueueTask(const QSharedPointer<LODocument>& doc, int part, const QRect& area, const qreal &zoom, int id) |
1027 | +{ |
1028 | + Q_ASSERT(doc != nullptr); |
1029 | + |
1030 | + m_queue.enqueue(EngineTask(doc, part, area, zoom, id)); |
1031 | + |
1032 | + doNextTask(); |
1033 | +} |
1034 | + |
1035 | +void RenderEngine::enqueueTask(const QSharedPointer<LODocument> &doc, int part, qreal size, int id) |
1036 | +{ |
1037 | + Q_ASSERT(doc != nullptr); |
1038 | + |
1039 | + m_queue.enqueue(EngineTask(doc, part, size, id)); |
1040 | |
1041 | doNextTask(); |
1042 | } |
1043 | @@ -33,10 +43,12 @@ |
1044 | } |
1045 | } |
1046 | |
1047 | -void RenderEngine::internalRenderCallback(int id, QImage img) |
1048 | +void RenderEngine::internalRenderCallback(int id, QImage img, bool isThumbnail) |
1049 | { |
1050 | m_activeTaskCount--; |
1051 | - Q_EMIT renderFinished(id, img); |
1052 | + if (isThumbnail) |
1053 | + Q_EMIT thumbnailRenderFinished(id, img); |
1054 | + else Q_EMIT renderFinished(id, img); |
1055 | doNextTask(); |
1056 | } |
1057 | |
1058 | @@ -46,14 +58,30 @@ |
1059 | qDebug() << " ---- doNextTask" << m_activeTaskCount << m_queue.count(); |
1060 | #endif |
1061 | |
1062 | + // Check for too much threads or empty queue. |
1063 | if (m_activeTaskCount >= m_idealThreadCount || !m_queue.count() || !m_enabled) |
1064 | return; |
1065 | |
1066 | + // We should avoid different part rendering in the same time. |
1067 | + if (m_activeTaskCount && m_queue.head().part != m_lastPart) |
1068 | + return; |
1069 | + |
1070 | m_activeTaskCount++; |
1071 | - auto task = m_queue.dequeue(); |
1072 | + EngineTask task = m_queue.dequeue(); |
1073 | + |
1074 | + // Set correct part. |
1075 | + m_lastPart = task.part; |
1076 | + task.document->setDocumentPart(m_lastPart); |
1077 | |
1078 | QtConcurrent::run( [=] { |
1079 | - QImage img = task.document->paintTile(task.area.size(), task.area, task.zoom); |
1080 | - QMetaObject::invokeMethod(this, "internalRenderCallback", Q_ARG(int, task.id), Q_ARG(QImage, img)); |
1081 | + if (task.isThumbnail) { |
1082 | + QImage img = task.document->paintThumbnail(task.size); |
1083 | + QMetaObject::invokeMethod(this, "internalRenderCallback", |
1084 | + Q_ARG(int, task.id), Q_ARG(QImage, img), Q_ARG(bool, task.isThumbnail)); |
1085 | + } else { |
1086 | + QImage img = task.document->paintTile(task.area.size(), task.area, task.zoom); |
1087 | + QMetaObject::invokeMethod(this, "internalRenderCallback", |
1088 | + Q_ARG(int, task.id), Q_ARG(QImage, img), Q_ARG(bool, task.isThumbnail)); |
1089 | + } |
1090 | }); |
1091 | } |
1092 | |
1093 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/renderengine.h' |
1094 | --- src/plugin/libreofficetoolkit-qml-plugin/renderengine.h 2015-09-23 16:48:39 +0000 |
1095 | +++ src/plugin/libreofficetoolkit-qml-plugin/renderengine.h 2015-10-11 19:35:30 +0000 |
1096 | @@ -10,19 +10,42 @@ |
1097 | |
1098 | #include "lodocument.h" |
1099 | |
1100 | +// TODO replace with class. |
1101 | + |
1102 | + |
1103 | +// TODO Need more OOP here. |
1104 | struct EngineTask |
1105 | { |
1106 | int id; |
1107 | + int part; |
1108 | + QSharedPointer<LODocument> document; |
1109 | + // Used in thumbnail rendering. |
1110 | + qreal size; |
1111 | + // Used in tile rendering. |
1112 | QRect area; |
1113 | qreal zoom; |
1114 | - QSharedPointer<LODocument> document; |
1115 | - |
1116 | + // Internal. |
1117 | + bool isThumbnail; |
1118 | public: |
1119 | - EngineTask(const QSharedPointer<LODocument>& d, const QRect& a, const qreal& z, int i): |
1120 | - id(i), |
1121 | - area(a), |
1122 | - zoom(z), |
1123 | - document(d) |
1124 | + |
1125 | + EngineTask(const QSharedPointer<LODocument>& d, int p, const QRect& a, const qreal& z, int i): |
1126 | + id(i), |
1127 | + part(p), |
1128 | + document(d), |
1129 | + size(0), |
1130 | + area(a), |
1131 | + zoom(z), |
1132 | + isThumbnail(false) |
1133 | + { } |
1134 | + |
1135 | + EngineTask(const QSharedPointer<LODocument>& d, int p, qreal s, int i): |
1136 | + id(i), |
1137 | + part(p), |
1138 | + document(d), |
1139 | + size(s), |
1140 | + area(), |
1141 | + zoom(0), |
1142 | + isThumbnail(true) |
1143 | { } |
1144 | }; |
1145 | |
1146 | @@ -37,7 +60,8 @@ |
1147 | const int DefaultIdealThreadCount = 2; |
1148 | |
1149 | public: |
1150 | - void enqueueTask(const QSharedPointer<LODocument>& doc, const QRect& area, const qreal& zoom, int id); |
1151 | + void enqueueTask(const QSharedPointer<LODocument>& doc, int part, const QRect& area, const qreal& zoom, int id); |
1152 | + void enqueueTask(const QSharedPointer<LODocument>& doc, int part, qreal size, int id); |
1153 | void dequeueTask(int id); |
1154 | |
1155 | static RenderEngine* instance() { |
1156 | @@ -46,23 +70,18 @@ |
1157 | return s_instance; |
1158 | } |
1159 | |
1160 | - int activeTaskCount() { return m_activeTaskCount; } |
1161 | - |
1162 | - bool enabled() { return m_enabled.loadAcquire(); } |
1163 | - void setEnabled(bool enabled) { |
1164 | - if (m_enabled.loadAcquire() == enabled) |
1165 | - return; |
1166 | - |
1167 | - m_enabled.storeRelease(enabled); |
1168 | - Q_EMIT enabledChanged(); |
1169 | + static int getNextId() { |
1170 | + static int idCounter = 0xDEAD0000; |
1171 | + return idCounter++; |
1172 | } |
1173 | |
1174 | Q_SIGNALS: |
1175 | void renderFinished(int id, QImage img); |
1176 | + void thumbnailRenderFinished(int id, QImage img); |
1177 | void enabledChanged(); |
1178 | |
1179 | private: |
1180 | - Q_INVOKABLE void internalRenderCallback(int id, QImage img); |
1181 | + Q_INVOKABLE void internalRenderCallback(int id, QImage img, bool isThumbnail); |
1182 | |
1183 | private slots: |
1184 | void doNextTask(); |
1185 | @@ -71,6 +90,7 @@ |
1186 | QQueue<EngineTask> m_queue; |
1187 | int m_activeTaskCount; |
1188 | int m_idealThreadCount; |
1189 | + int m_lastPart; |
1190 | |
1191 | QAtomicInt m_enabled; |
1192 | }; |
1193 | |
1194 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp' |
1195 | --- src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp 2015-09-22 00:01:22 +0000 |
1196 | +++ src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.cpp 2015-10-11 19:35:30 +0000 |
1197 | @@ -1,20 +1,20 @@ |
1198 | #include "sgtileitem.h" |
1199 | - |
1200 | #include "lodocument.h" |
1201 | #include "config.h" |
1202 | |
1203 | +#include <QQuickWindow> |
1204 | +#include <QSGSimpleTextureNode> |
1205 | + |
1206 | #ifdef DEBUG_SHOW_TILE_BORDER |
1207 | #include <QSGGeometryNode> |
1208 | #include <QSGFlatColorMaterial> |
1209 | #endif |
1210 | |
1211 | -int SGTileItem::s_idCounter = 0xDEAD0000; |
1212 | - |
1213 | -SGTileItem::SGTileItem(const QRect& area, const qreal &zoom, QQuickItem *parent) |
1214 | +SGTileItem::SGTileItem(const QRect& area, qreal zoom, int id, QQuickItem *parent) |
1215 | : QQuickItem(parent) |
1216 | , m_area(area) |
1217 | , m_zoomFactor(zoom) |
1218 | - , m_id (s_idCounter++) |
1219 | + , m_id (id) |
1220 | { |
1221 | setFlag(ItemHasContents, true); |
1222 | } |
1223 | |
1224 | === modified file 'src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h' |
1225 | --- src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h 2015-09-22 00:01:22 +0000 |
1226 | +++ src/plugin/libreofficetoolkit-qml-plugin/sgtileitem.h 2015-10-11 19:35:30 +0000 |
1227 | @@ -2,11 +2,7 @@ |
1228 | #define SGTILEITEM_H |
1229 | |
1230 | #include <QQuickItem> |
1231 | -#include <QQuickWindow> |
1232 | -#include <QSGSimpleTextureNode> |
1233 | #include <QImage> |
1234 | -#include <QtConcurrent/QtConcurrent> |
1235 | -#include <QAtomicInteger> |
1236 | |
1237 | class LODocument; |
1238 | |
1239 | @@ -14,7 +10,7 @@ |
1240 | { |
1241 | Q_OBJECT |
1242 | public: |
1243 | - SGTileItem(const QRect& area, const qreal &zoom = 1.0, QQuickItem *parent = 0); |
1244 | + SGTileItem(const QRect& area, qreal zoom, int id, QQuickItem *parent = 0); |
1245 | ~SGTileItem(); |
1246 | |
1247 | inline const QRect& area() { return m_area; } |
1248 | @@ -43,8 +39,6 @@ |
1249 | qreal m_zoomFactor; |
1250 | QImage m_data; |
1251 | int m_id; |
1252 | - |
1253 | - static int s_idCounter; |
1254 | }; |
1255 | |
1256 | #endif // SGTILEITEM_H |
FAILED: Continuous integration, rev:186 91.189. 93.70:8080/ job/ubuntu- docviewer- app-reboot- ci/41/ 91.189. 93.70:8080/ job/ubuntu- docviewer- app-reboot- vivid-amd64- ci/41/console
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/ubuntu- docviewer- app-reboot- ci/41/rebuild
http://