Merge lp:~aacid/unity8/optimize_LVWPH_layout into lp:unity8

Proposed by Albert Astals Cid
Status: Superseded
Proposed branch: lp:~aacid/unity8/optimize_LVWPH_layout
Merge into: lp:unity8
Diff against target: 350 lines (+69/-49)
9 files modified
plugins/Dash/listviewwithpageheader.cpp (+35/-26)
plugins/Dash/listviewwithpageheader.h (+1/-1)
qml/Dash/DashCategoryBase.qml (+3/-11)
qml/Dash/GenericScopeView.qml (+2/-2)
tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp (+2/-2)
tests/plugins/Dash/listviewwithpageheadersectiontest.cpp (+17/-2)
tests/plugins/Dash/listviewwithpageheadertestsection.qml (+3/-2)
tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml (+2/-1)
tests/plugins/Dash/tst_ListViewWithPageHeaderQML.qml (+4/-2)
To merge this branch: bzr merge lp:~aacid/unity8/optimize_LVWPH_layout
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Josh Arenson Approve
Andrea Cimitan Pending
Review via email: mp+289373@code.launchpad.net

This proposal has been superseded by a proposal from 2016-03-24.

Commit message

Don't use context properties but properties of the delegates

This increases a bit the requirements for delegates of the LVWPH but since we control them it's not really a problem.

In ::layout the setContextProperty calls accounted for around 45% according to callgrind, now it's around 10% only.

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?
No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2279
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/764/
Executed test runs:
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/423
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial,testname=qmluitests.sh/423
    FAILURE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=autopilot.sh/423/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1005
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1021
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1021
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1019
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1019/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1019
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1019/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1019
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1019/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1019
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1019/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1019
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1019/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1019
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1019/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/764/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Josh Arenson (josharenson) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass?
No, the usual

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2279
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/822/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1069
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1087
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1087
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1085
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1085/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/1085/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1085
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1085/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/1085/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1085
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1085/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/1085/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/822/rebuild

review: Needs Fixing (continuous-integration)
2280. By Albert Astals Cid

forgot to adapt this test

2281. By Albert Astals Cid

Merge sectionDelegateResizes

2282. By Albert Astals Cid

Merge

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/Dash/listviewwithpageheader.cpp'
--- plugins/Dash/listviewwithpageheader.cpp 2016-02-05 14:56:32 +0000
+++ plugins/Dash/listviewwithpageheader.cpp 2016-03-24 10:57:49 +0000
@@ -97,6 +97,7 @@
97#include <qqmlengine.h>97#include <qqmlengine.h>
98#pragma GCC diagnostic push98#pragma GCC diagnostic push
99#pragma GCC diagnostic ignored "-pedantic"99#pragma GCC diagnostic ignored "-pedantic"
100#include <private/qqmlcontext_p.h>
100#include <private/qqmldelegatemodel_p.h>101#include <private/qqmldelegatemodel_p.h>
101#include <private/qqmlglobal_p.h>102#include <private/qqmlglobal_p.h>
102#include <private/qquickitem_p.h>103#include <private/qquickitem_p.h>
@@ -285,7 +286,7 @@
285286
286 m_sectionDelegate = delegate;287 m_sectionDelegate = delegate;
287288
288 m_topSectionItem = getSectionItem(QString());289 m_topSectionItem = getSectionItem(QString(), false /*watchGeometry*/);
289 m_topSectionItem->setZ(3);290 m_topSectionItem->setZ(3);
290 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);291 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
291 connect(m_topSectionItem, &QQuickItem::heightChanged, this, &ListViewWithPageHeader::stickyHeaderHeightChanged);292 connect(m_topSectionItem, &QQuickItem::heightChanged, this, &ListViewWithPageHeader::stickyHeaderHeightChanged);
@@ -700,8 +701,10 @@
700701
701void ListViewWithPageHeader::releaseItem(ListItem *listItem)702void ListViewWithPageHeader::releaseItem(ListItem *listItem)
702{703{
703 QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(listItem->m_item);704 QQuickItemPrivate::get(listItem->m_item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
704 itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry);705 if (listItem->sectionItem()) {
706 QQuickItemPrivate::get(listItem->sectionItem())->removeItemChangeListener(this, QQuickItemPrivate::Geometry);
707 }
705 m_itemsToRelease << listItem;708 m_itemsToRelease << listItem;
706}709}
707710
@@ -744,14 +747,12 @@
744 return getSectionItem(section);747 return getSectionItem(section);
745}748}
746749
747QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText)750QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText, bool watchGeometry)
748{751{
749 QQuickItem *sectionItem = nullptr;752 QQuickItem *sectionItem = nullptr;
750753
751 QQmlContext *creationContext = m_sectionDelegate->creationContext();754 QQmlContext *creationContext = m_sectionDelegate->creationContext();
752 QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));755 QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
753 context->setContextProperty(QStringLiteral("section"), sectionText);
754 context->setContextProperty(QStringLiteral("delegateIndex"), -1);
755 QObject *nobj = m_sectionDelegate->beginCreate(context);756 QObject *nobj = m_sectionDelegate->beginCreate(context);
756 if (nobj) {757 if (nobj) {
757 QQml_setParent_noEvent(context, nobj);758 QQml_setParent_noEvent(context, nobj);
@@ -759,6 +760,8 @@
759 if (!sectionItem) {760 if (!sectionItem) {
760 delete nobj;761 delete nobj;
761 } else {762 } else {
763 sectionItem->setProperty("text", sectionText);
764 sectionItem->setProperty("delegateIndex", -1);
762 sectionItem->setZ(2);765 sectionItem->setZ(2);
763 QQml_setParent_noEvent(sectionItem, m_clipItem);766 QQml_setParent_noEvent(sectionItem, m_clipItem);
764 sectionItem->setParentItem(m_clipItem);767 sectionItem->setParentItem(m_clipItem);
@@ -768,7 +771,9 @@
768 }771 }
769 m_sectionDelegate->completeCreate();772 m_sectionDelegate->completeCreate();
770773
771 // TODO attach to sectionItem so we can accomodate to it changing its height774 if (watchGeometry) {
775 QQuickItemPrivate::get(sectionItem)->addItemChangeListener(this, QQuickItemPrivate::Geometry);
776 }
772777
773 return sectionItem;778 return sectionItem;
774}779}
@@ -792,8 +797,7 @@
792 if (!item->sectionItem()) {797 if (!item->sectionItem()) {
793 item->setSectionItem(getSectionItem(sectionText));798 item->setSectionItem(getSectionItem(sectionText));
794 } else {799 } else {
795 QQmlContext *context = QQmlEngine::contextForObject(item->sectionItem())->parentContext();800 item->sectionItem()->setProperty("text", sectionText);
796 context->setContextProperty(QStringLiteral("section"), sectionText);
797 }801 }
798 } else {802 } else {
799 if (item->sectionItem()) {803 if (item->sectionItem()) {
@@ -914,8 +918,7 @@
914 polish();918 polish();
915 }919 }
916 if (listItem->sectionItem()) {920 if (listItem->sectionItem()) {
917 QQmlContext *context = QQmlEngine::contextForObject(listItem->sectionItem())->parentContext();921 listItem->sectionItem()->setProperty("delegateIndex", modelIndex);
918 context->setContextProperty(QStringLiteral("delegateIndex"), modelIndex);
919 }922 }
920 adjustMinYExtent();923 adjustMinYExtent();
921 m_contentHeightDirty = true;924 m_contentHeightDirty = true;
@@ -939,9 +942,10 @@
939 return;942 return;
940943
941 item->setParentItem(m_clipItem);944 item->setParentItem(m_clipItem);
945 // FIXME Why do we need the refreshExpressions call?
942 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();946 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
943 context->setContextProperty(QStringLiteral("ListViewWithPageHeader"), this);947 QQmlContextPrivate::get(context)->data->refreshExpressions();
944 context->setContextProperty(QStringLiteral("heightToClip"), QVariant::fromValue<int>(0));948 item->setProperty("heightToClip", QVariant::fromValue<int>(0));
945 if (modelIndex == m_asyncRequestedIndex) {949 if (modelIndex == m_asyncRequestedIndex) {
946 createItem(modelIndex, false);950 createItem(modelIndex, false);
947 refill();951 refill();
@@ -1107,8 +1111,7 @@
1107 for (int i = 0; i < m_visibleItems.count(); ++i) {1111 for (int i = 0; i < m_visibleItems.count(); ++i) {
1108 ListItem *item = m_visibleItems[i];1112 ListItem *item = m_visibleItems[i];
1109 if (item->sectionItem()) {1113 if (item->sectionItem()) {
1110 QQmlContext *context = QQmlEngine::contextForObject(item->sectionItem())->parentContext();1114 item->sectionItem()->setProperty("delegateIndex", m_firstVisibleIndex + i);
1111 context->setContextProperty(QStringLiteral("delegateIndex"), m_firstVisibleIndex + i);
1112 }1115 }
1113 }1116 }
11141117
@@ -1126,15 +1129,23 @@
1126 }1129 }
1127}1130}
11281131
1129void ListViewWithPageHeader::itemGeometryChanged(QQuickItem * /*item*/, const QRectF &newGeometry, const QRectF &oldGeometry)1132void ListViewWithPageHeader::itemGeometryChanged(QQuickItem *item, const QRectF &newGeometry, const QRectF &oldGeometry)
1130{1133{
1131 const qreal heightDiff = newGeometry.height() - oldGeometry.height();1134 const qreal heightDiff = newGeometry.height() - oldGeometry.height();
1132 if (heightDiff != 0) {1135 if (heightDiff != 0) {
1133 if (!m_inContentHeightKeepHeaderShown && oldGeometry.y() + oldGeometry.height() + m_clipItem->y() <= contentY() && !m_visibleItems.isEmpty()) {1136 if (!m_visibleItems.isEmpty()) {
1134 ListItem *firstItem = m_visibleItems.first();1137 ListItem *firstItem = m_visibleItems.first();
1135 firstItem->setY(firstItem->y() - heightDiff);1138 const auto prevFirstItemY = firstItem->y();
1136 adjustMinYExtent();1139 if (!m_inContentHeightKeepHeaderShown && oldGeometry.y() + oldGeometry.height() + m_clipItem->y() <= contentY()) {
1137 layout();1140 firstItem->setY(firstItem->y() - heightDiff);
1141 } else if (item == firstItem->sectionItem()) {
1142 firstItem->setY(firstItem->y() + heightDiff);
1143 }
1144
1145 if (firstItem->y() != prevFirstItemY) {
1146 adjustMinYExtent();
1147 layout();
1148 }
1138 }1149 }
1139 refill();1150 refill();
1140 adjustMinYExtent();1151 adjustMinYExtent();
@@ -1270,8 +1281,7 @@
1270 } else {1281 } else {
1271 // Update the top sticky section header1282 // Update the top sticky section header
1272 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);1283 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
1273 QQmlContext *context = QQmlEngine::contextForObject(m_topSectionItem)->parentContext();1284 m_topSectionItem->setProperty("text", section);
1274 context->setContextProperty(QStringLiteral("section"), section);
12751285
1276 QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);1286 QQuickItemPrivate::get(m_topSectionItem)->setCulled(false);
1277 m_topSectionItem->setY(topSectionStickPos);1287 m_topSectionItem->setY(topSectionStickPos);
@@ -1283,19 +1293,18 @@
1283 break;1293 break;
1284 delegateIndex--;1294 delegateIndex--;
1285 }1295 }
1286 context->setContextProperty(QStringLiteral("delegateIndex"), delegateIndex);1296 m_topSectionItem->setProperty("delegateIndex", delegateIndex);
1287 if (item->sectionItem()) {1297 if (item->sectionItem()) {
1288 QQuickItemPrivate::get(item->sectionItem())->setCulled(true);1298 QQuickItemPrivate::get(item->sectionItem())->setCulled(true);
1289 }1299 }
1290 }1300 }
1291 }1301 }
1292 }1302 }
1293 QQmlContext *context = QQmlEngine::contextForObject(item->m_item)->parentContext();
1294 const qreal clipFrom = visibleFrom + (!item->sectionItem() && m_topSectionItem && !QQuickItemPrivate::get(m_topSectionItem)->culled ? m_topSectionItem->height() : 0);1303 const qreal clipFrom = visibleFrom + (!item->sectionItem() && m_topSectionItem && !QQuickItemPrivate::get(m_topSectionItem)->culled ? m_topSectionItem->height() : 0);
1295 if (!cull && pos < clipFrom) {1304 if (!cull && pos < clipFrom) {
1296 context->setContextProperty(QStringLiteral("heightToClip"), clipFrom - pos);1305 item->m_item->setProperty("heightToClip", clipFrom - pos);
1297 } else {1306 } else {
1298 context->setContextProperty(QStringLiteral("heightToClip"), QVariant::fromValue<int>(0));1307 item->m_item->setProperty("heightToClip", QVariant::fromValue<int>(0));
1299 }1308 }
1300// qDebug() << "ListViewWithPageHeader::layout" << item->m_item;1309// qDebug() << "ListViewWithPageHeader::layout" << item->m_item;
1301 pos += item->height();1310 pos += item->height();
13021311
=== modified file 'plugins/Dash/listviewwithpageheader.h'
--- plugins/Dash/listviewwithpageheader.h 2016-02-05 14:56:32 +0000
+++ plugins/Dash/listviewwithpageheader.h 2016-03-24 10:57:49 +0000
@@ -166,7 +166,7 @@
166 void reallyReleaseItem(ListItem *item);166 void reallyReleaseItem(ListItem *item);
167 void updateWatchedRoles();167 void updateWatchedRoles();
168 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);168 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
169 QQuickItem *getSectionItem(const QString &sectionText);169 QQuickItem *getSectionItem(const QString &sectionText, bool watchGeometry = true);
170 void updateSectionItem(int modelIndex);170 void updateSectionItem(int modelIndex);
171 void initializeValuesForEmptyList();171 void initializeValuesForEmptyList();
172172
173173
=== modified file 'qml/Dash/DashCategoryBase.qml'
--- qml/Dash/DashCategoryBase.qml 2015-07-15 15:07:19 +0000
+++ qml/Dash/DashCategoryBase.qml 2016-03-24 10:57:49 +0000
@@ -24,17 +24,9 @@
24 /* Relevant really only for ListViewWithPageHeader case: specify how many pixels we can overlap with the section header */24 /* Relevant really only for ListViewWithPageHeader case: specify how many pixels we can overlap with the section header */
25 readonly property int allowedOverlap: units.dp(1)25 readonly property int allowedOverlap: units.dp(1)
2626
27 property real __heightToClip: {27 property real heightToClip: 0
28 // Check this is in position where clipping is needed28 readonly property real __heightToClip: heightToClip >= allowedOverlap ? heightToClip - allowedOverlap : 0
29 if (typeof ListViewWithPageHeader !== 'undefined') {29
30 if (typeof heightToClip !== 'undefined') {
31 if (heightToClip >= allowedOverlap) {
32 return heightToClip - allowedOverlap;
33 }
34 }
35 }
36 return 0;
37 }
3830
39 /*!31 /*!
40 \internal32 \internal
4133
=== modified file 'qml/Dash/GenericScopeView.qml'
--- qml/Dash/GenericScopeView.qml 2016-03-14 08:53:26 +0000
+++ qml/Dash/GenericScopeView.qml 2016-03-24 10:57:49 +0000
@@ -607,10 +607,10 @@
607 sectionProperty: "name"607 sectionProperty: "name"
608 sectionDelegate: ListItems.Header {608 sectionDelegate: ListItems.Header {
609 objectName: "dashSectionHeader" + (delegate ? delegate.category : "")609 objectName: "dashSectionHeader" + (delegate ? delegate.category : "")
610 property int delegateIndex: -1
610 readonly property var delegate: categoryView.item(delegateIndex)611 readonly property var delegate: categoryView.item(delegateIndex)
611 width: categoryView.width612 width: categoryView.width
612 height: section != "" ? units.gu(5) : 0613 height: text != "" ? units.gu(5) : 0
613 text: section
614 color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText614 color: scopeStyle ? scopeStyle.foreground : theme.palette.normal.baseText
615 iconName: delegate && delegate.headerLink ? "go-next" : ""615 iconName: delegate && delegate.headerLink ? "go-next" : ""
616 onClicked: {616 onClicked: {
617617
=== modified file 'tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp'
--- tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp 2015-05-21 15:52:48 +0000
+++ tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp 2016-03-24 10:57:49 +0000
@@ -151,12 +151,12 @@
151151
152 QString section(QQuickItem *item)152 QString section(QQuickItem *item)
153 {153 {
154 return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("section")).toString() : QString();154 return item ? item->property("text").toString() : QString();
155 }155 }
156156
157 int sectionDelegateIndex(QQuickItem *item)157 int sectionDelegateIndex(QQuickItem *item)
158 {158 {
159 return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("delegateIndex")).toInt() : -1;159 return item ? item->property("delegateIndex").toInt() : -1;
160 }160 }
161161
162private Q_SLOTS:162private Q_SLOTS:
163163
=== modified file 'tests/plugins/Dash/listviewwithpageheadersectiontest.cpp'
--- tests/plugins/Dash/listviewwithpageheadersectiontest.cpp 2015-11-26 13:50:56 +0000
+++ tests/plugins/Dash/listviewwithpageheadersectiontest.cpp 2016-03-24 10:57:49 +0000
@@ -116,12 +116,12 @@
116116
117 QString section(QQuickItem *item) const117 QString section(QQuickItem *item) const
118 {118 {
119 return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("section")).toString() : QString();119 return item ? item->property("text").toString() : QString();
120 }120 }
121121
122 int sectionDelegateIndex(QQuickItem *item) const122 int sectionDelegateIndex(QQuickItem *item) const
123 {123 {
124 return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("delegateIndex")).toInt() : -1;124 return item ? item->property("delegateIndex").toInt() : -1;
125 }125 }
126126
127private Q_SLOTS:127private Q_SLOTS:
@@ -2180,6 +2180,21 @@
2180 verifyItem(2, 480., 390., false, "Agressive", false);2180 verifyItem(2, 480., 390., false, "Agressive", false);
2181 }2181 }
21822182
2183 void firstItemSectionHeightChange()
2184 {
2185 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 1), Q_ARG(QVariant, 5));
2186 model->setProperty(0, "type", "halfheight");
2187 verifyItem(0, 50., 170., false, "halfheight", false);
2188 }
2189
2190 void secondItemSectionHeightChange()
2191 {
2192 QMetaObject::invokeMethod(model, "removeItems", Q_ARG(QVariant, 2), Q_ARG(QVariant, 4));
2193 model->setProperty(1, "type", "halfheight");
2194 verifyItem(0, 50., 190., false, "Agressive", false);
2195 verifyItem(1, 240., 220., false, "halfheight", false);
2196 }
2197
2183private:2198private:
2184 QQuickView *view;2199 QQuickView *view;
2185 ListViewWithPageHeader *lvwph;2200 ListViewWithPageHeader *lvwph;
21862201
=== modified file 'tests/plugins/Dash/listviewwithpageheadertestsection.qml'
--- tests/plugins/Dash/listviewwithpageheadertestsection.qml 2015-07-15 15:07:19 +0000
+++ tests/plugins/Dash/listviewwithpageheadertestsection.qml 2016-03-24 10:57:49 +0000
@@ -97,9 +97,10 @@
97 sectionProperty: "type"97 sectionProperty: "type"
98 sectionDelegate: Component {98 sectionDelegate: Component {
99 Rectangle {99 Rectangle {
100 property alias text: theText.text
100 color: "green"101 color: "green"
101 height: 40102 height: section === "" ? 0 : section != "halfheight" ? 40 : 20;
102 Text { text: section; font.pixelSize: 34 }103 Text { id: theText; font.pixelSize: 34 }
103 anchors { left: parent.left; right: parent.right }104 anchors { left: parent.left; right: parent.right }
104 }105 }
105 }106 }
106107
=== modified file 'tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml'
--- tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml 2015-07-15 15:07:19 +0000
+++ tests/plugins/Dash/listviewwithpageheadertestsectionexternalmodel.qml 2016-03-24 10:57:49 +0000
@@ -65,9 +65,10 @@
65 sectionProperty: "type"65 sectionProperty: "type"
66 sectionDelegate: Component {66 sectionDelegate: Component {
67 Rectangle {67 Rectangle {
68 property alias text: theText.text
68 color: "green"69 color: "green"
69 height: 4070 height: 40
70 Text { text: section; font.pixelSize: 34 }71 Text { id: theText; font.pixelSize: 34 }
71 anchors { left: parent.left; right: parent.right }72 anchors { left: parent.left; right: parent.right }
72 }73 }
73 }74 }
7475
=== modified file 'tests/plugins/Dash/tst_ListViewWithPageHeaderQML.qml'
--- tests/plugins/Dash/tst_ListViewWithPageHeaderQML.qml 2015-07-15 15:07:19 +0000
+++ tests/plugins/Dash/tst_ListViewWithPageHeaderQML.qml 2016-03-24 10:57:49 +0000
@@ -81,9 +81,10 @@
81 sectionDelegate: Component {81 sectionDelegate: Component {
82 id: sectionHeaderComponent82 id: sectionHeaderComponent
83 Rectangle {83 Rectangle {
84 property alias text: theText.text
84 color: "green"85 color: "green"
85 height: listView.sectionHeaderHeight86 height: listView.sectionHeaderHeight
86 Text { text: section; font.pixelSize: 34 }87 Text { id: theText; font.pixelSize: 34 }
87 anchors { left: parent.left; right: parent.right }88 anchors { left: parent.left; right: parent.right }
88 }89 }
89 }90 }
@@ -92,9 +93,10 @@
92 Component {93 Component {
93 id: otherSectionHeaderComponent94 id: otherSectionHeaderComponent
94 Rectangle {95 Rectangle {
96 property alias text: theText.text
95 color: "green"97 color: "green"
96 height: 5098 height: 50
97 Text { text: section; font.pixelSize: 34 }99 Text { id: theText; font.pixelSize: 34 }
98 anchors { left: parent.left; right: parent.right }100 anchors { left: parent.left; right: parent.right }
99 }101 }
100 }102 }

Subscribers

People subscribed via source and target branches