summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-08-06 23:28:11 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-08-06 23:28:11 (GMT)
commitfe1165f3647c437528d9df437b939278f23260fc (patch)
tree6dac908075542e4b12b1da4d1a76c226bb34758b /src/declarative/fx
parentd469d5e12635a6bad54fe8bc9404c1fdf209635c (diff)
parentdbf6d52148c0265ccc6aec64f4a873a066535fc8 (diff)
downloadQt-fe1165f3647c437528d9df437b939278f23260fc.zip
Qt-fe1165f3647c437528d9df437b939278f23260fc.tar.gz
Qt-fe1165f3647c437528d9df437b939278f23260fc.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/fx')
-rw-r--r--src/declarative/fx/qfxpathview.cpp41
-rw-r--r--src/declarative/fx/qfxpathview.h1
2 files changed, 35 insertions, 7 deletions
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 6dcfcd1..45ff51c 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -241,10 +241,12 @@ void QFxPathView::setCurrentIndex(int idx)
idx = qAbs(idx % d->model->count());
if (d->model && idx != d->currentIndex) {
d->currentIndex = idx;
- d->snapToCurrent();
- int itemIndex = (idx - d->firstIndex + d->model->count()) % d->model->count();
- if (itemIndex < d->items.count())
- d->items.at(itemIndex)->setFocus(true);
+ if (d->model->count()) {
+ d->snapToCurrent();
+ int itemIndex = (idx - d->firstIndex + d->model->count()) % d->model->count();
+ if (itemIndex < d->items.count())
+ d->items.at(itemIndex)->setFocus(true);
+ }
emit currentIndexChanged();
}
}
@@ -565,9 +567,34 @@ bool QFxPathView::sceneEventFilter(QGraphicsItem *i, QEvent *e)
return QFxItem::sceneEventFilter(i, e);
}
+void QFxPathView::componentComplete()
+{
+ Q_D(QFxPathView);
+ QFxItem::componentComplete();
+ d->regenerate();
+
+ // move to correct offset
+ if (d->items.count()) {
+ int itemIndex = (d->currentIndex - d->firstIndex + d->model->count()) % d->model->count();
+
+ itemIndex += d->pathOffset;
+ itemIndex %= d->items.count();
+ qreal targetOffset = fmod(100 + (d->snapPos*100) - 100.0 * itemIndex / d->items.count(), 100);
+
+ if (targetOffset < 0)
+ targetOffset = 100.0 + targetOffset;
+ if (targetOffset != d->_offset) {
+ d->moveOffset.setValue(targetOffset);
+ }
+ }
+}
+
void QFxPathViewPrivate::regenerate()
{
Q_Q(QFxPathView);
+ if (!q->isComponentComplete())
+ return;
+
for (int i=0; i<items.count(); i++){
QFxItem *p = items[i];
releaseItem(p);
@@ -612,7 +639,7 @@ void QFxPathViewPrivate::updateItem(QFxItem *item, qreal percent)
void QFxPathView::refill()
{
Q_D(QFxPathView);
- if (!d->isValid())
+ if (!d->isValid() || !isComponentComplete())
return;
QList<qreal> positions;
@@ -688,7 +715,7 @@ void QFxPathView::itemsInserted(int modelIndex, int count)
{
//XXX support animated insertion
Q_D(QFxPathView);
- if (!d->isValid())
+ if (!d->isValid() || !isComponentComplete())
return;
if (d->pathItems == -1) {
for (int i = 0; i < count; ++i) {
@@ -718,7 +745,7 @@ void QFxPathView::itemsRemoved(int modelIndex, int count)
{
//XXX support animated removal
Q_D(QFxPathView);
- if (!d->isValid())
+ if (!d->isValid() || !isComponentComplete())
return;
if (d->pathItems == -1) {
for (int i = 0; i < count; ++i) {
diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h
index 4b8f12d..9cc8adb 100644
--- a/src/declarative/fx/qfxpathview.h
+++ b/src/declarative/fx/qfxpathview.h
@@ -109,6 +109,7 @@ protected:
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
bool sceneEventFilter(QGraphicsItem *, QEvent *);
+ void componentComplete();
private Q_SLOTS:
void refill();