Merge lp:~aacid/unity8/headerless_category_margin into lp:unity8
- headerless_category_margin
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Michał Sawicz | ||||
Approved revision: | 944 | ||||
Merged at revision: | 954 | ||||
Proposed branch: | lp:~aacid/unity8/headerless_category_margin | ||||
Merge into: | lp:unity8 | ||||
Diff against target: |
290 lines (+58/-36) 5 files modified
plugins/Dash/listviewwithpageheader.cpp (+39/-28) plugins/Dash/listviewwithpageheader.h (+4/-0) qml/Dash/GenericScopeView.qml (+1/-0) tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp (+3/-3) tests/plugins/Dash/listviewwithpageheadersectiontest.cpp (+11/-5) |
||||
To merge this branch: | bzr merge lp:~aacid/unity8/headerless_category_margin | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paweł Stołowski (community) | Approve | ||
Michał Sawicz | Approve | ||
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Review via email: mp+222132@code.launchpad.net |
Commit message
Improvements for headerless categories
LVPWH: No section name -> no header
LVPWH: New hasSectionHeader context property for delegates
GSV: Add topMargin if no hasSectionHeader
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
Albert Astals Cid (aacid) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:944
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Michał Sawicz (saviq) wrote : | # |
* Did you perform an exploratory manual test run of the code change and any related functionality?
Yup!
* Did CI run pass? If not, please explain why.
Don't ask... Complete havoc happened via a sync from debian.
Preview Diff
1 | === modified file 'plugins/Dash/listviewwithpageheader.cpp' | |||
2 | --- plugins/Dash/listviewwithpageheader.cpp 2014-04-24 14:13:21 +0000 | |||
3 | +++ plugins/Dash/listviewwithpageheader.cpp 2014-06-05 08:44:16 +0000 | |||
4 | @@ -138,6 +138,13 @@ | |||
5 | 138 | QQuickItemPrivate::get(m_sectionItem)->setCulled(culled); | 138 | QQuickItemPrivate::get(m_sectionItem)->setCulled(culled); |
6 | 139 | } | 139 | } |
7 | 140 | 140 | ||
8 | 141 | void ListViewWithPageHeader::ListItem::setSectionItem(QQuickItem *sectionItem) | ||
9 | 142 | { | ||
10 | 143 | m_sectionItem = sectionItem; | ||
11 | 144 | QQmlContext *context = QQmlEngine::contextForObject(m_item)->parentContext(); | ||
12 | 145 | context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(sectionItem != nullptr)); | ||
13 | 146 | } | ||
14 | 147 | |||
15 | 141 | ListViewWithPageHeader::ListViewWithPageHeader() | 148 | ListViewWithPageHeader::ListViewWithPageHeader() |
16 | 142 | : m_delegateModel(nullptr) | 149 | : m_delegateModel(nullptr) |
17 | 143 | , m_asyncRequestedIndex(-1) | 150 | , m_asyncRequestedIndex(-1) |
18 | @@ -422,7 +429,7 @@ | |||
19 | 422 | 429 | ||
20 | 423 | ListItem *listItem = itemAtIndex(modelIndex); | 430 | ListItem *listItem = itemAtIndex(modelIndex); |
21 | 424 | if (listItem) { | 431 | if (listItem) { |
23 | 425 | return maximizeVisibleArea(listItem, itemHeight + (listItem->m_sectionItem ? listItem->m_sectionItem->height() : 0)); | 432 | return maximizeVisibleArea(listItem, itemHeight + (listItem->sectionItem() ? listItem->sectionItem()->height() : 0)); |
24 | 426 | } | 433 | } |
25 | 427 | 434 | ||
26 | 428 | return false; | 435 | return false; |
27 | @@ -440,7 +447,7 @@ | |||
28 | 440 | contentYAnimationType = ContentYAnimationMaximizeVisibleArea; | 447 | contentYAnimationType = ContentYAnimationMaximizeVisibleArea; |
29 | 441 | m_contentYAnimation->start(); | 448 | m_contentYAnimation->start(); |
30 | 442 | } else if ((listItemY < contentY() && listItemY + listItemHeight < contentY() + height()) || | 449 | } else if ((listItemY < contentY() && listItemY + listItemHeight < contentY() + height()) || |
32 | 443 | (m_topSectionItem && !listItem->m_sectionItem && listItemY - m_topSectionItem->height() < contentY() && listItemY + listItemHeight < contentY() + height())) | 450 | (m_topSectionItem && !listItem->sectionItem() && listItemY - m_topSectionItem->height() < contentY() && listItemY + listItemHeight < contentY() + height())) |
33 | 444 | { | 451 | { |
34 | 445 | // we can scroll the list down to show more stuff | 452 | // we can scroll the list down to show more stuff |
35 | 446 | auto realVisibleListItemY = listItemY; | 453 | auto realVisibleListItemY = listItemY; |
36 | @@ -449,7 +456,7 @@ | |||
37 | 449 | // item we have to make sure to scroll it a bit more so that it is not underlapping | 456 | // item we have to make sure to scroll it a bit more so that it is not underlapping |
38 | 450 | // the top section sticky item | 457 | // the top section sticky item |
39 | 451 | bool topSectionShown = !QQuickItemPrivate::get(m_topSectionItem)->culled; | 458 | bool topSectionShown = !QQuickItemPrivate::get(m_topSectionItem)->culled; |
41 | 452 | if (topSectionShown && !listItem->m_sectionItem) { | 459 | if (topSectionShown && !listItem->sectionItem()) { |
42 | 453 | realVisibleListItemY -= m_topSectionItem->height(); | 460 | realVisibleListItemY -= m_topSectionItem->height(); |
43 | 454 | } | 461 | } |
44 | 455 | } | 462 | } |
45 | @@ -645,7 +652,7 @@ | |||
46 | 645 | if (flags & QQmlDelegateModel::Destroyed) { | 652 | if (flags & QQmlDelegateModel::Destroyed) { |
47 | 646 | item->setParentItem(nullptr); | 653 | item->setParentItem(nullptr); |
48 | 647 | } | 654 | } |
50 | 648 | delete listItem->m_sectionItem; | 655 | delete listItem->sectionItem(); |
51 | 649 | delete listItem; | 656 | delete listItem; |
52 | 650 | } | 657 | } |
53 | 651 | 658 | ||
54 | @@ -672,6 +679,9 @@ | |||
55 | 672 | return nullptr; | 679 | return nullptr; |
56 | 673 | 680 | ||
57 | 674 | const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty); | 681 | const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty); |
58 | 682 | if (section.isEmpty()) | ||
59 | 683 | return nullptr; | ||
60 | 684 | |||
61 | 675 | if (modelIndex > 0) { | 685 | if (modelIndex > 0) { |
62 | 676 | const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty); | 686 | const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty); |
63 | 677 | if (section == prevSection) | 687 | if (section == prevSection) |
64 | @@ -684,8 +694,8 @@ | |||
65 | 684 | // Steal the section header | 694 | // Steal the section header |
66 | 685 | ListItem *nextItem = itemAtIndex(modelIndex); // Not +1 since not yet inserted into m_visibleItems | 695 | ListItem *nextItem = itemAtIndex(modelIndex); // Not +1 since not yet inserted into m_visibleItems |
67 | 686 | if (nextItem) { | 696 | if (nextItem) { |
70 | 687 | QQuickItem *sectionItem = nextItem->m_sectionItem; | 697 | QQuickItem *sectionItem = nextItem->sectionItem(); |
71 | 688 | nextItem->m_sectionItem = nullptr; | 698 | nextItem->setSectionItem(nullptr); |
72 | 689 | return sectionItem; | 699 | return sectionItem; |
73 | 690 | } | 700 | } |
74 | 691 | } | 701 | } |
75 | @@ -793,7 +803,7 @@ | |||
76 | 793 | // qDebug() << "ListViewWithPageHeader::createItem::We have the item" << modelIndex << item; | 803 | // qDebug() << "ListViewWithPageHeader::createItem::We have the item" << modelIndex << item; |
77 | 794 | ListItem *listItem = new ListItem; | 804 | ListItem *listItem = new ListItem; |
78 | 795 | listItem->m_item = item; | 805 | listItem->m_item = item; |
80 | 796 | listItem->m_sectionItem = getSectionItem(modelIndex, false /*Not yet inserted into m_visibleItems*/); | 806 | listItem->setSectionItem(getSectionItem(modelIndex, false /*Not yet inserted into m_visibleItems*/)); |
81 | 797 | QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::Geometry); | 807 | QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::Geometry); |
82 | 798 | ListItem *prevItem = itemAtIndex(modelIndex - 1); | 808 | ListItem *prevItem = itemAtIndex(modelIndex - 1); |
83 | 799 | bool lostItem = false; // Is an item that we requested async but because of model changes | 809 | bool lostItem = false; // Is an item that we requested async but because of model changes |
84 | @@ -832,8 +842,8 @@ | |||
85 | 832 | m_firstVisibleIndex = modelIndex; | 842 | m_firstVisibleIndex = modelIndex; |
86 | 833 | polish(); | 843 | polish(); |
87 | 834 | } | 844 | } |
90 | 835 | if (listItem->m_sectionItem) { | 845 | if (listItem->sectionItem()) { |
91 | 836 | QQmlContext *context = QQmlEngine::contextForObject(listItem->m_sectionItem)->parentContext(); | 846 | QQmlContext *context = QQmlEngine::contextForObject(listItem->sectionItem())->parentContext(); |
92 | 837 | context->setContextProperty(QLatin1String("delegateIndex"), modelIndex); | 847 | context->setContextProperty(QLatin1String("delegateIndex"), modelIndex); |
93 | 838 | } | 848 | } |
94 | 839 | adjustMinYExtent(); | 849 | adjustMinYExtent(); |
95 | @@ -861,6 +871,7 @@ | |||
96 | 861 | QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext(); | 871 | QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext(); |
97 | 862 | context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this); | 872 | context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this); |
98 | 863 | context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0)); | 873 | context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0)); |
99 | 874 | context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(false)); | ||
100 | 864 | if (modelIndex == m_asyncRequestedIndex) { | 875 | if (modelIndex == m_asyncRequestedIndex) { |
101 | 865 | createItem(modelIndex, false); | 876 | createItem(modelIndex, false); |
102 | 866 | refill(); | 877 | refill(); |
103 | @@ -915,11 +926,11 @@ | |||
104 | 915 | if (visibleIndex >= 0 && visibleIndex < m_visibleItems.count()) { | 926 | if (visibleIndex >= 0 && visibleIndex < m_visibleItems.count()) { |
105 | 916 | ListItem *item = m_visibleItems[visibleIndex]; | 927 | ListItem *item = m_visibleItems[visibleIndex]; |
106 | 917 | // Pass the section item down if needed | 928 | // Pass the section item down if needed |
108 | 918 | if (item->m_sectionItem && visibleIndex + 1 < m_visibleItems.count()) { | 929 | if (item->sectionItem() && visibleIndex + 1 < m_visibleItems.count()) { |
109 | 919 | ListItem *nextItem = m_visibleItems[visibleIndex + 1]; | 930 | ListItem *nextItem = m_visibleItems[visibleIndex + 1]; |
113 | 920 | if (!nextItem->m_sectionItem) { | 931 | if (!nextItem->sectionItem()) { |
114 | 921 | nextItem->m_sectionItem = item->m_sectionItem; | 932 | nextItem->setSectionItem(item->sectionItem()); |
115 | 922 | item->m_sectionItem = nullptr; | 933 | item->setSectionItem(nullptr); |
116 | 923 | } | 934 | } |
117 | 924 | } | 935 | } |
118 | 925 | releaseItem(item); | 936 | releaseItem(item); |
119 | @@ -982,11 +993,11 @@ | |||
120 | 982 | // if we need adding a new section item | 993 | // if we need adding a new section item |
121 | 983 | if (m_sectionDelegate) { | 994 | if (m_sectionDelegate) { |
122 | 984 | ListItem *nextItem = itemAtIndex(modelIndex + 1); | 995 | ListItem *nextItem = itemAtIndex(modelIndex + 1); |
126 | 985 | if (nextItem && !nextItem->m_sectionItem) { | 996 | if (nextItem && !nextItem->sectionItem()) { |
127 | 986 | nextItem->m_sectionItem = getSectionItem(modelIndex + 1, true /* alredy inserted into m_visibleItems*/); | 997 | nextItem->setSectionItem(getSectionItem(modelIndex + 1, true /* alredy inserted into m_visibleItems*/)); |
128 | 987 | if (growUp && nextItem->m_sectionItem) { | 998 | if (growUp && nextItem->sectionItem()) { |
129 | 988 | ListItem *firstItem = m_visibleItems.first(); | 999 | ListItem *firstItem = m_visibleItems.first(); |
131 | 989 | firstItem->setY(firstItem->y() - nextItem->m_sectionItem->height()); | 1000 | firstItem->setY(firstItem->y() - nextItem->sectionItem()->height()); |
132 | 990 | } | 1001 | } |
133 | 991 | } | 1002 | } |
134 | 992 | } | 1003 | } |
135 | @@ -1012,8 +1023,8 @@ | |||
136 | 1012 | // qDebug() << "ListViewWithPageHeader::onModelUpdated Change" << change.index << change.count; | 1023 | // qDebug() << "ListViewWithPageHeader::onModelUpdated Change" << change.index << change.count; |
137 | 1013 | for (int i = change.index; i < change.count; ++i) { | 1024 | for (int i = change.index; i < change.count; ++i) { |
138 | 1014 | ListItem *item = itemAtIndex(i); | 1025 | ListItem *item = itemAtIndex(i); |
141 | 1015 | if (item && item->m_sectionItem) { | 1026 | if (item && item->sectionItem()) { |
142 | 1016 | QQmlContext *context = QQmlEngine::contextForObject(item->m_sectionItem)->parentContext(); | 1027 | QQmlContext *context = QQmlEngine::contextForObject(item->sectionItem())->parentContext(); |
143 | 1017 | const QString sectionText = m_delegateModel->stringValue(i, m_sectionProperty); | 1028 | const QString sectionText = m_delegateModel->stringValue(i, m_sectionProperty); |
144 | 1018 | context->setContextProperty(QLatin1String("section"), sectionText); | 1029 | context->setContextProperty(QLatin1String("section"), sectionText); |
145 | 1019 | } | 1030 | } |
146 | @@ -1026,8 +1037,8 @@ | |||
147 | 1026 | 1037 | ||
148 | 1027 | for (int i = 0; i < m_visibleItems.count(); ++i) { | 1038 | for (int i = 0; i < m_visibleItems.count(); ++i) { |
149 | 1028 | ListItem *item = m_visibleItems[i]; | 1039 | ListItem *item = m_visibleItems[i]; |
152 | 1029 | if (item->m_sectionItem) { | 1040 | if (item->sectionItem()) { |
153 | 1030 | QQmlContext *context = QQmlEngine::contextForObject(item->m_sectionItem)->parentContext(); | 1041 | QQmlContext *context = QQmlEngine::contextForObject(item->sectionItem())->parentContext(); |
154 | 1031 | context->setContextProperty(QLatin1String("delegateIndex"), m_firstVisibleIndex + i); | 1042 | context->setContextProperty(QLatin1String("delegateIndex"), m_firstVisibleIndex + i); |
155 | 1032 | } | 1043 | } |
156 | 1033 | } | 1044 | } |
157 | @@ -1156,18 +1167,18 @@ | |||
158 | 1156 | if (topSectionStickPos > pos) { | 1167 | if (topSectionStickPos > pos) { |
159 | 1157 | showStickySectionItem = true; | 1168 | showStickySectionItem = true; |
160 | 1158 | } else if (topSectionStickPos == pos) { | 1169 | } else if (topSectionStickPos == pos) { |
162 | 1159 | showStickySectionItem = !item->m_sectionItem; | 1170 | showStickySectionItem = !item->sectionItem(); |
163 | 1160 | } else { | 1171 | } else { |
164 | 1161 | showStickySectionItem = false; | 1172 | showStickySectionItem = false; |
165 | 1162 | } | 1173 | } |
166 | 1163 | if (!showStickySectionItem) { | 1174 | if (!showStickySectionItem) { |
167 | 1164 | QQuickItemPrivate::get(m_topSectionItem)->setCulled(true); | 1175 | QQuickItemPrivate::get(m_topSectionItem)->setCulled(true); |
169 | 1165 | if (item->m_sectionItem) { | 1176 | if (item->sectionItem()) { |
170 | 1166 | // This seems it should happen since why would we cull the top section | 1177 | // This seems it should happen since why would we cull the top section |
171 | 1167 | // if the first visible item has no section header? This only happens briefly | 1178 | // if the first visible item has no section header? This only happens briefly |
172 | 1168 | // when increasing the height of a list that is at the bottom, the m_topSectionItem | 1179 | // when increasing the height of a list that is at the bottom, the m_topSectionItem |
173 | 1169 | // gets shown shortly in the next polish call | 1180 | // gets shown shortly in the next polish call |
175 | 1170 | QQuickItemPrivate::get(item->m_sectionItem)->setCulled(false); | 1181 | QQuickItemPrivate::get(item->sectionItem())->setCulled(false); |
176 | 1171 | } | 1182 | } |
177 | 1172 | } else { | 1183 | } else { |
178 | 1173 | // Update the top sticky section header | 1184 | // Update the top sticky section header |
179 | @@ -1186,14 +1197,14 @@ | |||
180 | 1186 | delegateIndex--; | 1197 | delegateIndex--; |
181 | 1187 | } | 1198 | } |
182 | 1188 | context->setContextProperty(QLatin1String("delegateIndex"), delegateIndex); | 1199 | context->setContextProperty(QLatin1String("delegateIndex"), delegateIndex); |
185 | 1189 | if (item->m_sectionItem) { | 1200 | if (item->sectionItem()) { |
186 | 1190 | QQuickItemPrivate::get(item->m_sectionItem)->setCulled(true); | 1201 | QQuickItemPrivate::get(item->sectionItem())->setCulled(true); |
187 | 1191 | } | 1202 | } |
188 | 1192 | } | 1203 | } |
189 | 1193 | } | 1204 | } |
190 | 1194 | } | 1205 | } |
191 | 1195 | QQmlContext *context = QQmlEngine::contextForObject(item->m_item)->parentContext(); | 1206 | QQmlContext *context = QQmlEngine::contextForObject(item->m_item)->parentContext(); |
193 | 1196 | const qreal clipFrom = visibleFrom + (!item->m_sectionItem && m_topSectionItem && !QQuickItemPrivate::get(m_topSectionItem)->culled ? m_topSectionItem->height() : 0); | 1207 | const qreal clipFrom = visibleFrom + (!item->sectionItem() && m_topSectionItem && !QQuickItemPrivate::get(m_topSectionItem)->culled ? m_topSectionItem->height() : 0); |
194 | 1197 | if (!cull && pos < clipFrom) { | 1208 | if (!cull && pos < clipFrom) { |
195 | 1198 | context->setContextProperty(QLatin1String("heightToClip"), clipFrom - pos); | 1209 | context->setContextProperty(QLatin1String("heightToClip"), clipFrom - pos); |
196 | 1199 | } else { | 1210 | } else { |
197 | @@ -1210,7 +1221,7 @@ | |||
198 | 1210 | if (firstReallyVisibleItem >= 0) { | 1221 | if (firstReallyVisibleItem >= 0) { |
199 | 1211 | for (int i = firstReallyVisibleItem - m_firstVisibleIndex + 1; i < m_visibleItems.count(); ++i) { | 1222 | for (int i = firstReallyVisibleItem - m_firstVisibleIndex + 1; i < m_visibleItems.count(); ++i) { |
200 | 1212 | ListItem *item = m_visibleItems[i]; | 1223 | ListItem *item = m_visibleItems[i]; |
202 | 1213 | if (item->m_sectionItem) { | 1224 | if (item->sectionItem()) { |
203 | 1214 | if (m_topSectionItem->y() + m_topSectionItem->height() > item->y()) { | 1225 | if (m_topSectionItem->y() + m_topSectionItem->height() > item->y()) { |
204 | 1215 | m_topSectionItem->setY(item->y() - m_topSectionItem->height()); | 1226 | m_topSectionItem->setY(item->y() - m_topSectionItem->height()); |
205 | 1216 | } | 1227 | } |
206 | 1217 | 1228 | ||
207 | === modified file 'plugins/Dash/listviewwithpageheader.h' | |||
208 | --- plugins/Dash/listviewwithpageheader.h 2014-04-24 14:13:21 +0000 | |||
209 | +++ plugins/Dash/listviewwithpageheader.h 2014-06-05 08:44:16 +0000 | |||
210 | @@ -128,7 +128,11 @@ | |||
211 | 128 | bool culled() const; | 128 | bool culled() const; |
212 | 129 | void setCulled(bool culled); | 129 | void setCulled(bool culled); |
213 | 130 | 130 | ||
214 | 131 | QQuickItem *sectionItem() const { return m_sectionItem; } | ||
215 | 132 | void setSectionItem(QQuickItem *sectionItem); | ||
216 | 133 | |||
217 | 131 | QQuickItem *m_item; | 134 | QQuickItem *m_item; |
218 | 135 | private: | ||
219 | 132 | QQuickItem *m_sectionItem; | 136 | QQuickItem *m_sectionItem; |
220 | 133 | }; | 137 | }; |
221 | 134 | 138 | ||
222 | 135 | 139 | ||
223 | === modified file 'qml/Dash/GenericScopeView.qml' | |||
224 | --- qml/Dash/GenericScopeView.qml 2014-05-28 07:17:08 +0000 | |||
225 | +++ qml/Dash/GenericScopeView.qml 2014-06-05 08:44:16 +0000 | |||
226 | @@ -141,6 +141,7 @@ | |||
227 | 141 | top: parent.top | 141 | top: parent.top |
228 | 142 | left: parent.left | 142 | left: parent.left |
229 | 143 | right: parent.right | 143 | right: parent.right |
230 | 144 | topMargin: hasSectionHeader ? 0 : units.gu(2) | ||
231 | 144 | } | 145 | } |
232 | 145 | 146 | ||
233 | 146 | source: { | 147 | source: { |
234 | 147 | 148 | ||
235 | === modified file 'tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp' | |||
236 | --- tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp 2014-05-05 22:07:57 +0000 | |||
237 | +++ tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp 2014-06-05 08:44:16 +0000 | |||
238 | @@ -82,10 +82,10 @@ | |||
239 | 82 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->y(), pos); | 82 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->y(), pos); |
240 | 83 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->height(), height); | 83 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->height(), height); |
241 | 84 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_item)->culled, culled); | 84 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_item)->culled, culled); |
243 | 85 | QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), sectionHeader); | 85 | QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->sectionItem()), sectionHeader); |
244 | 86 | if (!sectionHeader.isNull()) { | 86 | if (!sectionHeader.isNull()) { |
247 | 87 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_sectionItem)->culled, sectionHeaderCulled); | 87 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->sectionItem())->culled, sectionHeaderCulled); |
248 | 88 | QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), lvwph->m_firstVisibleIndex + visibleIndex); | 88 | QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->sectionItem()), lvwph->m_firstVisibleIndex + visibleIndex); |
249 | 89 | } | 89 | } |
250 | 90 | } | 90 | } |
251 | 91 | 91 | ||
252 | 92 | 92 | ||
253 | === modified file 'tests/plugins/Dash/listviewwithpageheadersectiontest.cpp' | |||
254 | --- tests/plugins/Dash/listviewwithpageheadersectiontest.cpp 2014-05-05 22:07:57 +0000 | |||
255 | +++ tests/plugins/Dash/listviewwithpageheadersectiontest.cpp 2014-06-05 08:44:16 +0000 | |||
256 | @@ -39,10 +39,11 @@ | |||
257 | 39 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->y(), pos); | 39 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->y(), pos); |
258 | 40 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->height(), height); | 40 | QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->height(), height); |
259 | 41 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_item)->culled, culled); | 41 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_item)->culled, culled); |
261 | 42 | QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), sectionHeader); | 42 | QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->sectionItem()), sectionHeader); |
262 | 43 | QTRY_COMPARE(hasSectionHeaderProperty(lvwph->m_visibleItems[visibleIndex]->m_item), !sectionHeader.isNull()); | ||
263 | 43 | if (!sectionHeader.isNull()) { | 44 | if (!sectionHeader.isNull()) { |
266 | 44 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_sectionItem)->culled, sectionHeaderCulled); | 45 | QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->sectionItem())->culled, sectionHeaderCulled); |
267 | 45 | QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), lvwph->m_firstVisibleIndex + visibleIndex); | 46 | QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->sectionItem()), lvwph->m_firstVisibleIndex + visibleIndex); |
268 | 46 | } | 47 | } |
269 | 47 | } | 48 | } |
270 | 48 | 49 | ||
271 | @@ -109,12 +110,17 @@ | |||
272 | 109 | QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled); | 110 | QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled); |
273 | 110 | } | 111 | } |
274 | 111 | 112 | ||
276 | 112 | QString section(QQuickItem *item) | 113 | bool hasSectionHeaderProperty(QQuickItem *item) const |
277 | 114 | { | ||
278 | 115 | return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("hasSectionHeader")).toBool() : false; | ||
279 | 116 | } | ||
280 | 117 | |||
281 | 118 | QString section(QQuickItem *item) const | ||
282 | 113 | { | 119 | { |
283 | 114 | return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("section")).toString() : QString(); | 120 | return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("section")).toString() : QString(); |
284 | 115 | } | 121 | } |
285 | 116 | 122 | ||
287 | 117 | int sectionDelegateIndex(QQuickItem *item) | 123 | int sectionDelegateIndex(QQuickItem *item) const |
288 | 118 | { | 124 | { |
289 | 119 | return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("delegateIndex")).toInt() : -1; | 125 | return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("delegateIndex")).toInt() : -1; |
290 | 120 | } | 126 | } |
It looks bigger than it is, since i made m_sectionItem private and replaced its uses with getter+setter