Merge lp:~gcollura/ubuntu-calculator-app/reboot-better-scrolling-perf into lp:ubuntu-calculator-app

Proposed by Giulio Collura
Status: Merged
Approved by: Riccardo Padovani
Approved revision: 57
Merged at revision: 57
Proposed branch: lp:~gcollura/ubuntu-calculator-app/reboot-better-scrolling-perf
Merge into: lp:ubuntu-calculator-app
Diff against target: 202 lines (+81/-29)
3 files modified
app/ubuntu-calculator-app.qml (+79/-28)
app/upstreamcomponents/MultipleSelectionVisualModel.qml (+1/-1)
debian/copyright (+1/-0)
To merge this branch: bzr merge lp:~gcollura/ubuntu-calculator-app/reboot-better-scrolling-perf
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Bartosz Kosiorek Approve
Review via email: mp+245986@code.launchpad.net

Commit message

Improve scrolling performances by loading delegate items dynamically.

Description of the change

I've greatly improved scrolling performances, now rendering time is always around 10ms (see http://i.imgur.com/G7WqoGg.png). I've used a similar technique that music-app and ureadit are using.

To post a comment you must log in.
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

Works perfectly for me.

Thanks Giulio.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/ubuntu-calculator-app.qml'
2--- app/ubuntu-calculator-app.qml 2015-01-06 22:10:04 +0000
3+++ app/ubuntu-calculator-app.qml 2015-01-09 17:35:57 +0000
4@@ -69,12 +69,20 @@
5 StateChangeScript {
6 script: header.hide()
7 }
8+ PropertyChanges {
9+ target: scrollableView
10+ clip: false
11+ }
12 },
13 State {
14 name: "selection"
15 StateChangeScript {
16 script: header.show()
17 }
18+ PropertyChanges {
19+ target: scrollableView
20+ clip: true
21+ }
22 }
23 ]
24
25@@ -234,30 +242,31 @@
26 }
27 }
28
29- MultipleSelectionVisualModel {
30- id: visualModel
31- model: calculationHistory.getContents()
32-
33- onSelectionDone: {
34- for (var i = 0; i < items.count; i++) {
35- calculationHistory.deleteCalc(items.get(i).model.dbId, items.get(i).model.index);
36- }
37- }
38-
39- delegate: Screen {
40+ Component {
41+ id: emptyDelegate
42+ Item { }
43+ }
44+
45+ Component {
46+ id: screenDelegateComponent
47+ Screen {
48 id: screenDelegate
49 width: parent ? parent.width : 0
50
51+ property var model: itemModel
52 visible: model.dbId != -1
53
54 selectionMode: visualModel.isInSelectionMode
55- selected: visualModel.isSelected(screenDelegate)
56+ selected: visualModel.isSelected(visualDelegate)
57
58 property var removalAnimation
59 function remove() {
60 removalAnimation.start();
61 }
62
63+ // parent is the loader component
64+ property var visualDelegate: parent ? parent : null
65+
66 onSwippingChanged: {
67 visualModel.updateSwipeState(screenDelegate);
68 }
69@@ -268,22 +277,27 @@
70
71 onItemClicked: {
72 if (visualModel.isInSelectionMode) {
73- if (!visualModel.selectItem(screenDelegate)) {
74- visualModel.deselectItem(screenDelegate);
75+ if (!visualModel.selectItem(visualDelegate)) {
76+ visualModel.deselectItem(visualDelegate);
77 }
78 }
79 }
80
81 onItemPressAndHold: {
82 visualModel.startSelection();
83- visualModel.selectItem(screenDelegate);
84+ visualModel.selectItem(visualDelegate);
85 }
86
87- leftSideAction: Action {
88- iconName: "delete"
89- text: i18n.tr("Delete")
90- onTriggered: {
91- screenDelegate.remove();
92+ leftSideAction: screenDelegateDeleteAction.item
93+
94+ Loader {
95+ id: screenDelegateDeleteAction
96+ sourceComponent: Action {
97+ iconName: "delete"
98+ text: i18n.tr("Delete")
99+ onTriggered: {
100+ screenDelegate.remove();
101+ }
102 }
103 }
104
105@@ -306,12 +320,42 @@
106
107 ScriptAction {
108 script: {
109- calculationHistory.deleteCalc(dbId, index);
110- }
111- }
112- }
113- }
114-
115+ calculationHistory.deleteCalc(model.dbId, model.index);
116+ }
117+ }
118+ }
119+ }
120+ }
121+
122+ MultipleSelectionVisualModel {
123+ id: visualModel
124+ model: calculationHistory.getContents()
125+
126+ onSelectionDone: {
127+ for (var i = 0; i < items.count; i++) {
128+ calculationHistory.deleteCalc(items.get(i).model.dbId, items.get(i).model.index);
129+ }
130+ }
131+
132+ delegate: Component {
133+ Loader {
134+ property var itemModel: model
135+ width: parent.width
136+ height: model.dbId != -1 ? item.height : 0;
137+ sourceComponent: screenDelegateComponent
138+ opacity: ((y+height) >= scrollableView.contentY) && (y <= (scrollableView.contentY + scrollableView.height)) ? 1 : 0
139+ onOpacityChanged: {
140+ if (this.hasOwnProperty('item') && this.item != null) {
141+ if (opacity > 0) {
142+ sourceComponent = screenDelegateComponent;
143+ } else {
144+ this.item.visible = false;
145+ sourceComponent = emptyDelegate;
146+ }
147+ }
148+ }
149+ }
150+ }
151 }
152
153 ScrollableView {
154@@ -323,7 +367,14 @@
155 }
156 id: scrollableView
157 objectName: "scrollableView"
158- clip: true
159+
160+ Component.onCompleted: {
161+ // FIXME: workaround for qtubuntu not returning values depending on the grid unit definition
162+ // for Flickable.maximumFlickVelocity and Flickable.flickDeceleration
163+ var scaleFactor = units.gridUnit / 8;
164+ maximumFlickVelocity = maximumFlickVelocity * scaleFactor;
165+ flickDeceleration = flickDeceleration * scaleFactor;
166+ }
167
168 Repeater {
169 id: formulaView
170@@ -371,8 +422,8 @@
171 id: keyboardLoader
172 width: parent.width
173 source: mainView.width > mainView.height ? "ui/LandscapeKeyboard.qml" : "ui/PortraiKeyboard.qml"
174+ opacity: ((y+height) >= scrollableView.contentY) && (y <= (scrollableView.contentY + scrollableView.height)) ? 1 : 0
175 }
176-
177 }
178 }
179
180
181=== modified file 'app/upstreamcomponents/MultipleSelectionVisualModel.qml'
182--- app/upstreamcomponents/MultipleSelectionVisualModel.qml 2015-01-05 10:34:35 +0000
183+++ app/upstreamcomponents/MultipleSelectionVisualModel.qml 2015-01-09 17:35:57 +0000
184@@ -1,5 +1,5 @@
185 /*
186- * Copyright (C) 2012-2013 Canonical, Ltd.
187+ * Copyright (C) 2012-2015 Canonical, Ltd.
188 *
189 * This program is free software; you can redistribute it and/or modify
190 * it under the terms of the GNU General Public License as published by
191
192=== modified file 'debian/copyright'
193--- debian/copyright 2015-01-05 12:19:09 +0000
194+++ debian/copyright 2015-01-09 17:35:57 +0000
195@@ -7,6 +7,7 @@
196 2014 Bartosz Kosiorek <gang65@poczta.onet.pl>
197 2014 Michael Zanetti <michael.zanetti@canonical.com>
198 2014-2015 Riccardo Padovani <rpadovani@ubuntu.com>
199+ 2015 Giulio Collura <giulio.collura@gmail.com>
200 License: GPL-3
201
202 Files: debian/*

Subscribers

People subscribed via source and target branches