From 7c9a1d681c91c6f28a23a52a29ef6a08671ea49a Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 31 Jul 2009 14:42:08 +1000 Subject: Some pathview focus fixes. --- src/declarative/fx/qfxpathview.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 98121e6..092c258 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -575,13 +575,16 @@ void QFxPathViewPrivate::regenerate() int numItems = pathItems >= 0 ? pathItems : model->count(); for (int i=0; i < numItems && i < model->count(); ++i){ - QFxItem *item = getItem((i + firstIndex) % model->count()); + int index = (i + firstIndex) % model->count(); + QFxItem *item = getItem(index); if (!item) { qWarning() << "PathView: Cannot create item, index" << (i + firstIndex) % model->count(); return; } items.append(item); item->setZValue(i); + if (currentIndex == index) + item->setFocus(true); } q->refill(); } @@ -638,8 +641,11 @@ void QFxPathView::refill() d->firstIndex++; d->firstIndex %= d->model->count(); int index = (d->firstIndex + d->items.count())%d->model->count(); - d->items << d->getItem(index); - d->items.last()->setZValue(wrapIndex); + QFxItem *item = d->getItem(index); + item->setZValue(wrapIndex); + if (d->currentIndex == index) + item->setFocus(true); + d->items << item; d->pathOffset++; d->pathOffset=d->pathOffset % d->items.count(); } @@ -651,8 +657,11 @@ void QFxPathView::refill() d->firstIndex--; if (d->firstIndex < 0) d->firstIndex = d->model->count() - 1; - d->items.prepend(d->getItem(d->firstIndex)); - d->items.first()->setZValue(d->firstIndex); + QFxItem *item = d->getItem(d->firstIndex); + item->setZValue(d->firstIndex); + if (d->currentIndex == d->firstIndex) + item->setFocus(true); + d->items.prepend(item); d->pathOffset--; if (d->pathOffset < 0) d->pathOffset = d->items.count() - 1; -- cgit v0.12