on xenial help sign in
Disable expansion for categories with header links.
7abda69Michał Sawicz
qml/Dash/CardGrid.qml+1
@@ -27,6 +27,7 @@ DashRenderer {
27
27
28 expandedHeight: grid.totalContentHeight
28 expandedHeight: grid.totalContentHeight
29 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows), expandedHeight)
29 collapsedHeight: Math.min(grid.contentHeightForRows(collapsedRows), expandedHeight)
30+ collapsedItemCount: collapsedRows * grid.columns
30 originY: grid.originY
31 originY: grid.originY
31
32
32 ResponsiveGridView {
33 ResponsiveGridView {
qml/Dash/DashRenderer.qml+2
@@ -21,6 +21,8 @@ Item {
21
21
22 property int expandedHeight
22 property int expandedHeight
23
23
24+ property int collapsedItemCount: 0
25+
24 property int displayMarginBeginning: 0
26 property int displayMarginBeginning: 0
25
27
26 property int displayMarginEnd: 0
28 property int displayMarginEnd: 0
qml/Dash/GenericScopeView.qml+21−11
@@ -186,7 +186,8 @@ FocusScope {
186 }
186 }
187 }
187 }
188
188
189+ readonly property bool expanded: baseItem.expanded || !baseItem.expandable
189− height: baseItem.expandable && !baseItem.expanded ? item.collapsedHeight : item.expandedHeight
190+ height: expanded ? item.expandedHeight : item.collapsedHeight
190
191
191 source: {
192 source: {
192 switch (cardTool.categoryLayout) {
193 switch (cardTool.categoryLayout) {
@@ -236,17 +237,22 @@ FocusScope {
236 // so it's not implemented
237 // so it's not implemented
237 scopeView.scope.activate(result)
238 scopeView.scope.activate(result)
238 } else {
239 } else {
239− previewListView.model = target.model;
240+ openPreview(index);
240− previewListView.currentIndex = -1
241− previewListView.currentIndex = index;
242− previewListView.open = true
243 }
241 }
244 }
242 }
245− onPressAndHold: {
243+ onPressAndHold: openPreview(index)
244+
245+ function openPreview(index) {
246+ if (!rendererLoader.expanded && !seeAllLabel.visible && target.collapsedItemCount > 0) {
247+ previewLimitModel.model = target.model;
248+ previewLimitModel.limit = target.collapsedItemCount;
246− previewListView.model = target.model;
249+ previewListView.model = previewLimitModel;
250+ } else {
251+ previewListView.model = target.model;
252+ }
247− previewListView.currentIndex = -1
253+ previewListView.currentIndex = -1;
248 previewListView.currentIndex = index;
254 previewListView.currentIndex = index;
249− previewListView.open = true
255+ previewListView.open = true;
250 }
256 }
251 }
257 }
252 Connections {
258 Connections {
@@ -318,7 +324,7 @@ FocusScope {
318 left: parent.left
324 left: parent.left
319 right: parent.right
325 right: parent.right
320 }
326 }
321− height: baseItem.expandable ? seeAllLabel.font.pixelSize + units.gu(6) : 0
327+ height: seeAllLabel.visible ? seeAllLabel.font.pixelSize + units.gu(6) : 0
322
328
323 onClicked: {
329 onClicked: {
324 if (categoryView.expandedCategoryId != baseItem.category) {
330 if (categoryView.expandedCategoryId != baseItem.category) {
@@ -338,7 +344,7 @@ FocusScope {
338 fontSize: "small"
344 fontSize: "small"
339 font.weight: Font.Bold
345 font.weight: Font.Bold
340 color: scopeStyle ? scopeStyle.foreground : "grey"
346 color: scopeStyle ? scopeStyle.foreground : "grey"
341− visible: baseItem.expandable
347+ visible: baseItem.expandable && !baseItem.headerLink
342 }
348 }
343
349
344 Image {
350 Image {
@@ -404,6 +410,10 @@ FocusScope {
404 }
410 }
405 }
411 }
406
412
413+ LimitProxyModel {
414+ id: previewLimitModel
415+ }
416+
407 PreviewListView {
417 PreviewListView {
408 id: previewListView
418 id: previewListView
409 objectName: "previewListView"
419 objectName: "previewListView"
tests/mocks/Unity/fake_categories.cpp+1−1
@@ -169,7 +169,7 @@ Categories::data(const QModelIndex& index, int role) const
169 return map;
169 return map;
170 }
170 }
171 case RoleHeaderLink:
171 case RoleHeaderLink:
172− if (index.row() == 1) {
172+ if (index.row() == 1 || index.row() == 4) {
173 return QString("scope://query/1");
173 return QString("scope://query/1");
174 }
174 }
175 return QString();
175 return QString();
tests/qmltests/Dash/tst_GenericScopeView.qml+28−4
@@ -176,6 +176,28 @@ Item {
176 compare(spy.signalArguments[0][0], genericScopeView.scope.categories.data(1, Categories.RoleHeaderLink));
176 compare(spy.signalArguments[0][0], genericScopeView.scope.categories.data(1, Categories.RoleHeaderLink));
177 }
177 }
178
178
179+ function test_headerLink_disable_expansion() {
180+ var categoryListView = findChild(genericScopeView, "categoryListView");
181+ waitForRendering(categoryListView);
182+
183+ categoryListView.contentY = categoryListView.height * 2;
184+
185+ // wait for the item to be there
186+ tryCompareFunction(function() { return findChild(genericScopeView, "dashSectionHeader4") != null; }, true);
187+
188+ var categoryView = findChild(genericScopeView, "dashCategory4");
189+ verify(categoryView, "Can't find the category view.");
190+
191+ var seeAll = findChild(categoryView, "seeAll");
192+ verify(seeAll, "Can't find the seeAll element");
193+
194+ compare(seeAll.height, 0, "SeeAll should be 0-height.");
195+
196+ openPreview(4, 0);
197+
198+ compare(testCase.previewListView.count, 12, "There should only be 12 items in preview.");
199+ }
200+
179 function test_narrow_delegate_ranges_expand() {
201 function test_narrow_delegate_ranges_expand() {
180 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") !== null; }, true);
202 tryCompareFunction(function() { return findChild(genericScopeView, "dashCategory0") !== null; }, true);
181 var category = findChild(genericScopeView, "dashCategory0")
203 var category = findChild(genericScopeView, "dashCategory0")
@@ -220,17 +242,19 @@ Item {
220 compare(grid.height, grid.expandedHeight, "Only category should always be expanded");
242 compare(grid.height, grid.expandedHeight, "Only category should always be expanded");
221 }
243 }
222
244
223− function openPreview() {
245+ function openPreview(category, delegate) {
246+ if (category === undefined) category = 0;
247+ if (delegate === undefined) delegate = 0;
224 tryCompareFunction(function() {
248 tryCompareFunction(function() {
225− var cardGrid = findChild(genericScopeView, "0");
249+ var cardGrid = findChild(genericScopeView, category);
226 if (cardGrid != null) {
250 if (cardGrid != null) {
227− var tile = findChild(cardGrid, "delegate0");
251+ var tile = findChild(cardGrid, "delegate"+delegate);
228 return tile != null;
252 return tile != null;
229 }
253 }
230 return false;
254 return false;
231 },
255 },
232 true);
256 true);
233− var tile = findChild(findChild(genericScopeView, "0"), "delegate0");
257+ var tile = findChild(findChild(genericScopeView, category), "delegate"+delegate);
234 mouseClick(tile, tile.width / 2, tile.height / 2);
258 mouseClick(tile, tile.width / 2, tile.height / 2);
235 tryCompare(testCase.previewListView, "open", true);
259 tryCompare(testCase.previewListView, "open", true);
236 tryCompare(testCase.previewListView, "x", 0);
260 tryCompare(testCase.previewListView, "x", 0);