on xenial help sign in
export sectionHeaderHeight from LVWPH instead of hardcoding the size
commitaa4f77180f1df821bd9a68e7c92e54c827d8f46f authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 13 Nov 2013, 19:43 (13 years ago) parent86ff26f
3 files changed+9−4
Dash/GenericScopeView.qml+6−3 plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+1 tests/qmltests/Dash/tst_GenericScopeView.qml+2−1
Dash/GenericScopeView.qml+6−3
@@ -130,9 +130,10 @@ ScopeView {
130130 target: rendererLoader.item
131131 onClicked: {
132132 // 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);
134134 previewListView.categoryId = categoryId
135135 previewListView.categoryDelegate = rendererLoader.item
136+ previewListView.sectionHeaderHeight = sectionHeaderHeight;
136137 previewListView.model = model;
137138 previewListView.init = true;
138139 previewListView.currentIndex = index;
@@ -151,9 +152,10 @@ ScopeView {
151152 }
152153 }
153154 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);
155156 previewListView.categoryId = categoryId
156157 previewListView.categoryDelegate = rendererLoader.item
158+ previewListView.sectionHeaderHeight = sectionHeaderHeight;
157159 previewListView.model = model;
158160 previewListView.init = true;
159161 previewListView.currentIndex = index;
@@ -375,6 +377,7 @@ ScopeView {
375377 // To be set before opening the preview
376378 property string categoryId: ""
377379 property var categoryDelegate
380+ property int sectionHeaderHeight
378381
379382 // because the ListView is built asynchronous, setting the
380383 // currentIndex directly won't work. We need to refresh it
@@ -402,7 +405,7 @@ ScopeView {
402405 var newContentY = itemY - effect.positionPx - categoryDelegate.verticalSpacing;
403406
404407 // 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;
406409 var effectAdjust = Math.max(effect.positionPx, headerHeight);
407410
408411 // 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)
852852 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
853853 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
854854 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
855+ context->setContextProperty(QLatin1String("sectionHeaderHeight"), m_topSectionItem->height());
855856 if (modelIndex == m_asyncRequestedIndex) {
856857 createItem(modelIndex, false);
857858 refill();
tests/qmltests/Dash/tst_GenericScopeView.qml+2−1
@@ -144,8 +144,9 @@ Item {
144144 var openEffect = findChild(genericScopeView, "openEffect");
145145 tryCompare(openEffect, "gap", 1);
146146
147+ var previewListView = findChild(genericScopeView, "previewListView");
147148 var pageHeader = findChild(genericScopeView, "pageHeader");
148− verify(openEffect.positionPx >= pageHeader.height + units.gu(5));
149+ verify(openEffect.positionPx >= pageHeader.height + previewListView.sectionHeaderHeight);
149150 }
150151
151152 function test_previewCycle() {