on xenial help sign in
Merged albert branch
5d59c17Andrea Cimitan
qml/Components/ResponsiveGridView.qml+2−4
@@ -18,12 +18,10 @@ import QtQuick 2.4
18import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
19
19
20/*
20/*
21− Essentially a GridView where you can specify the maximum number of columns it can have.
21+ Essentially a GridView
22 */
22 */
23Item {
23Item {
24 property int minimumHorizontalSpacing: units.gu(0.5)
24 property int minimumHorizontalSpacing: units.gu(0.5)
25− // property int minimumNumberOfColumns: 2 // FIXME: not implemented
26− property int maximumNumberOfColumns: 6
27 readonly property int columns: gridView.columns
25 readonly property int columns: gridView.columns
28 property alias verticalSpacing: gridView.verticalSpacing
26 property alias verticalSpacing: gridView.verticalSpacing
29 readonly property alias margins: gridView.margin
27 readonly property alias margins: gridView.margin
@@ -81,7 +79,7 @@ Item {
81 }
79 }
82
80
83 property real allocatableHorizontalSpace: parent.width - columns * delegateWidth
81 property real allocatableHorizontalSpace: parent.width - columns * delegateWidth
84− property int columns: Math.min(columnsForSpacing(minimumHorizontalSpacing), maximumNumberOfColumns)
82+ property int columns: columnsForSpacing(minimumHorizontalSpacing)
85 property real horizontalSpacing: spacingForColumns(columns)
83 property real horizontalSpacing: spacingForColumns(columns)
86 property real verticalSpacing: horizontalSpacing
84 property real verticalSpacing: horizontalSpacing
87 property int margin: allocatableHorizontalSpace - columns * horizontalSpacing
85 property int margin: allocatableHorizontalSpace - columns * horizontalSpacing
qml/Dash/CardGrid.qml+3−1
@@ -20,12 +20,14 @@ import "../Components"
20DashRenderer {
20DashRenderer {
21 id: root
21 id: root
22
22
23+ readonly property real defaultMinimumHorizontalSpacing: units.gu(1)
23 readonly property int collapsedRows: {
24 readonly property int collapsedRows: {
24 if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2;
25 if (!cardTool || !cardTool.template || typeof cardTool.template["collapsed-rows"] != "number") return 2;
25 return cardTool.template["collapsed-rows"];
26 return cardTool.template["collapsed-rows"];
26 }
27 }
27 property string artShapeStyle: "inset";
28 property string artShapeStyle: "inset";
28 property string backgroundShapeStyle: "inset";
29 property string backgroundShapeStyle: "inset";
30+ property alias minimumHorizontalSpacing: grid.minimumHorizontalSpacing
29
31
30 expandedHeight: grid.totalContentHeight
32 expandedHeight: grid.totalContentHeight
31 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight)
33 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows, grid.cellHeight), expandedHeight)
@@ -45,7 +47,7 @@ DashRenderer {
45 ResponsiveGridView {
47 ResponsiveGridView {
46 id: grid
48 id: grid
47 anchors.fill: parent
49 anchors.fill: parent
48− minimumHorizontalSpacing: units.gu(1)
50+ minimumHorizontalSpacing: root.defaultMinimumHorizontalSpacing
49 delegateWidth: cardTool.cardWidth
51 delegateWidth: cardTool.cardWidth
50 delegateHeight: cardTool.cardHeight
52 delegateHeight: cardTool.cardHeight
51 verticalSpacing: units.gu(1)
53 verticalSpacing: units.gu(1)
qml/Dash/GenericScopeView.qml+4−1
@@ -385,12 +385,15 @@ FocusScope {
385 // Yeah, hackish :/
385 // Yeah, hackish :/
386 if (scopeView.width > units.gu(45)) {
386 if (scopeView.width > units.gu(45)) {
387 if (scopeView.width >= units.gu(70)) {
387 if (scopeView.width >= units.gu(70)) {
388− cardTool.cardWidth = units.gu(9);
388+ cardTool.cardWidth = units.gu(11);
389+ item.minimumHorizontalSpacing = units.gu(5);
390+ return;
389 } else {
391 } else {
390 cardTool.cardWidth = units.gu(10);
392 cardTool.cardWidth = units.gu(10);
391 }
393 }
392 }
394 }
393 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
395 cardTool.artShapeSize = Qt.size(units.gu(8), units.gu(7.5));
396+ item.minimumHorizontalSpacing = item.defaultMinimumHorizontalSpacing;
394 }
397 }
395 }
398 }
396
399
tests/mocks/Unity/fake_categories.cpp+1−1
@@ -141,7 +141,7 @@ ResultsModel* Categories::resultModel(int row) const
141 ResultsModel *result = m_resultsModels[row];
141 ResultsModel *result = m_resultsModels[row];
142 if (!result) {
142 if (!result) {
143 Categories *that = const_cast<Categories*>(this);
143 Categories *that = const_cast<Categories*>(this);
144− result = new ResultsModel(15, row, that);
144+ result = new ResultsModel(25, row, that);
145 m_resultsModels[row] = result;
145 m_resultsModels[row] = result;
146 }
146 }
147 return result;
147 return result;
tests/qmltests/Components/tst_ResponsiveGridView.qml−36
@@ -32,12 +32,6 @@ Item {
32 height: parent.height
32 height: parent.height
33 anchors.top: parent.top
33 anchors.top: parent.top
34 anchors.right: parent.right
34 anchors.right: parent.right
35− ListItem.ValueSelector {
36− id: maxColumnsSelector
37− text: "maximumNumberOfColumns"
38− values: [2,4,8,13,1000]
39− selectedIndex: 1
40− }
41 ListItem.ValueSelector {
35 ListItem.ValueSelector {
42 id: minHSpacingSelector
36 id: minHSpacingSelector
43 text: "minHorizontalSpacing"
37 text: "minHorizontalSpacing"
@@ -86,8 +80,6 @@ Item {
86 minimumHorizontalSpacing:
80 minimumHorizontalSpacing:
87 minHSpacingSelector.values[minHSpacingSelector.selectedIndex]
81 minHSpacingSelector.values[minHSpacingSelector.selectedIndex]
88 verticalSpacing: units.gu(2)
82 verticalSpacing: units.gu(2)
89− maximumNumberOfColumns:
90− maxColumnsSelector.values[maxColumnsSelector.selectedIndex]
91 delegateWidth: units.gu(6)
83 delegateWidth: units.gu(6)
92 delegateHeight: units.gu(6)
84 delegateHeight: units.gu(6)
93
85
@@ -123,31 +115,6 @@ Item {
123 name: "ResponsiveGridView"
115 name: "ResponsiveGridView"
124 when: windowShown
116 when: windowShown
125
117
126− function test_maximumNumberOfColumns_data() {
127− var data = new Array()
128−
129− data.push({selectedIndex: 0, maxColumnCount:2, columnCount: 2})
130− data.push({selectedIndex: 1, maxColumnCount:4, columnCount: 4})
131− data.push({selectedIndex: 2, maxColumnCount:8, columnCount: 8})
132− data.push({selectedIndex: 4, maxColumnCount:1000, columnCount: 13})
133−
134− return data
135− }
136−
137− /* Change ResponsiveGridView's maximumNumberOfColumns property and check
138− that the resulting number of columns matches expectations */
139− function test_maximumNumberOfColumns(data) {
140− minHSpacingSelector.selectedIndex = 0
141−
142− // sanity checks
143− compare(maxColumnsSelector.values[data.selectedIndex], data.maxColumnCount)
144− compare(minHSpacingSelector.values[0], 0)
145−
146− maxColumnsSelector.selectedIndex = data.selectedIndex
147− tryCompareFunction(countGridDelegatesOnFirstRow, data.columnCount);
148− compare(grid.columns, data.columnCount)
149− }
150−
151 function test_minimumHorizontalSpacing_data() {
118 function test_minimumHorizontalSpacing_data() {
152 var data = new Array()
119 var data = new Array()
153
120
@@ -162,10 +129,7 @@ Item {
162 /* Change ResponsiveGridView's minimumHorizontalSpacing property and check
129 /* Change ResponsiveGridView's minimumHorizontalSpacing property and check
163 that the resulting number of columns matches expectations */
130 that the resulting number of columns matches expectations */
164 function test_minimumHorizontalSpacing(data) {
131 function test_minimumHorizontalSpacing(data) {
165− maxColumnsSelector.selectedIndex = 4
166−
167 // sanity checks
132 // sanity checks
168− compare(maxColumnsSelector.values[4], 1000)
169 compare(minHSpacingSelector.values[data.selectedIndex], data.minHSpacing)
133 compare(minHSpacingSelector.values[data.selectedIndex], data.minHSpacing)
170
134
171 minHSpacingSelector.selectedIndex = data.selectedIndex
135 minHSpacingSelector.selectedIndex = data.selectedIndex
tests/qmltests/Dash/tst_GenericScopeView.qml+5−5
@@ -238,7 +238,7 @@ Item {
238
238
239 openPreview(4, 0);
239 openPreview(4, 0);
240
240
241− compare(testCase.subPageLoader.count, 12, "There should only be 12 items in preview.");
241+ compare(testCase.subPageLoader.count, 16, "There should only be 16 items in preview.");
242
242
243 closePreview();
243 closePreview();
244 }
244 }
@@ -413,7 +413,7 @@ Item {
413 var previewListViewList = findChild(subPageLoader.item, "listView");
413 var previewListViewList = findChild(subPageLoader.item, "listView");
414
414
415 // flick to the next previews
415 // flick to the next previews
416− tryCompare(testCase.subPageLoader, "count", 15);
416+ tryCompare(testCase.subPageLoader, "count", 25);
417 for (var i = 1; i < testCase.subPageLoader.count; ++i) {
417 for (var i = 1; i < testCase.subPageLoader.count; ++i) {
418 mouseFlick(testCase.subPageLoader.item, testCase.subPageLoader.width - units.gu(1),
418 mouseFlick(testCase.subPageLoader.item, testCase.subPageLoader.width - units.gu(1),
419 testCase.subPageLoader.height / 2,
419 testCase.subPageLoader.height / 2,
@@ -487,7 +487,7 @@ Item {
487 mockScope.setName("Mock Scope");
487 mockScope.setName("Mock Scope");
488 mockScope.categories.setCount(2);
488 mockScope.categories.setCount(2);
489 mockScope.categories.resultModel(0).setResultCount(50);
489 mockScope.categories.resultModel(0).setResultCount(50);
490− mockScope.categories.resultModel(1).setResultCount(15);
490+ mockScope.categories.resultModel(1).setResultCount(25);
491 mockScope.categories.setLayout(0, "grid");
491 mockScope.categories.setLayout(0, "grid");
492 mockScope.categories.setLayout(1, "grid");
492 mockScope.categories.setLayout(1, "grid");
493 mockScope.categories.setHeaderLink(0, "");
493 mockScope.categories.setHeaderLink(0, "");
@@ -529,7 +529,7 @@ Item {
529 mockScope.setId("mockScope");
529 mockScope.setId("mockScope");
530 mockScope.setName("Mock Scope");
530 mockScope.setName("Mock Scope");
531 mockScope.categories.setCount(2);
531 mockScope.categories.setCount(2);
532− mockScope.categories.resultModel(0).setResultCount(15);
532+ mockScope.categories.resultModel(0).setResultCount(25);
533 mockScope.categories.resultModel(1).setResultCount(50);
533 mockScope.categories.resultModel(1).setResultCount(50);
534 mockScope.categories.setLayout(0, "grid");
534 mockScope.categories.setLayout(0, "grid");
535 mockScope.categories.setLayout(1, "grid");
535 mockScope.categories.setLayout(1, "grid");
@@ -679,7 +679,7 @@ Item {
679
679
680 var cardTool = findChild(categorypredefined, "cardTool");
680 var cardTool = findChild(categorypredefined, "cardTool");
681
681
682− compare(cardTool.cardWidth, units.gu(9));
682+ compare(cardTool.cardWidth, units.gu(11));
683 shell.width = units.gu(46);
683 shell.width = units.gu(46);
684 waitForRendering(genericScopeView);
684 waitForRendering(genericScopeView);
685 compare(cardTool.cardWidth, units.gu(10));
685 compare(cardTool.cardWidth, units.gu(10));