on xenial help sign in
No need to adjust Y on index change if there's just one row
commit21cec270c71acd93f93f34ae6405f884381a45df authorAlbert Astals <albert.astals@canonical.com> dateTue 26 Nov 2013, 17:32 (13 years ago) parente7ad7f6
4 files changed+25−18
Components/FilterGrid.qml+2−1 Dash/DashFilterGrid.qml+1 Dash/DashRenderer.qml+2 Dash/GenericScopeView.qml+20−17
Components/FilterGrid.qml+2−1
@@ -41,11 +41,12 @@ Item {
4141
4242 /* Maximum number of rows to be show when filter=true. */
4343 property int collapsedRowCount: 2
44+ property int uncollapsedRowCount: Math.ceil(model.count / columns)
4445 readonly property int collapsedHeight: {
4546 return iconTileGrid.contentHeightForRows(Math.min(collapsedRowCount, Math.ceil(model.count / columns)))
4647 }
4748 readonly property int uncollapsedHeight: {
48− return iconTileGrid.contentHeightForRows(Math.ceil(model.count / columns))
49+ return iconTileGrid.contentHeightForRows(uncollapsedRowCount)
4950 }
5051
5152 property alias minimumHorizontalSpacing: iconTileGrid.minimumHorizontalSpacing
Dash/DashFilterGrid.qml+1
@@ -32,6 +32,7 @@ DashRenderer {
3232 collapsedHeight: filterGrid.collapsedHeight
3333 collapsedRowCount: filterGrid.collapsedRowCount
3434 columns: filterGrid.columns
35+ rows: filter ? filterGrid.collapsedRowCount : filterGrid.uncollapsedRowCount
3536 currentItem: filterGrid.currentItem
3637 expandable: filterGrid.expandable
3738 delegateCreationBegin: filterGrid.delegateCreationBegin
Dash/DashRenderer.qml+2
@@ -29,6 +29,8 @@ Item {
2929
3030 property int columns: 1
3131
32+ property int rows: 1
33+
3234 // Index of the highlighted item
3335 property int highlightIndex: -1
3436
Dash/GenericScopeView.qml+20−17
@@ -447,27 +447,30 @@ FocusScope {
447447 scopeView.scope.preview(item.uri, item.icon, item.category, 0, item.mimetype, item.title, item.comment, item.dndUri, item.metadata)
448448 }
449449
450− var itemY = categoryView.contentItem.mapFromItem(categoryDelegate.currentItem).y; //XXX not working fine with carousel, shift in y after first
450+ // Adjust contentY in case we need to change to it to show the next row
451+ if (categoryDelegate.rows > 1) {
452+ var itemY = categoryView.contentItem.mapFromItem(categoryDelegate.currentItem).y;
451453
452− // Find new contentY and effect.postionPx
453− var newContentY = itemY - effect.positionPx - categoryDelegate.verticalSpacing;
454+ // Find new contentY and effect.postionPx
455+ var newContentY = itemY - effect.positionPx - categoryDelegate.verticalSpacing;
454456
455− // Make sure the item is not covered by a header. Move the effect split down if necessary
456− var headerHeight = pageHeader.height + categoryView.stickyHeaderHeight;
457− var effectAdjust = Math.max(effect.positionPx, headerHeight);
457+ // Make sure the item is not covered by a header. Move the effect split down if necessary
458+ var headerHeight = pageHeader.height + categoryView.stickyHeaderHeight;
459+ var effectAdjust = Math.max(effect.positionPx, headerHeight);
458460
459− // Make sure we don't overscroll the listview. If yes, adjust effect position
460− if (newContentY < 0) {
461− effectAdjust += newContentY;
462− newContentY = 0;
463− }
464− if (newContentY > Math.max(0, categoryView.contentHeight - categoryView.height)) {
465− effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
466− newContentY = categoryView.contentHeight - categoryView.height;
467− }
461+ // Make sure we don't overscroll the listview. If yes, adjust effect position
462+ if (newContentY < 0) {
463+ effectAdjust += newContentY;
464+ newContentY = 0;
465+ }
466+ if (newContentY > Math.max(0, categoryView.contentHeight - categoryView.height)) {
467+ effectAdjust += -(categoryView.contentHeight - categoryView.height) + newContentY
468+ newContentY = categoryView.contentHeight - categoryView.height;
469+ }
468470
469− effect.positionPx = effectAdjust;
470− categoryView.contentY = newContentY;
471+ effect.positionPx = effectAdjust;
472+ categoryView.contentY = newContentY;
473+ }
471474 }
472475
473476 property bool open: false