summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qmlgraphicsgridview.cpp')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 9f9b336..7427266 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -578,29 +578,35 @@ void QmlGraphicsGridViewPrivate::createHighlight()
highlightYAnimator = 0;
}
- if (!highlightComponent)
- return;
-
if (currentItem) {
- QmlContext *highlightContext = new QmlContext(qmlContext(q));
- QObject *nobj = highlightComponent->create(highlightContext);
- if (nobj) {
- highlightContext->setParent(nobj);
- QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(nobj);
- if (item) {
- item->setParent(q->viewport());
- highlight = new FxGridItem(item, q);
- highlightXAnimator = new QmlEaseFollow(q);
- highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x")));
- highlightXAnimator->setDuration(150);
- highlightXAnimator->setEnabled(autoHighlight);
- highlightYAnimator = new QmlEaseFollow(q);
- highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y")));
- highlightYAnimator->setDuration(150);
- highlightYAnimator->setEnabled(autoHighlight);
+ QmlGraphicsItem *item = 0;
+ if (highlightComponent) {
+ QmlContext *highlightContext = new QmlContext(qmlContext(q));
+ QObject *nobj = highlightComponent->create(highlightContext);
+ if (nobj) {
+ highlightContext->setParent(nobj);
+ item = qobject_cast<QmlGraphicsItem *>(nobj);
+ if (!item)
+ delete nobj;
} else {
delete highlightContext;
}
+ } else {
+ item = new QmlGraphicsItem;
+ item->setParent(q->viewport());
+ }
+ if (item) {
+ item->setZValue(0);
+ item->setParent(q->viewport());
+ highlight = new FxGridItem(item, q);
+ highlightXAnimator = new QmlEaseFollow(q);
+ highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x")));
+ highlightXAnimator->setDuration(150);
+ highlightXAnimator->setEnabled(autoHighlight);
+ highlightYAnimator = new QmlEaseFollow(q);
+ highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y")));
+ highlightYAnimator->setDuration(150);
+ highlightYAnimator->setEnabled(autoHighlight);
}
}
}
@@ -1500,6 +1506,8 @@ void QmlGraphicsGridView::itemsMoved(int from, int to, int count)
if (item->index > from && item->index != -1) {
// move everything after the moved items.
item->index -= count;
+ if (item->index < d->visibleIndex)
+ d->visibleIndex = item->index;
}
++it;
}