Merge lp:~aacid/unity/remove_qsortfilterproxymodelqml_get into lp:unity/phablet

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michał Sawicz
Approved revision: no longer in the source branch.
Merged at revision: 666
Proposed branch: lp:~aacid/unity/remove_qsortfilterproxymodelqml_get
Merge into: lp:unity/phablet
Diff against target: 181 lines (+23/-48)
7 files modified
Dash/Dash.qml (+0/-16)
Dash/DashHome.qml (+3/-4)
Dash/DashVideos.qml (+13/-5)
Dash/Video/VideoPreview.qml (+3/-3)
Dash/Video/VideosFilterGrid.qml (+4/-2)
plugins/Utils/qsortfilterproxymodelqml.cpp (+0/-17)
plugins/Utils/qsortfilterproxymodelqml.h (+0/-1)
To merge this branch: bzr merge lp:~aacid/unity/remove_qsortfilterproxymodelqml_get
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+162955@code.launchpad.net

Commit message

Remove ::get() in qsortfilterproxymodelqml

Using ::get() means that all the data of the model for a given row is obtained which in most of the cases is unnecessary and in some could mean getting expensive data. This data should be somewhere in the QML already so we should use that and not re-query it again

Description of the change

The new if in DashVideos.qml is a bit ugly, but if we don't want that it'll require a bit of surgery at the Carousel level, that given that we plan to use the Listview'ed one "soon" i'd prefer not to do at the moment.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Please fix the comment re: the function - it did work, but wasn't called in correct places. Since we're switching to smart scopes soon, this will no longer be there anyway. So maybe we just drop it altogether already?

Please also add a comment to the commit message as to why we're removing the ::get().

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Dash/Dash.qml'
2--- Dash/Dash.qml 2013-02-27 17:36:32 +0000
3+++ Dash/Dash.qml 2013-05-08 13:31:29 +0000
4@@ -30,21 +30,6 @@
5 width: units.gu(40)
6 height: units.gu(71)
7
8- function updateLensesViewType(currentLensIndex, homeLensSelected) {
9- /* Lens.viewType need to be set for all lenses when switching lenses.
10- If showing the home lens, viewType must be set to "HomeView",
11- otherwise viewType must be set to "Hidden" for the non current lenses.
12- */
13- for (var i=0; i<filteredLenses.count; i++) {
14- var lens = filteredLenses.get(i)
15- if (homeLensSelected) {
16- lens.viewType = (i === currentLensIndex) ? Lens.LensView : Lens.HomeView
17- } else {
18- lens.viewType = (i === currentLensIndex) ? Lens.LensView : Lens.Hidden
19- }
20- }
21- }
22-
23 function setCurrentLens(lensId, animate, reset) {
24 var lensIndex = filteredLenses.findFirst(Lenses.RoleId, lensId)
25
26@@ -58,7 +43,6 @@
27 return
28 }
29
30- updateLensesViewType(lensIndex, (lensId == "home.lens"))
31 dashContent.setCurrentLensAtIndex(lensIndex, animate, reset)
32 }
33
34
35=== modified file 'Dash/DashHome.qml'
36--- Dash/DashHome.qml 2013-04-16 09:32:38 +0000
37+++ Dash/DashHome.qml 2013-05-08 13:31:29 +0000
38@@ -156,10 +156,9 @@
39 //FIXME: workaround for lack of previews for videos in Home lens.
40 //Need to connect to the clicked() signal here and act upon it here instead.
41 if (component === "VideosGrid") {
42- function playVideo(index) {
43- var video = item.model.get(index);
44- if (video && video.fileName) {
45- shell.activateApplication('/usr/share/applications/media-player.desktop', "/usr/share/demo-assets/videos/" + video.fileName);
46+ function playVideo(index, data) {
47+ if (data.fileUri) {
48+ shell.activateApplication('/usr/share/applications/media-player.desktop', "/usr/share/demo-assets/videos/" + data.fileUri);
49 }
50 }
51
52
53=== modified file 'Dash/DashVideos.qml'
54--- Dash/DashVideos.qml 2013-04-29 23:47:43 +0000
55+++ Dash/DashVideos.qml 2013-05-08 13:31:29 +0000
56@@ -117,9 +117,17 @@
57 Connections {
58 target: loader.item
59 onClicked: {
60- var item = loader.item.model.get(index)
61- if (item.column_5 != "") {
62- previewLoader.videoItem = loader.item.model.get(index);
63+ var dataItem;
64+ // VideosCarousel and VideosFilterGrid have different
65+ // clicked signals, accomodate for that
66+ if (categoryId == 0) {
67+ var fileUri = delegateItem.model.column_0.replace(/^[^:]+:/, "")
68+ dataItem = {fileUri: fileUri, nfoUri: delegateItem.model.column_5}
69+ } else {
70+ dataItem = data;
71+ }
72+ if (dataItem.nfoUri != "") {
73+ previewLoader.videoData = dataItem;
74 previewLoader.open = true;
75 effect.positionPx = mapToItem(categoryView, 0, itemY).y;
76 }
77@@ -156,7 +164,7 @@
78
79 property bool open: false
80 property bool onScreen: false
81- property var videoItem
82+ property var videoData
83
84
85 onOpenChanged: {
86@@ -166,7 +174,7 @@
87 }
88
89 onLoaded: {
90- item.item = videoItem;
91+ item.item = videoData;
92 }
93 }
94
95
96=== modified file 'Dash/Video/VideoPreview.qml'
97--- Dash/Video/VideoPreview.qml 2013-02-27 17:20:00 +0000
98+++ Dash/Video/VideoPreview.qml 2013-05-08 13:31:29 +0000
99@@ -24,15 +24,15 @@
100
101 property var item
102 property alias ready: nfo.ready
103- property url fileUri: item ? item.column_0.replace(/^[^:]+:/, "") : ""
104+ readonly property url fileUri: item ? item.fileUri : ""
105
106 VideoInfo {
107 id: nfo
108- source: item ? item.column_5 : ""
109+ source: item ? item.nfoUri : ""
110 }
111
112 title: nfo.ready ? nfo.video.title : ""
113- url: item ? item.column_5.replace(/\.nfo$/, "-fanart.jpg") : ""
114+ url: item ? item.nfoUri.replace(/\.nfo$/, "-fanart.jpg") : ""
115 previewWidthRatio: 0.6
116 playable: fileUri != ""
117
118
119=== modified file 'Dash/Video/VideosFilterGrid.qml'
120--- Dash/Video/VideosFilterGrid.qml 2013-04-22 10:10:47 +0000
121+++ Dash/Video/VideosFilterGrid.qml 2013-05-08 13:31:29 +0000
122@@ -30,7 +30,7 @@
123 readonly property int iconWidth: (width / columns) * 0.8
124 readonly property int iconHeight: iconWidth * 16 / 11
125
126- signal clicked(int index, real itemY)
127+ signal clicked(int index, var data, real itemY)
128
129 delegate: Tile {
130 id: tile
131@@ -43,7 +43,9 @@
132 source: model.column_1
133 fillMode: Image.PreserveAspectCrop
134 onClicked: {
135- filtergrid.clicked(index, tile.y);
136+ var fileUri = model.column_0.replace(/^[^:]+:/, "")
137+ var data = {fileUri: fileUri, nfoUri: model.column_5}
138+ filtergrid.clicked(index, data, tile.y);
139 }
140 }
141 }
142
143=== modified file 'plugins/Utils/qsortfilterproxymodelqml.cpp'
144--- plugins/Utils/qsortfilterproxymodelqml.cpp 2013-05-08 13:24:15 +0000
145+++ plugins/Utils/qsortfilterproxymodelqml.cpp 2013-05-08 13:31:29 +0000
146@@ -57,23 +57,6 @@
147 }
148 }
149
150-QVariantMap
151-QSortFilterProxyModelQML::get(int row)
152-{
153- if (sourceModel() == NULL) {
154- return QVariantMap();
155- }
156-
157- const QModelIndex modelIndex = index(row, 0);
158- QVariantMap result;
159- QHashIterator<int, QByteArray> i(roleNames());
160- while (i.hasNext()) {
161- i.next();
162- result[i.value()] = modelIndex.data(i.key());
163- }
164- return result;
165-}
166-
167 int
168 QSortFilterProxyModelQML::totalCount() const
169 {
170
171=== modified file 'plugins/Utils/qsortfilterproxymodelqml.h'
172--- plugins/Utils/qsortfilterproxymodelqml.h 2013-04-16 15:54:41 +0000
173+++ plugins/Utils/qsortfilterproxymodelqml.h 2013-05-08 13:31:29 +0000
174@@ -31,7 +31,6 @@
175 public:
176 explicit QSortFilterProxyModelQML(QObject *parent = 0);
177
178- Q_INVOKABLE QVariantMap get(int row);
179 Q_INVOKABLE int count();
180 Q_INVOKABLE int findFirst(int role, const QVariant& value) const;
181 virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;

Subscribers

People subscribed via source and target branches