summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2011-02-28 15:33:14 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2011-02-28 15:33:14 (GMT)
commita220e7c51c701a81a675a46a76838260527fcc8e (patch)
treea12130be836dba239c22dbd7d2af9db05d0a830c /src/declarative/graphicsitems
parenta27bce53b8d629c6eb41804476594abd0c9a482f (diff)
parentf691e052afbc6fef9f2954e7a7915be85a10f473 (diff)
downloadQt-a220e7c51c701a81a675a46a76838260527fcc8e.zip
Qt-a220e7c51c701a81a675a46a76838260527fcc8e.tar.gz
Qt-a220e7c51c701a81a675a46a76838260527fcc8e.tar.bz2
Merge commit 'refs/merge-requests/1113' of git://gitorious.org/qt/qt into merge-requests/1113
Conflicts: doc/src/development/qmake-manual.qdoc
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp41
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h2
4 files changed, 35 insertions, 14 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 80e853d..dc4196d 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -82,7 +82,7 @@ public:
item->setPos(QPointF(row, col));
}
}
- bool contains(int x, int y) const {
+ bool contains(qreal x, qreal y) const {
return (x >= item->x() && x < item->x() + view->cellWidth() &&
y >= item->y() && y < item->y() + view->cellHeight());
}
@@ -2294,7 +2294,7 @@ void QDeclarativeGridView::positionViewAtEnd()
\bold Note: methods should only be called after the Component has completed.
*/
-int QDeclarativeGridView::indexAt(int x, int y) const
+int QDeclarativeGridView::indexAt(qreal x, qreal y) const
{
Q_D(const QDeclarativeGridView);
for (int i = 0; i < d->visibleItems.count(); ++i) {
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index 248b9ef..e68a9ba 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -158,7 +158,7 @@ public:
enum PositionMode { Beginning, Center, End, Visible, Contain };
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
- Q_INVOKABLE int indexAt(int x, int y) const;
+ Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning();
Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd();
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index a60a4aa..338cb58 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -148,7 +148,7 @@ public:
else
item->setWidth(size);
}
- bool contains(int x, int y) const {
+ bool contains(qreal x, qreal y) const {
return (x >= item->x() && x < item->x() + item->width() &&
y >= item->y() && y < item->y() + item->height());
}
@@ -228,6 +228,26 @@ public:
return 0;
}
+ // Returns the item before modelIndex, if created.
+ // May return an item marked for removal.
+ FxListItem *itemBefore(int modelIndex) const {
+ if (modelIndex < visibleIndex)
+ return 0;
+ int idx = 1;
+ int lastIndex = -1;
+ while (idx < visibleItems.count()) {
+ FxListItem *item = visibleItems.at(idx);
+ if (item->index != -1)
+ lastIndex = item->index;
+ if (item->index == modelIndex)
+ return visibleItems.at(idx-1);
+ ++idx;
+ }
+ if (lastIndex == modelIndex-1)
+ return visibleItems.last();
+ return 0;
+ }
+
qreal position() const {
Q_Q(const QDeclarativeListView);
return orient == QDeclarativeListView::Vertical ? q->contentY() : q->contentX();
@@ -561,7 +581,7 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
QString propValue = model->stringValue(modelIndex, sectionCriteria->property());
listItem->attached->m_section = sectionCriteria->sectionString(propValue);
if (modelIndex > 0) {
- if (FxListItem *item = visibleItem(modelIndex-1))
+ if (FxListItem *item = itemBefore(modelIndex))
listItem->attached->m_prevSection = item->attached->section();
else
listItem->attached->m_prevSection = sectionAt(modelIndex-1);
@@ -969,18 +989,18 @@ void QDeclarativeListViewPrivate::updateSections()
QDeclarativeListViewAttached *prevAtt = 0;
int idx = -1;
for (int i = 0; i < visibleItems.count(); ++i) {
+ QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached;
+ attached->setPrevSection(prevSection);
if (visibleItems.at(i)->index != -1) {
- QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached;
- attached->setPrevSection(prevSection);
QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property());
attached->setSection(sectionCriteria->sectionString(propValue));
- if (prevAtt)
- prevAtt->setNextSection(attached->section());
- createSection(visibleItems.at(i));
- prevSection = attached->section();
- prevAtt = attached;
idx = visibleItems.at(i)->index;
}
+ createSection(visibleItems.at(i));
+ if (prevAtt)
+ prevAtt->setNextSection(attached->section());
+ prevSection = attached->section();
+ prevAtt = attached;
}
if (prevAtt) {
if (idx > 0 && idx < model->count()-1)
@@ -2732,7 +2752,7 @@ void QDeclarativeListView::positionViewAtEnd()
\bold Note: methods should only be called after the Component has completed.
*/
-int QDeclarativeListView::indexAt(int x, int y) const
+int QDeclarativeListView::indexAt(qreal x, qreal y) const
{
Q_D(const QDeclarativeListView);
for (int i = 0; i < d->visibleItems.count(); ++i) {
@@ -3096,6 +3116,7 @@ void QDeclarativeListView::destroyRemoved()
}
// Correct the positioning of the items
+ d->updateSections();
d->layout();
}
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index 10fbf10..265f4bd 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -208,7 +208,7 @@ public:
enum PositionMode { Beginning, Center, End, Visible, Contain };
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
- Q_INVOKABLE int indexAt(int x, int y) const;
+ Q_INVOKABLE int indexAt(qreal x, qreal y) const;
Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning();
Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd();