on xenial help sign in
Make headerless categories easier

Instead of having no header category (which is a bit confusing since the LVWPH code was designed so that when a category has no header it is because it shares the category with the previous one) what we have for headerless categories is a header of height 0, this way everything works as it should and results in cleaner code in the LVWPH and in GenericScopeView Approved by: Michał Sawicz

commit815f50e1c05bfd37d90215e7c0e6dfa2d9b092da authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 24 Jul 2014, 20:40 (12 years ago) parent1d7c1a33132c96
2 files changed+2−6
plugins/Dash/listviewwithpageheader.cpp−5 qml/Dash/GenericScopeView.qml+2−1
plugins/Dash/listviewwithpageheader.cpp−5
@@ -141,8 +141,6 @@ void ListViewWithPageHeader::ListItem::setCulled(bool culled)
141141void ListViewWithPageHeader::ListItem::setSectionItem(QQuickItem *sectionItem)
142142{
143143 m_sectionItem = sectionItem;
144− QQmlContext *context = QQmlEngine::contextForObject(m_item)->parentContext();
145− context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(sectionItem != nullptr));
146144}
147145
148146ListViewWithPageHeader::ListViewWithPageHeader()
@@ -685,8 +683,6 @@ QQuickItem *ListViewWithPageHeader::getSectionItem(int modelIndex, bool alreadyI
685683 return nullptr;
686684
687685 const QString section = m_delegateModel->stringValue(modelIndex, m_sectionProperty);
688− if (section.isEmpty())
689− return nullptr;
690686
691687 if (modelIndex > 0) {
692688 const QString prevSection = m_delegateModel->stringValue(modelIndex - 1, m_sectionProperty);
@@ -877,7 +873,6 @@ void ListViewWithPageHeader::itemCreated(int modelIndex, QObject *object)
877873 QQmlContext *context = QQmlEngine::contextForObject(item)->parentContext();
878874 context->setContextProperty(QLatin1String("ListViewWithPageHeader"), this);
879875 context->setContextProperty(QLatin1String("heightToClip"), QVariant::fromValue<int>(0));
880− context->setContextProperty(QLatin1String("hasSectionHeader"), QVariant::fromValue<bool>(false));
881876 if (modelIndex == m_asyncRequestedIndex) {
882877 createItem(modelIndex, false);
883878 refill();
qml/Dash/GenericScopeView.qml+2−1
@@ -171,7 +171,7 @@ FocusScope {
171171 top: parent.top
172172 left: parent.left
173173 right: parent.right
174− topMargin: hasSectionHeader ? 0 : units.gu(2)
174+ topMargin: name != "" ? 0 : units.gu(2)
175175 }
176176
177177 Behavior on height {
@@ -373,6 +373,7 @@ FocusScope {
373373 objectName: "dashSectionHeader" + (delegate ? delegate.category : "")
374374 property var delegate: categoryView.item(delegateIndex)
375375 width: categoryView.width
376+ height: section != "" ? units.gu(5) : 0
376377 text: section
377378 textColor: scopeStyle ? scopeStyle.foreground : "grey"
378379 }