summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-05-13 05:27:27 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-05-13 05:27:27 (GMT)
commit1786d77152a3112fe6e8ab5d1e1d8703d8278d57 (patch)
treeb4da20996eddd61bf874cb1303a93ffb7a35f0bc /src/declarative
parent05380361e7318a3a6536ddec2f00e76ebf819009 (diff)
parentb31d5914f166e0a8c67b05ff80a6a221f48c1945 (diff)
downloadQt-1786d77152a3112fe6e8ab5d1e1d8703d8278d57.zip
Qt-1786d77152a3112fe6e8ab5d1e1d8703d8278d57.tar.gz
Qt-1786d77152a3112fe6e8ab5d1e1d8703d8278d57.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp33
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h4
3 files changed, 38 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index 3d0df87..2d08c7c 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -377,7 +377,9 @@ void QDeclarativePath::createPointCache() const
{
Q_D(const QDeclarativePath);
qreal pathLength = d->_path.length();
- const int points = int(pathLength*2);
+ // more points means less jitter between items as they move along the
+ // path, but takes longer to generate
+ const int points = int(pathLength*5);
const int lastElement = d->_path.elementCount() - 1;
d->_pointCache.resize(points+1);
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 503d096..207cc25 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -49,6 +49,7 @@
#include <qlistmodelinterface_p.h>
#include <QGraphicsSceneEvent>
+#include <qmath.h>
#include <math.h>
QT_BEGIN_NAMESPACE
@@ -279,8 +280,8 @@ void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal perce
att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
}
QPointF pf = path->pointAt(percent);
- item->setX(pf.x() - item->width()*item->scale()/2);
- item->setY(pf.y() - item->height()*item->scale()/2);
+ item->setX(qRound(pf.x() - item->width()*item->scale()/2));
+ item->setY(qRound(pf.y() - item->height()*item->scale()/2));
}
void QDeclarativePathViewPrivate::regenerate()
@@ -527,6 +528,33 @@ void QDeclarativePathView::setCurrentIndex(int idx)
}
/*!
+ \qmlmethod PathView::incrementCurrentIndex()
+
+ Increments the current index.
+*/
+void QDeclarativePathView::incrementCurrentIndex()
+{
+ setCurrentIndex(currentIndex()+1);
+}
+
+
+/*!
+ \qmlmethod PathView::decrementCurrentIndex()
+
+ Decrements the current index.
+*/
+void QDeclarativePathView::decrementCurrentIndex()
+{
+ Q_D(QDeclarativePathView);
+ if (d->model && d->model->count()) {
+ int idx = currentIndex()-1;
+ if (idx < 0)
+ idx = d->model->count() - 1;
+ setCurrentIndex(idx);
+ }
+}
+
+/*!
\qmlproperty real PathView::offset
The offset specifies how far along the path the items are from their initial positions.
@@ -1312,6 +1340,7 @@ int QDeclarativePathViewPrivate::calcCurrentIndex()
if (offset < 0)
offset += model->count();
current = qRound(qAbs(qmlMod(model->count() - offset, model->count())));
+ current = current % model->count();
}
return current;
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index 85f47fd..349a01c 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -132,6 +132,10 @@ public:
static QDeclarativePathViewAttached *qmlAttachedProperties(QObject *);
+public Q_SLOTS:
+ void incrementCurrentIndex();
+ void decrementCurrentIndex();
+
Q_SIGNALS:
void currentIndexChanged();
void offsetChanged();