on xenial help sign in
Do the maximizeVisibleArea animation at the same time that the unfilterIne
commitbb6f147bcf87ae202359cb54e47fca6943cc17a7 authorAlbert Astals <albert.astals@canonical.com> dateTue 13 Aug 2013, 17:20 (13 years ago) parentd90fbf7
3 files changed+27−12
Dash/GenericScopeView.qml+3−5 plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+21−7 plugins/ListViewWithPageHeader/listviewwithpageheader.h+3
Dash/GenericScopeView.qml+3−5
@@ -101,11 +101,6 @@ ScopeView {
101101 delegateItem.model.dndUri,
102102 delegateItem.model.metadata)
103103 }
104− onFilterChanged: {
105− if (!target.filter) {
106− categoryView.maximizeVisibleArea(index);
107− }
108− }
109104 }
110105 Connections {
111106 target: categoryView
@@ -122,6 +117,9 @@ ScopeView {
122117 } else {
123118 item.filter = shouldFilter;
124119 }
120+ if (!shouldFilter) {
121+ categoryView.maximizeVisibleArea(index, item.uncollapsedHeight);
122+ }
125123 }
126124 }
127125 }
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+21−7
@@ -392,18 +392,32 @@ QQuickItem *ListViewWithPageHeader::item(int modelIndex) const
392392bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
393393{
394394 ListItem *listItem = itemAtIndex(modelIndex);
395− if (listItem)
396− {
395+ return maximizeVisibleArea(listItem, listItem->height());
396+}
397+
398+bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex, int itemHeight)
399+{
400+ ListItem *listItem = itemAtIndex(modelIndex);
401+ if (listItem) {
402+ return maximizeVisibleArea(listItem, itemHeight + (listItem->m_sectionItem ? listItem->m_sectionItem->height() : 0));
403+ }
404+
405+ return false;
406+}
407+
408+bool ListViewWithPageHeader::maximizeVisibleArea(ListItem *listItem, int listItemHeight)
409+{
410+ if (listItem) {
397411 layout();
398412 const auto listItemY = m_clipItem->y() + listItem->y();
399− if (listItemY > contentY() && listItemY + listItem->height() > contentY() + height()) {
413+ if (listItemY > contentY() && listItemY + listItemHeight > contentY() + height()) {
400414 // we can scroll the list up to show more stuff
401− const auto to = qMin(listItemY, listItemY + listItem->height() - height());
415+ const auto to = qMin(listItemY, listItemY + listItemHeight - height());
402416 m_contentYAnimation->setTo(to);
403417 contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
404418 m_contentYAnimation->start();
405− } else if ((listItemY < contentY() && listItemY + listItem->height() < contentY() + height()) ||
406− (m_topSectionItem && !listItem->m_sectionItem && listItemY - m_topSectionItem->height() < contentY() && listItemY + listItem->height() < contentY() + height()))
419+ } else if ((listItemY < contentY() && listItemY + listItemHeight < contentY() + height()) ||
420+ (m_topSectionItem && !listItem->m_sectionItem && listItemY - m_topSectionItem->height() < contentY() && listItemY + listItemHeight < contentY() + height()))
407421 {
408422 // we can scroll the list down to show more stuff
409423 auto realVisibleListItemY = listItemY;
@@ -416,7 +430,7 @@ bool ListViewWithPageHeader::maximizeVisibleArea(int modelIndex)
416430 realVisibleListItemY -= m_topSectionItem->height();
417431 }
418432 }
419− const auto to = qMax(realVisibleListItemY, listItemY + listItem->height() - height());
433+ const auto to = qMax(realVisibleListItemY, listItemY + listItemHeight - height());
420434 m_contentYAnimation->setTo(to);
421435 contentYAnimationType = ContentYAnimationMaximizeVisibleArea;
422436 m_contentYAnimation->start();
plugins/ListViewWithPageHeader/listviewwithpageheader.h+3
@@ -94,6 +94,7 @@ public:
9494 // Created items are those visible and the precached ones
9595 // Returns if the item existed or not
9696 Q_INVOKABLE bool maximizeVisibleArea(int modelIndex);
97+ Q_INVOKABLE bool maximizeVisibleArea(int modelIndex, int itemHeight);
9798
9899Q_SIGNALS:
99100 void modelChanged();
@@ -142,6 +143,8 @@ private:
142143 QQuickItem *m_sectionItem;
143144 };
144145
146+ bool maximizeVisibleArea(ListItem *listItem, int listItemHeight);
147+
145148 void createDelegateModel();
146149
147150 void layout();