on xenial help sign in
Dash category expansion.
137f3feAlbert Astals
Components/FilterGrid.qml+31−61
@@ -35,12 +35,18 @@ Item {
35
35
36 /* Whether, when collapsed, a button should be displayed enabling the user to expand
36 /* Whether, when collapsed, a button should be displayed enabling the user to expand
37 the grid to its full size. */
37 the grid to its full size. */
38− property bool expandable: true
38+ readonly property bool expandable: model.count > collapsedRowCount * iconTileGrid.columns
39
39
40 property var model: null
40 property var model: null
41
41
42 /* Maximum number of rows to be show when filter=true. */
42 /* Maximum number of rows to be show when filter=true. */
43 property int collapsedRowCount: 2
43 property int collapsedRowCount: 2
44+ readonly property int collapsedHeight: {
45+ return iconTileGrid.contentHeightForRows(Math.min(collapsedRowCount, Math.ceil(model.count / columns)))
46+ }
47+ readonly property int uncollapsedHeight: {
48+ return iconTileGrid.contentHeightForRows(Math.ceil(model.count / columns))
49+ }
44
50
45 property alias minimumHorizontalSpacing: iconTileGrid.minimumHorizontalSpacing
51 property alias minimumHorizontalSpacing: iconTileGrid.minimumHorizontalSpacing
46 property alias maximumNumberOfColumns: iconTileGrid.maximumNumberOfColumns
52 property alias maximumNumberOfColumns: iconTileGrid.maximumNumberOfColumns
@@ -55,7 +61,29 @@ Item {
55 readonly property alias moving: iconTileGrid.moving
61 readonly property alias moving: iconTileGrid.moving
56 readonly property alias pressDelay: iconTileGrid.pressDelay
62 readonly property alias pressDelay: iconTileGrid.pressDelay
57
63
58− height: childrenRect.height
64+ height: !filterAnimation.running ? childrenRect.height : height
65+ clip: filterAnimation.running
66+
67+ NumberAnimation {
68+ property bool filterEndValue
69+ id: filterAnimation
70+ target: root
71+ property: "height"
72+ to: filterEndValue ? root.collapsedHeight : root.uncollapsedHeight
73+ // Duration and easing here match the ListViewWithPageHeader::m_contentYAnimation
74+ // otherwise since both animations can run at the same time you'll get
75+ // some visual weirdness.
76+ duration: 200
77+ easing.type: Easing.InOutQuad
78+ onStopped: {
79+ root.filter = filterEndValue;
80+ }
81+ }
82+
83+ function startFilterAnimation(filter) {
84+ filterAnimation.filterEndValue = filter
85+ filterAnimation.start();
86+ }
59
87
60 ResponsiveGridView {
88 ResponsiveGridView {
61 id: iconTileGrid
89 id: iconTileGrid
@@ -72,66 +100,8 @@ Item {
72
100
73 model: LimitProxyModel {
101 model: LimitProxyModel {
74 model: root.model
102 model: root.model
75− limit: (filter) ? collapsedRowCount * iconTileGrid.columns : -1
103+ limit: (filter && !filterAnimation.running) ? collapsedRowCount * iconTileGrid.columns : -1
76 }
104 }
77
105
78 }
106 }
79−
80− Item {
81− anchors {
82− left: parent.left
83− right: parent.right
84− top: iconTileGrid.bottom
85− }
86− visible: (expandable && filter && model.count > collapsedRowCount * iconTileGrid.columns)
87− height: (visible) ? childrenRect.height + units.gu(2) : 0
88−
89− AbstractButton {
90− id: button
91− objectName: "filterToggleButton"
92−
93− anchors {
94− top: parent.top
95− horizontalCenter: parent.horizontalCenter
96− }
97− width: units.gu(22)
98− height: units.gu(4)
99−
100− UbuntuShape {
101− anchors.fill: parent
102− color: "#33ffffff" // FIXME no palette
103− radius: "small"
104− }
105−
106− UbuntuShape {
107− id: borderPressed
108−
109− anchors.fill: parent
110− radius: "small"
111− borderSource: "radius_pressed.sci"
112− opacity: button.pressed ? 1.0 : 0.0
113− Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
114− }
115−
116− Label {
117− anchors {
118− verticalCenter: parent.verticalCenter
119− left: parent.left
120− right: parent.right
121− leftMargin: units.gu(1)
122− rightMargin: units.gu(1)
123− }
124− text: (filter) ? "+ View all (" + model.count + ")" : "- Show fewer"
125− fontSize: "small"
126− color: Theme.palette.selected.backgroundText
127− opacity: 0.6
128− style: Text.Raised
129− styleColor: "black"
130− elide: Text.ElideMiddle
131− horizontalAlignment: Text.AlignHCenter
132− }
133−
134− onClicked: filter = !filter
135− }
136− }
137}
107}
Components/ListItems/Header.qml+19−2
@@ -24,6 +24,9 @@ Item {
24 \qmlproperty string text
24 \qmlproperty string text
25 */
25 */
26 property alias text: label.text
26 property alias text: label.text
27+ property alias image: image.source
28+
29+ signal clicked(variant mouse)
27
30
28 height: units.gu(4.5)
31 height: units.gu(4.5)
29
32
@@ -31,6 +34,7 @@ Item {
31 anchors {
34 anchors {
32 left: parent.left
35 left: parent.left
33 right: parent.right
36 right: parent.right
37+ rightMargin: units.gu(0.5)
34 top: parent.top
38 top: parent.top
35 bottom: bottomBorder.top
39 bottom: bottomBorder.top
36 }
40 }
@@ -40,8 +44,6 @@ Item {
40 anchors {
44 anchors {
41 left: parent.left
45 left: parent.left
42 leftMargin: units.gu(2)
46 leftMargin: units.gu(2)
43− right: parent.right
44− rightMargin: units.gu(0.5)
45 verticalCenter: parent.verticalCenter
47 verticalCenter: parent.verticalCenter
46 }
48 }
47
49
@@ -53,6 +55,16 @@ Item {
53 textFormat: Text.PlainText
55 textFormat: Text.PlainText
54 style: Text.Raised
56 style: Text.Raised
55 styleColor: "black"
57 styleColor: "black"
58+ width: parent.width - image.width - image.leftMargin - anchors.leftMargin
59+ }
60+
61+ Image {
62+ id: image
63+ readonly property double leftMargin: units.gu(1)
64+ x: label.x + label.contentWidth + leftMargin
65+ anchors {
66+ verticalCenter: parent.verticalCenter
67+ }
56 }
68 }
57 }
69 }
58
70
@@ -64,4 +76,9 @@ Item {
64 bottom: parent.bottom
76 bottom: parent.bottom
65 }
77 }
66 }
78 }
79+
80+ MouseArea {
81+ anchors.fill: parent
82+ onClicked: parent.clicked(mouse)
83+ }
67}
84}
Components/ResponsiveGridView.qml+7−1
@@ -32,12 +32,18 @@ Item {
32 property alias delegate: gridView.delegate
32 property alias delegate: gridView.delegate
33 readonly property int cellWidth: gridView.cellWidth
33 readonly property int cellWidth: gridView.cellWidth
34 readonly property int cellHeight: gridView.cellHeight
34 readonly property int cellHeight: gridView.cellHeight
35− readonly property int totalContentHeight: Math.ceil(gridView.model.count / columns) * cellHeight + verticalSpacing
35+ readonly property int totalContentHeight: {
36+ return contentHeightForRows(Math.ceil(gridView.model.count / columns))
37+ }
36 property alias interactive: gridView.interactive
38 property alias interactive: gridView.interactive
37 readonly property alias flicking: gridView.flicking
39 readonly property alias flicking: gridView.flicking
38 readonly property alias moving: gridView.moving
40 readonly property alias moving: gridView.moving
39 readonly property alias pressDelay: gridView.pressDelay
41 readonly property alias pressDelay: gridView.pressDelay
40
42
43+ function contentHeightForRows(rows) {
44+ return rows * cellHeight + verticalSpacing
45+ }
46+
41 GridView {
47 GridView {
42 id: gridView
48 id: gridView
43 objectName: "responsiveGridViewGrid"
49 objectName: "responsiveGridViewGrid"
Components/Tile.qml−6
@@ -84,10 +84,4 @@ AbstractButton {
84 horizontalAlignment: Text.AlignHCenter
84 horizontalAlignment: Text.AlignHCenter
85 }
85 }
86 }
86 }
87−
88− GridView.onRemove: SequentialAnimation {
89− PropertyAction { target: root; property: "GridView.delayRemove"; value: true }
90− NumberAnimation { target: root; property: "opacity"; from: 1; to: 0; duration: 200; easing.type: Easing.InOutQuad }
91− PropertyAction { target: root; property: "GridView.delayRemove"; value: false }
92− }
93}
87}
Dash/Apps/ApplicationsFilterGrid.qml−1
@@ -23,7 +23,6 @@ FilterGrid {
23 id: filterGrid
23 id: filterGrid
24
24
25 filter: false
25 filter: false
26− expandable: false
27 minimumHorizontalSpacing: units.gu(0.5)
26 minimumHorizontalSpacing: units.gu(0.5)
28 maximumNumberOfColumns: 6
27 maximumNumberOfColumns: 6
29 delegateWidth: units.gu(11)
28 delegateWidth: units.gu(11)
Dash/Generic/GenericFilterGrid.qml−1
@@ -21,7 +21,6 @@ import "../../Components/IconUtil.js" as IconUtil
21FilterGrid {
21FilterGrid {
22 id: filtergrid
22 id: filtergrid
23
23
24− filter: false
25 minimumHorizontalSpacing: units.gu(0.5)
24 minimumHorizontalSpacing: units.gu(0.5)
26 delegateWidth: units.gu(11)
25 delegateWidth: units.gu(11)
27 delegateHeight: units.gu(9.5)
26 delegateHeight: units.gu(9.5)
Dash/GenericScopeView.qml+39
@@ -53,9 +53,14 @@ ScopeView {
53 onAtYEndChanged: if (atYEnd) endReached()
53 onAtYEndChanged: if (atYEnd) endReached()
54 onMovingChanged: if (moving && atYEnd) endReached()
54 onMovingChanged: if (moving && atYEnd) endReached()
55
55
56+ property int expandedIndex: -1
57+
56 delegate: ListItems.Base {
58 delegate: ListItems.Base {
57 highlightWhenPressed: false
59 highlightWhenPressed: false
58
60
61+ readonly property bool expandable: rendererLoader.item ? rendererLoader.item.expandable : false
62+ readonly property bool filtered: rendererLoader.item ? rendererLoader.item.filter : true
63+
59 Loader {
64 Loader {
60 id: rendererLoader
65 id: rendererLoader
61 anchors {
66 anchors {
@@ -97,13 +102,47 @@ ScopeView {
97 delegateItem.model.metadata)
102 delegateItem.model.metadata)
98 }
103 }
99 }
104 }
105+ Connections {
106+ target: categoryView
107+ onExpandedIndexChanged: {
108+ var item = rendererLoader.item;
109+ if (item.expandable) {
110+ var shouldFilter = index != categoryView.expandedIndex;
111+ if (shouldFilter != item.filter) {
112+ // If the filter animation will be seen start it, otherwise, just flip the switch
113+ var shrinkingVisible = shouldFilter && y + item.collapsedHeight < categoryView.height;
114+ var growingVisible = !shouldFilter && y + height < categoryView.height;
115+ if (shrinkingVisible || growingVisible) {
116+ item.startFilterAnimation(shouldFilter)
117+ } else {
118+ item.filter = shouldFilter;
119+ }
120+ if (!shouldFilter) {
121+ categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
122+ }
123+ }
124+ }
125+ }
126+ }
100 }
127 }
101 }
128 }
102
129
103 sectionProperty: "name"
130 sectionProperty: "name"
104 sectionDelegate: ListItems.Header {
131 sectionDelegate: ListItems.Header {
132+ property var delegate: categoryView.item(delegateIndex)
105 width: categoryView.width
133 width: categoryView.width
106 text: section
134 text: section
135+ image: {
136+ if (delegate && delegate.expandable)
137+ return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
138+ return "";
139+ }
140+ onClicked: {
141+ if (categoryView.expandedIndex != delegateIndex)
142+ categoryView.expandedIndex = delegateIndex;
143+ else
144+ categoryView.expandedIndex = -1;
145+ }
107 }
146 }
108 pageHeader: PageHeader {
147 pageHeader: PageHeader {
109 id: pageHeader
148 id: pageHeader
Dash/Music/MusicFilterGrid.qml−1
@@ -20,7 +20,6 @@ import "../../Components"
20FilterGrid {
20FilterGrid {
21 id: filterGrid
21 id: filterGrid
22
22
23− expandable: false
24 minimumHorizontalSpacing: units.gu(2)
23 minimumHorizontalSpacing: units.gu(2)
25 maximumNumberOfColumns: 5
24 maximumNumberOfColumns: 5
26 delegateWidth: units.gu(17)
25 delegateWidth: units.gu(17)
Dash/Video/VideosFilterGrid.qml−1
@@ -20,7 +20,6 @@ import "../../Components"
20FilterGrid {
20FilterGrid {
21 id: filtergrid
21 id: filtergrid
22
22
23− expandable: false
24 minimumHorizontalSpacing: units.gu(0.5)
23 minimumHorizontalSpacing: units.gu(0.5)
25 maximumNumberOfColumns: 5
24 maximumNumberOfColumns: 5
26 delegateWidth: units.gu(11)
25 delegateWidth: units.gu(11)
Dash/graphics/header_handlearrow2@20.pngnew file

Binary file not shown.

Dash/graphics/header_handlearrow@20.pngnew file

Binary file not shown.

plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+46−11
@@ -280,7 +280,7 @@ void ListViewWithPageHeader::setSectionDelegate(QQmlComponent *delegate)
280
280
281 m_sectionDelegate = delegate;
281 m_sectionDelegate = delegate;
282
282
283− m_topSectionItem = getSectionItem(-1, QString());
283+ m_topSectionItem = getSectionItem(QString());
284 m_topSectionItem->setZ(3);
284 m_topSectionItem->setZ(3);
285 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
285 QQuickItemPrivate::get(m_topSectionItem)->setCulled(true);
286
286
@@ -380,20 +380,51 @@ void ListViewWithPageHeader::showHeader()
380 }
380 }
381}
381}
382
382
383+QQuickItem *ListViewWithPageHeader::item(int modelIndex) const
384+{
385+ ListItem *item = itemAtIndex(modelIndex);
386+ if (item)
387+ return item->m_item;
388+ else
389+ return nullptr;
390+}
391+
383bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
392bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
384{
393{
385 ListItem *listItem = itemAtIndex(modelIndex);
394 ListItem *listItem = itemAtIndex(modelIndex);
386− if (listItem)
395+ if (listItem) {
387− {
396+ return maximizeVisibleArea(listItem, listItem->height());
397+ }
398+
399+ return false;
400+}
401+
402+bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex, int itemHeight)
403+{
404+ if (itemHeight < 0)
405+ return false;
406+
407+ ListItem *listItem = itemAtIndex(modelIndex);
408+ if (listItem) {
409+ return maximizeVisibleArea(listItem, itemHeight + (listItem->m_sectionItem ? listItem->m_sectionItem->height() : 0));
410+ }
411+
412+ return false;
413+}
414+
415+bool ListViewWithPageHeader::maximizeVisibleArea(ListItem *listItem, int listItemHeight)
416+{
417+ if (listItem) {
418+ layout();
388 const auto listItemY = m_clipItem->y() + listItem->y();
419 const auto listItemY = m_clipItem->y() + listItem->y();
389− if (listItemY > contentY() && listItemY + listItem->height() > contentY() + height()) {
420+ if (listItemY > contentY() && listItemY + listItemHeight > contentY() + height()) {
390 // we can scroll the list up to show more stuff
421 // we can scroll the list up to show more stuff
391− const auto to = qMin(listItemY, listItemY + listItem->height() - height());
422+ const auto to = qMin(listItemY, listItemY + listItemHeight - height());
392 m_contentYAnimation->setTo(to);
423 m_contentYAnimation->setTo(to);
393 contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
424 contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
394 m_contentYAnimation->start();
425 m_contentYAnimation->start();
395− } else if ((listItemY < contentY() && listItemY + listItem->height() < contentY() + height()) ||
426+ } else if ((listItemY < contentY() && listItemY + listItemHeight < contentY() + height()) ||
396− (m_topSectionItem && !listItem->m_sectionItem && listItemY - m_topSectionItem->height() < contentY() && listItemY + listItem->height() < contentY() + height()))
427+ (m_topSectionItem && !listItem->m_sectionItem && listItemY - m_topSectionItem->height() < contentY() && listItemY + listItemHeight < contentY() + height()))
397 {
428 {
398 // we can scroll the list down to show more stuff
429 // we can scroll the list down to show more stuff
399 auto realVisibleListItemY = listItemY;
430 auto realVisibleListItemY = listItemY;
@@ -406,7 +437,7 @@ bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
406 realVisibleListItemY -= m_topSectionItem->height();
437 realVisibleListItemY -= m_topSectionItem->height();
407 }
438 }
408 }
439 }
409− const auto to = qMax(realVisibleListItemY, listItemY + listItem->height() - height());
440+ const auto to = qMax(realVisibleListItemY, listItemY + listItemHeight - height());
410 m_contentYAnimation->setTo(to);
441 m_contentYAnimation->setTo(to);
411 contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
442 contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
412 m_contentYAnimation->start();
443 m_contentYAnimation->start();
@@ -641,17 +672,17 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyI
641 }
672 }
642 }
673 }
643
674
644− return getSectionItem(modelIndex, section);
675+ return getSectionItem(section);
645}
676}
646
677
647−QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, const QString &sectionText)
678+QQuickItem *ListViewWithPageHeader::getSectionItem(const QString &sectionText)
648{
679{
649 QQuickItem *sectionItem = nullptr;
680 QQuickItem *sectionItem = nullptr;
650
681
651 QQmlContext *creationContext = m_sectionDelegate->creationContext();
682 QQmlContext *creationContext = m_sectionDelegate->creationContext();
652 QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
683 QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
653 context->setContextProperty(QLatin1String("section"), sectionText);
684 context->setContextProperty(QLatin1String("section"), sectionText);
654− context->setContextProperty(QLatin1String("delegateIndex"), modelIndex);
685+ context->setContextProperty(QLatin1String("delegateIndex"), -1);
655 QObject *nobj = m_sectionDelegate->beginCreate(context);
686 QObject *nobj = m_sectionDelegate->beginCreate(context);
656 if (nobj) {
687 if (nobj) {
657 QQml_setParent_noEvent(context, nobj);
688 QQml_setParent_noEvent(context, nobj);
@@ -786,6 +817,10 @@ ListViewWithPageHeader::ListItem *ListViewWithPageHeader::createItem(int modelIn
786 m_firstVisibleIndex = modelIndex;
817 m_firstVisibleIndex = modelIndex;
787 polish();
818 polish();
788 }
819 }
820+ if (listItem->m_sectionItem) {
821+ QQmlContext *context = QQmlEngine::contextForObject(listItem->m_sectionItem)->parentContext();
822+ context->setContextProperty(QLatin1String("delegateIndex"), modelIndex);
823+ }
789 adjustMinYExtent();
824 adjustMinYExtent();
790 m_contentHeightDirty = true;
825 m_contentHeightDirty = true;
791 }
826 }
plugins/ListViewWithPageHeader/listviewwithpageheader.h+5−1
@@ -88,11 +88,13 @@ public:
88
88
89 Q_INVOKABLE void positionAtBeginning();
89 Q_INVOKABLE void positionAtBeginning();
90 Q_INVOKABLE void showHeader();
90 Q_INVOKABLE void showHeader();
91+ Q_INVOKABLE QQuickItem *item(int modelIndex) const;
91
92
92 // The index has to be created for this to try to do something
93 // The index has to be created for this to try to do something
93 // Created items are those visible and the precached ones
94 // Created items are those visible and the precached ones
94 // Returns if the item existed or not
95 // Returns if the item existed or not
95 Q_INVOKABLE bool maximizeVisibleArea(int modelIndex);
96 Q_INVOKABLE bool maximizeVisibleArea(int modelIndex);
97+ Q_INVOKABLE bool maximizeVisibleArea(int modelIndex, int itemHeight);
96
98
97Q_SIGNALS:
99Q_SIGNALS:
98 void modelChanged();
100 void modelChanged();
@@ -141,6 +143,8 @@ private:
141 QQuickItem *m_sectionItem;
143 QQuickItem *m_sectionItem;
142 };
144 };
143
145
146+ bool maximizeVisibleArea(ListItem *listItem, int listItemHeight);
147+
144 void createDelegateModel();
148 void createDelegateModel();
145
149
146 void layout();
150 void layout();
@@ -157,7 +161,7 @@ private:
157 void reallyReleaseItem(ListItem *item);
161 void reallyReleaseItem(ListItem *item);
158 void updateWatchedRoles();
162 void updateWatchedRoles();
159 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
163 QQuickItem *getSectionItem(int modelIndex, bool alreadyInserted);
160− QQuickItem *getSectionItem(int modelIndex, const QString &sectionText);
164+ QQuickItem *getSectionItem(const QString &sectionText);
161
165
162#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
166#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
163 QQuickVisualDataModel *m_delegateModel;
167 QQuickVisualDataModel *m_delegateModel;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+22
@@ -1612,6 +1612,28 @@ private Q_SLOTS:
1612 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1612 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1613 }
1613 }
1614
1614
1615+ void testMaximizeVisibleAreaWithItemResize()
1616+ {
1617+ model->setProperty(0, "size", 1000);
1618+
1619+ bool res = lvwph->maximizeVisibleArea(1);
1620+ QVERIFY(res);
1621+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
1622+
1623+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1624+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1625+ verifyItem(0, -658., 1000., false);
1626+ verifyItem(1, 342., 200., false);
1627+ verifyItem(2, 542, 350., true);
1628+ QCOMPARE(lvwph->m_minYExtent, 0.);
1629+ QCOMPARE(lvwph->m_clipItem->y(), 708.);
1630+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1631+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1632+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1633+ QCOMPARE(lvwph->contentY(), 708.);
1634+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1635+ }
1636+
1615private:
1637private:
1616 QQuickView *view;
1638 QQuickView *view;
1617 ListViewWithPageHeader *lvwph;
1639 ListViewWithPageHeader *lvwph;
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+22
@@ -2033,6 +2033,28 @@ private Q_SLOTS:
2033 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
2033 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
2034 }
2034 }
2035
2035
2036+ void testMaximizeVisibleAreaWithItemResize()
2037+ {
2038+ model->setProperty(0, "size", 1000);
2039+
2040+ bool res = lvwph->maximizeVisibleArea(1);
2041+ QVERIFY(res);
2042+ QTRY_VERIFY(!lvwph->m_contentYAnimation->isRunning());
2043+
2044+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
2045+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
2046+ verifyItem(0, -738., 1040., false, "Agressive", true);
2047+ verifyItem(1, 302., 240., false, "Regular", false);
2048+ verifyItem(2, 542, 390., true, "Mild", true);
2049+ QCOMPARE(lvwph->m_minYExtent, 0.);
2050+ QCOMPARE(lvwph->m_clipItem->y(), 788.);
2051+ QCOMPARE(lvwph->m_clipItem->clip(), false);
2052+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
2053+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
2054+ QCOMPARE(lvwph->contentY(), 788.);
2055+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
2056+ }
2057+
2036private:
2058private:
2037 QQuickView *view;
2059 QQuickView *view;
2038 ListViewWithPageHeader *lvwph;
2060 ListViewWithPageHeader *lvwph;
tests/qmltests/Components/tst_FilterGrid.qml−35
@@ -42,15 +42,6 @@ Rectangle {
42 values: [1,2,3,4]
42 values: [1,2,3,4]
43 selectedIndex: 1
43 selectedIndex: 1
44 }
44 }
45− Row {
46− spacing: units.gu(1)
47− Label { anchors.verticalCenter: parent.verticalCenter
48− text: "Expandable" }
49− CheckBox {
50− id: expandableCheckBox
51− checked: true
52− }
53− }
54 Row {
45 Row {
55 spacing: units.gu(1)
46 spacing: units.gu(1)
56 Label { anchors.verticalCenter: parent.verticalCenter
47 Label { anchors.verticalCenter: parent.verticalCenter
@@ -94,7 +85,6 @@ Rectangle {
94 collapsedRowCount:
85 collapsedRowCount:
95 collapsedRowCountSelector.values[collapsedRowCountSelector.selectedIndex]
86 collapsedRowCountSelector.values[collapsedRowCountSelector.selectedIndex]
96 filter: filterCheckBox.checked
87 filter: filterCheckBox.checked
97− expandable: expandableCheckBox.checked
98 minimumHorizontalSpacing: units.gu(1)
88 minimumHorizontalSpacing: units.gu(1)
99 delegateWidth: units.gu(6)
89 delegateWidth: units.gu(6)
100 delegateHeight: units.gu(6)
90 delegateHeight: units.gu(6)
@@ -142,31 +132,6 @@ Rectangle {
142 collapsedRowCountSelector.selectedIndex = 1
132 collapsedRowCountSelector.selectedIndex = 1
143 }
133 }
144
134
145− // Checks that the filter toggle button, the one that says "View All (xy)",
146− // shows up only when it's possible for the grid to be expanded.
147− function test_filterToggleButton() {
148− var filterToggleButton = findChild(filterGrid, "filterToggleButton");
149−
150− for (var i = 0; i < 4; ++i) {
151− collapsedRowCountSelector.selectedIndex = i
152− // row count == index + 1
153− // The total number of rows is 4.
154−
155− expandableCheckBox.checked = false
156− compare(filterToggleButton.visible, false)
157− expandableCheckBox.checked = true
158−
159− if ((i+1) < 4)
160− compare(filterToggleButton.visible, true)
161− else
162− compare(filterToggleButton.visible, false)
163− }
164−
165− // back to initial state
166− collapsedRowCountSelector.selectedIndex = 1
167− expandableCheckBox.checked = true
168− }
169−
170 function countVisibleDelegates() {
135 function countVisibleDelegates() {
171 return __countVisibleDelegates(filterGrid.visibleChildren, 0)
136 return __countVisibleDelegates(filterGrid.visibleChildren, 0)
172 }
137 }