Merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/lok-qml-currentpart-moved into lp:ubuntu-docviewer-app

Proposed by Stefano Verzegnassi on 2016-01-07
Status: Merged
Approved by: Stefano Verzegnassi on 2016-01-16
Approved revision: 237
Merged at revision: 265
Proposed branch: lp:~verzegnassi-stefano/ubuntu-docviewer-app/lok-qml-currentpart-moved
Merge into: lp:ubuntu-docviewer-app
Diff against target: 456 lines (+64/-65)
10 files modified
po/com.ubuntu.docviewer.pot (+4/-4)
src/app/qml/loView/KeybHelper.js (+5/-5)
src/app/qml/loView/PartsView.qml (+13/-14)
src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp (+6/-21)
src/plugin/libreofficetoolkit-qml-plugin/lodocument.h (+2/-8)
src/plugin/libreofficetoolkit-qml-plugin/lorendertask.cpp (+2/-2)
src/plugin/libreofficetoolkit-qml-plugin/lorendertask.h (+1/-1)
src/plugin/libreofficetoolkit-qml-plugin/loview.cpp (+20/-2)
src/plugin/libreofficetoolkit-qml-plugin/loview.h (+6/-0)
src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml (+5/-8)
To merge this branch: bzr merge lp:~verzegnassi-stefano/ubuntu-docviewer-app/lok-qml-currentpart-moved
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve on 2016-01-16
Nicholas Skaggs Needs Fixing on 2016-01-08
Roman Shchekin 2016-01-07 Approve on 2016-01-08
Review via email: mp+281840@code.launchpad.net

Commit Message

[lok-qml] Moved 'currentPart' property from LODocument to LOView.

Description of the Change

[lok-qml] Moved 'currentPart' property from LODocument to LOView.

To post a comment you must log in.
review: Approve (continuous-integration)
Roman Shchekin (mrqtros) wrote :

We discussed it already, approve.

review: Approve

FAILED: Autolanding.
More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/docviewer-app-autolanding/33/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1399/console

review: Needs Fixing (continuous-integration)
Nicholas Skaggs (nskaggs) wrote :

I'm looking at this and re-running. Some jenkins hiccups.

FAILED: Autolanding.
More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/docviewer-app-autolanding/34/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1400/console

review: Needs Fixing (continuous-integration)
Nicholas Skaggs (nskaggs) wrote :

Text conflict in src/app/qml/loView/PartsView.qml
1 conflicts encountered.

review: Needs Fixing

Thanks Nicholas!

Conflict fixed. Let's see if everything works well now

review: Needs Fixing (continuous-integration)

FAILED: Autolanding.
More details in the following jenkins job:
https://core-apps-jenkins.ubuntu.com/job/docviewer-app-autolanding/50/
Executed test runs:
    None: https://core-apps-jenkins.ubuntu.com/job/generic-land-mp/1458/console

review: Needs Fixing (continuous-integration)
237. By Stefano Verzegnassi on 2016-01-16

Merged trunk - updated translation template

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/com.ubuntu.docviewer.pot'
2--- po/com.ubuntu.docviewer.pot 2016-01-14 13:48:06 +0000
3+++ po/com.ubuntu.docviewer.pot 2016-01-16 12:32:06 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: \n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2016-01-14 08:46-0500\n"
9+"POT-Creation-Date: 2016-01-16 13:11+0100\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@@ -215,7 +215,7 @@
14 msgstr ""
15
16 #: ../src/app/qml/documentPage/DocumentPage.qml:23
17-#: /home/mhall/projects/Ubuntu/coreapps/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:3
18+#: /tmp/lok-qml-currentpart-moved-build/po/com.ubuntu.docviewer.desktop.in.in.h:3
19 msgid "Documents"
20 msgstr ""
21
22@@ -444,10 +444,10 @@
23 msgid "copy %1"
24 msgstr ""
25
26-#: /home/mhall/projects/Ubuntu/coreapps/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
27+#: /tmp/lok-qml-currentpart-moved-build/po/com.ubuntu.docviewer.desktop.in.in.h:1
28 msgid "Document Viewer"
29 msgstr ""
30
31-#: /home/mhall/projects/Ubuntu/coreapps/ubuntu-docviewer-app-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
32+#: /tmp/lok-qml-currentpart-moved-build/po/com.ubuntu.docviewer.desktop.in.in.h:2
33 msgid "documents;viewer;pdf;reader;"
34 msgstr ""
35
36=== modified file 'src/app/qml/loView/KeybHelper.js'
37--- src/app/qml/loView/KeybHelper.js 2015-11-30 12:12:10 +0000
38+++ src/app/qml/loView/KeybHelper.js 2016-01-16 12:32:06 +0000
39@@ -22,7 +22,7 @@
40
41 if (event.key == Qt.Key_PageUp) {
42 if (isPresentation)
43- view.document.currentPart -= 1
44+ view.currentPart -= 1
45 else
46 view.moveView("vertical", -view.height)
47
48@@ -31,7 +31,7 @@
49
50 if (event.key == Qt.Key_PageDown) {
51 if (isPresentation)
52- view.document.currentPart += 1
53+ view.currentPart += 1
54 else
55 view.moveView("vertical", view.height)
56
57@@ -42,7 +42,7 @@
58 if (event.modifiers & Qt.ControlModifier) {
59 view.contentX = 0
60 view.contentY = 0
61- view.document.currentPart = 0
62+ view.currentPart = 0
63 } else {
64 view.contentX = 0
65 view.contentY = 0
66@@ -53,8 +53,8 @@
67 if (event.modifiers & Qt.ControlModifier) {
68 view.contentX = view.contentWidth - view.width
69 view.contentY = view.contentHeight - view.height
70- console.log(view.document.currentPart, view.document.partsCount - 1)
71- view.document.currentPart = view.document.partsCount - 1
72+ console.log(view.currentPart, view.document.partsCount - 1)
73+ view.currentPart = view.document.partsCount - 1
74 } else {
75 view.contentX = view.contentWidth - view.width
76 view.contentY = view.contentHeight - view.height
77
78=== modified file 'src/app/qml/loView/PartsView.qml'
79--- src/app/qml/loView/PartsView.qml 2015-11-30 23:15:12 +0000
80+++ src/app/qml/loView/PartsView.qml 2016-01-16 12:32:06 +0000
81@@ -34,8 +34,8 @@
82 // used in vertical mode
83 property bool isWide: width > units.gu(24)
84
85- currentIndex: view.model ? loView.document.currentPart : -1
86-
87+ currentIndex: view.model ? loView.currentPart : -1
88+
89 // Ensure that items next to current item are always visible (and then
90 // clickable) without the need of extra interaction from the user.
91 // FIXME: If the current item is out the visible area, the 'highlightMove'
92@@ -66,8 +66,8 @@
93 width: internal.verticalItemWidth
94 height: internal.verticalItemHeight
95
96- color: (loView.document.currentPart === model.index) ? theme.palette.selected.background
97- : "transparent"
98+ color: (loView.currentPart === model.index) ? theme.palette.selected.background
99+ : "transparent"
100
101 onClicked: internal.delegate_onClicked(model.index)
102
103@@ -99,8 +99,8 @@
104 wrapMode: Text.WordWrap
105 text: model.name
106 visible: view.isWide
107- color: (loView.document.currentPart === model.index) ? UbuntuColors.orange
108- : theme.palette.selected.backgroundText
109+ color: (loView.currentPart === model.index) ? UbuntuColors.orange
110+ : theme.palette.selected.backgroundText
111 }
112
113 /* UITK 1.3 specs: Slot C */
114@@ -108,8 +108,8 @@
115 SlotsLayout.position: SlotsLayout.Trailing
116
117 text: model.index + 1
118- color: (loView.document.currentPart === model.index) ? UbuntuColors.orange
119- : theme.palette.selected.backgroundText
120+ color: (loView.currentPart === model.index) ? UbuntuColors.orange
121+ : theme.palette.selected.backgroundText
122 }
123 }
124 }
125@@ -125,8 +125,8 @@
126 width: internal.horizontalItemWidth
127 height: internal.horizontalItemHeight
128
129- color: (loView.document.currentPart === model.index) ? theme.palette.selected.background
130- : "transparent"
131+ color: (loView.currentPart === model.index) ? theme.palette.selected.background
132+ : "transparent"
133
134 onClicked: internal.delegate_onClicked(model.index)
135
136@@ -152,8 +152,8 @@
137 Label {
138 Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
139 text: model.index + 1
140- color: (loView.document.currentPart === model.index) ? UbuntuColors.orange
141- : theme.palette.selected.backgroundText
142+ color: (loView.currentPart === model.index) ? UbuntuColors.orange
143+ : theme.palette.selected.backgroundText
144 }
145 }
146 }
147@@ -173,7 +173,7 @@
148 readonly property int horizontalItemHeight: view.height
149
150 function delegate_onClicked(index) {
151- loView.document.currentPart = index
152+ loView.currentPart = index
153
154 // Check if the view has been included in a nested page (e.g.
155 // bottomEdge). If so, close that page and return to the
156@@ -183,6 +183,5 @@
157 }
158 }
159
160-
161 Scrollbar { flickableItem: view; parent: view.parent }
162 }
163
164=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp'
165--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-11-28 22:11:54 +0000
166+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2016-01-16 12:32:06 +0000
167@@ -34,7 +34,6 @@
168
169 LODocument::LODocument()
170 : m_path("")
171- , m_currentPart(-1)
172 , m_error(LibreOfficeError::NoError)
173 , m_lokDocument(nullptr)
174 {
175@@ -60,22 +59,6 @@
176 loadDocument(m_path);
177 }
178
179-int LODocument::currentPart() {
180- return m_currentPart;
181-}
182-
183-void LODocument::setCurrentPart(int index)
184-{
185- if (!m_lokDocument)
186- return;
187-
188- if (m_currentPart == index || index < 0 || index > partsCount() - 1)
189- return;
190-
191- m_currentPart = index;
192- Q_EMIT currentPartChanged();
193-}
194-
195 // Load the document
196 void LODocument::loadDocument(const QString &pathName)
197 {
198@@ -122,8 +105,6 @@
199 m_docType = DocumentType(m_lokDocument->getDocumentType());
200 Q_EMIT documentTypeChanged();
201
202- setCurrentPart(m_lokDocument->getPart());
203-
204 m_lokDocument->initializeForRendering();
205 qDebug() << "Document loaded successfully !";
206
207@@ -170,11 +151,13 @@
208 return QSize(pWidth, pHeight);
209 }
210
211-QImage LODocument::paintTile(const QSize& canvasSize, const QRect& tileSize, const qreal &zoom)
212+QImage LODocument::paintTile(int part, const QSize& canvasSize, const QRect& tileSize, const qreal &zoom)
213 {
214 if (!m_lokDocument)
215 return QImage();
216
217+ m_lokDocument->setPart(part);
218+
219 QImage result = QImage(canvasSize.width(), canvasSize.height(), QImage::Format_RGB32);
220
221 #ifdef DEBUG_TILE_BENCHMARK
222@@ -196,11 +179,13 @@
223 return result.rgbSwapped();
224 }
225
226-QImage LODocument::paintThumbnail(qreal size)
227+QImage LODocument::paintThumbnail(int part, qreal size)
228 {
229 if (!m_lokDocument)
230 return QImage();
231
232+ m_lokDocument->setPart(part);
233+
234 #ifdef DEBUG_TILE_BENCHMARK
235 QElapsedTimer renderTimer;
236 renderTimer.start();
237
238=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.h'
239--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2015-11-28 22:11:54 +0000
240+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2016-01-16 12:32:06 +0000
241@@ -33,7 +33,6 @@
242 Q_DISABLE_COPY(LODocument)
243
244 Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
245- Q_PROPERTY(int currentPart READ currentPart WRITE setCurrentPart NOTIFY currentPartChanged)
246 // Declare partsCount as constant at the moment, since LOK-plugin is just a viewer for now.
247 Q_PROPERTY(int partsCount READ partsCount CONSTANT)
248 Q_PROPERTY(int documentPart READ documentPart WRITE setDocumentPart NOTIFY documentPartChanged)
249@@ -56,9 +55,6 @@
250 QString path() const;
251 void setPath(const QString& pathName);
252
253- int currentPart();
254- void setCurrentPart(int index);
255-
256 DocumentType documentType() const;
257
258 int documentPart() const;
259@@ -66,8 +62,8 @@
260
261 QSize documentSize() const;
262
263- QImage paintTile(const QSize& canvasSize, const QRect& tileSize, const qreal& zoom = 1.0);
264- QImage paintThumbnail(qreal size);
265+ QImage paintTile(int part, const QSize& canvasSize, const QRect& tileSize, const qreal& zoom = 1.0);
266+ QImage paintThumbnail(int part, qreal size);
267
268 int partsCount();
269 QString getPartName(int index) const;
270@@ -77,14 +73,12 @@
271
272 Q_SIGNALS:
273 void pathChanged();
274- void currentPartChanged();
275 void documentTypeChanged();
276 void documentPartChanged();
277 void errorChanged();
278
279 private:
280 QString m_path;
281- int m_currentPart;
282 DocumentType m_docType;
283 LibreOfficeError::Error m_error;
284 lok::Document *m_lokDocument;
285
286=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lorendertask.cpp'
287--- src/plugin/libreofficetoolkit-qml-plugin/lorendertask.cpp 2015-12-12 10:06:55 +0000
288+++ src/plugin/libreofficetoolkit-qml-plugin/lorendertask.cpp 2016-01-16 12:32:06 +0000
289@@ -16,10 +16,10 @@
290
291 QImage TileRenderTask::doWork()
292 {
293- return m_document->paintTile(m_area.size(), m_area, m_zoom);
294+ return m_document->paintTile(m_part, m_area.size(), m_area, m_zoom);
295 }
296
297 QImage ThumbnailRenderTask::doWork()
298 {
299- return m_document->paintThumbnail(m_size);
300+ return m_document->paintThumbnail(m_part, m_size);
301 }
302
303=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lorendertask.h'
304--- src/plugin/libreofficetoolkit-qml-plugin/lorendertask.h 2015-12-12 10:06:55 +0000
305+++ src/plugin/libreofficetoolkit-qml-plugin/lorendertask.h 2016-01-16 12:32:06 +0000
306@@ -16,7 +16,7 @@
307 {
308 public:
309 virtual bool canBeRunInParallel(AbstractRenderTask* prevTask);
310- virtual void prepare() { m_document->setDocumentPart(m_part); }
311+ virtual void prepare() { /* do nothing */ }
312
313 int part() { return m_part; }
314 void setPart(int p) { m_part = p; }
315
316=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp'
317--- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-11-28 22:11:54 +0000
318+++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2016-01-16 12:32:06 +0000
319@@ -36,6 +36,7 @@
320 , m_parentFlickable(nullptr)
321 , m_document(nullptr)
322 , m_partsModel(nullptr)
323+ , m_currentPart(0)
324 , m_zoomFactor(1.0)
325 , m_cacheBuffer(TILE_SIZE * 3)
326 , m_visibleArea(0, 0, 0, 0)
327@@ -114,7 +115,8 @@
328 engine->addImageProvider("lok", m_imageProvider);
329 // --------------------------------------------------
330
331- connect(m_document.data(), SIGNAL(currentPartChanged()), this, SLOT(invalidateAllTiles()));
332+ setCurrentPart(0);
333+ connect(this, SIGNAL(currentPartChanged()), this, SLOT(invalidateAllTiles()));
334
335 Q_EMIT documentChanged();
336 }
337@@ -130,6 +132,22 @@
338 return m_partsModel;
339 }
340
341+int LOView::currentPart() {
342+ return m_currentPart;
343+}
344+
345+void LOView::setCurrentPart(int index)
346+{
347+ if (!m_document)
348+ return;
349+
350+ if (m_currentPart == index || index < 0 || index > (m_document.data()->partsCount() - 1))
351+ return;
352+
353+ m_currentPart = index;
354+ Q_EMIT currentPartChanged();
355+}
356+
357 qreal LOView::zoomFactor() const
358 {
359 return m_zoomFactor;
360@@ -399,7 +417,7 @@
361 {
362 TileRenderTask* task = new TileRenderTask();
363 task->setId(id);
364- task->setPart(m_document->currentPart());
365+ task->setPart(m_currentPart);
366 task->setDocument(m_document);
367 task->setArea(rect);
368 task->setZoom(m_zoomFactor);
369
370=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.h'
371--- src/plugin/libreofficetoolkit-qml-plugin/loview.h 2015-12-12 10:06:55 +0000
372+++ src/plugin/libreofficetoolkit-qml-plugin/loview.h 2016-01-16 12:32:06 +0000
373@@ -39,6 +39,7 @@
374 Q_PROPERTY(QQuickItem* parentFlickable READ parentFlickable WRITE setParentFlickable NOTIFY parentFlickableChanged)
375 Q_PROPERTY(LODocument* document READ document /*WRITE setDocument*/ NOTIFY documentChanged)
376 Q_PROPERTY(LOPartsModel* partsModel READ partsModel NOTIFY partsModelChanged)
377+ Q_PROPERTY(int currentPart READ currentPart WRITE setCurrentPart NOTIFY currentPartChanged)
378 Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
379 Q_PROPERTY(ZoomMode zoomMode READ zoomMode NOTIFY zoomModeChanged)
380 Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged)
381@@ -61,6 +62,9 @@
382 LODocument* document() const;
383 LOPartsModel* partsModel() const;
384
385+ int currentPart();
386+ void setCurrentPart(int index);
387+
388 qreal zoomFactor() const;
389 void setZoomFactor(const qreal zoom);
390
391@@ -77,6 +81,7 @@
392 void parentFlickableChanged();
393 void documentChanged();
394 void partsModelChanged();
395+ void currentPartChanged();
396 void zoomFactorChanged();
397 void zoomModeChanged();
398 void cacheBufferChanged();
399@@ -96,6 +101,7 @@
400 LOPartsModel* m_partsModel; // TODO MB move to document.
401 LOPartsImageProvider* m_imageProvider; // The QQmlEngine takes ownership of provider.
402
403+ int m_currentPart;
404 qreal m_zoomFactor;
405 ZoomMode m_zoomMode;
406 int m_cacheBuffer;
407
408=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml'
409--- src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml 2015-11-27 16:39:21 +0000
410+++ src/plugin/libreofficetoolkit-qml-plugin/qml/Viewer.qml 2016-01-16 12:32:06 +0000
411@@ -26,6 +26,7 @@
412 property alias partsModel: view.partsModel
413 property alias zoomMode: view.zoomMode
414 property alias error: view.error
415+ property alias currentPart: view.currentPart
416
417 property string documentPath: ""
418
419@@ -61,22 +62,22 @@
420
421 function goNextPart()
422 {
423- document.currentPart = Math.min(document.currentPart + 1, document.partsCount - 1)
424+ currentPart = Math.min(currentPart + 1, document.partsCount - 1)
425 }
426
427 function goPreviousPart()
428 {
429- document.currentPart = Math.max(0, document.currentPart - 1)
430+ currentPart = Math.max(0, currentPart - 1)
431 }
432
433 function goFirstPart()
434 {
435- document.currentPart = 0
436+ currentPart = 0
437 }
438
439 function goLastPart()
440 {
441- document.currentPart = document.partsCount - 1
442+ currentPart = document.partsCount - 1
443 }
444
445 onDocumentPathChanged: {
446@@ -97,10 +98,6 @@
447 id: view
448
449 parentFlickable: rootFlickable
450- }
451-
452- Connections {
453- target: view.document
454
455 onCurrentPartChanged: {
456 // Position view at top-left corner

Subscribers

People subscribed via source and target branches