Merge lp:~unity-team/unity8/tablePreviewWidget into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Michael Zanetti
Approved revision: 1106
Merged at revision: 1211
Proposed branch: lp:~unity-team/unity8/tablePreviewWidget
Merge into: lp:unity8
Prerequisite: lp:~saviq/unity8/preview-customizations
Diff against target: 263 lines (+202/-1)
6 files modified
qml/Dash/Previews/PreviewTable.qml (+80/-0)
qml/Dash/Previews/PreviewWidgetFactory.qml (+1/-0)
tests/qmltests/CMakeLists.txt (+1/-0)
tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml (+5/-1)
tests/qmltests/Dash/Previews/tst_PreviewTable.qml (+114/-0)
tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml (+1/-0)
To merge this branch: bzr merge lp:~unity-team/unity8/tablePreviewWidget
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Abstain
Michael Zanetti (community) Approve
Andrea Cimitan Pending
Review via email: mp+230787@code.launchpad.net

This proposal supersedes a proposal from 2014-08-08.

Commit message

Add table preview widget

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
Prerequisite lp:~saviq/unity8/preview-customizations

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes, only using tests though since no scope uses it

* Did you make sure that your branch does not contain spurious tags?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

* If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Weren't there designs that also had table headers? Should probably support that too...

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

Maybe they were designs with headers, but there is no mention of headers in the previews spec and i have not seen any design with headers.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1101. By Michał Sawicz

Merge lp:~saviq/unity8/preview-customizations

1102. By Michał Sawicz

Use theme's baseText instead of grey.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Are we ok with reaching out of context for widgetData?

See 2 inline questions

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

ok

 * Did you perform an exploratory manual test run of the code change and any related functionality?

positive

 * Did CI run pass? If not, please explain why.

negative (unrelated)

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

> Are we ok with reaching out of context for widgetData?

Hmm? widgetData is a property of all PreviewWidgets, where are we reaching out?

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

Merge lp:~saviq/unity8/preview-customizations

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) :
review: Abstain
1108. By Michał Sawicz

Merge lp:~saviq/unity8/preview-customizations

1109. By Michał Sawicz

Merge lp:~saviq/unity8/preview-customizations

1110. By Michał Sawicz

Merge lp:~saviq/unity8/preview-customizations

1111. By Albert Astals Cid

Merge trunk

1112. By Michał Sawicz

Merge lp:~saviq/unity8/preview-customizations

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mirco Müller (macslow) wrote :

I wonder why testDashContent failed on Jenkins, when tried locally it passed without a failure.

Revision history for this message
Michał Sawicz (saviq) wrote :

It segfaulted, see revision. It was 1107 instead of tip - 1112

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'qml/Dash/Previews/PreviewTable.qml'
2--- qml/Dash/Previews/PreviewTable.qml 1970-01-01 00:00:00 +0000
3+++ qml/Dash/Previews/PreviewTable.qml 2014-08-26 10:55:11 +0000
4@@ -0,0 +1,80 @@
5+/*
6+ * Copyright (C) 2014 Canonical, Ltd.
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+import QtQuick 2.0
22+import QtQuick.Layouts 1.1
23+import Ubuntu.Components 0.1
24+import "../../Components"
25+
26+/*! \brief Preview widget for table.
27+
28+ This widget shows two columns contained in widgetData["values"]
29+ as arrays of label,value along with a title that comes from widgetData["title"].
30+
31+ In case the widget is collapsed it only shows 3 lines of values.
32+ */
33+
34+PreviewWidget {
35+ id: root
36+ implicitHeight: column.implicitHeight
37+
38+ readonly property int maximumCollapsedRowCount: 3
39+
40+ Column {
41+ id: column
42+ objectName: "column"
43+ spacing: units.gu(1)
44+
45+ Label {
46+ id: titleLabel
47+ objectName: "titleLabel"
48+ anchors {
49+ left: parent.left
50+ right: parent.right
51+ }
52+ height: visible ? implicitHeight : 0
53+ fontSize: "large"
54+ color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
55+ visible: text !== ""
56+ opacity: .8
57+ text: widgetData["title"] || ""
58+ }
59+
60+ GridLayout {
61+ objectName: "gridLayout"
62+ columns: 2
63+ columnSpacing: units.gu(2)
64+ Repeater {
65+ id: rowsRepeater
66+ model: widgetData["values"]
67+
68+ delegate: Repeater {
69+ id: perRowRepeater
70+ readonly property int rowIndex: index
71+ model: widgetData["values"][index]
72+ delegate: Label {
73+ objectName: "label"+rowIndex+index
74+ fontSize: "small"
75+ text: perRowRepeater.model[index]
76+ visible: root.expanded || rowIndex < maximumCollapsedRowCount
77+ color: root.scopeStyle ? root.scopeStyle.foreground : Theme.palette.normal.baseText
78+ font.bold: index == 0
79+ }
80+ }
81+ }
82+ }
83+ }
84+}
85
86=== modified file 'qml/Dash/Previews/PreviewWidgetFactory.qml'
87--- qml/Dash/Previews/PreviewWidgetFactory.qml 2014-08-26 10:55:10 +0000
88+++ qml/Dash/Previews/PreviewWidgetFactory.qml 2014-08-26 10:55:11 +0000
89@@ -58,6 +58,7 @@
90 case "payments": return "PreviewPayments.qml";
91 case "rating-input": return "PreviewRatingInput.qml";
92 case "reviews": return "PreviewRatingDisplay.qml";
93+ case "table": return "PreviewTable.qml";
94 case "text": return "PreviewTextSummary.qml";
95 case "video": return "PreviewVideoPlayback.qml";
96 default: return "";
97
98=== modified file 'tests/qmltests/CMakeLists.txt'
99--- tests/qmltests/CMakeLists.txt 2014-08-25 13:10:28 +0000
100+++ tests/qmltests/CMakeLists.txt 2014-08-26 10:55:11 +0000
101@@ -50,6 +50,7 @@
102 add_qml_test(Dash/Previews PreviewProgress)
103 add_qml_test(Dash/Previews PreviewRatingDisplay)
104 add_qml_test(Dash/Previews PreviewRatingInput)
105+add_qml_test(Dash/Previews PreviewTable)
106 add_qml_test(Dash/Previews PreviewTextSummary)
107 add_qml_test(Dash/Previews PreviewVideoPlayback)
108 add_qml_test(Dash/Previews PreviewWidgetFactory)
109
110=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml'
111--- tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml 2014-08-21 11:23:33 +0000
112+++ tests/qmltests/Dash/Previews/tst_PreviewExpandable.qml 2014-08-26 10:55:11 +0000
113@@ -30,6 +30,10 @@
114 property string longText2: "This is a very very very long text. 1 This is a very very very long text. 2 This is a very very very long text. 3 This is a very very very long text. 4 This is a very very very long text. 5 This is a very very very long text. 6 This is a very very very long text. 7 This is a very very very long text. 8 This is a very very very long text. 9 This is a very very very long text. 10 This is a very very very long text. 11 This is a very very very long text."
115 property string shortText: "This is a short text :)"
116
117+ property var tableData: {
118+ "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
119+ }
120+
121 ListModel {
122 id: widgetsModel
123 }
124@@ -42,7 +46,7 @@
125
126 Component.onCompleted: {
127 widgetsModel.append({"type": "text", "widgetId": "text1", "properties": { "text": longText }});
128- widgetsModel.append({"type": "text", "widgetId": "text2", "properties": { "text": longText2 }});
129+ widgetsModel.append({"type": "text", "widgetId": "table1", "properties": { "text": tableData }});
130 widgetsModel.append({"type": "text", "widgetId": "text3", "properties": { "text": shortText }});
131 widgetsModel.append({"type": "text", "widgetId": "text4", "properties": { "text": longText }});
132 }
133
134=== added file 'tests/qmltests/Dash/Previews/tst_PreviewTable.qml'
135--- tests/qmltests/Dash/Previews/tst_PreviewTable.qml 1970-01-01 00:00:00 +0000
136+++ tests/qmltests/Dash/Previews/tst_PreviewTable.qml 2014-08-26 10:55:11 +0000
137@@ -0,0 +1,114 @@
138+/*
139+ * Copyright 2014 Canonical Ltd.
140+ *
141+ * This program is free software; you can redistribute it and/or modify
142+ * it under the terms of the GNU General Public License as published by
143+ * the Free Software Foundation; version 3.
144+ *
145+ * This program is distributed in the hope that it will be useful,
146+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
147+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
148+ * GNU General Public License for more details.
149+ *
150+ * You should have received a copy of the GNU General Public License
151+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
152+ */
153+
154+import QtQuick 2.0
155+import QtTest 1.0
156+import Ubuntu.Components 0.1
157+import "../../../../qml/Dash/Previews"
158+import Unity.Test 0.1 as UT
159+
160+Rectangle {
161+ id: root
162+ width: units.gu(40)
163+ height: units.gu(80)
164+ color: Theme.palette.selected.background
165+
166+ property var widgetDataComplete: {
167+ "title": "Title here",
168+ "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
169+ }
170+
171+ property var widgetDataNoTitle: {
172+ "values": [ [ "Long Label 1", "Value 1"], [ "Label 2", "Long Value 2"], [ "Label 3", "Value 3"], [ "Label 4", "Value 4"], [ "Label 5", "Value 5"] ]
173+ }
174+
175+ PreviewTable {
176+ id: previewTable
177+ anchors { left: parent.left; right: parent.right }
178+ widgetData: widgetDataComplete
179+
180+ Rectangle {
181+ color: "red"
182+ anchors.fill: parent
183+ opacity: 0.5
184+ }
185+ }
186+
187+ UT.UnityTestCase {
188+ name: "PreviewTableTest"
189+ when: windowShown
190+
191+ function init() {
192+ previewTable.widgetData = widgetDataComplete;
193+ }
194+
195+ function test_values() {
196+ compare(findChild(previewTable, "label00").text, "Long Label 1");
197+ compare(findChild(previewTable, "label01").text, "Value 1");
198+ compare(findChild(previewTable, "label10").text, "Label 2");
199+ compare(findChild(previewTable, "label11").text, "Long Value 2");
200+ compare(findChild(previewTable, "label20").text, "Label 3");
201+ compare(findChild(previewTable, "label21").text, "Value 3");
202+ compare(findChild(previewTable, "label30").text, "Label 4");
203+ compare(findChild(previewTable, "label31").text, "Value 4");
204+ compare(findChild(previewTable, "label40").text, "Label 5");
205+ compare(findChild(previewTable, "label41").text, "Value 5");
206+ }
207+
208+ function test_optional_title() {
209+ var titleLabel = findChild(previewTable, "titleLabel");
210+ compare(titleLabel.visible, true);
211+ var titleHeight = titleLabel.height;
212+ var prevHeight = previewTable.height;
213+
214+ previewTable.widgetData = widgetDataNoTitle;
215+ var column = findChild(previewTable, "column");
216+ tryCompare(previewTable, "height", prevHeight - titleHeight - column.spacing );
217+ }
218+
219+ function test_show_collapsed() {
220+ verify(findChild(previewTable, "label00").visible);
221+ verify(findChild(previewTable, "label01").visible);
222+ verify(findChild(previewTable, "label10").visible);
223+ verify(findChild(previewTable, "label11").visible);
224+ verify(findChild(previewTable, "label20").visible);
225+ verify(findChild(previewTable, "label21").visible);
226+ verify(findChild(previewTable, "label30").visible);
227+ verify(findChild(previewTable, "label31").visible);
228+ verify(findChild(previewTable, "label40").visible);
229+ verify(findChild(previewTable, "label41").visible);
230+
231+ waitForRendering(previewTable);
232+ var prevHeight = previewTable.height;
233+ previewTable.expanded = false;
234+
235+ verify(findChild(previewTable, "label00").visible);
236+ verify(findChild(previewTable, "label01").visible);
237+ verify(findChild(previewTable, "label10").visible);
238+ verify(findChild(previewTable, "label11").visible);
239+ verify(findChild(previewTable, "label20").visible);
240+ verify(findChild(previewTable, "label21").visible);
241+ verify(!findChild(previewTable, "label30").visible);
242+ verify(!findChild(previewTable, "label31").visible);
243+ verify(!findChild(previewTable, "label40").visible);
244+ verify(!findChild(previewTable, "label41").visible);
245+
246+ var labelHeight = findChild(previewTable, "label00").height;
247+ var gridLayout = findChild(previewTable, "gridLayout");
248+ tryCompare(previewTable, "height", prevHeight - labelHeight * 2 - gridLayout.rowSpacing * 2);
249+ }
250+ }
251+}
252
253=== modified file 'tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml'
254--- tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-07-30 14:08:29 +0000
255+++ tests/qmltests/Dash/Previews/tst_PreviewWidgetFactory.qml 2014-08-26 10:55:11 +0000
256@@ -84,6 +84,7 @@
257 { tag: "Progress", type: "progress", source: "PreviewProgress.qml" },
258 { tag: "Rating Input", type: "rating-input", source: "PreviewRatingInput.qml" },
259 { tag: "Rating Display", type: "reviews", source: "PreviewRatingDisplay.qml" },
260+ { tag: "Table", type: "table", source: "PreviewTable.qml" },
261 { tag: "Text", type: "text", source: "PreviewTextSummary.qml" },
262 { tag: "Video", type: "video", source: "PreviewVideoPlayback.qml" },
263 ];

Subscribers

People subscribed via source and target branches