summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativepath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativepath.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index e2042fc73b..a904869532 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE
/*!
\internal
\class QDeclarativePathElement
- \ingroup group_utility
*/
/*!
@@ -86,7 +85,6 @@ QT_BEGIN_NAMESPACE
/*!
\internal
\class QDeclarativePath
- \ingroup group_utility
\brief The QDeclarativePath class defines a path.
\sa QDeclarativePathView
*/
@@ -117,6 +115,7 @@ void QDeclarativePath::setStartX(qreal x)
return;
d->startX = x;
emit startXChanged();
+ processPath();
}
qreal QDeclarativePath::startY() const
@@ -132,6 +131,7 @@ void QDeclarativePath::setStartY(qreal y)
return;
d->startY = y;
emit startYChanged();
+ processPath();
}
/*!
@@ -220,6 +220,9 @@ void QDeclarativePath::processPath()
{
Q_D(QDeclarativePath);
+ if (!d->componentComplete)
+ return;
+
d->_pointCache.clear();
d->_attributePoints.clear();
d->_path = QPainterPath();
@@ -284,10 +287,18 @@ void QDeclarativePath::processPath()
emit changed();
}
+void QDeclarativePath::classBegin()
+{
+ Q_D(QDeclarativePath);
+ d->componentComplete = false;
+}
+
void QDeclarativePath::componentComplete()
{
Q_D(QDeclarativePath);
QSet<QString> attrs;
+ d->componentComplete = true;
+
// First gather up all the attributes
foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
if (QDeclarativePathAttribute *attribute =
@@ -311,6 +322,17 @@ QPainterPath QDeclarativePath::path() const
QStringList QDeclarativePath::attributes() const
{
Q_D(const QDeclarativePath);
+ if (!d->componentComplete) {
+ QSet<QString> attrs;
+
+ // First gather up all the attributes
+ foreach (QDeclarativePathElement *pathElement, d->_pathElements) {
+ if (QDeclarativePathAttribute *attribute =
+ qobject_cast<QDeclarativePathAttribute *>(pathElement))
+ attrs.insert(attribute->name());
+ }
+ return attrs.toList();
+ }
return d->_attributes;
}
@@ -355,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);
@@ -500,7 +524,6 @@ void QDeclarativeCurve::setY(qreal y)
/*!
\internal
\class QDeclarativePathAttribute
- \ingroup group_utility
\brief The QDeclarativePathAttribute class allows to set the value of an attribute at a given position in the path.
\sa QDeclarativePath
@@ -573,7 +596,6 @@ void QDeclarativePathAttribute::setValue(qreal value)
/*!
\internal
\class QDeclarativePathLine
- \ingroup group_utility
\brief The QDeclarativePathLine class defines a straight line.
\sa QDeclarativePath
@@ -606,7 +628,7 @@ void QDeclarativePathLine::addToPath(QPainterPath &path)
\qml
Path {
startX: 0; startY: 0
- PathQuad x: 200; y: 0; controlX: 100; controlY: 150 }
+ PathQuad { x: 200; y: 0; controlX: 100; controlY: 150 }
}
\endqml
\endtable
@@ -617,7 +639,6 @@ void QDeclarativePathLine::addToPath(QPainterPath &path)
/*!
\internal
\class QDeclarativePathQuad
- \ingroup group_utility
\brief The QDeclarativePathQuad class defines a quadratic Bezier curve with a control point.
\sa QDeclarativePath
@@ -692,8 +713,9 @@ void QDeclarativePathQuad::addToPath(QPainterPath &path)
Path {
startX: 20; startY: 0
PathCubic {
- x: 180; y: 0; control1X: -10; control1Y: 90
- control2X: 210; control2Y: 90
+ x: 180; y: 0
+ control1X: -10; control1Y: 90
+ control2X: 210; control2Y: 90
}
}
\endqml
@@ -705,7 +727,6 @@ void QDeclarativePathQuad::addToPath(QPainterPath &path)
/*!
\internal
\class QDeclarativePathCubic
- \ingroup group_utility
\brief The QDeclarativePathCubic class defines a cubic Bezier curve with two control points.
\sa QDeclarativePath
@@ -831,7 +852,6 @@ void QDeclarativePathCubic::addToPath(QPainterPath &path)
/*!
\internal
\class QDeclarativePathPercent
- \ingroup group_utility
\brief The QDeclarativePathPercent class manipulates the way a path is interpreted.
QDeclarativePathPercent allows you to bunch up items (or spread out items) along various
@@ -848,6 +868,9 @@ qreal QDeclarativePathPercent::value() const
void QDeclarativePathPercent::setValue(qreal value)
{
- _value = value;
+ if (_value != value) {
+ _value = value;
+ emit changed();
+ }
}
QT_END_NAMESPACE