summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-23 22:58:07 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-23 22:58:07 (GMT)
commitab86990893ef1b431c555c46a1e0df7cb9e37927 (patch)
treee817cd0655e18c6f4f1f1980d2bad9325cb9e426 /src
parent520cca521ed320ab6751041d9a7bf9c18ee98fa1 (diff)
parentd19f691a5646725c69b232e2adde8c2f961eb571 (diff)
downloadQt-ab86990893ef1b431c555c46a1e0df7cb9e37927.zip
Qt-ab86990893ef1b431c555c46a1e0df7cb9e37927.tar.gz
Qt-ab86990893ef1b431c555c46a1e0df7cb9e37927.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmetatype.cpp26
-rw-r--r--src/corelib/kernel/qmetatype.h8
-rw-r--r--src/corelib/kernel/qvariant.cpp55
-rw-r--r--src/corelib/kernel/qvariant.h12
-rw-r--r--src/corelib/tools/qeasingcurve.cpp69
-rw-r--r--src/corelib/tools/qeasingcurve.h11
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles.cpp67
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsparticles_p.h55
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp27
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p.h19
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp20
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview_p.h15
-rw-r--r--src/declarative/qml/qml.pri10
-rw-r--r--src/declarative/qml/qmlcompiler.cpp12
-rw-r--r--src/declarative/qml/qmldirparser.cpp220
-rw-r--r--src/declarative/qml/qmldirparser_p.h125
-rw-r--r--src/declarative/qml/qmlengine.cpp256
-rw-r--r--src/declarative/qml/qmlengine.h1
-rw-r--r--src/declarative/qml/qmlengine_p.h10
-rw-r--r--src/declarative/qml/qmlextensioninterface.h67
-rw-r--r--src/declarative/qml/qmlextensionplugin.cpp87
-rw-r--r--src/declarative/qml/qmlextensionplugin.h (renamed from src/declarative/qml/qmlmoduleplugin.h)36
-rw-r--r--src/declarative/qml/qmlmetaproperty.cpp10
-rw-r--r--src/declarative/qml/qmlmetaproperty_p.h3
-rw-r--r--src/declarative/qml/qmlmoduleplugin.cpp111
-rw-r--r--src/declarative/qml/qmlpropertycache.cpp22
-rw-r--r--src/declarative/qml/qmlpropertycache_p.h7
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp70
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h57
-rw-r--r--src/declarative/qml/qmlworkerscript.cpp2
-rw-r--r--src/declarative/util/qmlanimation.cpp163
-rw-r--r--src/declarative/util/qmlanimation_p.h9
-rw-r--r--src/declarative/util/qmlanimation_p_p.h2
-rw-r--r--src/declarative/util/qmlview.cpp94
-rw-r--r--src/declarative/util/qmlview.h3
-rw-r--r--src/multimedia/qml/qml.cpp10
-rw-r--r--src/multimedia/qml/qml.h4
-rw-r--r--src/plugins/qmlmodules/multimedia/multimedia.cpp16
39 files changed, 1339 insertions, 454 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 870baab..9e187d4 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -48,6 +48,7 @@
#include "qstringlist.h"
#include "qvector.h"
#include "qlocale.h"
+#include "qeasingcurve.h"
#ifdef QT_BOOTSTRAPPED
# ifndef QT_NO_GEOM_VARIANT
@@ -176,6 +177,7 @@ QT_BEGIN_NAMESPACE
\value QVector3D QVector3D
\value QVector4D QVector4D
\value QQuaternion QQuaternion
+ \value QEasingCurve QEasingCurve
\value User Base value for user types
@@ -256,6 +258,7 @@ static const struct { const char * typeName; int type; } types[] = {
{"QPointF", QMetaType::QPointF},
{"QRegExp", QMetaType::QRegExp},
{"QVariantHash", QMetaType::QVariantHash},
+ {"QEasingCurve", QMetaType::QEasingCurve},
/* All GUI types */
{"QColorGroup", 63},
@@ -666,6 +669,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
stream << *static_cast<const NS(QRegExp)*>(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ stream << *static_cast<const NS(QEasingCurve)*>(data);
+ break;
+#endif
#ifdef QT3_SUPPORT
case QMetaType::QColorGroup:
#endif
@@ -863,6 +871,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
stream >> *static_cast< NS(QRegExp)*>(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ stream >> *static_cast< NS(QEasingCurve)*>(data);
+ break;
+#endif
#ifdef QT3_SUPPORT
case QMetaType::QColorGroup:
#endif
@@ -1007,6 +1020,10 @@ void *QMetaType::construct(int type, const void *copy)
case QMetaType::QRegExp:
return new NS(QRegExp)(*static_cast<const NS(QRegExp)*>(copy));
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ return new NS(QEasingCurve)(*static_cast<const NS(QEasingCurve)*>(copy));
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1098,6 +1115,10 @@ void *QMetaType::construct(int type, const void *copy)
case QMetaType::QRegExp:
return new NS(QRegExp);
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ return new NS(QEasingCurve);
+#endif
case QMetaType::Void:
return 0;
default:
@@ -1253,6 +1274,11 @@ void QMetaType::destroy(int type, void *data)
delete static_cast< NS(QRegExp)* >(data);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QMetaType::QEasingCurve:
+ delete static_cast< NS(QEasingCurve)* >(data);
+ break;
+#endif
case QMetaType::Void:
break;
default: {
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index c23caed..33126e8 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -69,7 +69,7 @@ public:
QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
- QVariantHash = 28, LastCoreType = 28 /* QVariantHash */,
+ QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve,
FirstGuiType = 63 /* QColorGroup */,
#ifdef QT3_SUPPORT
@@ -81,12 +81,12 @@ public:
QTextLength = 78, QTextFormat = 79, QMatrix = 80, QTransform = 81,
QMatrix4x4 = 82, QVector2D = 83, QVector3D = 84, QVector4D = 85,
QQuaternion = 86,
- LastGuiType = 86 /* QQuaternion */,
+ LastGuiType = QQuaternion,
FirstCoreExtType = 128 /* VoidStar */,
VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132,
UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137,
- LastCoreExtType = 137 /* QWidgetStar */,
+ LastCoreExtType = QWidgetStar,
// This logic must match the one in qglobal.h
#if defined(QT_COORD_TYPE)
@@ -290,6 +290,7 @@ class QPointF;
#ifndef QT_NO_REGEXP
class QRegExp;
#endif
+class QEasingCurve;
class QWidget;
class QObject;
@@ -359,6 +360,7 @@ Q_DECLARE_BUILTIN_METATYPE(QPointF, QPointF)
#ifndef QT_NO_REGEXP
Q_DECLARE_BUILTIN_METATYPE(QRegExp, QRegExp)
#endif
+Q_DECLARE_BUILTIN_METATYPE(QEasingCurve, QEasingCurve)
#ifdef QT3_SUPPORT
Q_DECLARE_BUILTIN_METATYPE(QColorGroup, QColorGroup)
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index e1b5825..384a3cd 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -46,6 +46,7 @@
#include "qdebug.h"
#include "qmap.h"
#include "qdatetime.h"
+#include "qeasingcurve.h"
#include "qlist.h"
#include "qstring.h"
#include "qstringlist.h"
@@ -146,6 +147,11 @@ static void construct(QVariant::Private *x, const void *copy)
v_construct<QRegExp>(x, copy);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ v_construct<QEasingCurve>(x, copy);
+ break;
+#endif
case QVariant::Int:
x->data.i = copy ? *static_cast<const int *>(copy) : 0;
break;
@@ -259,6 +265,11 @@ static void clear(QVariant::Private *d)
v_clear<QRegExp>(d);
break;
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ v_clear<QEasingCurve>(d);
+ break;
+#endif
case QVariant::LongLong:
case QVariant::ULongLong:
case QVariant::Double:
@@ -317,6 +328,9 @@ static bool isNull(const QVariant::Private *d)
case QVariant::PointF:
return v_cast<QPointF>(d)->isNull();
#endif
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+#endif
case QVariant::Url:
case QVariant::Locale:
case QVariant::RegExp:
@@ -435,6 +449,10 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b)
return *v_cast<QTime>(a) == *v_cast<QTime>(b);
case QVariant::DateTime:
return *v_cast<QDateTime>(a) == *v_cast<QDateTime>(b);
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ return *v_cast<QEasingCurve>(a) == *v_cast<QEasingCurve>(b);
+#endif
case QVariant::ByteArray:
return *v_cast<QByteArray>(a) == *v_cast<QByteArray>(b);
case QVariant::BitArray:
@@ -1097,6 +1115,11 @@ static void streamDebug(QDebug dbg, const QVariant &v)
case QVariant::DateTime:
dbg.nospace() << v.toDateTime();
break;
+#ifndef QT_BOOTSTRAPPED
+ case QVariant::EasingCurve:
+ dbg.nospace() << v.toEasingCurve();
+ break;
+#endif
case QVariant::ByteArray:
dbg.nospace() << v.toByteArray();
break;
@@ -1265,6 +1288,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler;
\value Date a QDate
\value DateTime a QDateTime
\value Double a double
+ \value EasingCurve a QEasingCurve
\value Font a QFont
\value Hash a QVariantHash
\value Icon a QIcon
@@ -1483,6 +1507,12 @@ QVariant::QVariant(const char *val)
*/
/*!
+ \fn QVariant::QVariant(const QEasingCurve &val)
+
+ Constructs a new variant with an easing curve value, \a val.
+*/
+
+/*!
\fn QVariant::QVariant(const QByteArray &val)
Constructs a new variant with a bytearray value, \a val.
@@ -1681,6 +1711,10 @@ QVariant::QVariant(const QTime &val)
{ d.is_null = false; d.type = Time; v_construct<QTime>(&d, val); }
QVariant::QVariant(const QDateTime &val)
{ d.is_null = false; d.type = DateTime; v_construct<QDateTime>(&d, val); }
+#ifndef QT_BOOTSTRAPPED
+QVariant::QVariant(const QEasingCurve &val)
+{ d.is_null = false; d.type = EasingCurve; v_construct<QEasingCurve>(&d, val); }
+#endif
QVariant::QVariant(const QList<QVariant> &list)
{ d.is_null = false; d.type = List; v_construct<QVariantList>(&d, list); }
QVariant::QVariant(const QMap<QString, QVariant> &map)
@@ -1870,7 +1904,7 @@ QVariant::Type QVariant::nameToType(const char *name)
}
#ifndef QT_NO_DATASTREAM
-enum { MapFromThreeCount = 35 };
+enum { MapFromThreeCount = 36 };
static const ushort map_from_three[MapFromThreeCount] =
{
QVariant::Invalid,
@@ -1902,6 +1936,7 @@ static const ushort map_from_three[MapFromThreeCount] =
QVariant::Date,
QVariant::Time,
QVariant::DateTime,
+ QVariant::EasingCurve,
QVariant::ByteArray,
QVariant::BitArray,
QVariant::KeySequence,
@@ -2165,6 +2200,21 @@ QDateTime QVariant::toDateTime() const
}
/*!
+ \fn QEasingCurve QVariant::toEasingCurve() const
+
+ Returns the variant as a QEasingCurve if the variant has type() \l
+ EasingCurve; otherwise returns a default easing curve.
+
+ \sa canConvert(), convert()
+*/
+#ifndef QT_BOOTSTRAPPED
+QEasingCurve QVariant::toEasingCurve() const
+{
+ return qVariantToHelper<QEasingCurve>(d, EasingCurve, handler);
+}
+#endif
+
+/*!
\fn QByteArray QVariant::toByteArray() const
Returns the variant as a QByteArray if the variant has type() \l
@@ -2605,8 +2655,9 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QRegExp*/ 0,
-/*QHash*/ 0
+/*QHash*/ 0,
+/*QEasingCurve*/ 0
};
/*!
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 1a9e43a..9628dbf 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -60,6 +60,7 @@ class QBitArray;
class QDataStream;
class QDate;
class QDateTime;
+class QEasingCurve;
class QLine;
class QLineF;
class QLocale;
@@ -128,9 +129,10 @@ class Q_CORE_EXPORT QVariant
LineF = 24,
Point = 25,
PointF = 26,
- RegExp = 27,
+ RegExp = 27,
Hash = 28,
- LastCoreType = Hash,
+ EasingCurve = 29,
+ LastCoreType = EasingCurve,
// value 62 is internally reserved
#ifdef QT3_SUPPORT
@@ -219,6 +221,9 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QVariant(const QRegExp &regExp);
#endif
+#ifndef QT_BOOTSTRAPPED
+ QVariant(const QEasingCurve &easing);
+#endif
QVariant(Qt::GlobalColor color);
QVariant& operator=(const QVariant &other);
@@ -280,6 +285,9 @@ class Q_CORE_EXPORT QVariant
#ifndef QT_NO_REGEXP
QRegExp toRegExp() const;
#endif
+#ifndef QT_BOOTSTRAPPED
+ QEasingCurve toEasingCurve() const;
+#endif
#ifdef QT3_SUPPORT
inline QT3_SUPPORT int &asInt();
diff --git a/src/corelib/tools/qeasingcurve.cpp b/src/corelib/tools/qeasingcurve.cpp
index b6a2df4..89edb2d 100644
--- a/src/corelib/tools/qeasingcurve.cpp
+++ b/src/corelib/tools/qeasingcurve.cpp
@@ -600,11 +600,11 @@ QEasingCurve::QEasingCurve(Type type)
Construct a copy of \a other.
*/
QEasingCurve::QEasingCurve(const QEasingCurve &other)
-: d_ptr(new QEasingCurvePrivate)
+ : d_ptr(new QEasingCurvePrivate)
{
// ### non-atomic, requires malloc on shallow copy
*d_ptr = *other.d_ptr;
- if(other.d_ptr->config)
+ if (other.d_ptr->config)
d_ptr->config = other.d_ptr->config->copy();
}
@@ -629,7 +629,7 @@ QEasingCurve &QEasingCurve::operator=(const QEasingCurve &other)
}
*d_ptr = *other.d_ptr;
- if(other.d_ptr->config)
+ if (other.d_ptr->config)
d_ptr->config = other.d_ptr->config->copy();
return *this;
@@ -845,6 +845,67 @@ QDebug operator<<(QDebug debug, const QEasingCurve &item)
}
return debug;
}
-#endif
+#endif // QT_NO_DEBUG_STREAM
+
+#ifndef QT_NO_DATASTREAM
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing)
+ \relates QEasingCurve
+
+ Writes the given \a easing curve to the given \a stream and returns a
+ reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+QDataStream &operator<<(QDataStream &stream, const QEasingCurve &easing)
+{
+ stream << easing.d_ptr->type;
+ stream << quint64(intptr_t(easing.d_ptr->func));
+
+ bool hasConfig = easing.d_ptr->config;
+ stream << hasConfig;
+ if (hasConfig) {
+ stream << easing.d_ptr->config->_p;
+ stream << easing.d_ptr->config->_a;
+ stream << easing.d_ptr->config->_o;
+ }
+ return stream;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing)
+ \relates QQuaternion
+
+ Reads an easing curve from the given \a stream into the given \a quaternion
+ and returns a reference to the stream.
+
+ \sa {Format of the QDataStream Operators}
+*/
+
+QDataStream &operator>>(QDataStream &stream, QEasingCurve &easing)
+{
+ QEasingCurve::Type type;
+ int int_type;
+ stream >> int_type;
+ type = static_cast<QEasingCurve::Type>(int_type);
+ easing.setType(type);
+
+ quint64 ptr_func;
+ stream >> ptr_func;
+ easing.d_ptr->func = QEasingCurve::EasingFunction(intptr_t(ptr_func));
+
+ bool hasConfig;
+ stream >> hasConfig;
+ if (hasConfig) {
+ QEasingCurveFunction *config = curveToFunctionObject(type);
+ stream >> config->_p;
+ stream >> config->_a;
+ stream >> config->_o;
+ easing.d_ptr->config = config;
+ }
+ return stream;
+}
+#endif // QT_NO_DATASTREAM
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qeasingcurve.h b/src/corelib/tools/qeasingcurve.h
index ae8822e..173fba4 100644
--- a/src/corelib/tools/qeasingcurve.h
+++ b/src/corelib/tools/qeasingcurve.h
@@ -100,13 +100,24 @@ public:
qreal valueForProgress(qreal progress) const;
private:
QEasingCurvePrivate *d_ptr;
+#ifndef QT_NO_DEBUG_STREAM
friend Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
+#endif
+#ifndef QT_NO_DATASTREAM
+ friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&);
+ friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
+#endif
};
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QEasingCurve &item);
#endif
+#ifndef QT_NO_DATASTREAM
+Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QEasingCurve&);
+Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QEasingCurve &);
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index bf370ae..ab87c03 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -977,7 +977,7 @@ void QmlGraphicsGridView::setHighlight(QmlComponent *highlight)
Component {
id: myHighlight
Rectangle {
- id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60 >
+ id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60
y: SpringFollow { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 }
x: SpringFollow { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 }
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
index 08fce74..e23f6f0 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp
@@ -188,13 +188,13 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv
*/
/*!
- \qmlproperty int ParticleMotionGravity::xattractor
- \qmlproperty int ParticleMotionGravity::yattractor
+ \qmlproperty qreal ParticleMotionGravity::xattractor
+ \qmlproperty qreal ParticleMotionGravity::yattractor
These properties hold the x and y coordinates of the point attracting the particles.
*/
/*!
- \qmlproperty int ParticleMotionGravity::acceleration
+ \qmlproperty qreal ParticleMotionGravity::acceleration
This property holds the acceleration to apply to the particles.
*/
@@ -213,6 +213,31 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv
\brief the acceleration to apply to the particles.
*/
+void QmlGraphicsParticleMotionGravity::setXAttractor(qreal x)
+{
+ if (qFuzzyCompare(x, _xAttr))
+ return;
+ _xAttr = x;
+ emit xattractorChanged();
+}
+
+void QmlGraphicsParticleMotionGravity::setYAttractor(qreal y)
+{
+ if (qFuzzyCompare(y, _yAttr))
+ return;
+ _yAttr = y;
+ emit yattractorChanged();
+}
+
+void QmlGraphicsParticleMotionGravity::setAcceleration(qreal accel)
+{
+ qreal scaledAccel = accel/1000000.0;
+ if (qFuzzyCompare(scaledAccel, _accel))
+ return;
+ _accel = scaledAccel;
+ emit accelerationChanged();
+}
+
void QmlGraphicsParticleMotionGravity::advance(QmlGraphicsParticle &p, int interval)
{
qreal xdiff = p.x - _xAttr;
@@ -276,14 +301,14 @@ Rectangle {
*/
/*!
- \qmlproperty int QmlGraphicsParticleMotionWander::xvariance
- \qmlproperty int QmlGraphicsParticleMotionWander::yvariance
+ \qmlproperty qreal QmlGraphicsParticleMotionWander::xvariance
+ \qmlproperty qreal QmlGraphicsParticleMotionWander::yvariance
These properties set the amount to wander in the x and y directions.
*/
/*!
- \qmlproperty int QmlGraphicsParticleMotionWander::pace
+ \qmlproperty qreal QmlGraphicsParticleMotionWander::pace
This property holds how quickly the paricles will move from side to side.
*/
@@ -335,6 +360,33 @@ void QmlGraphicsParticleMotionWander::destroy(QmlGraphicsParticle &p)
delete (Data*)p.data;
}
+void QmlGraphicsParticleMotionWander::setXVariance(qreal var)
+{
+ qreal scaledVar = var / 1000.0;
+ if (qFuzzyCompare(scaledVar, _xvariance))
+ return;
+ _xvariance = scaledVar;
+ emit xvarianceChanged();
+}
+
+void QmlGraphicsParticleMotionWander::setYVariance(qreal var)
+{
+ qreal scaledVar = var / 1000.0;
+ if (qFuzzyCompare(scaledVar, _yvariance))
+ return;
+ _yvariance = scaledVar;
+ emit yvarianceChanged();
+}
+
+void QmlGraphicsParticleMotionWander::setPace(qreal pace)
+{
+ qreal scaledPace = pace / 1000.0;
+ if (qFuzzyCompare(scaledPace, _pace))
+ return;
+ _pace = scaledPace;
+ emit paceChanged();
+}
+
//---------------------------------------------------------------------------
class QmlGraphicsParticlesPainter : public QmlGraphicsItem
{
@@ -1125,7 +1177,10 @@ QmlGraphicsParticleMotion *QmlGraphicsParticles::motion() const
void QmlGraphicsParticles::setMotion(QmlGraphicsParticleMotion *motion)
{
Q_D(QmlGraphicsParticles);
+ if (motion == d->motion)
+ return;
d->motion = motion;
+ emit motionChanged();
}
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
index 7f0f9cd..8e66335 100644
--- a/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsparticles_p.h
@@ -77,27 +77,32 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsParticleMotionGravity : public QmlGraphics
{
Q_OBJECT
- Q_PROPERTY(int xattractor READ xAttractor WRITE setXAttractor)
- Q_PROPERTY(int yattractor READ yAttractor WRITE setYAttractor)
- Q_PROPERTY(int acceleration READ acceleration WRITE setAcceleration)
+ Q_PROPERTY(qreal xattractor READ xAttractor WRITE setXAttractor NOTIFY xattractorChanged)
+ Q_PROPERTY(qreal yattractor READ yAttractor WRITE setYAttractor NOTIFY yattractorChanged)
+ Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
public:
QmlGraphicsParticleMotionGravity(QObject *parent=0)
- : QmlGraphicsParticleMotion(parent), _xAttr(0), _yAttr(0), _accel(0.00005) {}
+ : QmlGraphicsParticleMotion(parent), _xAttr(0.0), _yAttr(0.0), _accel(0.00005) {}
- int xAttractor() const { return _xAttr; }
- void setXAttractor(int x) { _xAttr = x; }
+ qreal xAttractor() const { return _xAttr; }
+ void setXAttractor(qreal x);
- int yAttractor() const { return _yAttr; }
- void setYAttractor(int y) { _yAttr = y; }
+ qreal yAttractor() const { return _yAttr; }
+ void setYAttractor(qreal y);
- int acceleration() const { return int(_accel * 1000000); }
- void setAcceleration(int accel) { _accel = qreal(accel)/1000000.0; }
+ qreal acceleration() const { return _accel * 1000000; }
+ void setAcceleration(qreal accel);
virtual void advance(QmlGraphicsParticle &, int interval);
+Q_SIGNALS:
+ void xattractorChanged();
+ void yattractorChanged();
+ void accelerationChanged();
+
private:
- int _xAttr;
- int _yAttr;
+ qreal _xAttr;
+ qreal _yAttr;
qreal _accel;
};
@@ -121,18 +126,23 @@ public:
qreal y_var;
};
- Q_PROPERTY(int xvariance READ xVariance WRITE setXVariance)
- int xVariance() const { return int(_xvariance * 1000); }
- void setXVariance(int var) { _xvariance = var / 1000.0; }
+ Q_PROPERTY(qreal xvariance READ xVariance WRITE setXVariance NOTIFY xvarianceChanged)
+ qreal xVariance() const { return _xvariance * 1000.0; }
+ void setXVariance(qreal var);
- Q_PROPERTY(int yvariance READ yVariance WRITE setYVariance)
- int yVariance() const { return int(_yvariance * 1000); }
- void setYVariance(int var) { _yvariance = var / 1000.0; }
+ Q_PROPERTY(qreal yvariance READ yVariance WRITE setYVariance NOTIFY yvarianceChanged)
+ qreal yVariance() const { return _yvariance * 1000.0; }
+ void setYVariance(qreal var);
- Q_PROPERTY(int pace READ pace WRITE setPace)
- int pace() const { return int(_pace * 1000); }
- void setPace(int pace) { _pace = pace / 1000.0; }
+ Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged)
+ qreal pace() const { return _pace * 1000.0; }
+ void setPace(qreal pace);
+Q_SIGNALS:
+ void xvarianceChanged();
+ void yvarianceChanged();
+ void paceChanged();
+
private:
QmlGraphicsParticles *particles;
qreal _xvariance;
@@ -157,7 +167,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsParticles : public QmlGraphicsItem
Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged)
Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged)
- Q_PROPERTY(QmlGraphicsParticleMotion *motion READ motion WRITE setMotion)
+ Q_PROPERTY(QmlGraphicsParticleMotion *motion READ motion WRITE setMotion NOTIFY motionChanged)
Q_CLASSINFO("DefaultProperty", "motion")
public:
@@ -225,6 +235,7 @@ Q_SIGNALS:
void velocityChanged();
void velocityDeviationChanged();
void emittingChanged();
+ void motionChanged();
private Q_SLOTS:
void imageLoaded();
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index 8adf239..805c912 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -138,7 +138,10 @@ QmlTransition *QmlGraphicsBasePositioner::move() const
void QmlGraphicsBasePositioner::setMove(QmlTransition *mt)
{
Q_D(QmlGraphicsBasePositioner);
+ if (mt == d->moveTransition)
+ return;
d->moveTransition = mt;
+ emit moveChanged();
}
QmlTransition *QmlGraphicsBasePositioner::add() const
@@ -150,7 +153,11 @@ QmlTransition *QmlGraphicsBasePositioner::add() const
void QmlGraphicsBasePositioner::setAdd(QmlTransition *add)
{
Q_D(QmlGraphicsBasePositioner);
+ if (add == d->addTransition)
+ return;
+
d->addTransition = add;
+ emit addChanged();
}
void QmlGraphicsBasePositioner::componentComplete()
@@ -362,7 +369,7 @@ Column {
move: Transition {
NumberAnimation {
properties: "y"
- ease: "easeOutBounce"
+ easing: "easeOutBounce"
}
}
}
@@ -647,6 +654,24 @@ QmlGraphicsGrid::QmlGraphicsGrid(QmlGraphicsItem *parent) :
many rows some rows will be of zero width.
*/
+void QmlGraphicsGrid::setColumns(const int columns)
+{
+ if (columns == _columns)
+ return;
+ _columns = columns;
+ prePositioning();
+ emit columnsChanged();
+}
+
+void QmlGraphicsGrid::setRows(const int rows)
+{
+ if (rows == _rows)
+ return;
+ _rows = rows;
+ prePositioning();
+ emit rowsChanged();
+}
+
void QmlGraphicsGrid::doPositioning()
{
int c=_columns,r=_rows;//Actual number of rows/columns
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
index 1fb687a..2f905e5 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p.h
@@ -62,8 +62,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsBasePositioner : public QmlGraphicsItem
Q_OBJECT
Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
- Q_PROPERTY(QmlTransition *move READ move WRITE setMove)
- Q_PROPERTY(QmlTransition *add READ add WRITE setAdd)
+ Q_PROPERTY(QmlTransition *move READ move WRITE setMove NOTIFY moveChanged)
+ Q_PROPERTY(QmlTransition *add READ add WRITE setAdd NOTIFY addChanged)
public:
enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 };
QmlGraphicsBasePositioner(PositionerType, QmlGraphicsItem *parent);
@@ -86,6 +86,8 @@ protected:
Q_SIGNALS:
void spacingChanged();
+ void moveChanged();
+ void addChanged();
protected Q_SLOTS:
virtual void doPositioning()=0;
@@ -134,16 +136,21 @@ private:
class Q_DECLARATIVE_EXPORT QmlGraphicsGrid : public QmlGraphicsBasePositioner
{
Q_OBJECT
- Q_PROPERTY(int rows READ rows WRITE setRows)
- Q_PROPERTY(int columns READ columns WRITE setcolumns)
+ Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowChanged)
+ Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged)
public:
QmlGraphicsGrid(QmlGraphicsItem *parent=0);
int rows() const {return _rows;}
- void setRows(const int rows){_rows = rows;}
+ void setRows(const int rows);
int columns() const {return _columns;}
- void setcolumns(const int columns){_columns = columns;}
+ void setColumns(const int columns);
+
+Q_SIGNALS:
+ void rowsChanged();
+ void columnsChanged();
+
protected Q_SLOTS:
virtual void doPositioning();
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index 0c21f75..f9bbb22 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -483,6 +483,8 @@ void QmlGraphicsWebView::setRenderingEnabled(bool enabled)
if (d->rendering == enabled)
return;
d->rendering = enabled;
+ emit renderingEnabledChanged();
+
setCacheFrozen(!enabled);
if (enabled)
clearCache();
@@ -596,7 +598,10 @@ int QmlGraphicsWebView::pressGrabTime() const
void QmlGraphicsWebView::setPressGrabTime(int ms)
{
Q_D(QmlGraphicsWebView);
+ if (d->pressTime == ms)
+ return;
d->pressTime = ms;
+ emit pressGrabTimeChanged();
}
void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event)
@@ -1024,6 +1029,7 @@ void QmlGraphicsWebView::setHtml(const QString &html, const QUrl &baseUrl)
d->pending_url = baseUrl;
d->pending_string = html;
}
+ emit htmlChanged();
}
void QmlGraphicsWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl)
@@ -1116,8 +1122,10 @@ QmlComponent *QmlGraphicsWebView::newWindowComponent() const
void QmlGraphicsWebView::setNewWindowComponent(QmlComponent *newWindow)
{
Q_D(QmlGraphicsWebView);
- delete d->newWindowComponent;
+ if (newWindow == d->newWindowComponent)
+ return;
d->newWindowComponent = newWindow;
+ emit newWindowComponentChanged();
}
@@ -1137,8 +1145,16 @@ QmlGraphicsItem *QmlGraphicsWebView::newWindowParent() const
void QmlGraphicsWebView::setNewWindowParent(QmlGraphicsItem *parent)
{
Q_D(QmlGraphicsWebView);
- delete d->newWindowParent;
+ if (parent == d->newWindowParent)
+ return;
+ if (d->newWindowParent && parent) {
+ QList<QGraphicsItem *> children = d->newWindowParent->childItems();
+ for (int i = 0; i < children.count(); ++i) {
+ children.at(i)->setParentItem(parent);
+ }
+ }
d->newWindowParent = parent;
+ emit newWindowParentChanged();
}
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
index 30ba0e4..ca63be9 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h
@@ -97,9 +97,9 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged)
- Q_PROPERTY(QString html READ html WRITE setHtml)
+ Q_PROPERTY(QString html READ html WRITE setHtml NOTIFY htmlChanged)
- Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime)
+ Q_PROPERTY(int pressGrabTime READ pressGrabTime WRITE setPressGrabTime NOTIFY pressGrabTimeChanged)
Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth NOTIFY preferredWidthChanged)
Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight NOTIFY preferredHeightChanged)
@@ -116,10 +116,10 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem
Q_PROPERTY(QmlListProperty<QObject> javaScriptWindowObjects READ javaScriptWindowObjects CONSTANT)
- Q_PROPERTY(QmlComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent)
- Q_PROPERTY(QmlGraphicsItem* newWindowParent READ newWindowParent WRITE setNewWindowParent)
+ Q_PROPERTY(QmlComponent* newWindowComponent READ newWindowComponent WRITE setNewWindowComponent NOTIFY newWindowComponentChanged)
+ Q_PROPERTY(QmlGraphicsItem* newWindowParent READ newWindowParent WRITE setNewWindowParent NOTIFY newWindowParentChanged)
- Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled)
+ Q_PROPERTY(bool renderingEnabled READ renderingEnabled WRITE setRenderingEnabled NOTIFY renderingEnabledChanged)
public:
QmlGraphicsWebView(QmlGraphicsItem *parent=0);
@@ -192,7 +192,12 @@ Q_SIGNALS:
void titleChanged(const QString&);
void iconChanged();
void statusTextChanged();
+ void htmlChanged();
+ void pressGrabTimeChanged();
void zoomFactorChanged();
+ void newWindowComponentChanged();
+ void newWindowParentChanged();
+ void renderingEnabledChanged();
void loadStarted();
void loadFinished();
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index f09a944..1e4e234 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -7,7 +7,6 @@ SOURCES += \
$$PWD/qmlexpression.cpp \
$$PWD/qmlbinding.cpp \
$$PWD/qmlmetaproperty.cpp \
- $$PWD/qmlmoduleplugin.cpp \
$$PWD/qmlcomponent.cpp \
$$PWD/qmlcontext.cpp \
$$PWD/qmlcustomparser.cpp \
@@ -52,6 +51,8 @@ SOURCES += \
$$PWD/qmlworkerscript.cpp \
$$PWD/qmlimageprovider.cpp \
$$PWD/qmlnetworkaccessmanagerfactory.cpp \
+ $$PWD/qmldirparser.cpp \
+ $$PWD/qmlextensionplugin.cpp \
$$PWD/qmllist.cpp
HEADERS += \
@@ -63,7 +64,6 @@ HEADERS += \
$$PWD/qmlbinding_p.h \
$$PWD/qmlbinding_p_p.h \
$$PWD/qmlmetaproperty.h \
- $$PWD/qmlmoduleplugin.h \
$$PWD/qmlcomponent.h \
$$PWD/qmlcomponent_p.h \
$$PWD/qmlcustomparser_p.h \
@@ -122,7 +122,11 @@ HEADERS += \
$$PWD/qmlscriptclass_p.h \
$$PWD/qmlguard_p.h \
$$PWD/qmlimageprovider.h \
- $$PWD/qmlnetworkaccessmanagerfactory.h
+ $$PWD/qmlnetworkaccessmanagerfactory.h \
+ $$PWD/qmldirparser_p.h \
+ $$PWD/qmlextensioninterface.h \
+ $$PWD/qmlextensionplugin.h
+
QT += sql
include(parser/parser.pri)
include(rewriter/rewriter.pri)
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 10b6e4f..4365b17 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1132,10 +1132,10 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
Property *idProp = 0;
if (obj->properties.count() > 1 ||
(obj->properties.count() == 1 && obj->properties.begin().key() != "id"))
- COMPILE_EXCEPTION(*obj->properties.begin(), QCoreApplication::translate("QmlCompiler","Invalid component specification"));
+ COMPILE_EXCEPTION(*obj->properties.begin(), QCoreApplication::translate("QmlCompiler","Component elements may not contain properties other than id"));
if (!obj->scriptBlockObjects.isEmpty())
- COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), QCoreApplication::translate("QmlCompiler","Invalid component specification"));
+ COMPILE_EXCEPTION(obj->scriptBlockObjects.first(), QCoreApplication::translate("QmlCompiler","Component elements may not contain script blocks"));
if (obj->properties.count())
idProp = *obj->properties.begin();
@@ -2609,7 +2609,13 @@ int QmlCompiler::genContextCache()
int QmlCompiler::genValueTypeData(QmlParser::Property *valueTypeProp,
QmlParser::Property *prop)
{
- return output->indexForByteArray(QmlMetaPropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index, valueTypeProp->index, valueTypeProp->type));
+ QByteArray data =
+ QmlMetaPropertyPrivate::saveValueType(prop->parent->metaObject(), prop->index,
+ QmlEnginePrivate::get(engine)->valueTypes[prop->type]->metaObject(),
+ valueTypeProp->index);
+// valueTypeProp->index, valueTypeProp->type);
+
+ return output->indexForByteArray(data);
}
int QmlCompiler::genPropertyData(QmlParser::Property *prop)
diff --git a/src/declarative/qml/qmldirparser.cpp b/src/declarative/qml/qmldirparser.cpp
new file mode 100644
index 0000000..60beb72
--- /dev/null
+++ b/src/declarative/qml/qmldirparser.cpp
@@ -0,0 +1,220 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmldirparser_p.h"
+#include "qmlerror.h"
+
+#include <QtCore/QTextStream>
+#include <QtCore/QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+QmlDirParser::QmlDirParser()
+ : _isParsed(false)
+{
+}
+
+QmlDirParser::~QmlDirParser()
+{
+}
+
+QUrl QmlDirParser::url() const
+{
+ return _url;
+}
+
+void QmlDirParser::setUrl(const QUrl &url)
+{
+ _url = url;
+}
+
+QString QmlDirParser::source() const
+{
+ return _source;
+}
+
+void QmlDirParser::setSource(const QString &source)
+{
+ _isParsed = false;
+ _source = source;
+}
+
+bool QmlDirParser::isParsed() const
+{
+ return _isParsed;
+}
+
+bool QmlDirParser::parse()
+{
+ if (_isParsed)
+ return true;
+
+ _isParsed = true;
+ _errors.clear();
+ _plugins.clear();
+ _components.clear();
+
+ QTextStream stream(&_source);
+ int lineNumber = 0;
+
+ forever {
+ ++lineNumber;
+
+ const QString line = stream.readLine();
+ if (line.isNull())
+ break;
+
+ QString sections[3];
+ int sectionCount = 0;
+
+ int index = 0;
+ const int length = line.length();
+
+ while (index != length) {
+ const QChar ch = line.at(index);
+
+ if (ch.isSpace()) {
+ do { ++index; }
+ while (index != length && line.at(index).isSpace());
+
+ } else if (ch == QLatin1Char('#')) {
+ // recognized a comment
+ break;
+
+ } else {
+ const int start = index;
+
+ do { ++index; }
+ while (index != length && !line.at(index).isSpace());
+
+ const QString lexeme = line.mid(start, index - start);
+
+ if (sectionCount >= 3) {
+ reportError(lineNumber, start, QLatin1String("unexpected token"));
+
+ } else {
+ sections[sectionCount++] = lexeme;
+ }
+ }
+ }
+
+ if (sectionCount == 0) {
+ continue; // no sections, no party.
+
+ } else if (sections[0] == QLatin1String("plugin")) {
+ if (sectionCount < 2) {
+ reportError(lineNumber, -1,
+ QString::fromUtf8("plugin directive requires 2 arguments, but %1 were provided").arg(sectionCount + 1));
+
+ continue;
+ }
+
+ const Plugin entry(sections[1], sections[2]);
+
+ _plugins.append(entry);
+
+ } else if (sectionCount == 3) {
+ const QString &version = sections[1];
+ const int dotIndex = version.indexOf(QLatin1Char('.'));
+
+ if (dotIndex == -1) {
+ qWarning() << "expected '.'"; // ### use reportError
+
+ } else if (version.indexOf(QLatin1Char('.'), dotIndex + 1) != -1) {
+ qWarning() << "unexpected '.'"; // ### use reportError
+
+ } else {
+ bool validVersionNumber = false;
+ const int majorVersion = version.left(dotIndex).toInt(&validVersionNumber);
+
+ if (validVersionNumber) {
+ const int minorVersion = version.mid(dotIndex + 1).toInt(&validVersionNumber);
+
+ if (validVersionNumber) {
+ const Component entry(sections[0], sections[2], majorVersion, minorVersion);
+
+ _components.append(entry);
+ }
+ }
+ }
+ } else {
+ // ### use reportError
+ qWarning() << "a component declaration requires 3 arguments, but" << (sectionCount + 1) << "were provided";
+ }
+ }
+
+ return hasError();
+}
+
+void QmlDirParser::reportError(int line, int column, const QString &description)
+{
+ QmlError error;
+ error.setUrl(_url);
+ error.setLine(line);
+ error.setColumn(column);
+ error.setDescription(description);
+ _errors.append(error);
+}
+
+bool QmlDirParser::hasError() const
+{
+ if (! _errors.isEmpty())
+ return true;
+
+ return false;
+}
+
+QList<QmlError> QmlDirParser::errors() const
+{
+ return _errors;
+}
+
+QList<QmlDirParser::Plugin> QmlDirParser::plugins() const
+{
+ return _plugins;
+}
+
+QList<QmlDirParser::Component> QmlDirParser::components() const
+{
+ return _components;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmldirparser_p.h b/src/declarative/qml/qmldirparser_p.h
new file mode 100644
index 0000000..c58c03f
--- /dev/null
+++ b/src/declarative/qml/qmldirparser_p.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLDIRPARSER_P_H
+#define QMLDIRPARSER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QUrl>
+#include <QtCore/QHash>
+
+QT_BEGIN_NAMESPACE
+
+class QmlError;
+
+class QmlDirParser
+{
+ Q_DISABLE_COPY(QmlDirParser)
+
+public:
+ QmlDirParser();
+ ~QmlDirParser();
+
+ QUrl url() const;
+ void setUrl(const QUrl &url);
+
+ QString source() const;
+ void setSource(const QString &source);
+
+ bool isParsed() const;
+ bool parse();
+
+ bool hasError() const;
+ QList<QmlError> errors() const;
+
+ struct Plugin
+ {
+ Plugin() {}
+
+ Plugin(const QString &name, const QString &path)
+ : name(name), path(path) {}
+
+ QString name;
+ QString path;
+ };
+
+ struct Component
+ {
+ Component()
+ : majorVersion(0), minorVersion(0) {}
+
+ Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion)
+ : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {}
+
+ QString typeName;
+ QString fileName;
+ int majorVersion;
+ int minorVersion;
+ };
+
+ QList<Component> components() const;
+ QList<Plugin> plugins() const;
+
+private:
+ void reportError(int line, int column, const QString &message);
+
+private:
+ QList<QmlError> _errors;
+ QUrl _url;
+ QString _source;
+ QList<Component> _components;
+ QList<Plugin> _plugins;
+ unsigned _isParsed: 1;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMLDIRPARSER_P_H
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 2460f52..c7e1e16 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -50,7 +50,6 @@
#include "qmlexpression.h"
#include "qmlcomponent.h"
#include "qmlmetaproperty_p.h"
-#include "qmlmoduleplugin.h"
#include "qmlbinding_p_p.h"
#include "qmlvme_p.h"
#include "qmlenginedebug_p.h"
@@ -66,6 +65,8 @@
#include "qmlscriptclass_p.h"
#include "qmlnetworkaccessmanagerfactory.h"
#include "qmlimageprovider.h"
+#include "qmldirparser_p.h"
+#include "qmlextensioninterface.h"
#include "qmllist_p.h"
#include <qfxperf_p_p.h>
@@ -82,6 +83,7 @@
#include <QDebug>
#include <QMetaObject>
#include <QStack>
+#include <QPluginLoader>
#include <QtCore/qlibraryinfo.h>
#include <QtCore/qthreadstorage.h>
#include <QtCore/qthread.h>
@@ -94,7 +96,6 @@
#include <QGraphicsObject>
#include <QtCore/qcryptographichash.h>
-#include <private/qfactoryloader_p.h>
#include <private/qobject_p.h>
#include <private/qscriptdeclarativeclass_p.h>
@@ -156,6 +157,21 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
}
globalClass = new QmlGlobalScriptClass(&scriptEngine);
fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml"));
+
+ // env import paths
+ QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
+ if (!envImportPath.isEmpty()) {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ QLatin1Char pathSep(';');
+#else
+ QLatin1Char pathSep(':');
+#endif
+ foreach (const QString &path, QString::fromLatin1(envImportPath).split(pathSep, QString::SkipEmptyParts)) {
+ QString canonicalPath = QDir(path).canonicalPath();
+ if (!canonicalPath.isEmpty() && !environmentImportPath.contains(canonicalPath))
+ environmentImportPath.append(canonicalPath);
+ }
+ }
}
QUrl QmlScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
@@ -1235,7 +1251,6 @@ struct QmlEnginePrivate::ImportedNamespace {
QList<int> majversions;
QList<int> minversions;
QList<bool> isLibrary;
- QList<bool> isBuiltin; // Types provided by C++ code (including plugins)
QList<QString> qmlDirContent;
bool find(const QByteArray& type, int *vmajor, int *vminor, QmlType** type_return, QUrl* url_return) const
@@ -1244,23 +1259,23 @@ struct QmlEnginePrivate::ImportedNamespace {
int vmaj = majversions.at(i);
int vmin = minversions.at(i);
- if (isBuiltin.at(i)) {
- QByteArray qt = uris.at(i).toUtf8();
- qt += '/';
- qt += type;
- if (qmlImportTrace())
- qDebug() << "Look in" << qt;
- QmlType *t = QmlMetaType::qmlType(qt,vmaj,vmin);
+ QByteArray qt = uris.at(i).toUtf8();
+ qt += '/';
+ qt += type;
+
+ if (qmlImportTrace())
+ qDebug() << "Look in" << qt;
+ QmlType *t = QmlMetaType::qmlType(qt,vmaj,vmin);
+ if (t) {
if (vmajor) *vmajor = vmaj;
if (vminor) *vminor = vmin;
- if (t) {
- if (qmlImportTrace())
- qDebug() << "Found" << qt;
- if (type_return)
- *type_return = t;
- return true;
- }
+ if (qmlImportTrace())
+ qDebug() << "Found" << qt;
+ if (type_return)
+ *type_return = t;
+ return true;
}
+
QUrl url = QUrl(urls.at(i) + QLatin1Char('/') + QString::fromUtf8(type) + QLatin1String(".qml"));
QString qmldircontent = qmlDirContent.at(i);
if (vmaj>=0 || !qmldircontent.isEmpty()) {
@@ -1271,27 +1286,25 @@ struct QmlEnginePrivate::ImportedNamespace {
qmldircontent = QString::fromUtf8(qmldir.readAll());
}
}
- QString typespace = QString::fromUtf8(type)+QLatin1Char(' ');
- QStringList lines = qmldircontent.split(QLatin1Char('\n'));
- foreach (QString line, lines) {
- if (line.isEmpty() || line.at(0) == QLatin1Char('#'))
- continue;
- if (line.startsWith(typespace)) {
- int space1 = line.indexOf(QLatin1Char(' '));
- int space2 = space1 >=0 ? line.indexOf(QLatin1Char(' '),space1+1) : -1;
- QString mapversions = line.mid(space1+1,space2<0?line.length()-space1-1:space2-space1-1);
- int dot = mapversions.indexOf(QLatin1Char('.'));
- int mapvmaj = mapversions.left(dot).toInt();
- if (mapvmaj<=vmaj) {
- if (mapvmaj<vmaj || vmin >= mapversions.mid(dot+1).toInt()) {
- QStringRef mapfile = space2<0 ? QStringRef() : line.midRef(space2+1,line.length()-space2-1);
- if (url_return)
- *url_return = url.resolved(QUrl(mapfile.toString()));
- return true;
- }
+
+ const QString typeName = QString::fromUtf8(type);
+
+ QmlDirParser qmldirParser;
+ qmldirParser.setUrl(url);
+ qmldirParser.setSource(qmldircontent);
+ qmldirParser.parse();
+
+ foreach (const QmlDirParser::Component &c, qmldirParser.components()) { // ### TODO: cache the components
+ if (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion)) {
+ if (c.typeName == typeName) {
+ if (url_return)
+ *url_return = url.resolved(QUrl(c.fileName));
+
+ return true;
}
}
}
+
} else {
// XXX search non-files too! (eg. zip files, see QT-524)
QFileInfo f(toLocalFileOrQrc(url));
@@ -1306,9 +1319,6 @@ struct QmlEnginePrivate::ImportedNamespace {
}
};
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QmlModuleFactoryInterface_iid, QLatin1String("/qmlmodules")))
-
class QmlImportsPrivate {
public:
QmlImportsPrivate() : ref(1)
@@ -1321,7 +1331,9 @@ public:
delete s;
}
- bool add(const QUrl& base, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType, const QStringList& importPath)
+ QSet<QString> qmlDirFilesForWhichPluginsHaveBeenLoaded;
+
+ bool add(const QUrl& base, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType, const QStringList& importPath, QmlEngine *engine)
{
QmlEnginePrivate::ImportedNamespace *s;
if (prefix.isEmpty()) {
@@ -1332,39 +1344,63 @@ public:
set.insert(prefix,(s=new QmlEnginePrivate::ImportedNamespace));
}
QString url = uri;
- bool isbuiltin = false;
if (importType == QmlScriptParser::Import::Library) {
- url.replace(QLatin1Char('.'),QLatin1Char('/'));
+ url.replace(QLatin1Char('.'), QLatin1Char('/'));
bool found = false;
- foreach (QString p, importPath) {
- QString dir = p+QLatin1Char('/')+url;
+ QString content;
+ QString dir;
+
+ // user import paths
+ QStringList paths;
+
+ // base..
+ paths += QFileInfo(base.toLocalFile()).path();
+ paths += importPath;
+ paths += QmlEnginePrivate::get(engine)->environmentImportPath;
+
+ foreach (const QString &p, paths) {
+ dir = p+QLatin1Char('/')+url;
QFileInfo fi(dir+QLatin1String("/qmldir"));
+ const QString absoluteFilePath = fi.absoluteFilePath();
+
if (fi.isFile()) {
- url = QUrl::fromLocalFile(fi.absolutePath()).toString();
found = true;
+
+ url = QUrl::fromLocalFile(fi.absolutePath()).toString();
+
+ QFile file(absoluteFilePath);
+ if (file.open(QFile::ReadOnly))
+ content = QString::fromUtf8(file.readAll());
+
+ if (! qmlDirFilesForWhichPluginsHaveBeenLoaded.contains(absoluteFilePath)) {
+ qmlDirFilesForWhichPluginsHaveBeenLoaded.insert(absoluteFilePath);
+
+ QmlDirParser qmldirParser;
+ qmldirParser.setSource(content);
+ qmldirParser.parse();
+
+ foreach (const QmlDirParser::Plugin &plugin, qmldirParser.plugins()) {
+ QString resolvedFilePath = QmlEnginePrivate::get(engine)->resolvePlugin(dir + QDir::separator() + plugin.path,
+ plugin.name);
+
+ if (!resolvedFilePath.isEmpty())
+ engine->importExtension(resolvedFilePath, uri);
+ }
+ }
+
break;
}
}
- if (!found) {
- // XXX assume it is a built-in type qualifier
- isbuiltin = true;
- }
- QFactoryLoader *l = loader();
- QmlModuleFactoryInterface *factory =
- qobject_cast<QmlModuleFactoryInterface*>(l->instance(uri));
- if (factory) {
- factory->defineModuleOnce(uri);
- isbuiltin = true;
- }
+
} else {
url = base.resolved(QUrl(url)).toString();
}
+
s->uris.prepend(uri);
s->urls.prepend(url);
s->majversions.prepend(vmaj);
s->minversions.prepend(vmin);
s->isLibrary.prepend(importType == QmlScriptParser::Import::Library);
- s->isBuiltin.prepend(isbuiltin);
s->qmlDirContent.prepend(qmldircontent);
return true;
}
@@ -1387,10 +1423,11 @@ public:
if (s) {
if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return))
return true;
- if (s->urls.count() == 1 && !s->isBuiltin[0] && !s->isLibrary[0] && url_return) {
+ if (s->urls.count() == 1 && !s->isLibrary[0] && url_return) {
*url_return = QUrl(s->urls[0]+QLatin1Char('/')).resolved(QUrl(QString::fromUtf8(unqualifiedtype) + QLatin1String(".qml")));
return true;
}
+
}
if (url_return) {
*url_return = base.resolved(QUrl(QString::fromUtf8(type + ".qml")));
@@ -1451,9 +1488,6 @@ static QmlTypeNameCache *cacheForNamespace(QmlEngine *engine, const QmlEnginePri
QList<QmlType *> types = QmlMetaType::qmlTypes();
for (int ii = 0; ii < set.uris.count(); ++ii) {
- if (!set.isBuiltin.at(ii))
- continue;
-
QByteArray base = set.uris.at(ii).toUtf8() + '/';
int major = set.majversions.at(ii);
int minor = set.minversions.at(ii);
@@ -1552,6 +1586,24 @@ void QmlEngine::addImportPath(const QString& path)
}
/*!
+ Imports the given \a extension into this QmlEngine. Returns
+ true if the extension was successfully imported.
+
+ \sa QmlExtensionInterface
+*/
+bool QmlEngine::importExtension(const QString &fileName, const QString &uri)
+{
+ QPluginLoader loader(fileName);
+
+ if (QmlExtensionInterface *iface = qobject_cast<QmlExtensionInterface *>(loader.instance())) {
+ iface->initialize(this, uri.toUtf8().constData());
+ return true;
+ }
+
+ return false;
+}
+
+/*!
\property QmlEngine::offlineStoragePath
\brief the directory for storing offline user data
@@ -1580,6 +1632,87 @@ QString QmlEngine::offlineStoragePath() const
return d->scriptEngine.offlineStoragePath;
}
+/*!
+ \internal
+
+ Returns the result of the merge of \a baseName with \a dir, \a suffixes, and \a prefix.
+ */
+QString QmlEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName,
+ const QStringList &suffixes,
+ const QString &prefix)
+{
+ foreach (const QString &suffix, suffixes) {
+ QString pluginFileName = prefix;
+
+ pluginFileName += baseName;
+ pluginFileName += QLatin1Char('.');
+ pluginFileName += suffix;
+
+ QFileInfo fileInfo(dir, pluginFileName);
+
+ if (fileInfo.exists())
+ return fileInfo.absoluteFilePath();
+ }
+
+ return QString();
+}
+
+/*!
+ \internal
+
+ Returns the result of the merge of \a baseName with \a dir and the platform suffix.
+
+ \table
+ \header \i Platform \i Valid suffixes
+ \row \i Windows \i \c .dll
+ \row \i Unix/Linux \i \c .so
+ \row \i AIX \i \c .a
+ \row \i HP-UX \i \c .sl, \c .so (HP-UXi)
+ \row \i Mac OS X \i \c .dylib, \c .bundle, \c .so
+ \row \i Symbian \i \c .dll
+ \endtable
+
+ Version number on unix are ignored.
+*/
+QString QmlEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName)
+{
+#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+ return resolvePlugin(dir, baseName, QStringList(QLatin1String("dll")));
+#elif defined(Q_OS_SYMBIAN)
+ return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dll") << QLatin1String("qtplugin"));
+#else
+
+# if defined(Q_OS_DARWIN)
+
+ return resolvePlugin(dir, baseName, QStringList() << QLatin1String("dylib") << QLatin1String("so") << QLatin1String("bundle"),
+ QLatin1String("lib"));
+# else // Generic Unix
+ QStringList validSuffixList;
+
+# if defined(Q_OS_HPUX)
+/*
+ See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF":
+ "In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
+ the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
+ */
+ validSuffixList << QLatin1String("sl");
+# if defined __ia64
+ validSuffixList << QLatin1String("so");
+# endif
+# elif defined(Q_OS_AIX)
+ validSuffixList << QLatin1String("a") << QLatin1String("so");
+# elif defined(Q_OS_UNIX)
+ validSuffixList << QLatin1String("so");
+# endif
+
+ // Examples of valid library names:
+ // libfoo.so
+
+ return resolvePlugin(dir, baseName, validSuffixList, QLatin1String("lib"));
+# endif
+
+#endif
+}
/*!
\internal
@@ -1597,7 +1730,8 @@ QString QmlEngine::offlineStoragePath() const
*/
bool QmlEnginePrivate::addToImport(Imports* imports, const QString& qmldircontent, const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const
{
- bool ok = imports->d->add(imports->d->base,qmldircontent,uri,prefix,vmaj,vmin,importType,fileImportPath);
+ QmlEngine *engine = QmlEnginePrivate::get(const_cast<QmlEnginePrivate *>(this));
+ bool ok = imports->d->add(imports->d->base,qmldircontent,uri,prefix,vmaj,vmin,importType,fileImportPath, engine);
if (qmlImportTrace())
qDebug() << "QmlEngine::addToImport(" << imports << uri << prefix << vmaj << '.' << vmin << (importType==QmlScriptParser::Import::Library? "Library" : "File") << ": " << ok;
return ok;
diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h
index 64d0b9d..dd2012a 100644
--- a/src/declarative/qml/qmlengine.h
+++ b/src/declarative/qml/qmlengine.h
@@ -78,6 +78,7 @@ public:
void clearComponentCache();
void addImportPath(const QString& dir);
+ bool importExtension(const QString &fileName, const QString &uri);
void setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *);
QmlNetworkAccessManagerFactory *networkAccessManagerFactory() const;
diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h
index 3fe7991..85c5fbe 100644
--- a/src/declarative/qml/qmlengine_p.h
+++ b/src/declarative/qml/qmlengine_p.h
@@ -104,6 +104,7 @@ class QmlCleanup;
class QmlDelayedError;
class QmlWorkerScriptEngine;
class QmlGlobalScriptClass;
+class QDir;
class QmlScriptEngine : public QScriptEngine
{
@@ -263,6 +264,15 @@ public:
QmlImportsPrivate *d;
};
+
+ QStringList environmentImportPath;
+
+ QString resolvePlugin(const QDir &dir, const QString &baseName,
+ const QStringList &suffixes,
+ const QString &prefix = QString());
+ QString resolvePlugin(const QDir &dir, const QString &baseName);
+
+
bool addToImport(Imports*, const QString& qmlDirContent,const QString& uri, const QString& prefix, int vmaj, int vmin, QmlScriptParser::Import::Type importType) const;
bool resolveType(const Imports&, const QByteArray& type,
QmlType** type_return, QUrl* url_return,
diff --git a/src/declarative/qml/qmlextensioninterface.h b/src/declarative/qml/qmlextensioninterface.h
new file mode 100644
index 0000000..644ef1e
--- /dev/null
+++ b/src/declarative/qml/qmlextensioninterface.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLEXTENSIONINTERFACE_H
+#define QMLEXTENSIONINTERFACE_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QmlEngine;
+
+struct Q_DECLARATIVE_EXPORT QmlExtensionInterface
+{
+ virtual ~QmlExtensionInterface() {}
+ virtual void initialize(QmlEngine *engine, const char *uri) = 0;
+};
+
+Q_DECLARE_INTERFACE(QmlExtensionInterface, "com.trolltech.Qt.QmlExtensionInterface/1.0")
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMLEXTENSIONINTERFACE_H
diff --git a/src/declarative/qml/qmlextensionplugin.cpp b/src/declarative/qml/qmlextensionplugin.cpp
new file mode 100644
index 0000000..c1195d2
--- /dev/null
+++ b/src/declarative/qml/qmlextensionplugin.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlextensionplugin.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \since 4.7
+ \class QmlExtensionPlugin
+ \brief The QmlExtensionPlugin class provides an abstract base for custom QML extension plugins.
+
+ \ingroup plugins
+
+ QmlExtensionPlugin is a plugin interface that makes it
+ possible to offer extensions that can be loaded dynamically into
+ applications using the QmlEngine class.
+
+ Writing a QML extension plugin is achieved by subclassing this
+ base class, reimplementing the pure virtual initialize()
+ function, and exporting the class using the Q_EXPORT_PLUGIN2()
+ macro. See \l {How to Create Qt Plugins} for details.
+
+ \sa QmlEngine::importExtension()
+*/
+
+/*!
+ \fn void QmlExtensionPlugin::initialize(QmlEngine *engine)
+
+ Initializes the extension specified in the given \a engine.
+*/
+
+/*!
+ Constructs a QML extension plugin with the given \a parent.
+
+ Note that this constructor is invoked automatically by the
+ Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
+ explicitly.
+*/
+QmlExtensionPlugin::QmlExtensionPlugin(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QmlExtensionPlugin::~QmlExtensionPlugin()
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlmoduleplugin.h b/src/declarative/qml/qmlextensionplugin.h
index b28f1ad..8cc64ad 100644
--- a/src/declarative/qml/qmlmoduleplugin.h
+++ b/src/declarative/qml/qmlextensionplugin.h
@@ -39,14 +39,12 @@
**
****************************************************************************/
-#ifndef QMLMODULEPLUGIN_H
-#define QMLMODULEPLUGIN_H
+#ifndef QMLEXTENSIONPLUGIN_H
+#define QMLEXTENSIONPLUGIN_H
#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qset.h>
-#include <QtCore/qbytearray.h>
+
+#include "qmlextensioninterface.h"
QT_BEGIN_HEADER
@@ -54,33 +52,21 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-struct Q_DECLARATIVE_EXPORT QmlModuleFactoryInterface : public QFactoryInterface
-{
- virtual void defineModuleOnce(const QString& uri) = 0;
-};
-
-#define QmlModuleFactoryInterface_iid "com.nokia.Qt.QmlModuleFactoryInterface"
+class QmlEngine;
-Q_DECLARE_INTERFACE(QmlModuleFactoryInterface, QmlModuleFactoryInterface_iid)
-
-
-class Q_DECLARATIVE_EXPORT QmlModulePlugin : public QObject, public QmlModuleFactoryInterface
+class Q_DECLARATIVE_EXPORT QmlExtensionPlugin : public QObject, public QmlExtensionInterface
{
Q_OBJECT
- Q_INTERFACES(QmlModuleFactoryInterface:QFactoryInterface)
+ Q_INTERFACES(QmlExtensionInterface)
public:
- explicit QmlModulePlugin(QObject *parent = 0);
- ~QmlModulePlugin();
-
- virtual void defineModule(const QString& uri) = 0;
+ explicit QmlExtensionPlugin(QObject *parent = 0);
+ ~QmlExtensionPlugin();
-private:
- void defineModuleOnce(const QString& uri);
- QSet<QString> defined;
+ virtual void initialize(QmlEngine *engine, const char *uri) = 0;
};
QT_END_NAMESPACE
QT_END_HEADER
-#endif // QMLMODULEPLUGIN_H
+#endif // QMLEXTENSIONPLUGIN_H
diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp
index ac619ec..d731393 100644
--- a/src/declarative/qml/qmlmetaproperty.cpp
+++ b/src/declarative/qml/qmlmetaproperty.cpp
@@ -777,6 +777,7 @@ bool QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value,
writeBack->read(object, core.coreIndex);
QmlPropertyCache::Data data = core;
+ data.flags = valueType.flags;
data.coreIndex = valueType.valueTypeCoreIdx;
data.propType = valueType.valueTypePropType;
rv = write(writeBack, data, value, context, flags);
@@ -1082,15 +1083,20 @@ struct ValueTypeSerializedData : public SerializedData {
};
QByteArray QmlMetaPropertyPrivate::saveValueType(const QMetaObject *metaObject, int index,
- int subIndex, int subType)
+ const QMetaObject *subObject, int subIndex)
{
+ QMetaProperty prop = metaObject->property(index);
+ QMetaProperty subProp = subObject->property(subIndex);
+
ValueTypeSerializedData sd;
sd.type = QmlMetaProperty::ValueTypeProperty;
sd.core.load(metaObject->property(index));
+ sd.valueType.flags = QmlPropertyCache::Data::flagsForProperty(subProp);
sd.valueType.valueTypeCoreIdx = subIndex;
- sd.valueType.valueTypePropType = subType;
+ sd.valueType.valueTypePropType = subProp.userType();
QByteArray rv((const char *)&sd, sizeof(sd));
+
return rv;
}
diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h
index b99e5be..9236bd3 100644
--- a/src/declarative/qml/qmlmetaproperty_p.h
+++ b/src/declarative/qml/qmlmetaproperty_p.h
@@ -111,7 +111,8 @@ public:
static QmlAbstractBinding *setBinding(QObject *, const QmlPropertyCache::Data &, QmlAbstractBinding *,
QmlMetaProperty::WriteFlags flags = QmlMetaProperty::DontRemoveBinding);
- static QByteArray saveValueType(const QMetaObject *, int, int, int);
+ static QByteArray saveValueType(const QMetaObject *, int,
+ const QMetaObject *, int);
static QByteArray saveProperty(const QMetaObject *, int);
static QmlMetaProperty restore(const QByteArray &, QObject *, QmlContext * = 0);
diff --git a/src/declarative/qml/qmlmoduleplugin.cpp b/src/declarative/qml/qmlmoduleplugin.cpp
deleted file mode 100644
index 8019805..0000000
--- a/src/declarative/qml/qmlmoduleplugin.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmlmoduleplugin.h"
-#include "qstringlist.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QmlModulePlugin
- \brief The QmlModulePlugin class provides an abstract base for custom QML module plugins.
- \reentrant
- \ingroup plugins
-
- The QML module plugin is a simple plugin interface that makes it
- easy to add custom QML modules that can be loaded dynamically
- into applications.
-
- Writing a QML module plugin is achieved by subclassing this base
- class, reimplementing the pure virtual function keys(), and
- exporting the class with the Q_EXPORT_PLUGIN2() macro. See \l{How
- to Create Qt Plugins} for details.
-
- The strings returned by keys() should be the list of URIs of modules
- that the plugin registers.
-
- The plugin should register QML types with qmlRegisterType() when the
- defineModule() method is called.
-
- See the example in \c{examples/declarative/plugins}.
-*/
-
-/*!
- Constructs a QML module plugin with the given \a parent. This is
- invoked automatically by the Q_EXPORT_PLUGIN2() macro.
-*/
-QmlModulePlugin::QmlModulePlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys the QML module plugin.
-
- You never have to call this explicitly. Qt destroys a plugin
- automatically when it is no longer used.
-*/
-QmlModulePlugin::~QmlModulePlugin()
-{
-}
-
-/*!
- \fn void QmlModulePlugin::defineModule(const QString& uri)
-
- Subclasses must override this function to register types
- of the module \a uri, which will be one of the strings returned by keys().
-
- The plugin registers QML types with qmlRegisterType():
-
- \code
- qmlRegisterType<MyClass>("com.nokia.MyModule", 1, 0, "MyType", "MyClass");
- \endcode
-*/
-
-void QmlModulePlugin::defineModuleOnce(const QString& uri)
-{
- if (!defined.contains(uri)) {
- defined += uri;
- defineModule(uri);
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp
index 2d087b6..81f8e51 100644
--- a/src/declarative/qml/qmlpropertycache.cpp
+++ b/src/declarative/qml/qmlpropertycache.cpp
@@ -49,13 +49,11 @@ Q_DECLARE_METATYPE(QScriptValue);
QT_BEGIN_NAMESPACE
-void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
+QmlPropertyCache::Data::Flags QmlPropertyCache::Data::flagsForProperty(const QMetaProperty &p, QmlEngine *engine)
{
- propType = p.userType();
- if (QVariant::Type(propType) == QVariant::LastType)
- propType = qMetaTypeId<QVariant>();
- coreIndex = p.propertyIndex();
- notifyIndex = p.notifySignalIndex();
+ int propType = p.userType();
+
+ Flags flags;
if (p.isConstant())
flags |= Data::IsConstant;
@@ -78,6 +76,18 @@ void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
else if (cat == QmlMetaType::List)
flags |= Data::IsQList;
}
+
+ return flags;
+}
+
+void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine)
+{
+ propType = p.userType();
+ if (QVariant::Type(propType) == QVariant::LastType)
+ propType = qMetaTypeId<QVariant>();
+ coreIndex = p.propertyIndex();
+ notifyIndex = p.notifySignalIndex();
+ flags = flagsForProperty(p, engine);
}
void QmlPropertyCache::Data::load(const QMetaMethod &m)
diff --git a/src/declarative/qml/qmlpropertycache_p.h b/src/declarative/qml/qmlpropertycache_p.h
index 18eea80..4a98b88 100644
--- a/src/declarative/qml/qmlpropertycache_p.h
+++ b/src/declarative/qml/qmlpropertycache_p.h
@@ -104,6 +104,7 @@ public:
int coreIndex;
int notifyIndex;
+ static Flags flagsForProperty(const QMetaProperty &, QmlEngine *engine = 0);
void load(const QMetaProperty &, QmlEngine *engine = 0);
void load(const QMetaMethod &);
QString name(QObject *);
@@ -113,6 +114,7 @@ public:
struct ValueTypeData {
inline ValueTypeData();
inline bool operator==(const ValueTypeData &);
+ Data::Flags flags; // flags on the value type wrapper
int valueTypeCoreIdx; // The prop index of the access property on the value type wrapper
int valueTypePropType; // The QVariant::Type of access property on the value type wrapper
};
@@ -173,13 +175,14 @@ QmlPropertyCache::property(const QScriptDeclarativeClass::Identifier &id) const
}
QmlPropertyCache::ValueTypeData::ValueTypeData()
-: valueTypeCoreIdx(-1), valueTypePropType(0)
+: flags(QmlPropertyCache::Data::NoFlags), valueTypeCoreIdx(-1), valueTypePropType(0)
{
}
bool QmlPropertyCache::ValueTypeData::operator==(const ValueTypeData &o)
{
- return valueTypeCoreIdx == o.valueTypeCoreIdx &&
+ return flags == o.flags &&
+ valueTypeCoreIdx == o.valueTypeCoreIdx &&
valueTypePropType == o.valueTypePropType;
}
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp
index 33c3e76..e3b4219 100644
--- a/src/declarative/qml/qmlvaluetype.cpp
+++ b/src/declarative/qml/qmlvaluetype.cpp
@@ -75,6 +75,8 @@ QmlValueType *QmlValueTypeFactory::valueType(int t)
return new QmlRectFValueType;
case QVariant::Vector3D:
return new QmlVector3DValueType;
+ case QVariant::EasingCurve:
+ return new QmlEasingValueType;
case QVariant::Font:
return new QmlFontValueType;
default:
@@ -473,6 +475,74 @@ void QmlVector3DValueType::setZ(qreal z)
vector.setZ(z);
}
+QmlEasingValueType::QmlEasingValueType(QObject *parent)
+: QmlValueType(parent)
+{
+}
+
+void QmlEasingValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &easing, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QmlEasingValueType::write(QObject *obj, int idx, QmlMetaProperty::WriteFlags flags)
+{
+ int status = -1;
+ void *a[] = { &easing, 0, &status, &flags };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+QVariant QmlEasingValueType::value()
+{
+ return QVariant(easing);
+}
+
+void QmlEasingValueType::setValue(QVariant value)
+{
+ easing = qvariant_cast<QEasingCurve>(value);
+}
+
+QmlEasingValueType::Type QmlEasingValueType::type() const
+{
+ return (QmlEasingValueType::Type)easing.type();
+}
+
+qreal QmlEasingValueType::amplitude() const
+{
+ return easing.amplitude();
+}
+
+qreal QmlEasingValueType::overshoot() const
+{
+ return easing.overshoot();
+}
+
+qreal QmlEasingValueType::period() const
+{
+ return easing.period();
+}
+
+void QmlEasingValueType::setType(QmlEasingValueType::Type type)
+{
+ easing.setType((QEasingCurve::Type)type);
+}
+
+void QmlEasingValueType::setAmplitude(qreal amplitude)
+{
+ easing.setAmplitude(amplitude);
+}
+
+void QmlEasingValueType::setOvershoot(qreal overshoot)
+{
+ easing.setOvershoot(overshoot);
+}
+
+void QmlEasingValueType::setPeriod(qreal period)
+{
+ easing.setPeriod(period);
+}
+
QmlFontValueType::QmlFontValueType(QObject *parent)
: QmlValueType(parent), hasPixelSize(false)
{
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
index 0a152e8..6dd3703 100644
--- a/src/declarative/qml/qmlvaluetype_p.h
+++ b/src/declarative/qml/qmlvaluetype_p.h
@@ -57,6 +57,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
+#include <QtCore/qeasingcurve.h>
#include <QtCore/qvariant.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qfont.h>
@@ -256,6 +257,62 @@ private:
QVector3D vector;
};
+class Q_AUTOTEST_EXPORT QmlEasingValueType : public QmlValueType
+{
+ Q_OBJECT
+ Q_ENUMS(Type)
+
+ Q_PROPERTY(QmlEasingValueType::Type type READ type WRITE setType)
+ Q_PROPERTY(qreal amplitude READ amplitude WRITE setAmplitude)
+ Q_PROPERTY(qreal overshoot READ overshoot WRITE setOvershoot)
+ Q_PROPERTY(qreal period READ period WRITE setPeriod)
+public:
+ enum Type {
+ Linear = QEasingCurve::Linear,
+ InQuad = QEasingCurve::InQuad, OutQuad = QEasingCurve::OutQuad,
+ InOutQuad = QEasingCurve::InOutQuad, OutInQuad = QEasingCurve::OutInQuad,
+ InCubic = QEasingCurve::InCubic, OutCubic = QEasingCurve::OutCubic,
+ InOutCubic = QEasingCurve::InOutCubic, OutInCubic = QEasingCurve::OutInCubic,
+ InQuart = QEasingCurve::InQuart, OutQuart = QEasingCurve::OutQuart,
+ InOutQuart = QEasingCurve::InOutQuart, OutInQuart = QEasingCurve::OutInQuart,
+ InQuint = QEasingCurve::InQuint, OutQuint = QEasingCurve::OutQuint,
+ InOutQuint = QEasingCurve::InOutQuint, OutInQuint = QEasingCurve::OutInQuint,
+ InSine = QEasingCurve::InSine, OutSine = QEasingCurve::OutSine,
+ InOutSine = QEasingCurve::InOutSine, OutInSine = QEasingCurve::OutInSine,
+ InExpo = QEasingCurve::InExpo, OutExpo = QEasingCurve::OutExpo,
+ InOutExpo = QEasingCurve::InOutExpo, OutInExpo = QEasingCurve::OutInExpo,
+ InCirc = QEasingCurve::InCirc, OutCirc = QEasingCurve::OutCirc,
+ InOutCirc = QEasingCurve::InOutCirc, OutInCirc = QEasingCurve::OutInCirc,
+ InElastic = QEasingCurve::InElastic, OutElastic = QEasingCurve::OutElastic,
+ InOutElastic = QEasingCurve::InOutElastic, OutInElastic = QEasingCurve::OutInElastic,
+ InBack = QEasingCurve::InBack, OutBack = QEasingCurve::OutBack,
+ InOutBack = QEasingCurve::InOutBack, OutInBack = QEasingCurve::OutInBack,
+ InBounce = QEasingCurve::InBounce, OutBounce = QEasingCurve::OutBounce,
+ InOutBounce = QEasingCurve::InOutBounce, OutInBounce = QEasingCurve::OutInBounce,
+ InCurve = QEasingCurve::InCurve, OutCurve = QEasingCurve::OutCurve,
+ SineCurve = QEasingCurve::SineCurve, CosineCurve = QEasingCurve::CosineCurve,
+ };
+
+ QmlEasingValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int, QmlMetaProperty::WriteFlags);
+ virtual QVariant value();
+ virtual void setValue(QVariant value);
+
+ Type type() const;
+ qreal amplitude() const;
+ qreal overshoot() const;
+ qreal period() const;
+ void setType(Type);
+ void setAmplitude(qreal);
+ void setOvershoot(qreal);
+ void setPeriod(qreal);
+
+private:
+ QEasingCurve easing;
+};
+
class Q_AUTOTEST_EXPORT QmlFontValueType : public QmlValueType
{
Q_OBJECT
diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp
index a2e8c7a..9a48c4f 100644
--- a/src/declarative/qml/qmlworkerscript.cpp
+++ b/src/declarative/qml/qmlworkerscript.cpp
@@ -169,7 +169,7 @@ private:
class QmlWorkerListModelAgent : public QObject
{
Q_OBJECT
- Q_PROPERTY(int count READ count);
+ Q_PROPERTY(int count READ count)
public:
QmlWorkerListModelAgent(QmlWorkerListModel *);
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 6dcce58..2f24167 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -66,79 +66,6 @@
QT_BEGIN_NAMESPACE
-static QEasingCurve stringToCurve(const QString &curve, QObject *obj)
-{
- QEasingCurve easingCurve;
-
- QString normalizedCurve = curve;
- bool hasParams = curve.contains(QLatin1Char('('));
- QStringList props;
-
- if (hasParams) {
- QString easeName = curve.trimmed();
- if (!easeName.endsWith(QLatin1Char(')'))) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Unmatched parenthesis in easing function \"%1\"").arg(curve);
- return easingCurve;
- }
-
- int idx = easeName.indexOf(QLatin1Char('('));
- QString prop_str =
- easeName.mid(idx + 1, easeName.length() - 1 - idx - 1);
- normalizedCurve = easeName.left(idx);
- if (!normalizedCurve.startsWith(QLatin1String("ease"))) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Easing function \"%1\" must start with \"ease\"").arg(curve);
- return easingCurve;
- }
-
- props = prop_str.split(QLatin1Char(','));
- }
-
- if (normalizedCurve.startsWith(QLatin1String("ease")))
- normalizedCurve = normalizedCurve.mid(4);
-
- static int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type");
- static QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index);
-
- int value = me.keyToValue(normalizedCurve.toUtf8().constData());
- if (value < 0) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing curve \"%1\"").arg(curve);
- return easingCurve;
- }
- easingCurve.setType((QEasingCurve::Type)value);
-
- if (hasParams) {
- foreach(const QString &str, props) {
- int sep = str.indexOf(QLatin1Char(':'));
-
- if (sep == -1) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
- continue;
- }
-
- QString propName = str.left(sep).trimmed();
- bool isOk;
- qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk);
-
- if (propName.isEmpty() || !isOk) {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Improperly specified parameter in easing function \"%1\"").arg(curve);
- continue;
- }
-
- if (propName == QLatin1String("amplitude")) {
- easingCurve.setAmplitude(propValue);
- } else if (propName == QLatin1String("period")) {
- easingCurve.setPeriod(propValue);
- } else if (propName == QLatin1String("overshoot")) {
- easingCurve.setOvershoot(propValue);
- } else {
- qmlInfo(obj) << QmlPropertyAnimation::tr("Unknown easing parameter \"%1\"").arg(propName);
- continue;
- }
- }
- }
- return easingCurve;
-}
-
QML_DEFINE_NOCREATE_TYPE(QmlAbstractAnimation)
/*!
@@ -1927,195 +1854,195 @@ void QmlPropertyAnimation::setTo(const QVariant &t)
}
/*!
- \qmlproperty string PropertyAnimation::easing
+ \qmlproperty QEasingCurve PropertyAnimation::easing
\brief the easing curve used for the transition.
Available values are:
\table
\row
- \o \c easeLinear
+ \o \c Linear
\o Easing curve for a linear (t) function: velocity is constant.
\o \inlineimage qeasingcurve-linear.png
\row
- \o \c easeInQuad
+ \o \c InQuad
\o Easing curve for a quadratic (t^2) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-inquad.png
\row
- \o \c easeOutQuad
+ \o \c OutQuad
\o Easing curve for a quadratic (t^2) function: decelerating to zero velocity.
\o \inlineimage qeasingcurve-outquad.png
\row
- \o \c easeInOutQuad
+ \o \c InOutQuad
\o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutquad.png
\row
- \o \c easeOutInQuad
+ \o \c OutInQuad
\o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinquad.png
\row
- \o \c easeInCubic
+ \o \c InCubic
\o Easing curve for a cubic (t^3) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-incubic.png
\row
- \o \c easeOutCubic
+ \o \c OutCubic
\o Easing curve for a cubic (t^3) function: decelerating from zero velocity.
\o \inlineimage qeasingcurve-outcubic.png
\row
- \o \c easeInOutCubic
+ \o \c InOutCubic
\o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutcubic.png
\row
- \o \c easeOutInCubic
+ \o \c OutInCubic
\o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outincubic.png
\row
- \o \c easeInQuart
+ \o \c InQuart
\o Easing curve for a quartic (t^4) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-inquart.png
\row
- \o \c easeOutQuart
+ \o \c OutQuart
\o Easing curve for a cubic (t^4) function: decelerating from zero velocity.
\o \inlineimage qeasingcurve-outquart.png
\row
- \o \c easeInOutQuart
+ \o \c InOutQuart
\o Easing curve for a cubic (t^4) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutquart.png
\row
- \o \c easeOutInQuart
+ \o \c OutInQuart
\o Easing curve for a cubic (t^4) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinquart.png
\row
- \o \c easeInQuint
+ \o \c InQuint
\o Easing curve for a quintic (t^5) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-inquint.png
\row
- \o \c easeOutQuint
+ \o \c OutQuint
\o Easing curve for a cubic (t^5) function: decelerating from zero velocity.
\o \inlineimage qeasingcurve-outquint.png
\row
- \o \c easeInOutQuint
+ \o \c InOutQuint
\o Easing curve for a cubic (t^5) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutquint.png
\row
- \o \c easeOutInQuint
+ \o \c OutInQuint
\o Easing curve for a cubic (t^5) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinquint.png
\row
- \o \c easeInSine
+ \o \c InSine
\o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-insine.png
\row
- \o \c easeOutSine
+ \o \c OutSine
\o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity.
\o \inlineimage qeasingcurve-outsine.png
\row
- \o \c easeInOutSine
+ \o \c InOutSine
\o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutsine.png
\row
- \o \c easeOutInSine
+ \o \c OutInSine
\o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinsine.png
\row
- \o \c easeInExpo
+ \o \c InExpo
\o Easing curve for an exponential (2^t) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-inexpo.png
\row
- \o \c easeOutExpo
+ \o \c OutExpo
\o Easing curve for an exponential (2^t) function: decelerating from zero velocity.
\o \inlineimage qeasingcurve-outexpo.png
\row
- \o \c easeInOutExpo
+ \o \c InOutExpo
\o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutexpo.png
\row
- \o \c easeOutInExpo
+ \o \c OutInExpo
\o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinexpo.png
\row
- \o \c easeInCirc
+ \o \c InCirc
\o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-incirc.png
\row
- \o \c easeOutCirc
+ \o \c OutCirc
\o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity.
\o \inlineimage qeasingcurve-outcirc.png
\row
- \o \c easeInOutCirc
+ \o \c InOutCirc
\o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutcirc.png
\row
- \o \c easeOutInCirc
+ \o \c OutInCirc
\o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outincirc.png
\row
- \o \c easeInElastic
+ \o \c InElastic
\o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity.
\br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
\o \inlineimage qeasingcurve-inelastic.png
\row
- \o \c easeOutElastic
+ \o \c OutElastic
\o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity.
\br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter.
\o \inlineimage qeasingcurve-outelastic.png
\row
- \o \c easeInOutElastic
+ \o \c InOutElastic
\o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutelastic.png
\row
- \o \c easeOutInElastic
+ \o \c OutInElastic
\o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinelastic.png
\row
- \o \c easeInBack
+ \o \c InBack
\o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity.
\o \inlineimage qeasingcurve-inback.png
\row
- \o \c easeOutBack
+ \o \c OutBack
\o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity.
\o \inlineimage qeasingcurve-outback.png
\row
- \o \c easeInOutBack
+ \o \c InOutBack
\o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutback.png
\row
- \o \c easeOutInBack
+ \o \c OutInBack
\o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinback.png
\row
- \o \c easeInBounce
+ \o \c InBounce
\o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity.
\o \inlineimage qeasingcurve-inbounce.png
\row
- \o \c easeOutBounce
+ \o \c OutBounce
\o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity.
\o \inlineimage qeasingcurve-outbounce.png
\row
- \o \c easeInOutBounce
+ \o \c InOutBounce
\o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration.
\o \inlineimage qeasingcurve-inoutbounce.png
\row
- \o \c easeOutInBounce
+ \o \c OutInBounce
\o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
\o \inlineimage qeasingcurve-outinbounce.png
\endtable
*/
-QString QmlPropertyAnimation::easing() const
+QEasingCurve QmlPropertyAnimation::easing() const
{
Q_D(const QmlPropertyAnimation);
return d->easing;
}
-void QmlPropertyAnimation::setEasing(const QString &e)
+void QmlPropertyAnimation::setEasing(const QEasingCurve &e)
{
Q_D(QmlPropertyAnimation);
if (d->easing == e)
return;
d->easing = e;
- d->va->setEasingCurve(stringToCurve(d->easing, this));
+ d->va->setEasingCurve(d->easing);
emit easingChanged(e);
}
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 623ad8d..fd868bc 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -51,6 +51,7 @@
#include <qmlscriptstring.h>
#include <QtCore/qvariant.h>
+#include <QtCore/qeasingcurve.h>
#include <QtCore/QAbstractAnimation>
#include <QtGui/qcolor.h>
@@ -261,7 +262,7 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation
Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged)
Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged)
- Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged)
+ Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged)
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged)
@@ -281,8 +282,8 @@ public:
QVariant to() const;
void setTo(const QVariant &);
- QString easing() const;
- void setEasing(const QString &);
+ QEasingCurve easing() const;
+ void setEasing(const QEasingCurve &);
QObject *target() const;
void setTarget(QObject *);
@@ -307,7 +308,7 @@ Q_SIGNALS:
void durationChanged(int);
void fromChanged(QVariant);
void toChanged(QVariant);
- void easingChanged(const QString &);
+ void easingChanged(const QEasingCurve &);
void propertiesChanged(const QString &);
void targetChanged(QObject *, const QString &);
};
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index 056ce82..8c88f14 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -327,7 +327,7 @@ public:
QVariant from;
QVariant to;
- QString easing;
+ QEasingCurve easing;
QObject *target;
QString propertyName;
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp
index 05c6460..9e95b66 100644
--- a/src/declarative/util/qmlview.cpp
+++ b/src/declarative/util/qmlview.cpp
@@ -425,52 +425,58 @@ void QmlView::continueExecute()
return;
}
- if (obj) {
- if (QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(obj)) {
-
- d->scene.addItem(item);
-
- QPerformanceLog::displayData();
- QPerformanceLog::clear();
- d->root = item;
- d->qmlRoot = item;
- connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
- connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
- if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
- d->initialSize.setWidth(d->qmlRoot->width());
- if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
- d->initialSize.setHeight(d->qmlRoot->height());
- resize(d->initialSize);
-
- if (d->resizeMode == SizeRootObjectToView) {
- d->qmlRoot->setWidth(width());
- d->qmlRoot->setHeight(height());
- } else {
- QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
- emit sceneResized(sz);
- resize(sz);
- }
- updateGeometry();
- } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) {
- d->scene.addItem(item);
- qWarning() << "QmlView::resizeMode is not honored for components of type QGraphicsObject";
- } else if (QWidget *wid = qobject_cast<QWidget *>(obj)) {
- window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
- window()->setAttribute(Qt::WA_NoSystemBackground, false);
- if (!layout()) {
- setLayout(new QVBoxLayout);
- layout()->setContentsMargins(0, 0, 0, 0);
- } else if (layout()->count()) {
- // Hide the QGraphicsView in GV mode.
- QLayoutItem *item = layout()->itemAt(0);
- if (item->widget())
- item->widget()->hide();
- }
- layout()->addWidget(wid);
- emit sceneResized(wid->size());
+ setRootObject(obj);
+ emit statusChanged(status());
+}
+
+
+/*!
+ \internal
+*/
+void QmlView::setRootObject(QObject *obj)
+{
+ if (QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem *>(obj)) {
+ d->scene.addItem(item);
+
+ QPerformanceLog::displayData();
+ QPerformanceLog::clear();
+ d->root = item;
+ d->qmlRoot = item;
+ connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
+ connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
+ if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0)
+ d->initialSize.setWidth(d->qmlRoot->width());
+ if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0)
+ d->initialSize.setHeight(d->qmlRoot->height());
+ resize(d->initialSize);
+
+ if (d->resizeMode == SizeRootObjectToView) {
+ d->qmlRoot->setWidth(width());
+ d->qmlRoot->setHeight(height());
+ } else {
+ QSize sz(d->qmlRoot->width(),d->qmlRoot->height());
+ emit sceneResized(sz);
+ resize(sz);
}
+ updateGeometry();
+ } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) {
+ d->scene.addItem(item);
+ qWarning() << "QmlView::resizeMode is not honored for components of type QGraphicsObject";
+ } else if (QWidget *wid = qobject_cast<QWidget *>(obj)) {
+ window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
+ window()->setAttribute(Qt::WA_NoSystemBackground, false);
+ if (!layout()) {
+ setLayout(new QVBoxLayout);
+ layout()->setContentsMargins(0, 0, 0, 0);
+ } else if (layout()->count()) {
+ // Hide the QGraphicsView in GV mode.
+ QLayoutItem *item = layout()->itemAt(0);
+ if (item->widget())
+ item->widget()->hide();
+ }
+ layout()->addWidget(wid);
+ emit sceneResized(wid->size());
}
- emit statusChanged(status());
}
/*!
diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h
index 5f72781..26be18f 100644
--- a/src/declarative/util/qmlview.h
+++ b/src/declarative/util/qmlview.h
@@ -100,7 +100,8 @@ private Q_SLOTS:
protected:
virtual void resizeEvent(QResizeEvent *);
virtual void paintEvent(QPaintEvent *event);
- void timerEvent(QTimerEvent*);
+ virtual void timerEvent(QTimerEvent*);
+ virtual void setRootObject(QObject *obj);
friend class QmlViewPrivate;
QmlViewPrivate *d;
diff --git a/src/multimedia/qml/qml.cpp b/src/multimedia/qml/qml.cpp
index b9ee212..43a32c5 100644
--- a/src/multimedia/qml/qml.cpp
+++ b/src/multimedia/qml/qml.cpp
@@ -55,11 +55,13 @@ namespace QtMultimedia
\internal
*/
-void qRegisterQmlElements()
+void qRegisterQmlElements(QmlEngine *engine, const char *uri)
{
- qmlRegisterType<QSoundEffect>("Qt.multimedia", 4, 7, "SoundEffect", "SoundEffect");
- qmlRegisterType<QmlAudio>("Qt.multimedia", 4, 7, "Audio", "Audio");
- qmlRegisterType<QmlGraphicsVideo>("Qt.multimedia", 4, 7, "Video", "Video");
+ Q_UNUSED(engine);
+
+ qmlRegisterType<QSoundEffect>(uri, 4, 7, "SoundEffect", "SoundEffect");
+ qmlRegisterType<QmlAudio>(uri, 4, 7, "Audio", "Audio");
+ qmlRegisterType<QmlGraphicsVideo>(uri, 4, 7, "Video", "Video");
}
}
diff --git a/src/multimedia/qml/qml.h b/src/multimedia/qml/qml.h
index 41274c8..c4159b3 100644
--- a/src/multimedia/qml/qml.h
+++ b/src/multimedia/qml/qml.h
@@ -47,11 +47,13 @@
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+class QmlEngine;
+
QT_MODULE(Multimedia)
namespace QtMultimedia
{
-extern void Q_MULTIMEDIA_EXPORT qRegisterQmlElements();
+extern void Q_MULTIMEDIA_EXPORT qRegisterQmlElements(QmlEngine *engine, const char *uri);
}
QT_END_NAMESPACE
diff --git a/src/plugins/qmlmodules/multimedia/multimedia.cpp b/src/plugins/qmlmodules/multimedia/multimedia.cpp
index d9414ee..0ebdfd9 100644
--- a/src/plugins/qmlmodules/multimedia/multimedia.cpp
+++ b/src/plugins/qmlmodules/multimedia/multimedia.cpp
@@ -39,27 +39,19 @@
**
****************************************************************************/
-#include <QtDeclarative/qmlmoduleplugin.h>
+#include <QtDeclarative/qmlextensionplugin.h>
#include <QtDeclarative/qml.h>
#include <QtMultimedia/qml.h>
QT_BEGIN_NAMESPACE
-class QMultimediaQmlModule : public QmlModulePlugin
+class QMultimediaQmlModule : public QmlExtensionPlugin
{
Q_OBJECT
public:
- QStringList keys() const
+ virtual void initialize(QmlEngine *engine, const char *uri)
{
- return QStringList() << QLatin1String("Qt.multimedia");
- }
-
- void defineModule(const QString& uri)
- {
- Q_UNUSED(uri)
- Q_ASSERT(uri == QLatin1String("Qt.multimedia"));
-
- QtMultimedia::qRegisterQmlElements();
+ QtMultimedia::qRegisterQmlElements(engine, uri);
}
};