on xenial help sign in
More headerless category fixes

* When removing an item don't pass header down to next item if it was headerless because it should have no header (as oposed to it being headerless because shares section with previous item) * Also push the sticky header up if a headerless category is croping up

commitf4fa25f2ffe920face9339fb15976784a0065f06 authorAlbert Astals <albert.astals@canonical.com> dateTue 22 Jul 2014, 18:54 (12 years ago) parentcd6a049
1 file changed+20−3
plugins/Dash/listviewwithpageheader.cpp+20−3
plugins/Dash/listviewwithpageheader.cpp+20−3
@@ -931,12 +931,17 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
931931 const int visibleIndex = remove.index + i - m_firstVisibleIndex;
932932 if (visibleIndex >= 0 && visibleIndex < m_visibleItems.count()) {
933933 ListItem *item = m_visibleItems[visibleIndex];
934− // Pass the section item down if needed
934+ // Pass the section item down if needed i.e. has no sectionItem because
935+ // had same section string (and not because it has no section at all)
935936 if (item->sectionItem() && visibleIndex + 1 < m_visibleItems.count()) {
936937 ListItem *nextItem = m_visibleItems[visibleIndex + 1];
937938 if (!nextItem->sectionItem()) {
938− nextItem->setSectionItem(item->sectionItem());
939− item->setSectionItem(nullptr);
939+ const int modelIndex = remove.index + i;
940+ const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
941+ if (!section.isEmpty()) {
942+ nextItem->setSectionItem(item->sectionItem());
943+ item->setSectionItem(nullptr);
944+ }
940945 }
941946 }
942947 releaseItem(item);
@@ -1250,6 +1255,18 @@ void ListViewWithPageHeader::layout()
12501255 m_topSectionItem->setY(item->y() - m_topSectionItem->height());
12511256 }
12521257 break;
1258+ } else {
1259+ // Is there no header because it's same section name or because has no section?
1260+ // Because it is because we have no section (header) we still have to push it up
1261+ const QString section = m_delegateModel->stringValue(firstReallyVisibleItem + 1, m_sectionProperty);
1262+ if (section.isEmpty()) {
1263+ if (m_topSectionItem->y() + m_topSectionItem->height() > item->y()) {
1264+ m_topSectionItem->setY(item->y() - m_topSectionItem->height());
1265+ QQmlContext *context = QQmlEngine::contextForObject(item->m_item)->parentContext();
1266+ context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
1267+ }
1268+ break;
1269+ }
12531270 }
12541271 }
12551272 }