summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/declarative/QmlChanges.txt2
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp33
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h13
3 files changed, 43 insertions, 5 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 432b5d6..336fbbf 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -14,6 +14,8 @@ Component:
- isReady, isLoading, isError and isNull properties removed, use
status property instead
- errorsString() renamed to errorString()
+ListView:
+ - ListView.prevSection property changed to ListView.previousSection
TextInput xToPosition -> positionAt (to match TextEdit.positionAt)
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index a69fc3f..4be8705 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -575,6 +575,10 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
listItem->attached->m_prevSection = item->attached->section();
else
listItem->attached->m_prevSection = sectionAt(modelIndex-1);
+ if (FxListItem *item = visibleItem(modelIndex+1))
+ listItem->attached->m_nextSection = item->attached->section();
+ else
+ listItem->attached->m_nextSection = sectionAt(modelIndex+1);
}
}
if (model->completePending()) {
@@ -951,14 +955,26 @@ void QDeclarativeListViewPrivate::updateSections()
QString prevSection;
if (visibleIndex > 0)
prevSection = sectionAt(visibleIndex-1);
+ QDeclarativeListViewAttached *prevAtt = 0;
+ int idx = -1;
for (int i = 0; i < visibleItems.count(); ++i) {
if (visibleItems.at(i)->index != -1) {
QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached;
attached->setPrevSection(prevSection);
+ if (prevAtt)
+ prevAtt->setNextSection(attached->section());
createSection(visibleItems.at(i));
prevSection = attached->section();
+ prevAtt = attached;
+ idx = visibleItems.at(i)->index;
}
}
+ if (prevAtt) {
+ if (idx > 0 && idx < model->count()-1)
+ prevAtt->setNextSection(sectionAt(idx+1));
+ else
+ prevAtt->setNextSection(QString());
+ }
}
}
@@ -1418,7 +1434,7 @@ QDeclarativeListView::~QDeclarativeListView()
*/
/*!
- \qmlattachedproperty string ListView::prevSection
+ \qmlattachedproperty string ListView::previousSection
This attached property holds the section of the previous element.
It is attached to each instance of the delegate.
@@ -1427,6 +1443,15 @@ QDeclarativeListView::~QDeclarativeListView()
*/
/*!
+ \qmlattachedproperty string ListView::nextSection
+ This attached property holds the section of the next element.
+
+ It is attached to each instance of the delegate.
+
+ The section is evaluated using the \l {ListView::section.property}{section} properties.
+*/
+
+/*!
\qmlattachedproperty string ListView::section
This attached property holds the section of this element.
@@ -1963,9 +1988,9 @@ void QDeclarativeListView::setCacheBuffer(int b)
\c section.delegate holds the delegate component for each section.
- Each item in the list has attached properties named \c ListView.section and
- \c ListView.prevSection. These may be used to place a section header for
- related items.
+ Each item in the list has attached properties named \c ListView.section,
+ \c ListView.previousSection and \c ListView.nextSection. These may be
+ used to place a section header for related items.
For example, here is a ListView that displays a list of animals, separated
into sections. Each item in the ListView is placed in a different section
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index 505f659..f55db9b 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -279,7 +279,7 @@ public:
}
}
- Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged)
+ Q_PROPERTY(QString previousSection READ prevSection NOTIFY prevSectionChanged)
QString prevSection() const { return m_prevSection; }
void setPrevSection(const QString &sect) {
if (m_prevSection != sect) {
@@ -288,6 +288,15 @@ public:
}
}
+ Q_PROPERTY(QString nextSection READ nextSection NOTIFY nextSectionChanged)
+ QString nextSection() const { return m_nextSection; }
+ void setNextSection(const QString &sect) {
+ if (m_nextSection != sect) {
+ m_nextSection = sect;
+ emit nextSectionChanged();
+ }
+ }
+
Q_PROPERTY(QString section READ section NOTIFY sectionChanged)
QString section() const { return m_section; }
void setSection(const QString &sect) {
@@ -313,6 +322,7 @@ Q_SIGNALS:
void currentItemChanged();
void sectionChanged();
void prevSectionChanged();
+ void nextSectionChanged();
void delayRemoveChanged();
void add();
void remove();
@@ -321,6 +331,7 @@ public:
QDeclarativeListView *m_view;
mutable QString m_section;
QString m_prevSection;
+ QString m_nextSection;
bool m_isCurrent : 1;
bool m_delayRemove : 1;
};