Merge lp:~unity-team/unity8/new-scopes-vj-integration into lp:~unity-team/unity8/new-scopes

Proposed by Albert Astals Cid
Status: Rejected
Rejected by: Albert Astals Cid
Proposed branch: lp:~unity-team/unity8/new-scopes-vj-integration
Merge into: lp:~unity-team/unity8/new-scopes
Diff against target: 381 lines (+337/-1)
5 files modified
qml/Components/ResponsiveVerticalJournal.qml (+68/-0)
qml/Dash/CardVerticalJournal.qml (+60/-0)
qml/Dash/GenericScopeView.qml (+2/-1)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml (+206/-0)
To merge this branch: bzr merge lp:~unity-team/unity8/new-scopes-vj-integration
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Needs Fixing
Michał Sawicz Pending
Review via email: mp+214786@code.launchpad.net

This proposal supersedes a proposal from 2014-01-16.

Description of the change

Add VerticalJournal integration.

To post a comment you must log in.
Revision history for this message
Michał Karnicki (karni) wrote : Posted in a previous version of this proposal

PS the abstractjournal.cpp and verticaljournal.cpp changes come from Albert, and have been merged in a different branch already. I added them to avoid crashers.

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Number of columns should be dynamic based on delegate width.

review: Needs Fixing
Revision history for this message
Michał Karnicki (karni) wrote : Posted in a previous version of this proposal
Revision history for this message
Michał Karnicki (karni) wrote : Posted in a previous version of this proposal

unity-scope-tool shows nothing, when JSON updated to: 'category-layout': 'vertical-journal' :(

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Why left, right and top margin but no bottom margin?

review: Needs Information
Revision history for this message
Michał Karnicki (karni) wrote : Posted in a previous version of this proposal

I followed ResponsiveGridView implementation as reference. Added bottom margin.

Revision history for this message
Michał Karnicki (karni) wrote : Posted in a previous version of this proposal

Getting seg fault'ed when I add the filtering capability. Will have to leave this to Saviq.

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

I'm sure we can debug that crash without Saviq, which stacktrace are you getting? How easy is it to reproduce?

Revision history for this message
Michał Karnicki (karni) wrote : Posted in a previous version of this proposal

lp:~unity-team/unity8/new-scopes-vj-integration-filter
$ ./build -c
$ ./builddir/tools/unity-scope-tool
Override category -> set category-layout to "vertical-journal", apply.
Notice seg fault.

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Does not segfault here :S

Are you doing any other change? Or do you have uncommited changes?

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Can you rebase (except for CardVerticalJournal) onto lp:unity8 at some point please?

Revision history for this message
Albert Astals Cid (aacid) wrote :

Needs resubmission against lp:unity8

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

We don't do new-scopes anymore

Unmerged revisions

590. By Michał Karnicki

Expand CardVerticalJournal to fill its parent.

589. By Michał Karnicki

Add bottom margin.

588. By Michał Karnicki

Fetch template and components from DashRenderer. Set RVJ columnWidth cased on card size from template.

587. By Michał Karnicki

Bind ResponsiveVJ model and height.

586. By Michał Karnicki

Update CardVerticalJournal defaults.

585. By Michał Karnicki

Make column count dynamic.

584. By Michał Karnicki

Fix copyright headers.

583. By Michał Karnicki

Don't try to fix the header title positioning with hardcorded value.

582. By Michał Karnicki

Fix column and row spacing tests.

581. By Michał Karnicki

Add ResponsiveVerticalJournal tests. column and row spacing still not passing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/DashViews/abstractdashview.cpp'
2=== modified file 'plugins/DashViews/verticaljournal.cpp'
3=== added file 'qml/Components/ResponsiveVerticalJournal.qml'
4--- qml/Components/ResponsiveVerticalJournal.qml 1970-01-01 00:00:00 +0000
5+++ qml/Components/ResponsiveVerticalJournal.qml 2014-04-08 15:12:51 +0000
6@@ -0,0 +1,68 @@
7+/*
8+ * Copyright (C) 2013-2014 Canonical, Ltd.
9+ *
10+ * This program is free software; you can redistribute it and/or modify
11+ * it under the terms of the GNU General Public License as published by
12+ * the Free Software Foundation; version 3.
13+ *
14+ * This program is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public License
20+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+import QtQuick 2.0
24+import Ubuntu.Components 0.1
25+import "../Components"
26+import DashViews 0.1
27+
28+// A VerticalJournal, which allows setting max number of columns. Based on
29+// defined column width, delegates are spread in the horizontal space.
30+Item {
31+ property int minimumColumnSpacing: units.gu(0.5)
32+ property int maximumNumberOfColumns: 2
33+
34+ property alias columnWidth: verticalJournalView.columnWidth
35+ property alias rowSpacing: verticalJournalView.rowSpacing
36+ property alias model: verticalJournalView.model
37+ property alias delegate: verticalJournalView.delegate
38+ property alias delegateCreationBegin: verticalJournalView.delegateCreationBegin
39+ property alias delegateCreationEnd: verticalJournalView.delegateCreationEnd
40+
41+ //readonly property alias currentItem // TODO bug #1269024
42+
43+ VerticalJournal {
44+ id: verticalJournalView
45+ objectName: "responsiveVerticalJournalView"
46+ anchors {
47+ fill: parent
48+ leftMargin: columnSpacing/2
49+ rightMargin: columnSpacing/2
50+ topMargin: rowSpacing/2
51+ bottomMargin: rowSpacing/2
52+ }
53+ clip: parent.height != implicitHeight
54+
55+ function px2gu(pixels) {
56+ return Math.floor(pixels / units.gu(1))
57+ }
58+
59+ function columnsForSpacing(spacing) {
60+ // parent.width = columns * columnWidth +
61+ // (columns-1) * spacing + spacing(margins)
62+ return Math.max(1, Math.floor(parent.width / (columnWidth + spacing)))
63+ }
64+
65+ function spacingForColumns(columns) {
66+ var spacingGU = px2gu((parent.width - columns * columnWidth) / columns)
67+ return units.gu(spacingGU)
68+ }
69+
70+ property int expectedColumns: Math.min(
71+ columnsForSpacing(minimumColumnSpacing), maximumNumberOfColumns)
72+ columnSpacing: spacingForColumns(expectedColumns)
73+ }
74+}
75
76=== added file 'qml/Dash/CardVerticalJournal.qml'
77--- qml/Dash/CardVerticalJournal.qml 1970-01-01 00:00:00 +0000
78+++ qml/Dash/CardVerticalJournal.qml 2014-04-08 15:12:51 +0000
79@@ -0,0 +1,60 @@
80+/*
81+ * Copyright (C) 2013 Canonical, Ltd.
82+ *
83+ * This program is free software; you can redistribute it and/or modify
84+ * it under the terms of the GNU General Public License as published by
85+ * the Free Software Foundation; version 3.
86+ *
87+ * This program is distributed in the hope that it will be useful,
88+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
89+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90+ * GNU General Public License for more details.
91+ *
92+ * You should have received a copy of the GNU General Public License
93+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
94+ */
95+
96+import QtQuick 2.0
97+import Ubuntu.Components 0.1
98+import "../Components"
99+
100+DashRenderer {
101+ id: genericVerticalJournal
102+
103+ property alias minimumColumnSpacing: cardVerticalJournal.minimumColumnSpacing
104+ property alias maximumNumberOfColumns: cardVerticalJournal.maximumNumberOfColumns
105+ property alias columnWidth: cardVerticalJournal.columnWidth
106+ property alias rowSpacing: cardVerticalJournal.rowSpacing
107+
108+ anchors.fill: parent
109+
110+ ResponsiveVerticalJournal {
111+ id: cardVerticalJournal
112+ anchors.fill: parent
113+ maximumNumberOfColumns: 2
114+ minimumColumnSpacing: units.gu(1)
115+ rowSpacing: units.gu(1)
116+ model: genericVerticalJournal.model
117+
118+ columnWidth: {
119+ if (genericVerticalJournal.template !== undefined) {
120+ switch (genericVerticalJournal.template['card-size']) {
121+ case "small": return units.gu(12);
122+ case "large": return units.gu(38);
123+ }
124+ }
125+ return units.gu(18.5);
126+ }
127+
128+ delegate: Card {
129+ id: card
130+ objectName: "delegate" + index
131+ cardData: model
132+ template: genericVerticalJournal.template
133+ components: genericVerticalJournal.components
134+
135+ //onClicked: cardVerticalJournal.clicked(index, tile.y)
136+ //onPressAndHold: cardVerticalJournal.pressAndHold(index, tile.y)
137+ }
138+ }
139+}
140
141=== modified file 'qml/Dash/GenericScopeView.qml'
142--- qml/Dash/GenericScopeView.qml 2014-03-06 11:06:07 +0000
143+++ qml/Dash/GenericScopeView.qml 2014-04-08 15:12:51 +0000
144@@ -1,5 +1,5 @@
145 /*
146- * Copyright (C) 2013 Canonical, Ltd.
147+ * Copyright (C) 2013-2014 Canonical, Ltd.
148 *
149 * This program is free software; you can redistribute it and/or modify
150 * it under the terms of the GNU General Public License as published by
151@@ -339,6 +339,7 @@
152 }
153 switch (layout) {
154 case "carousel": return "CardCarousel.qml";
155+ case "vertical-journal": return "CardVerticalJournal.qml";
156 case "grid":
157 default: return "CardFilterGrid.qml";
158 }
159
160=== modified file 'tests/qmltests/CMakeLists.txt'
161--- tests/qmltests/CMakeLists.txt 2014-03-03 12:24:20 +0000
162+++ tests/qmltests/CMakeLists.txt 2014-04-08 15:12:51 +0000
163@@ -32,6 +32,7 @@
164 add_qml_test(Components Rating)
165 add_qml_test(Components ResponsiveFlowView)
166 add_qml_test(Components ResponsiveGridView)
167+add_qml_test(Components ResponsiveVerticalJournal IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
168 add_qml_test(Components Revealer)
169 add_qml_test(Components SeeMore)
170 add_qml_test(Components Showable)
171
172=== added file 'tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml'
173--- tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml 1970-01-01 00:00:00 +0000
174+++ tests/qmltests/Components/tst_ResponsiveVerticalJournal.qml 2014-04-08 15:12:51 +0000
175@@ -0,0 +1,206 @@
176+/*
177+ * Copyright 2013-2014 Canonical Ltd.
178+ *
179+ * This program is free software; you can redistribute it and/or modify
180+ * it under the terms of the GNU General Public License as published by
181+ * the Free Software Foundation; version 3.
182+ *
183+ * This program is distributed in the hope that it will be useful,
184+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
185+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
186+ * GNU General Public License for more details.
187+ *
188+ * You should have received a copy of the GNU General Public License
189+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
190+ */
191+
192+import QtQuick 2.0
193+import QtTest 1.0
194+import ".."
195+import "../../../qml/Components"
196+import Ubuntu.Components.ListItems 0.1 as ListItem
197+import Ubuntu.Components 0.1
198+import Utils 0.1
199+import Unity.Test 0.1 as UT
200+
201+Item {
202+ width: journalRect.width + controls.width
203+ height: units.gu(80)
204+
205+ Column {
206+ id: controls
207+ width: units.gu(40)
208+ height: parent.height
209+ anchors.top: parent.top
210+ anchors.right: parent.right
211+ ListItem.ValueSelector {
212+ id: cardSizeSelector
213+ text: "card-size"
214+ // small, medium, large card sizes
215+ values: [units.gu(12), units.gu(18.5), units.gu(38)]
216+ selectedIndex: 0
217+ }
218+ ListItem.ValueSelector {
219+ id: minColumnSpacingSelector
220+ text: "minColumnSpacing"
221+ values: [0, units.gu(2), units.gu(8), units.gu(25)]
222+ selectedIndex: 0
223+ }
224+ ListItem.ValueSelector {
225+ id: maxColumnsSelector
226+ text: "maxColumns"
227+ values: [1, 2, 3, 8, 15, fakeModel.count]
228+ selectedIndex: 1
229+ }
230+ ListItem.ValueSelector {
231+ id: rowSpacingSelector
232+ text: "rowSpacing"
233+ values: [units.gu(1), units.gu(2), units.gu(4), units.gu(8)]
234+ selectedIndex: 1
235+ }
236+ }
237+
238+ ListModel {
239+ id: fakeModel
240+ ListElement { name: "A" }
241+ ListElement { name: "B" }
242+ ListElement { name: "C" }
243+ ListElement { name: "D" }
244+ ListElement { name: "E" }
245+ ListElement { name: "F" }
246+ ListElement { name: "G" }
247+ ListElement { name: "H" }
248+ ListElement { name: "I" }
249+ ListElement { name: "J" }
250+ ListElement { name: "K" }
251+ ListElement { name: "L" }
252+ ListElement { name: "M" }
253+ ListElement { name: "N" }
254+ ListElement { name: "O" }
255+ ListElement { name: "P" }
256+ ListElement { name: "Q" }
257+ ListElement { name: "R" }
258+ ListElement { name: "S" }
259+ ListElement { name: "T" }
260+ ListElement { name: "U" }
261+ }
262+
263+ SortFilterProxyModel {
264+ id: wrappedFakeModel
265+ model: fakeModel
266+ }
267+
268+ Rectangle {
269+ id: journalRect
270+ width: units.gu(80)
271+ height: parent.height
272+ color: "grey"
273+ anchors.top: parent.top
274+ anchors.left: parent.left
275+
276+ ResponsiveVerticalJournal {
277+ id: journal
278+ anchors.fill: parent
279+ model: wrappedFakeModel
280+ minimumColumnSpacing: minColumnSpacingSelector.
281+ values[minColumnSpacingSelector.selectedIndex]
282+ maximumNumberOfColumns:
283+ maxColumnsSelector.values[maxColumnsSelector.selectedIndex]
284+ rowSpacing:
285+ rowSpacingSelector.values[rowSpacingSelector.selectedIndex]
286+ columnWidth: // XXX karni: How do I get that from the delegate?
287+ cardSizeSelector.values[cardSizeSelector.selectedIndex]
288+
289+ delegate: Rectangle {
290+ id: delegateItem
291+ // So that it can be identified by test code
292+ property bool isJournalDelegate: true
293+ objectName: "delegate" + index
294+ color: "grey"
295+ border.color: "red"
296+ border.width: 1
297+
298+ // width derived from Card's template['card-size']
299+ width: cardSizeSelector.values[cardSizeSelector.selectedIndex]
300+ height: Math.max(units.gu(8), Math.floor(Math.random() * 300))
301+
302+ Rectangle {
303+ color: "green"
304+ anchors.centerIn: parent
305+ width: units.gu(6)
306+ height: units.gu(6)
307+ Text {
308+ anchors.centerIn: parent
309+ text: name
310+ }
311+ }
312+
313+ Text { x:0; y:0; text:"(" + parent.x + ", " + parent.y + ")"}
314+ }
315+ }
316+ }
317+
318+ UT.UnityTestCase {
319+ name: "ResponsiveVerticalJournal"
320+ when: windowShown
321+
322+ function test_minimumColumnSpacing_data() {
323+ var data = new Array()
324+ data.push({minColumnSpacingIndex: 0, expectedColumns: 2})
325+ data.push({minColumnSpacingIndex: 1, expectedColumns: 2})
326+ data.push({minColumnSpacingIndex: 2, expectedColumns: 1})
327+ return data
328+ }
329+
330+ // Test how minimumColumnSpacing affects column count.
331+ function test_minimumColumnSpacing(data) {
332+ cardSizeSelector.selectedIndex = 2 // large card
333+ maxColumnsSelector.selectedIndex = 1 // two columns
334+
335+ minColumnSpacingSelector.selectedIndex = data.minColumnSpacingIndex
336+
337+ tryCompareFunction(countJournalDelegatesOnFirstRow, data.expectedColumns)
338+ }
339+
340+ function test_maximumNumberOfColumns_data() {
341+ var data = new Array()
342+ // Change maxColumns
343+ data.push({maxColumnsIndex: 0, cardSizeIndex: 0, expectedColumns: 1})
344+ data.push({maxColumnsIndex: 1, cardSizeIndex: 0, expectedColumns: 2})
345+ data.push({maxColumnsIndex: 2, cardSizeIndex: 0, expectedColumns: 3})
346+ data.push({maxColumnsIndex: 3, cardSizeIndex: 0, expectedColumns: 6})
347+ data.push({maxColumnsIndex: 4, cardSizeIndex: 0, expectedColumns: 6})
348+ // Change card size
349+ data.push({maxColumnsIndex: 3, cardSizeIndex: 1, expectedColumns: 4})
350+ data.push({maxColumnsIndex: 3, cardSizeIndex: 2, expectedColumns: 2})
351+ return data
352+ }
353+
354+ // Test how maximumNumberOfColumns and columnWidth affect column count.
355+ function test_maximumNumberOfColumns(data) {
356+ minColumnSpacingSelector.selectedIndex = 0 // no spacing
357+
358+ cardSizeSelector.selectedIndex = data.cardSizeIndex // columnWidth
359+ maxColumnsSelector.selectedIndex = data.maxColumnsIndex
360+
361+ tryCompareFunction(countJournalDelegatesOnFirstRow, data.expectedColumns)
362+ }
363+
364+ function countJournalDelegatesOnFirstRow() {
365+ return __countJournalDelegatesOnFirstRow(journal.visibleChildren, 0)
366+ }
367+
368+ function __countJournalDelegatesOnFirstRow(objList, total) {
369+ for (var i = 0; i < objList.length; ++i) {
370+ var child = objList[i];
371+ if (child.isJournalDelegate !== undefined && child.y === 0) {
372+ ++total;
373+ } else {
374+ total = __countJournalDelegatesOnFirstRow(
375+ child.visibleChildren, total)
376+ }
377+ }
378+ return total
379+ }
380+ }
381+}

Subscribers

People subscribed via source and target branches

to all changes: