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