on xenial help sign in
export sectionHeaderHeight from LVWPH instead of hardcoding the size
aa4f771Michael Zanetti
Dash/GenericScopeView.qml+6−3
@@ -130,9 +130,10 @@ ScopeView {
130 target: rendererLoader.item
130 target: rendererLoader.item
131 onClicked: {
131 onClicked: {
132 // Prepare the preview in case activate() triggers a preview only
132 // Prepare the preview in case activate() triggers a preview only
133− effect.positionPx = mapToItem(categoryView, 0, itemY).y
133+ effect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + sectionHeaderHeight);
134 previewListView.categoryId = categoryId
134 previewListView.categoryId = categoryId
135 previewListView.categoryDelegate = rendererLoader.item
135 previewListView.categoryDelegate = rendererLoader.item
136+ previewListView.sectionHeaderHeight = sectionHeaderHeight;
136 previewListView.model = model;
137 previewListView.model = model;
137 previewListView.init = true;
138 previewListView.init = true;
138 previewListView.currentIndex = index;
139 previewListView.currentIndex = index;
@@ -151,9 +152,10 @@ ScopeView {
151 }
152 }
152 }
153 }
153 onPressAndHold: {
154 onPressAndHold: {
154− effect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + units.gu(5));
155+ effect.positionPx = Math.max(mapToItem(categoryView, 0, itemY).y, pageHeader.height + sectionHeaderHeight);
155 previewListView.categoryId = categoryId
156 previewListView.categoryId = categoryId
156 previewListView.categoryDelegate = rendererLoader.item
157 previewListView.categoryDelegate = rendererLoader.item
158+ previewListView.sectionHeaderHeight = sectionHeaderHeight;
157 previewListView.model = model;
159 previewListView.model = model;
158 previewListView.init = true;
160 previewListView.init = true;
159 previewListView.currentIndex = index;
161 previewListView.currentIndex = index;
@@ -375,6 +377,7 @@ ScopeView {
375 // To be set before opening the preview
377 // To be set before opening the preview
376 property string categoryId: ""
378 property string categoryId: ""
377 property var categoryDelegate
379 property var categoryDelegate
380+ property int sectionHeaderHeight
378
381
379 // because the ListView is built asynchronous, setting the
382 // because the ListView is built asynchronous, setting the
380 // currentIndex directly won't work. We need to refresh it
383 // currentIndex directly won't work. We need to refresh it
@@ -402,7 +405,7 @@ ScopeView {
402 var newContentY = itemY - effect.positionPx - categoryDelegate.verticalSpacing;
405 var newContentY = itemY - effect.positionPx - categoryDelegate.verticalSpacing;
403
406
404 // Make sure the item is not covered by a header. Move the effect split down if necessary
407 // Make sure the item is not covered by a header. Move the effect split down if necessary
405− var headerHeight = pageHeader.height + units.gu(5); // sectionHeader's height
408+ var headerHeight = pageHeader.height + previewListView.sectionHeaderHeight;
406 var effectAdjust = Math.max(effect.positionPx, headerHeight);
409 var effectAdjust = Math.max(effect.positionPx, headerHeight);
407
410
408 // Make sure we don't overscroll the listview. If yes, adjust effect position
411 // Make sure we don't overscroll the listview. If yes, adjust effect position
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+1
@@ -852,6 +852,7 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
852 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
852 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
853 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
853 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
854 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
854 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
855+ context->setContextProperty(QLatin1String("sectionHeaderHeight"), m_topSectionItem->height());
855 if (modelIndex == m_asyncRequestedIndex) {
856 if (modelIndex == m_asyncRequestedIndex) {
856 createItem(modelIndex, false);
857 createItem(modelIndex, false);
857 refill();
858 refill();
tests/qmltests/Dash/tst_GenericScopeView.qml+2−1
@@ -144,8 +144,9 @@ Item {
144 var openEffect = findChild(genericScopeView, "openEffect");
144 var openEffect = findChild(genericScopeView, "openEffect");
145 tryCompare(openEffect, "gap", 1);
145 tryCompare(openEffect, "gap", 1);
146
146
147+ var previewListView = findChild(genericScopeView, "previewListView");
147 var pageHeader = findChild(genericScopeView, "pageHeader");
148 var pageHeader = findChild(genericScopeView, "pageHeader");
148− verify(openEffect.positionPx >= pageHeader.height + units.gu(5));
149+ verify(openEffect.positionPx >= pageHeader.height + previewListView.sectionHeaderHeight);
149 }
150 }
150
151
151 function test_previewCycle() {
152 function test_previewCycle() {