From 9681d2190541c63a39b2cfe70dc3aaa161ebe703 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 14:34:57 +1000 Subject: More cleanup --- src/declarative/extra/qbindablemap.h | 3 +-- src/declarative/extra/qfxanimatedimageitem.h | 5 ++--- src/declarative/extra/qfxblendedimage.h | 2 +- src/declarative/extra/qfxflowview.cpp | 4 ++-- src/declarative/extra/qfxflowview.h | 1 + src/declarative/extra/qfxintegermodel.cpp | 2 +- src/declarative/extra/qfxintegermodel.h | 4 ++-- src/declarative/extra/qmlbehaviour.cpp | 4 ++-- src/declarative/extra/qmlbehaviour.h | 1 + src/declarative/extra/qmldatetimeformatter.cpp | 2 ++ src/declarative/extra/qmldatetimeformatter.h | 2 +- src/declarative/extra/qmlnumberformatter.cpp | 4 ++-- src/declarative/extra/qmlnumberformatter.h | 4 ++-- src/declarative/extra/qmlsqlconnection.h | 2 ++ src/declarative/extra/qmlsqlquery.cpp | 2 ++ src/declarative/extra/qmlsqlquery.h | 1 + src/declarative/extra/qmltimer.h | 3 +++ src/declarative/extra/qmlxmllistmodel.cpp | 5 ++--- src/declarative/extra/qnumberformat.cpp | 3 ++- src/declarative/extra/qnumberformat.h | 2 +- 20 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/declarative/extra/qbindablemap.h b/src/declarative/extra/qbindablemap.h index c76928d..aa1908e 100644 --- a/src/declarative/extra/qbindablemap.h +++ b/src/declarative/extra/qbindablemap.h @@ -48,7 +48,6 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -80,8 +79,8 @@ private: friend class QBindableMapMetaObject; }; - QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h index 5d115d7..e59a8c7 100644 --- a/src/declarative/extra/qfxanimatedimageitem.h +++ b/src/declarative/extra/qfxanimatedimageitem.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QMovie; class QFxAnimatedImageItemPrivate; @@ -90,11 +90,10 @@ private: Q_DISABLE_COPY(QFxAnimatedImageItem) Q_DECLARE_PRIVATE(QFxAnimatedImageItem) }; - QML_DECLARE_TYPE(QFxAnimatedImageItem) - QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/extra/qfxblendedimage.h b/src/declarative/extra/qfxblendedimage.h index 248cc9d..f16d543 100644 --- a/src/declarative/extra/qfxblendedimage.h +++ b/src/declarative/extra/qfxblendedimage.h @@ -103,8 +103,8 @@ private: }; QML_DECLARE_TYPE(QFxBlendedImage) - QT_END_NAMESPACE QT_END_HEADER + #endif // QFXBLENDEDIMAGE_H diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp index 77cd6df..e3b79f5 100644 --- a/src/declarative/extra/qfxflowview.cpp +++ b/src/declarative/extra/qfxflowview.cpp @@ -376,6 +376,6 @@ void QFxFlowView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QML_DEFINE_TYPE(QFxFlowView,FlowView); -#include "qfxflowview.moc" - QT_END_NAMESPACE + +#include "qfxflowview.moc" diff --git a/src/declarative/extra/qfxflowview.h b/src/declarative/extra/qfxflowview.h index 0e7c2d3..0693d6e 100644 --- a/src/declarative/extra/qfxflowview.h +++ b/src/declarative/extra/qfxflowview.h @@ -50,6 +50,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxVisualItemModel; class QFxFlowViewValue; class QFxFlowViewAttached; diff --git a/src/declarative/extra/qfxintegermodel.cpp b/src/declarative/extra/qfxintegermodel.cpp index 53814cd..437073e 100644 --- a/src/declarative/extra/qfxintegermodel.cpp +++ b/src/declarative/extra/qfxintegermodel.cpp @@ -41,8 +41,8 @@ #include "qfxintegermodel.h" - QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QFxIntegerModel, IntegerModel) class QFxIntegerModelPrivate diff --git a/src/declarative/extra/qfxintegermodel.h b/src/declarative/extra/qfxintegermodel.h index 43504d8..7c522f8 100644 --- a/src/declarative/extra/qfxintegermodel.h +++ b/src/declarative/extra/qfxintegermodel.h @@ -46,12 +46,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxIntegerModelPrivate; class Q_DECLARATIVE_EXPORT QFxIntegerModel : public QListModelInterface { @@ -79,8 +79,8 @@ private: QML_DECLARE_TYPE(QFxIntegerModel) - QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/extra/qmlbehaviour.cpp b/src/declarative/extra/qmlbehaviour.cpp index 4beca5e..4165d56 100644 --- a/src/declarative/extra/qmlbehaviour.cpp +++ b/src/declarative/extra/qmlbehaviour.cpp @@ -254,6 +254,6 @@ void QmlBehaviour::classComplete() d->context->deactivate(); } -#include "qmlbehaviour.moc" - QT_END_NAMESPACE + +#include "qmlbehaviour.moc" diff --git a/src/declarative/extra/qmlbehaviour.h b/src/declarative/extra/qmlbehaviour.h index 7cc83b2..967d3aa 100644 --- a/src/declarative/extra/qmlbehaviour.h +++ b/src/declarative/extra/qmlbehaviour.h @@ -51,6 +51,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlAbstractAnimation; class QmlBehaviourPrivate; class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource, diff --git a/src/declarative/extra/qmldatetimeformatter.cpp b/src/declarative/extra/qmldatetimeformatter.cpp index ad0e473..158431a 100644 --- a/src/declarative/extra/qmldatetimeformatter.cpp +++ b/src/declarative/extra/qmldatetimeformatter.cpp @@ -44,6 +44,7 @@ #include QT_BEGIN_NAMESPACE + //TODO: may need optimisation as the QDateTime member may not be needed? // be able to set a locale? @@ -365,4 +366,5 @@ void QmlDateTimeFormatter::classComplete() } QML_DEFINE_TYPE(QmlDateTimeFormatter, DateTimeFormatter) + QT_END_NAMESPACE diff --git a/src/declarative/extra/qmldatetimeformatter.h b/src/declarative/extra/qmldatetimeformatter.h index 84b27e3..c4f1362 100644 --- a/src/declarative/extra/qmldatetimeformatter.h +++ b/src/declarative/extra/qmldatetimeformatter.h @@ -50,6 +50,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlDateTimeFormatterPrivate; class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus { @@ -105,7 +106,6 @@ private: Q_DISABLE_COPY(QmlDateTimeFormatter) Q_DECLARE_PRIVATE(QmlDateTimeFormatter) }; - QML_DECLARE_TYPE(QmlDateTimeFormatter) QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlnumberformatter.cpp b/src/declarative/extra/qmlnumberformatter.cpp index 1549525..b24f2d8 100644 --- a/src/declarative/extra/qmlnumberformatter.cpp +++ b/src/declarative/extra/qmlnumberformatter.cpp @@ -42,8 +42,8 @@ #include "qmlnumberformatter.h" #include "private/qobject_p.h" - QT_BEGIN_NAMESPACE + //TODO: set locale // docs // this is a wrapper around qnumberformat (test integration) @@ -210,6 +210,6 @@ void QmlNumberFormatter::classComplete() d->classComplete = true; d->updateText(); } - QML_DEFINE_TYPE(QmlNumberFormatter, NumberFormatter); + QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlnumberformatter.h b/src/declarative/extra/qmlnumberformatter.h index e4efc03..24af8c0 100644 --- a/src/declarative/extra/qmlnumberformatter.h +++ b/src/declarative/extra/qmlnumberformatter.h @@ -45,12 +45,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlNumberFormatterPrivate; class Q_DECLARATIVE_EXPORT QmlNumberFormatter : public QObject, public QmlParserStatus { @@ -85,8 +85,8 @@ private: QML_DECLARE_TYPE(QmlNumberFormatter) - QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/extra/qmlsqlconnection.h b/src/declarative/extra/qmlsqlconnection.h index ede8bcb..0fcb183 100644 --- a/src/declarative/extra/qmlsqlconnection.h +++ b/src/declarative/extra/qmlsqlconnection.h @@ -50,6 +50,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QSqlDatabase; class QmlSqlConnectionPrivate; class Q_DECLARATIVE_EXPORT QmlSqlConnection : public QObject, public QmlParserStatus @@ -112,5 +113,6 @@ QML_DECLARE_TYPE(QmlSqlConnection) QT_END_NAMESPACE QT_END_HEADER + #endif // QMLXMLLISTMODEL_H diff --git a/src/declarative/extra/qmlsqlquery.cpp b/src/declarative/extra/qmlsqlquery.cpp index 2b11774..d9d9760 100644 --- a/src/declarative/extra/qmlsqlquery.cpp +++ b/src/declarative/extra/qmlsqlquery.cpp @@ -55,6 +55,7 @@ #include QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QmlSqlBind, SqlBind) QML_DEFINE_TYPE(QmlSqlQuery, SqlQuery) @@ -790,4 +791,5 @@ void QmlSqlQueryPrivate::grabRoles() const roles.append(i); } } + QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlsqlquery.h b/src/declarative/extra/qmlsqlquery.h index 06ade08..72e6560f 100644 --- a/src/declarative/extra/qmlsqlquery.h +++ b/src/declarative/extra/qmlsqlquery.h @@ -140,5 +140,6 @@ QML_DECLARE_TYPE(QmlSqlQuery) QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/extra/qmltimer.h b/src/declarative/extra/qmltimer.h index 8171385..2a73e65 100644 --- a/src/declarative/extra/qmltimer.h +++ b/src/declarative/extra/qmltimer.h @@ -48,6 +48,7 @@ #include QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -95,5 +96,7 @@ private Q_SLOTS: QML_DECLARE_TYPE(QmlTimer) QT_END_NAMESPACE + QT_END_HEADER + #endif diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 082c9c2..48949b3 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -61,7 +61,6 @@ QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(XmlListModelRole, XmlRole) QML_DEFINE_TYPE(QmlXmlListModel, XmlListModel) - class QmlXmlListModelPrivate; struct QmlXmlRoleList : public QmlConcreteList { @@ -643,6 +642,6 @@ void QmlXmlListModel::queryCompleted(int id, int size) } } -#include "qmlxmllistmodel.moc" - QT_END_NAMESPACE + +#include "qmlxmllistmodel.moc" diff --git a/src/declarative/extra/qnumberformat.cpp b/src/declarative/extra/qnumberformat.cpp index 424c125..d317c27 100644 --- a/src/declarative/extra/qnumberformat.cpp +++ b/src/declarative/extra/qnumberformat.cpp @@ -41,8 +41,8 @@ #include "qnumberformat.h" - QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QNumberFormat,NumberFormat) QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal), @@ -221,4 +221,5 @@ QString QNumberFormat::formatDecimal(const QString &formatDec, const QString &de } return outputDecimal; } + QT_END_NAMESPACE diff --git a/src/declarative/extra/qnumberformat.h b/src/declarative/extra/qnumberformat.h index fba9872..92f89da 100644 --- a/src/declarative/extra/qnumberformat.h +++ b/src/declarative/extra/qnumberformat.h @@ -165,8 +165,8 @@ private: }; QML_DECLARE_TYPE(QNumberFormat) - QT_END_NAMESPACE QT_END_HEADER + #endif -- cgit v0.12 From 7cba48bea33dcb80979975b27047d81025d054a5 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 30 Jun 2009 10:38:45 +0200 Subject: First set of changes to add dynamic properties to the QML DOM. --- src/declarative/qml/qmldom.cpp | 248 +++++++++++++++++++++++++++++--- src/declarative/qml/qmldom.h | 31 ++++ src/declarative/qml/qmldom_p.h | 11 ++ src/declarative/qml/qmlparser.cpp | 3 +- src/declarative/qml/qmlparser_p.h | 1 + src/declarative/qml/qmlscriptparser.cpp | 2 + 6 files changed, 273 insertions(+), 23 deletions(-) diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 5271dc5..d517b39 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -278,6 +278,23 @@ QmlDomPropertyPrivate::~QmlDomPropertyPrivate() if (property) property->release(); } +QmlDomDynamicPropertyPrivate::QmlDomDynamicPropertyPrivate(): + valid(false) +{ +} + +QmlDomDynamicPropertyPrivate::QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &other) +: QSharedData(other), valid(other.valid) +{ + property = other.property; + if (valid && property.defaultValue) property.defaultValue->addref(); +} + +QmlDomDynamicPropertyPrivate::~QmlDomDynamicPropertyPrivate() +{ + if (valid && property.defaultValue) property.defaultValue->release(); +} + /*! \class QmlDomProperty \internal @@ -322,8 +339,8 @@ QmlDomProperty &QmlDomProperty::operator=(const QmlDomProperty &other) } /*! - Return the name of this property. - + Return the name of this property. + \qml Text { x: 10 @@ -331,7 +348,7 @@ Text { font.bold: true } \endqml - + As illustrated above, a property name can be a simple string, such as "x" or "y", or a more complex "dot property", such as "font.bold". In both cases the full name is returned ("x", "y" and "font.bold") by this method. @@ -358,7 +375,7 @@ Text { } \endqml - For each of the properties shown above, this method would return ("x"), + For each of the properties shown above, this method would return ("x"), ("y") and ("font", "bold"). \sa QmlDomProperty::propertyName() @@ -370,7 +387,7 @@ QList QmlDomProperty::propertyNameParts() const } /*! - Return true if this property is used as a default property in the QML + Return true if this property is used as a default property in the QML document. \qml @@ -380,8 +397,8 @@ QList QmlDomProperty::propertyNameParts() const The above two examples return the same DOM tree, except that the second has the default property flag set on the text property. Observe that whether - or not a property has isDefaultProperty set is determined by how the - property is used, and not only by whether the property is the types default + or not a property has isDefaultProperty set is determined by how the + property is used, and not only by whether the property is the types default property. */ bool QmlDomProperty::isDefaultProperty() const @@ -415,7 +432,7 @@ void QmlDomProperty::setValue(const QmlDomValue &value) } /*! - Returns the position in the input data where the property ID startd, or 0 if + Returns the position in the input data where the property ID startd, or -1 if the property is invalid. */ int QmlDomProperty::position() const @@ -423,19 +440,174 @@ int QmlDomProperty::position() const if (d && d->property) { return d->property->location.range.offset; } else - return 0; + return -1; } /*! Returns the length in the input data from where the property ID started upto - the end of it, or 0 if the property is invalid. + the end of it, or -1 if the property is invalid. */ int QmlDomProperty::length() const { if (d && d->property) return d->property->location.range.length; else - return 0; + return -1; +} + +/*! + Construct an invalid QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty::QmlDomDynamicProperty(): + d(new QmlDomDynamicPropertyPrivate) +{ +} + +/*! + Create a copy of \a other QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty::QmlDomDynamicProperty(const QmlDomDynamicProperty &other): + d(other.d) +{ +} + +/*! + Destroy the QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty::~QmlDomDynamicProperty() +{ +} + +/*! + Assign \a other to this QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty &QmlDomDynamicProperty::operator=(const QmlDomDynamicProperty &other) +{ + d = other.d; + return *this; +} + +bool QmlDomDynamicProperty::isValid() const +{ + return d && d->valid; +} + +/*! + Return the name of this dynamic property. + + \qml +Item { + property int count: 10; +} + \endqml + + As illustrated above, a dynamic property name can have a name and a + default value ("10"). +*/ +QByteArray QmlDomDynamicProperty::propertyName() const +{ + if (isValid()) + return d->property.name; + else + return QByteArray(); +} + +QVariant::Type QmlDomDynamicProperty::propertyType() const +{ + if (isValid()) { + switch (d->property.type) { + case QmlParser::Object::DynamicProperty::Bool: + return QVariant::Bool; + + case QmlParser::Object::DynamicProperty::Color: + return QVariant::Color; + + case QmlParser::Object::DynamicProperty::Date: + return QVariant::Date; + + case QmlParser::Object::DynamicProperty::Int: + return QVariant::Int; + + case QmlParser::Object::DynamicProperty::Real: + return QVariant::Double; + + case QmlParser::Object::DynamicProperty::String: + return QVariant::String; + + case QmlParser::Object::DynamicProperty::Url: + return QVariant::Url; + + case QmlParser::Object::DynamicProperty::Variant: + return QVariant:: + + default: + return QVariant::Invalid; + } + } else { + return QVariant::Invalid; + } +} + +/*! + Return true if this property is used as a default property in the QML + document. + + \qml + +hello + \endqml + + The above two examples return the same DOM tree, except that the second has + the default property flag set on the text property. Observe that whether + or not a property has isDefaultProperty set is determined by how the + property is used, and not only by whether the property is the types default + property. +*/ +bool QmlDomDynamicProperty::isDefaultProperty() const +{ + if (isValid()) + return d->property.isDefaultProperty; + else + return false; +} + +/*! + Returns the default value as a QmlDomProperty. +*/ +QmlDomProperty QmlDomDynamicProperty::defaultValue() const +{ + QmlDomProperty rp; + + if (isValid()) { + rp.d->property = d->property.defaultValue; + rp.d->property->addref(); + } + + return rp; +} + +/*! + Returns the position in the input data where the property ID startd, or 0 if + the property is invalid. +*/ +int QmlDomDynamicProperty::position() const +{ + if (isValid()) { + return d->property.range.offset; + } else + return -1; +} + +/*! + Returns the length in the input data from where the property ID started upto + the end of it, or 0 if the property is invalid. +*/ +int QmlDomDynamicProperty::length() const +{ + if (isValid()) + return d->property.range.length; + else + return -1; } QmlDomObjectPrivate::QmlDomObjectPrivate() @@ -701,6 +873,38 @@ void QmlDomObject::addProperty(const QByteArray &name, const QmlDomValue &value) qWarning("QmlDomObject::addProperty(const QByteArray &, const QmlDomValue &): Not implemented"); } +QList QmlDomObject::dynamicProperties() const +{ + QList properties; + + for (int i = 0; i < d->object->dynamicProperties.size(); ++i) { + QmlDomDynamicProperty p; + p.d = new QmlDomDynamicPropertyPrivate; + p.d->property = d->object->dynamicProperties.at(i); + if (p.d->property.defaultValue) p.d->property.defaultValue->addref(); + p.d->valid = true; + properties.append(p); + } + + return properties; +} + +QmlDomDynamicProperty QmlDomObject::dynamicProperty(const QByteArray &name) const +{ + QmlDomDynamicProperty p; + + for (int i = 0; i < d->object->dynamicProperties.size(); ++i) { + if (d->object->dynamicProperties.at(i).name == name) { + p.d = new QmlDomDynamicPropertyPrivate; + p.d->property = d->object->dynamicProperties.at(i); + if (p.d->property.defaultValue) p.d->property.defaultValue->addref(); + p.d->valid = true; + } + } + + return p; +} + /*! Returns true if this object is a custom type. Custom types are special types that allow embeddeding non-QML data, such as SVG or HTML data, @@ -769,26 +973,26 @@ QmlDomComponent QmlDomObject::toComponent() const /*! Returns the position in the input data where the property assignment started -, or 0 if the property is invalid. +, or -1 if the property is invalid. */ int QmlDomObject::position() const { if (d && d->object) return d->object->location.range.offset; else - return 0; + return -1; } /*! Returns the length in the input data from where the property assignment star -ted upto the end of it, or 0 if the property is invalid. +ted upto the end of it, or -1 if the property is invalid. */ int QmlDomObject::length() const { if (d && d->object) return d->object->location.range.length; else - return 0; + return -1; } // Returns the URL of the type, if it is an external type, or an empty URL if @@ -1323,25 +1527,25 @@ QmlDomList QmlDomValue::toList() const } /*! - Returns the position in the input data where the property value startd, or 0 + Returns the position in the input data where the property value startd, or -1 if the value is invalid. */ int QmlDomValue::position() const { if (type() == Invalid) - return 0; + return -1; else return d->value->location.range.offset; } /*! Returns the length in the input data from where the property value started u -pto the end of it, or 0 if the value is invalid. +pto the end of it, or -1 if the value is invalid. */ int QmlDomValue::length() const { if (type() == Invalid) - return 0; + return -1; else return d->value->location.range.length; } @@ -1436,7 +1640,7 @@ void QmlDomList::setValues(const QList &values) } /*! - Returns the position in the input data where the list started, or 0 if + Returns the position in the input data where the list started, or -1 if the property is invalid. */ int QmlDomList::position() const @@ -1444,7 +1648,7 @@ int QmlDomList::position() const if (d && d->property) { return d->property->listValueRange.offset; } else - return 0; + return -1; } /*! @@ -1456,7 +1660,7 @@ int QmlDomList::length() const if (d && d->property) return d->property->listValueRange.length; else - return 0; + return -1; } /*! diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index ab3e39f..1dddb5f 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -44,6 +44,7 @@ #include #include +#include #include QT_BEGIN_HEADER @@ -107,9 +108,36 @@ public: private: friend class QmlDomObject; + friend class QmlDomDynamicProperty; QSharedDataPointer d; }; +class QmlDomDynamicPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty +{ +public: + QmlDomDynamicProperty(); + QmlDomDynamicProperty(const QmlDomDynamicProperty &); + ~QmlDomDynamicProperty(); + QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &); + + bool isValid() const; + + QByteArray propertyName() const; + QVariant::Type propertyType() const; + + bool isDefaultProperty() const; + + QmlDomProperty defaultValue() const; + + int position() const; + int length() const; + +private: + friend class QmlDomObject; + QSharedDataPointer d; +}; + class QmlDomObjectPrivate; class Q_DECLARATIVE_EXPORT QmlDomObject { @@ -133,6 +161,9 @@ public: void removeProperty(const QByteArray &); void addProperty(const QByteArray &, const QmlDomValue &); + QList dynamicProperties() const; + QmlDomDynamicProperty dynamicProperty(const QByteArray &) const; + bool isCustomType() const; QByteArray customTypeData() const; void setCustomTypeData(const QByteArray &); diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index 441269c..6a7032e 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -91,6 +91,17 @@ public: QmlParser::Property *property; }; +class QmlDomDynamicPropertyPrivate : public QSharedData +{ +public: + QmlDomDynamicPropertyPrivate(); + QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &); + ~QmlDomDynamicPropertyPrivate(); + + bool valid; + QmlParser::Object::DynamicProperty property; +}; + class QmlDomValuePrivate : public QSharedData { public: diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index 5ad4a6e..6f0b0b7 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -113,7 +113,8 @@ QmlParser::Object::DynamicProperty::DynamicProperty(const DynamicProperty &o) : isDefaultProperty(o.isDefaultProperty), type(o.type), name(o.name), - defaultValue(o.defaultValue) + defaultValue(o.defaultValue), + range(o.range) { } diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 78040da..29a9390 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -139,6 +139,7 @@ namespace QmlParser Type type; QByteArray name; QmlParser::Property *defaultValue; + LocationRange range; }; struct DynamicSignal { DynamicSignal(); diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index fb7492d..f1d4fd2 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -532,6 +532,8 @@ bool ProcessAST::visit(AST::UiPublicMember *node) property.isDefaultProperty = node->isDefaultMember; property.type = type; property.name = name.toUtf8(); + property.range.offset = node->firstSourceLocation().offset; + property.range.length = node->semicolonToken.end() - property.range.offset; if (node->expression) { // default value property.defaultValue = new Property; -- cgit v0.12 From 028a6a00c5653c6dc0641b215287e33b8312d7a7 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 30 Jun 2009 13:17:19 +0200 Subject: Fixes for the dynamic properties in the QML DOM. --- src/declarative/qml/qmldom.cpp | 31 +++++++++++++++++-------------- src/declarative/qml/qmldom.h | 3 +-- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 053ea14..9015e5c 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -512,40 +512,40 @@ QByteArray QmlDomDynamicProperty::propertyName() const return QByteArray(); } -QVariant::Type QmlDomDynamicProperty::propertyType() const +int QmlDomDynamicProperty::propertyType() const { if (isValid()) { switch (d->property.type) { case QmlParser::Object::DynamicProperty::Bool: - return QVariant::Bool; + return QMetaType::type("bool"); case QmlParser::Object::DynamicProperty::Color: - return QVariant::Color; + return QMetaType::type("QColor"); case QmlParser::Object::DynamicProperty::Date: - return QVariant::Date; + return QMetaType::type("QDateTime"); case QmlParser::Object::DynamicProperty::Int: - return QVariant::Int; + return QMetaType::type("int"); case QmlParser::Object::DynamicProperty::Real: - return QVariant::Double; + return QMetaType::type("double"); case QmlParser::Object::DynamicProperty::String: - return QVariant::String; + return QMetaType::type("QString"); case QmlParser::Object::DynamicProperty::Url: - return QVariant::Url; + return QMetaType::type("QUrl"); case QmlParser::Object::DynamicProperty::Variant: - return QVariant:: + return QMetaType::type("QVariant"); default: - return QVariant::Invalid; + break; } - } else { - return QVariant::Invalid; } + + return -1; } /*! @@ -578,7 +578,7 @@ QmlDomProperty QmlDomDynamicProperty::defaultValue() const { QmlDomProperty rp; - if (isValid()) { + if (isValid() && d->property.defaultValue) { rp.d->property = d->property.defaultValue; rp.d->property->addref(); } @@ -881,8 +881,11 @@ QList QmlDomObject::dynamicProperties() const QmlDomDynamicProperty p; p.d = new QmlDomDynamicPropertyPrivate; p.d->property = d->object->dynamicProperties.at(i); - if (p.d->property.defaultValue) p.d->property.defaultValue->addref(); p.d->valid = true; + + if (p.d->property.defaultValue) + p.d->property.defaultValue->addref(); + properties.append(p); } diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index 1dddb5f..170ef56 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -44,7 +44,6 @@ #include #include -#include #include QT_BEGIN_HEADER @@ -124,7 +123,7 @@ public: bool isValid() const; QByteArray propertyName() const; - QVariant::Type propertyType() const; + int propertyType() const; bool isDefaultProperty() const; -- cgit v0.12 From 61fcaa0e659e1bc676e0ce4124d49aaae565b26c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 09:38:45 +1000 Subject: Support compile-in-namespace for the declarative module. --- src/corelib/kernel/qmetaobjectbuilder.cpp | 41 ++++++++++++++++++++-- src/corelib/kernel/qmetaobjectbuilder_p.h | 52 ++++++++++++++++++++++++++-- src/declarative/canvas/qsimplecanvas_p.h | 7 ++-- src/declarative/canvas/qsimplecanvasitem.h | 7 ++-- src/declarative/declarative.pro | 1 - src/declarative/extra/qfxanimatedimageitem.h | 3 +- src/declarative/extra/qfxblendedimage.h | 3 +- src/declarative/extra/qfxflowview.cpp | 4 +-- src/declarative/extra/qfxflowview.h | 3 +- src/declarative/extra/qfxintegermodel.h | 4 +-- src/declarative/extra/qmlbehaviour.h | 3 +- src/declarative/extra/qmldatetimeformatter.h | 3 +- src/declarative/extra/qmlnumberformatter.h | 4 +-- src/declarative/extra/qmlsqlconnection.h | 4 +-- src/declarative/extra/qmlsqlquery.h | 7 ++-- src/declarative/extra/qmltimer.h | 3 +- src/declarative/extra/qmlxmllistmodel.h | 6 ++-- src/declarative/extra/qnumberformat.cpp | 2 +- src/declarative/extra/qnumberformat.h | 3 +- src/declarative/fx/qfxanchors.h | 6 ++-- src/declarative/fx/qfxblurfilter.h | 7 ++-- src/declarative/fx/qfxcomponentinstance.h | 5 +-- src/declarative/fx/qfxcontentwrapper.h | 7 ++-- src/declarative/fx/qfxevents_p.h | 7 ++-- src/declarative/fx/qfxflickable.h | 7 ++-- src/declarative/fx/qfxflipable.cpp | 2 ++ src/declarative/fx/qfxflipable.h | 3 +- src/declarative/fx/qfxfocuspanel.h | 6 ++-- src/declarative/fx/qfxfocusrealm.h | 6 ++-- src/declarative/fx/qfxgridview.h | 4 +-- src/declarative/fx/qfxhighlightfilter.h | 5 +-- src/declarative/fx/qfximage.h | 3 +- src/declarative/fx/qfxitem.cpp | 4 ++- src/declarative/fx/qfxitem.h | 8 ++--- src/declarative/fx/qfxkeyactions.h | 6 ++-- src/declarative/fx/qfxkeyproxy.h | 5 +-- src/declarative/fx/qfxlayouts.h | 8 +++-- src/declarative/fx/qfxlistview.h | 6 ++-- src/declarative/fx/qfxmouseregion.h | 5 +-- src/declarative/fx/qfxpainteditem.h | 5 +-- src/declarative/fx/qfxparticles.h | 11 +++--- src/declarative/fx/qfxpath.h | 18 +++++----- src/declarative/fx/qfxpathview.h | 3 +- src/declarative/fx/qfxrect.h | 9 ++--- src/declarative/fx/qfxreflectionfilter.h | 3 +- src/declarative/fx/qfxrepeater.h | 7 ++-- src/declarative/fx/qfxscalegrid.h | 5 +-- src/declarative/fx/qfxshadowfilter.cpp | 4 +-- src/declarative/fx/qfxshadowfilter.h | 7 ++-- src/declarative/fx/qfxtext.h | 5 +-- src/declarative/fx/qfxtextedit.h | 5 +-- src/declarative/fx/qfxtransform.cpp | 4 +-- src/declarative/fx/qfxtransform.h | 15 ++++---- src/declarative/fx/qfxvisualitemmodel.cpp | 2 +- src/declarative/fx/qfxvisualitemmodel.h | 3 +- src/declarative/fx/qfxwebview.cpp | 4 +-- src/declarative/fx/qfxwebview.h | 11 +++--- src/declarative/fx/qfxwidgetcontainer.h | 3 +- src/declarative/opengl/glbasicshaders.h | 5 ++- src/declarative/qml/qml.h | 8 ++--- src/declarative/qml/qmlbindablevalue.cpp | 3 +- src/declarative/qml/qmlbindablevalue.h | 3 +- src/declarative/qml/qmlboundsignal.cpp | 2 +- src/declarative/qml/qmlcompiler_p.h | 3 +- src/declarative/qml/qmlcomponent.h | 5 +-- src/declarative/qml/qmlcustomparser.cpp | 3 +- src/declarative/qml/qmlcustomparser_p.h | 5 +-- src/declarative/qml/qmldom_p.h | 9 +---- src/declarative/qml/qmlengine.cpp | 7 ++-- src/declarative/qml/qmlmetaproperty.cpp | 4 +-- src/declarative/qml/qmlmetaproperty_p.h | 4 +++ src/declarative/qml/qmlmetatype.cpp | 4 +-- src/declarative/qml/qmlparser_p.h | 3 +- src/declarative/qml/qmlpropertyvaluesource.h | 3 +- src/declarative/qml/qmlproxymetaobject.cpp | 3 +- src/declarative/test/qfxtestengine.h | 4 +-- src/declarative/test/qfxtestobjects.cpp | 12 +++---- src/declarative/test/qfxtestobjects.h | 5 ++- src/declarative/test/qfxtestview.h | 5 ++- src/declarative/util/qmlanimation.h | 22 ++++++------ src/declarative/util/qmlbind.h | 3 +- src/declarative/util/qmlconnection.h | 3 +- src/declarative/util/qmlfollow.h | 4 +-- src/declarative/util/qmlfont.h | 3 +- src/declarative/util/qmllistmodel.cpp | 11 +++--- src/declarative/util/qmlpackage.h | 3 +- src/declarative/util/qmlscript.h | 3 +- src/declarative/util/qmlsetproperties.h | 3 +- src/declarative/util/qmlstate.h | 5 +-- src/declarative/util/qmlstategroup.h | 3 +- src/declarative/util/qmlstateoperations.h | 7 ++-- src/declarative/util/qmltransition.h | 3 +- src/declarative/widgets/graphicslayouts.h | 12 +++---- src/declarative/widgets/graphicswidgets.h | 6 ++-- tools/linguist/lupdate/qml.cpp | 4 +-- tools/qmldebugger/canvasframerate.cpp | 4 +++ tools/qmldebugger/canvasframerate.h | 4 +++ tools/qmldebugger/canvasscene.cpp | 3 ++ tools/qmldebugger/canvasscene.h | 4 +++ tools/qmlviewer/qmlviewer.cpp | 4 +++ tools/qmlviewer/qmlviewer.h | 3 ++ 101 files changed, 381 insertions(+), 230 deletions(-) diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index de75bde..d4891ff 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1,16 +1,49 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_EXTENDED_DUAL_LICENSE$ +** $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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qmetaobjectbuilder_p.h" #include +QT_BEGIN_NAMESPACE + /*! \class QMetaObjectBuilder \brief The QMetaObjectBuilder class supports building QMetaObject objects at runtime. @@ -2444,3 +2477,5 @@ void QMetaEnumBuilder::removeKey(int index) d->values.removeAt(index); } } + +QT_END_NAMESPACE diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h index dc95745..952364a 100644 --- a/src/corelib/kernel/qmetaobjectbuilder_p.h +++ b/src/corelib/kernel/qmetaobjectbuilder_p.h @@ -1,21 +1,65 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_EXTENDED_DUAL_LICENSE$ +** $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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QMETAOBJECTBUILDER_H #define QMETAOBJECTBUILDER_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of moc. This header file may change from version to version without notice, +// or even be removed. +// +// We mean it. +// + #include #include #include #include +QT_BEGIN_NAMESPACE + class QMetaObjectBuilderPrivate; class QMetaMethodBuilder; class QMetaMethodBuilderPrivate; @@ -266,4 +310,6 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::AddMembers) Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaObjectBuilder::MetaObjectFlags) +QT_END_NAMESPACE + #endif diff --git a/src/declarative/canvas/qsimplecanvas_p.h b/src/declarative/canvas/qsimplecanvas_p.h index 3a0186e..c900ccf 100644 --- a/src/declarative/canvas/qsimplecanvas_p.h +++ b/src/declarative/canvas/qsimplecanvas_p.h @@ -81,11 +81,14 @@ private: QSimpleCanvas::Matrix defaultTransform; QSimpleCanvas::Matrix invDefaultTransform; }; +QT_END_NAMESPACE #endif #include #include +QT_BEGIN_NAMESPACE + struct QSimpleCanvasGraphicsView : public QGraphicsView { public: @@ -198,6 +201,6 @@ public: int paintVersion; }; -#endif - QT_END_NAMESPACE + +#endif diff --git a/src/declarative/canvas/qsimplecanvasitem.h b/src/declarative/canvas/qsimplecanvasitem.h index dce3007..6452aa4 100644 --- a/src/declarative/canvas/qsimplecanvasitem.h +++ b/src/declarative/canvas/qsimplecanvasitem.h @@ -328,11 +328,8 @@ private: QSimpleCanvasLayer(); }; - - -#endif // _GFXCANVASITEM_H_ - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QSIMPLECANVASITEM_H diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index 382f3cb..9f555fe 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -3,7 +3,6 @@ QPRO_PWD = $$PWD QT = core gui xml script network contains(QT_CONFIG, svg): QT += svg DEFINES += QT_BUILD_DECLARATIVE_LIB -DEFINES += QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h index e59a8c7..86ded86 100644 --- a/src/declarative/extra/qfxanimatedimageitem.h +++ b/src/declarative/extra/qfxanimatedimageitem.h @@ -90,10 +90,11 @@ private: Q_DISABLE_COPY(QFxAnimatedImageItem) Q_DECLARE_PRIVATE(QFxAnimatedImageItem) }; -QML_DECLARE_TYPE(QFxAnimatedImageItem) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxAnimatedImageItem) + QT_END_HEADER #endif diff --git a/src/declarative/extra/qfxblendedimage.h b/src/declarative/extra/qfxblendedimage.h index f16d543..44de94c 100644 --- a/src/declarative/extra/qfxblendedimage.h +++ b/src/declarative/extra/qfxblendedimage.h @@ -101,10 +101,11 @@ private: QPixmap primPix; QPixmap secPix; }; -QML_DECLARE_TYPE(QFxBlendedImage) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxBlendedImage) + QT_END_HEADER #endif // QFXBLENDEDIMAGE_H diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp index e3b79f5..254e423 100644 --- a/src/declarative/extra/qfxflowview.cpp +++ b/src/declarative/extra/qfxflowview.cpp @@ -42,6 +42,8 @@ #include "qfxvisualitemmodel.h" #include "qfxflowview.h" +#include + QT_BEGIN_NAMESPACE class QFxFlowViewAttached : public QObject @@ -288,8 +290,6 @@ void QFxFlowView::moveItem(QFxItem *item, const QPointF &p) m_timeline.move(*yv, p.y(), 100); } -#include - void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event) { for (int ii = 0; ii < m_items.count(); ++ii) { diff --git a/src/declarative/extra/qfxflowview.h b/src/declarative/extra/qfxflowview.h index 0693d6e..2bec6a1 100644 --- a/src/declarative/extra/qfxflowview.h +++ b/src/declarative/extra/qfxflowview.h @@ -98,10 +98,11 @@ private: QList m_values; int m_dragIdx; }; -QML_DECLARE_TYPE(QFxFlowView); QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFlowView); + QT_END_HEADER #endif // QFXFLOWVIEW_H diff --git a/src/declarative/extra/qfxintegermodel.h b/src/declarative/extra/qfxintegermodel.h index 7c522f8..7fced2c 100644 --- a/src/declarative/extra/qfxintegermodel.h +++ b/src/declarative/extra/qfxintegermodel.h @@ -77,10 +77,10 @@ private: QFxIntegerModelPrivate *d; }; -QML_DECLARE_TYPE(QFxIntegerModel) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxIntegerModel) + QT_END_HEADER #endif diff --git a/src/declarative/extra/qmlbehaviour.h b/src/declarative/extra/qmlbehaviour.h index 967d3aa..1b5f524 100644 --- a/src/declarative/extra/qmlbehaviour.h +++ b/src/declarative/extra/qmlbehaviour.h @@ -87,10 +87,11 @@ protected: private Q_SLOTS: void propertyValueChanged(); }; -QML_DECLARE_TYPE(QmlBehaviour) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlBehaviour) + QT_END_HEADER #endif // QMLBEHAVIOUR_H diff --git a/src/declarative/extra/qmldatetimeformatter.h b/src/declarative/extra/qmldatetimeformatter.h index c4f1362..71b366c 100644 --- a/src/declarative/extra/qmldatetimeformatter.h +++ b/src/declarative/extra/qmldatetimeformatter.h @@ -106,10 +106,11 @@ private: Q_DISABLE_COPY(QmlDateTimeFormatter) Q_DECLARE_PRIVATE(QmlDateTimeFormatter) }; -QML_DECLARE_TYPE(QmlDateTimeFormatter) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlDateTimeFormatter) + QT_END_HEADER #endif diff --git a/src/declarative/extra/qmlnumberformatter.h b/src/declarative/extra/qmlnumberformatter.h index 24af8c0..6924fa5 100644 --- a/src/declarative/extra/qmlnumberformatter.h +++ b/src/declarative/extra/qmlnumberformatter.h @@ -83,10 +83,10 @@ private: Q_DECLARE_PRIVATE(QmlNumberFormatter) }; -QML_DECLARE_TYPE(QmlNumberFormatter) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlNumberFormatter) + QT_END_HEADER #endif diff --git a/src/declarative/extra/qmlsqlconnection.h b/src/declarative/extra/qmlsqlconnection.h index 0fcb183..88a727a 100644 --- a/src/declarative/extra/qmlsqlconnection.h +++ b/src/declarative/extra/qmlsqlconnection.h @@ -108,10 +108,10 @@ private: Q_DECLARE_PRIVATE(QmlSqlConnection) }; -QML_DECLARE_TYPE(QmlSqlConnection) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlSqlConnection) + QT_END_HEADER #endif // QMLXMLLISTMODEL_H diff --git a/src/declarative/extra/qmlsqlquery.h b/src/declarative/extra/qmlsqlquery.h index 72e6560f..8be758f 100644 --- a/src/declarative/extra/qmlsqlquery.h +++ b/src/declarative/extra/qmlsqlquery.h @@ -82,8 +82,6 @@ private: Q_DECLARE_PRIVATE(QmlSqlBind) }; -QML_DECLARE_TYPE(QmlSqlBind) - class QSqlQuery; class QmlSqlQueryPrivate; class Q_DECLARATIVE_EXPORT QmlSqlQuery : public QListModelInterface, public QmlParserStatus @@ -135,10 +133,11 @@ private: Q_DECLARE_PRIVATE(QmlSqlQuery) }; -QML_DECLARE_TYPE(QmlSqlQuery) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlSqlBind) +QML_DECLARE_TYPE(QmlSqlQuery) + QT_END_HEADER #endif diff --git a/src/declarative/extra/qmltimer.h b/src/declarative/extra/qmltimer.h index 2a73e65..0df4cb9 100644 --- a/src/declarative/extra/qmltimer.h +++ b/src/declarative/extra/qmltimer.h @@ -93,10 +93,11 @@ private Q_SLOTS: void ticked(); void stateChanged(QAbstractAnimation::State,QAbstractAnimation::State); }; -QML_DECLARE_TYPE(QmlTimer) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlTimer) + QT_END_HEADER #endif diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index 0d41456..804f13f 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -84,7 +84,6 @@ private: QString m_name; QString m_query; }; -QML_DECLARE_TYPE(XmlListModelRole) class QmlXmlListModelPrivate; class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public QmlParserStatus @@ -144,10 +143,11 @@ private: Q_DISABLE_COPY(QmlXmlListModel) }; -QML_DECLARE_TYPE(QmlXmlListModel) - QT_END_NAMESPACE +QML_DECLARE_TYPE(XmlListModelRole) +QML_DECLARE_TYPE(QmlXmlListModel) + QT_END_HEADER #endif // QMLXMLLISTMODEL_H diff --git a/src/declarative/extra/qnumberformat.cpp b/src/declarative/extra/qnumberformat.cpp index d317c27..cde2fb0 100644 --- a/src/declarative/extra/qnumberformat.cpp +++ b/src/declarative/extra/qnumberformat.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(QNumberFormat,NumberFormat) +QML_DEFINE_NOCREATE_TYPE(QNumberFormat) QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal), _groupingSize(0) diff --git a/src/declarative/extra/qnumberformat.h b/src/declarative/extra/qnumberformat.h index 92f89da..830cf79 100644 --- a/src/declarative/extra/qnumberformat.h +++ b/src/declarative/extra/qnumberformat.h @@ -163,10 +163,11 @@ private: QString _text; }; -QML_DECLARE_TYPE(QNumberFormat) QT_END_NAMESPACE +QML_DECLARE_TYPE(QNumberFormat) + QT_END_HEADER #endif diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 94c22a6..dcd5d79 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -77,8 +77,6 @@ public: AnchorLine anchorLine; }; -Q_DECLARE_METATYPE(QFxAnchorLine) - class QFxAnchorsPrivate; class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject { @@ -186,10 +184,12 @@ private: Q_DISABLE_COPY(QFxAnchors) Q_DECLARE_PRIVATE(QFxAnchors) }; -QML_DECLARE_TYPE(QFxAnchors) QT_END_NAMESPACE +Q_DECLARE_METATYPE(QFxAnchorLine) +QML_DECLARE_TYPE(QFxAnchors) + QT_END_HEADER #endif diff --git a/src/declarative/fx/qfxblurfilter.h b/src/declarative/fx/qfxblurfilter.h index 90285de..830663f 100644 --- a/src/declarative/fx/qfxblurfilter.h +++ b/src/declarative/fx/qfxblurfilter.h @@ -45,12 +45,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxBlurFilterPrivate; class Q_DECLARATIVE_EXPORT QFxBlurFilter : public QSimpleCanvasFilter { @@ -73,10 +73,11 @@ protected: private: QFxBlurFilterPrivate *d; }; -QML_DECLARE_TYPE(QFxBlurFilter) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxBlurFilter) + QT_END_HEADER + #endif // QFXBLURFILTER_H diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h index e749272..f3bf6b3 100644 --- a/src/declarative/fx/qfxcomponentinstance.h +++ b/src/declarative/fx/qfxcomponentinstance.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxComponentInstancePrivate; class Q_DECLARATIVE_EXPORT QFxComponentInstance : public QFxItem { @@ -80,10 +80,11 @@ protected: private: Q_DECLARE_PRIVATE(QFxComponentInstance) }; -QML_DECLARE_TYPE(QFxComponentInstance) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxComponentInstance) + QT_END_HEADER #endif // QFXCOMPONENTINSTANCE_H diff --git a/src/declarative/fx/qfxcontentwrapper.h b/src/declarative/fx/qfxcontentwrapper.h index d8fe0b8..9a9a89c 100644 --- a/src/declarative/fx/qfxcontentwrapper.h +++ b/src/declarative/fx/qfxcontentwrapper.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxContentWrapperPrivate; class Q_DECLARATIVE_EXPORT QFxContentWrapper : public QFxItem { @@ -73,7 +73,6 @@ protected: private: Q_DECLARE_PRIVATE(QFxContentWrapper) }; -QML_DECLARE_TYPE(QFxContentWrapper) class Q_DECLARATIVE_EXPORT QFxContent : public QFxItem { @@ -81,10 +80,12 @@ class Q_DECLARATIVE_EXPORT QFxContent : public QFxItem public: QFxContent(QFxItem *parent=0) : QFxItem(parent) {} }; -QML_DECLARE_TYPE(QFxContent) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxContentWrapper) +QML_DECLARE_TYPE(QFxContent) + QT_END_HEADER #endif // QFXCONTENTWRAPPER_H diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h index 60494e6..fbf0c5f 100644 --- a/src/declarative/fx/qfxevents_p.h +++ b/src/declarative/fx/qfxevents_p.h @@ -89,8 +89,6 @@ private: QKeyEvent event; }; -QML_DECLARE_TYPE(QFxKeyEvent) - class QFxMouseEvent : public QObject { Q_OBJECT @@ -131,8 +129,9 @@ private: bool _accepted; }; -QML_DECLARE_TYPE(QFxMouseEvent) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxKeyEvent) +QML_DECLARE_TYPE(QFxMouseEvent) + #endif // QFXEVENTS_P_H diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h index 2c858bc..da38df8 100644 --- a/src/declarative/fx/qfxflickable.h +++ b/src/declarative/fx/qfxflickable.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxFlickablePrivate; class Q_DECLARATIVE_EXPORT QFxFlickable : public QFxItem { @@ -186,10 +186,11 @@ private: Q_DISABLE_COPY(QFxFlickable) Q_DECLARE_PRIVATE(QFxFlickable) }; -QML_DECLARE_TYPE(QFxFlickable) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFlickable) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index 9595724..7672858 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -44,6 +44,8 @@ #include "qfxtransform.h" #include +QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QFxFlipable,Flipable) class QFxFlipablePrivate : public QFxItemPrivate diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h index 6630633..06f8b93 100644 --- a/src/declarative/fx/qfxflipable.h +++ b/src/declarative/fx/qfxflipable.h @@ -97,10 +97,11 @@ private: Q_DISABLE_COPY(QFxFlipable) Q_DECLARE_PRIVATE(QFxFlipable) }; -QML_DECLARE_TYPE(QFxFlipable) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFlipable) + QT_END_HEADER #endif // QFXFLIPABLE_H diff --git a/src/declarative/fx/qfxfocuspanel.h b/src/declarative/fx/qfxfocuspanel.h index 60f9118..623c9fb 100644 --- a/src/declarative/fx/qfxfocuspanel.h +++ b/src/declarative/fx/qfxfocuspanel.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class Q_DECLARATIVE_EXPORT QFxFocusPanel : public QFxItem { Q_OBJECT @@ -72,10 +72,10 @@ private: Q_DISABLE_COPY(QFxFocusPanel) }; -QML_DECLARE_TYPE(QFxFocusPanel) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFocusPanel) + QT_END_HEADER #endif // QFXFOCUSPANEL_H diff --git a/src/declarative/fx/qfxfocusrealm.h b/src/declarative/fx/qfxfocusrealm.h index d2aadce..20fc5ad 100644 --- a/src/declarative/fx/qfxfocusrealm.h +++ b/src/declarative/fx/qfxfocusrealm.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class Q_DECLARATIVE_EXPORT QFxFocusRealm : public QFxItem { Q_OBJECT @@ -58,10 +58,10 @@ public: virtual ~QFxFocusRealm(); }; -QML_DECLARE_TYPE(QFxFocusRealm) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFocusRealm) + QT_END_HEADER #endif // QFXFOCUSREALM_H diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h index 19c21c4..b6d585e 100644 --- a/src/declarative/fx/qfxgridview.h +++ b/src/declarative/fx/qfxgridview.h @@ -139,10 +139,10 @@ private: void refill(); }; -QML_DECLARE_TYPE(QFxGridView) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxGridView) + QT_END_HEADER #endif diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxhighlightfilter.h index 33f0963..56509a3 100644 --- a/src/declarative/fx/qfxhighlightfilter.h +++ b/src/declarative/fx/qfxhighlightfilter.h @@ -45,12 +45,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxHighlightFilterPrivate; class Q_DECLARATIVE_EXPORT QFxHighlightFilter : public QSimpleCanvasFilter { @@ -89,10 +89,11 @@ protected: private: QFxHighlightFilterPrivate *d; }; -QML_DECLARE_TYPE(QFxHighlightFilter) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxHighlightFilter) + QT_END_HEADER #endif // QFXHIGHLIGHTFILTER_H diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 35b921a..3071a9e 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -120,10 +120,11 @@ private: Q_DECLARE_PRIVATE(QFxImage) void setGridScaledImage(const QFxGridScaledImage& sci); }; -QML_DECLARE_TYPE(QFxImage) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxImage) + QT_END_HEADER #endif // QFXIMAGE_H diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 1c35290..7ccad5f 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -133,7 +133,9 @@ QFxContents::QFxContents() : m_height(0), m_width(0) The contents properties allow an item access to the size of its children. This property is useful if you have an item that needs to be - sized to fit its children. + sized to fit its children. +*/ + /*! \property QFxContents::height \brief The height of the contents. diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 67a4553..2b45f73 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -86,7 +86,6 @@ private: qreal m_height; qreal m_width; }; -QML_DECLARE_TYPE(QFxContents) Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors) class QmlState; @@ -266,12 +265,13 @@ private: Q_DISABLE_COPY(QFxItem) Q_DECLARE_PRIVATE(QFxItem) }; -QML_DECLARE_TYPE(QFxItem) - -QML_DECLARE_TYPE(QSimpleCanvasFilter) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxContents) +QML_DECLARE_TYPE(QFxItem) +QML_DECLARE_TYPE(QSimpleCanvasFilter) + QT_END_HEADER #endif // QFXITEM_H diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h index cea992a..91c2806 100644 --- a/src/declarative/fx/qfxkeyactions.h +++ b/src/declarative/fx/qfxkeyactions.h @@ -47,12 +47,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxKeyActionsPrivate; class Q_DECLARATIVE_EXPORT QFxKeyActions : public QFxItem { @@ -310,10 +310,10 @@ private: QFxKeyActionsPrivate *d; }; -QML_DECLARE_TYPE(QFxKeyActions) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxKeyActions) + QT_END_HEADER #endif // QFXKEYACTIONS_H diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h index 38cff7a..d075295 100644 --- a/src/declarative/fx/qfxkeyproxy.h +++ b/src/declarative/fx/qfxkeyproxy.h @@ -49,6 +49,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxKeyProxyPrivate; class Q_DECLARATIVE_EXPORT QFxKeyProxy : public QFxItem { @@ -69,10 +70,10 @@ private: QFxKeyProxyPrivate *d; }; -QML_DECLARE_TYPE(QFxKeyProxy) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxKeyProxy) + QT_END_HEADER #endif // QFXKEYPROXY_H diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h index b119d6f..112fe85 100644 --- a/src/declarative/fx/qfxlayouts.h +++ b/src/declarative/fx/qfxlayouts.h @@ -128,7 +128,6 @@ protected Q_SLOTS: private: Q_DISABLE_COPY(QFxVerticalLayout) }; -QML_DECLARE_TYPE(QFxVerticalLayout) class Q_DECLARATIVE_EXPORT QFxHorizontalLayout: public QFxBaseLayout { @@ -140,7 +139,6 @@ protected Q_SLOTS: private: Q_DISABLE_COPY(QFxHorizontalLayout) }; -QML_DECLARE_TYPE(QFxHorizontalLayout) class Q_DECLARATIVE_EXPORT QFxGridLayout : public QFxBaseLayout { @@ -163,9 +161,13 @@ private: int _columns; Q_DISABLE_COPY(QFxGridLayout) }; -QML_DECLARE_TYPE(QFxGridLayout) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxVerticalLayout) +QML_DECLARE_TYPE(QFxHorizontalLayout) +QML_DECLARE_TYPE(QFxGridLayout) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index 5dfb0e4..6e9451e 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxVisualItemModel; class QFxListViewPrivate; class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable @@ -145,10 +145,10 @@ private Q_SLOTS: void destroyingItem(QFxItem *item); }; -QML_DECLARE_TYPE(QFxListView) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxListView) + QT_END_HEADER #endif diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h index d7db1dc..429ad00 100644 --- a/src/declarative/fx/qfxmouseregion.h +++ b/src/declarative/fx/qfxmouseregion.h @@ -86,7 +86,6 @@ private: int _ymax; Q_DISABLE_COPY(QFxDrag) }; -QML_DECLARE_TYPE(QFxDrag) class QFxMouseEvent; class QFxMouseRegionPrivate; @@ -154,10 +153,12 @@ private: Q_DISABLE_COPY(QFxMouseRegion) Q_DECLARE_PRIVATE(QFxMouseRegion) }; -QML_DECLARE_TYPE(QFxMouseRegion) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxDrag) +QML_DECLARE_TYPE(QFxMouseRegion) + QT_END_HEADER #endif // QFXMOUSEREGION_H diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h index 6cb8fe7..7a0a9a9 100644 --- a/src/declarative/fx/qfxpainteditem.h +++ b/src/declarative/fx/qfxpainteditem.h @@ -101,10 +101,11 @@ private: Q_DISABLE_COPY(QFxPaintedItem) Q_DECLARE_PRIVATE(QFxPaintedItem) }; -QML_DECLARE_TYPE(QFxPaintedItem) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPaintedItem) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h index b3a569b..cfaffa7 100644 --- a/src/declarative/fx/qfxparticles.h +++ b/src/declarative/fx/qfxparticles.h @@ -66,7 +66,6 @@ public: virtual void created(QFxParticle &); virtual void destroy(QFxParticle &); }; -QML_DECLARE_TYPE(QFxParticleMotion) class Q_DECLARATIVE_EXPORT QFxParticleMotionLinear : public QFxParticleMotion { @@ -77,7 +76,6 @@ public: virtual void advance(QFxParticle &, int interval); }; -QML_DECLARE_TYPE(QFxParticleMotionLinear) class Q_DECLARATIVE_EXPORT QFxParticleMotionGravity : public QFxParticleMotion { @@ -106,7 +104,6 @@ private: int _yAttr; qreal _accel; }; -QML_DECLARE_TYPE(QFxParticleMotionGravity) class Q_DECLARATIVE_EXPORT QFxParticleMotionWander : public QFxParticleMotion { @@ -146,7 +143,6 @@ private: qreal _yvariance; qreal _pace; }; -QML_DECLARE_TYPE(QFxParticleMotionWander) class QFxParticlesPrivate; class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem @@ -231,10 +227,15 @@ private: Q_DISABLE_COPY(QFxParticles) Q_DECLARE_PRIVATE(QFxParticles) }; -QML_DECLARE_TYPE(QFxParticles) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxParticleMotion) +QML_DECLARE_TYPE(QFxParticleMotionLinear) +QML_DECLARE_TYPE(QFxParticleMotionGravity) +QML_DECLARE_TYPE(QFxParticleMotionWander) +QML_DECLARE_TYPE(QFxParticles) + QT_END_HEADER #endif diff --git a/src/declarative/fx/qfxpath.h b/src/declarative/fx/qfxpath.h index 39b9d01..04d24c6 100644 --- a/src/declarative/fx/qfxpath.h +++ b/src/declarative/fx/qfxpath.h @@ -61,7 +61,6 @@ public: Q_SIGNALS: void changed(); }; -QML_DECLARE_TYPE(QFxPathElement) class Q_DECLARATIVE_EXPORT QFxPathAttribute : public QFxPathElement { @@ -83,7 +82,6 @@ private: QString _name; qreal _value; }; -QML_DECLARE_TYPE(QFxPathAttribute) class Q_DECLARATIVE_EXPORT QFxCurve : public QFxPathElement { @@ -106,7 +104,6 @@ private: qreal _x; qreal _y; }; -QML_DECLARE_TYPE(QFxCurve) class Q_DECLARATIVE_EXPORT QFxPathLine : public QFxCurve { @@ -116,7 +113,6 @@ public: void addToPath(QPainterPath &path); }; -QML_DECLARE_TYPE(QFxPathLine) class Q_DECLARATIVE_EXPORT QFxPathQuad : public QFxCurve { @@ -139,7 +135,6 @@ private: qreal _controlX; qreal _controlY; }; -QML_DECLARE_TYPE(QFxPathQuad) class Q_DECLARATIVE_EXPORT QFxPathCubic : public QFxCurve { @@ -172,7 +167,6 @@ private: int _control2X; int _control2Y; }; -QML_DECLARE_TYPE(QFxPathCubic) class Q_DECLARATIVE_EXPORT QFxPathPercent : public QFxPathElement { @@ -187,7 +181,6 @@ public: private: qreal _value; }; -QML_DECLARE_TYPE(QFxPathPercent) class QFxPathPrivate; class Q_DECLARATIVE_EXPORT QFxPath : public QObject, public QmlParserStatus @@ -249,9 +242,18 @@ private: Q_DISABLE_COPY(QFxPath) Q_DECLARE_PRIVATE(QFxPath) }; -QML_DECLARE_TYPE(QFxPath) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPathElement) +QML_DECLARE_TYPE(QFxPathAttribute) +QML_DECLARE_TYPE(QFxCurve) +QML_DECLARE_TYPE(QFxPathLine) +QML_DECLARE_TYPE(QFxPathQuad) +QML_DECLARE_TYPE(QFxPathCubic) +QML_DECLARE_TYPE(QFxPathPercent) +QML_DECLARE_TYPE(QFxPath) + QT_END_HEADER + #endif // QFXPATH_H diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h index cbdafa8..159c865 100644 --- a/src/declarative/fx/qfxpathview.h +++ b/src/declarative/fx/qfxpathview.h @@ -127,10 +127,11 @@ private: Q_DISABLE_COPY(QFxPathView) Q_DECLARE_PRIVATE(QFxPathView) }; -QML_DECLARE_TYPE(QFxPathView) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPathView) + QT_END_HEADER #endif // QFXPATHVIEW_H diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index df490b0..2b35d8d 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -77,7 +77,6 @@ private: QColor _color; bool _valid; }; -QML_DECLARE_TYPE(QFxPen) class Q_DECLARATIVE_EXPORT QFxGradientStop : public QObject { @@ -102,7 +101,6 @@ private: qreal m_position; QColor m_color; }; -QML_DECLARE_TYPE(QFxGradientStop) class Q_DECLARATIVE_EXPORT QFxGradient : public QObject { @@ -130,7 +128,6 @@ private: mutable QGradient *m_gradient; friend class QFxGradientStop; }; -QML_DECLARE_TYPE(QFxGradient) class QFxRectPrivate; class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem @@ -184,10 +181,14 @@ private: Q_DISABLE_COPY(QFxRect) Q_DECLARE_PRIVATE(QFxRect) }; -QML_DECLARE_TYPE(QFxRect) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPen) +QML_DECLARE_TYPE(QFxGradientStop) +QML_DECLARE_TYPE(QFxGradient) +QML_DECLARE_TYPE(QFxRect) + QT_END_HEADER #endif // QFXRECT_H diff --git a/src/declarative/fx/qfxreflectionfilter.h b/src/declarative/fx/qfxreflectionfilter.h index 6e56b5e..d862040 100644 --- a/src/declarative/fx/qfxreflectionfilter.h +++ b/src/declarative/fx/qfxreflectionfilter.h @@ -87,10 +87,11 @@ private: Q_DISABLE_COPY(QFxReflectionFilter) QFxReflectionFilterPrivate *d; }; -QML_DECLARE_TYPE(QFxReflectionFilter) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxReflectionFilter) + QT_END_HEADER #endif // QFXREFLECTIONFILTER_H diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h index c1b194a..b82b9b0 100644 --- a/src/declarative/fx/qfxrepeater.h +++ b/src/declarative/fx/qfxrepeater.h @@ -44,12 +44,12 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxRepeaterPrivate; class Q_DECLARATIVE_EXPORT QFxRepeater : public QFxItem { @@ -80,10 +80,11 @@ private: Q_DISABLE_COPY(QFxRepeater) Q_DECLARE_PRIVATE(QFxRepeater) }; -QML_DECLARE_TYPE(QFxRepeater) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxRepeater) + QT_END_HEADER -#endif // _QFXREPEATER_H_ +#endif // QFXREPEATER_H diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h index c59cb32..03b2dd3 100644 --- a/src/declarative/fx/qfxscalegrid.h +++ b/src/declarative/fx/qfxscalegrid.h @@ -110,10 +110,11 @@ private: int _b; QString _pix; }; -QML_DECLARE_TYPE(QFxScaleGrid) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxScaleGrid) + QT_END_HEADER + #endif // QFXSCALEGRID_H diff --git a/src/declarative/fx/qfxshadowfilter.cpp b/src/declarative/fx/qfxshadowfilter.cpp index 10c332c..d37d565 100644 --- a/src/declarative/fx/qfxshadowfilter.cpp +++ b/src/declarative/fx/qfxshadowfilter.cpp @@ -47,9 +47,9 @@ #include #endif -class QFxShadowFilterPrivate - QT_BEGIN_NAMESPACE + +class QFxShadowFilterPrivate { public: QFxShadowFilterPrivate() diff --git a/src/declarative/fx/qfxshadowfilter.h b/src/declarative/fx/qfxshadowfilter.h index 67d165a..1cbe54f 100644 --- a/src/declarative/fx/qfxshadowfilter.h +++ b/src/declarative/fx/qfxshadowfilter.h @@ -77,10 +77,11 @@ protected: private: QFxShadowFilterPrivate *d; }; -QML_DECLARE_TYPE(QFxShadowFilter) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxShadowFilter) + QT_END_HEADER -#endif // _QFXSHADOWFILTER_H_ + +#endif // QFXSHADOWFILTER_H diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index b929a6f..1f5a7b8 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -143,10 +143,11 @@ private: Q_DISABLE_COPY(QFxText) Q_DECLARE_PRIVATE(QFxText) }; -QML_DECLARE_TYPE(QFxText) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxText) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index b761a1b..24ba3fe 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -202,10 +202,11 @@ private: Q_DISABLE_COPY(QFxTextEdit) Q_DECLARE_PRIVATE(QFxTextEdit) }; -QML_DECLARE_TYPE(QFxTextEdit) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxTextEdit) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index a4c5d22..2c4f842 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -46,11 +46,11 @@ #include #ifndef M_PI - -QT_BEGIN_NAMESPACE #define M_PI 3.14159265358979323846 #endif +QT_BEGIN_NAMESPACE + QML_DEFINE_NOCREATE_TYPE(QFxTransform); /*! diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h index 7be8adc..8693e7b 100644 --- a/src/declarative/fx/qfxtransform.h +++ b/src/declarative/fx/qfxtransform.h @@ -67,7 +67,6 @@ public: virtual bool isIdentity() const; virtual QSimpleCanvas::Matrix transform() const; }; -QML_DECLARE_TYPE(QFxTransform) class Q_DECLARATIVE_EXPORT QFxAxis : public QObject { @@ -107,7 +106,6 @@ private: qreal _endY; qreal _endZ; }; -QML_DECLARE_TYPE(QFxAxis) class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform { @@ -145,7 +143,6 @@ private: mutable bool _dirty; mutable QSimpleCanvas::Matrix _transform; }; -QML_DECLARE_TYPE(QFxRotation) class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform { @@ -174,7 +171,6 @@ private: mutable bool _dirty; mutable QSimpleCanvas::Matrix _transform; }; -QML_DECLARE_TYPE(QFxRotation3D) class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform { @@ -203,7 +199,6 @@ private: mutable bool _dirty; mutable QSimpleCanvas::Matrix _transform; }; -QML_DECLARE_TYPE(QFxTranslation3D) class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform { @@ -244,7 +239,6 @@ private: qreal _angle; qreal _aspect; }; -QML_DECLARE_TYPE(QFxPerspective) class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform { @@ -310,10 +304,17 @@ private: QSizeF s; QPointF p1, p2, p3, p4; }; -QML_DECLARE_TYPE(QFxSquish) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxTransform) +QML_DECLARE_TYPE(QFxAxis) +QML_DECLARE_TYPE(QFxRotation) +QML_DECLARE_TYPE(QFxRotation3D) +QML_DECLARE_TYPE(QFxTranslation3D) +QML_DECLARE_TYPE(QFxPerspective) +QML_DECLARE_TYPE(QFxSquish) + QT_END_HEADER #endif // QFXTRANSFORM_H diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index c60a379..d3ab4cc 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -52,9 +52,9 @@ #include "qmllistaccessor.h" #include "qfxvisualitemmodel.h" +QML_DECLARE_TYPE(QListModelInterface) QT_BEGIN_NAMESPACE -QML_DECLARE_TYPE(QListModelInterface) class QFxVisualItemModelParts; class QFxVisualItemModelData; diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h index 968cc2e..9cacde4 100644 --- a/src/declarative/fx/qfxvisualitemmodel.h +++ b/src/declarative/fx/qfxvisualitemmodel.h @@ -123,10 +123,11 @@ private Q_SLOTS: private: Q_DISABLE_COPY(QFxVisualItemModel) }; -QML_DECLARE_TYPE(QFxVisualItemModel) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxVisualItemModel) + QT_END_HEADER #endif // QFXVISUALITEMMODEL_H diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index f4a06ce..3ab64bc 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -1010,6 +1010,6 @@ QObject *QFxWebPage::createPlugin(const QString &, const QUrl &url, const QStrin return new QWidget_Dummy_Plugin(comp,view(),paramNames,paramValues); } -#include "qfxwebview.moc" - QT_END_NAMESPACE + +#include "qfxwebview.moc" diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index 0ac1895..f5fd721 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -49,14 +49,14 @@ #include #include - QT_BEGIN_HEADER +class QWebHistory; +class QWebSettings; + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QWebHistory; -class QWebSettings; class QFxWebViewPrivate; class QNetworkRequest; class QFxWebView; @@ -206,10 +206,11 @@ private: Q_DISABLE_COPY(QFxWebView) Q_DECLARE_PRIVATE(QFxWebView) }; -QML_DECLARE_TYPE(QFxWebView) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxWebView) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxwidgetcontainer.h index cc36010..862a280 100644 --- a/src/declarative/fx/qfxwidgetcontainer.h +++ b/src/declarative/fx/qfxwidgetcontainer.h @@ -72,10 +72,11 @@ protected: private: QGraphicsWidget *_graphicsWidget; }; -QML_DECLARE_TYPE(QFxWidgetContainer) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxWidgetContainer) + QT_END_HEADER #endif // QFXGRAPHICSWIDGET_H diff --git a/src/declarative/opengl/glbasicshaders.h b/src/declarative/opengl/glbasicshaders.h index 7d358d8..877f0fc 100644 --- a/src/declarative/opengl/glbasicshaders.h +++ b/src/declarative/opengl/glbasicshaders.h @@ -236,9 +236,8 @@ private: GLBasicShadersPrivate *d; }; -#endif // _GLBASICSHADERS_H_ - - QT_END_NAMESPACE QT_END_HEADER + +#endif // _GLBASICSHADERS_H_ diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index 51ca612..1990b7f 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -54,8 +54,6 @@ QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - QT_MODULE(Declarative) #define QML_DECLARE_TYPE(TYPE) \ @@ -73,6 +71,8 @@ QT_MODULE(Declarative) #define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \ QML_DECLARE_TYPE_HASMETATYPE(INTERFACE) +QT_BEGIN_NAMESPACE + #define QML_DEFINE_INTERFACE(INTERFACE) \ template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterInterface(#INTERFACE)); @@ -110,11 +110,11 @@ QObject *qmlAttachedPropertiesObject(const QObject *obj) return qmlAttachedPropertiesObjectById(idx, obj); } +QT_END_NAMESPACE + QML_DECLARE_TYPE(QObject) Q_DECLARE_METATYPE(QVariant) -QT_END_NAMESPACE - QT_END_HEADER #endif // QML_H diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp index 222ea87..f447d4f 100644 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ b/src/declarative/qml/qmlbindablevalue.cpp @@ -48,6 +48,8 @@ #include #include +Q_DECLARE_METATYPE(QList); + QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS); @@ -114,7 +116,6 @@ void QmlBindableValue::forceUpdate() update(); } -Q_DECLARE_METATYPE(QList); void QmlBindableValue::update() { Q_D(QmlBindableValue); diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h index 00da57e..12da9f6 100644 --- a/src/declarative/qml/qmlbindablevalue.h +++ b/src/declarative/qml/qmlbindablevalue.h @@ -88,10 +88,11 @@ protected: private: Q_DECLARE_PRIVATE(QmlBindableValue) }; -QML_DECLARE_TYPE(QmlBindableValue) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlBindableValue) + QT_END_HEADER #endif // QMLBINDABLEVALUE_H diff --git a/src/declarative/qml/qmlboundsignal.cpp b/src/declarative/qml/qmlboundsignal.cpp index 5815dc6..9779e46 100644 --- a/src/declarative/qml/qmlboundsignal.cpp +++ b/src/declarative/qml/qmlboundsignal.cpp @@ -47,6 +47,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -88,7 +89,6 @@ int QmlBoundSignalProxy::qt_metacall(QMetaObject::Call c, int id, void **a) } } -#include QmlBoundSignalParameters::QmlBoundSignalParameters(const QMetaMethod &method, QObject *parent) : QObject(parent), types(0), values(0) diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 2c722b9..819c4ad 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -61,9 +61,8 @@ #include #include -class QStringList; - QT_BEGIN_NAMESPACE + class QmlEngine; class QmlComponent; class QmlCompiledComponent; diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index 2e80b6b..db34e16 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -105,11 +105,12 @@ private: friend class QmlVME; friend struct QmlCompositeTypeData; }; -Q_DECLARE_METATYPE(QmlComponent::Status) -QML_DECLARE_TYPE(QmlComponent) QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlComponent::Status) +QML_DECLARE_TYPE(QmlComponent) + QT_END_HEADER #endif // QMLCOMPONENT_H diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp index c90ab47..b543978 100644 --- a/src/declarative/qml/qmlcustomparser.cpp +++ b/src/declarative/qml/qmlcustomparser.cpp @@ -43,6 +43,8 @@ #include "qmlcustomparser_p_p.h" #include "qmlparser_p.h" +#include + QT_BEGIN_NAMESPACE using namespace QmlParser; @@ -120,7 +122,6 @@ QmlCustomParserNodePrivate::fromObject(QmlParser::Object *root) return rootNode; } -#include QmlCustomParserProperty QmlCustomParserNodePrivate::fromProperty(QmlParser::Property *p) { diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 67f39d9..914ddbd 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -85,7 +85,6 @@ private: friend class QmlCustomParserPropertyPrivate; QmlCustomParserPropertyPrivate *d; }; -Q_DECLARE_METATYPE(QmlCustomParserProperty) class QmlCustomParserNodePrivate; class Q_DECLARATIVE_EXPORT QmlCustomParserNode @@ -104,7 +103,6 @@ private: friend class QmlCustomParserNodePrivate; QmlCustomParserNodePrivate *d; }; -Q_DECLARE_METATYPE(QmlCustomParserNode) class Q_DECLARATIVE_EXPORT QmlCustomParser { @@ -119,6 +117,9 @@ public: QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlCustomParserProperty) +Q_DECLARE_METATYPE(QmlCustomParserNode) + QT_END_HEADER #endif diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index a7c3cc7..101b17f 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -54,15 +54,10 @@ // #include - -QT_BEGIN_HEADER +#include "qmlparser_p.h" QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) - -#include "qmlparser_p.h" - class QmlDomDocumentPrivate : public QSharedData { public: @@ -125,7 +120,5 @@ public: QT_END_NAMESPACE -QT_END_HEADER - #endif // QMLDOM_P_H diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 8c926b7..9ee2f8d 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -73,12 +73,13 @@ #include #include +Q_DECLARE_METATYPE(QmlMetaProperty) +Q_DECLARE_METATYPE(QList); + QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER) -Q_DECLARE_METATYPE(QmlMetaProperty) - QML_DEFINE_TYPE(QObject,Object) static QScriptValue qmlMetaProperty_emit(QScriptContext *ctx, QScriptEngine *engine) @@ -1077,8 +1078,6 @@ void QmlExpression::valueChanged() { } -Q_DECLARE_METATYPE(QList); - void BindExpressionProxy::changed() { e->valueChanged(); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 218fdf8..448671e 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -50,6 +50,8 @@ #include #include +Q_DECLARE_METATYPE(QList); + QT_BEGIN_NAMESPACE class QMetaPropertyEx : public QMetaProperty @@ -651,8 +653,6 @@ QVariant QmlMetaProperty::read() const return QVariant(); } -Q_DECLARE_METATYPE(QList); - void QmlMetaPropertyPrivate::writeSignalProperty(const QVariant &value) { QString expr = value.toString(); diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 3bd9089..69fd5c3 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -55,6 +55,8 @@ #include "qmlmetaproperty.h" +QT_BEGIN_NAMESPACE + class QmlContext; class QmlMetaPropertyPrivate { @@ -89,4 +91,6 @@ public: void writeValueProperty(const QVariant &); }; +QT_END_NAMESPACE + #endif // QMLMETAPROPERTY_P_H diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index f69e5e5..b15f711 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -59,8 +59,6 @@ #include #include -QT_BEGIN_NAMESPACE - #ifdef QT_BOOTSTRAPPED # ifndef QT_NO_GEOM_VARIANT # define QT_NO_GEOM_VARIANT @@ -79,6 +77,8 @@ QT_BEGIN_NAMESPACE #endif #define NS(x) QT_PREPEND_NAMESPACE(x) +QT_BEGIN_NAMESPACE + struct QmlMetaTypeData { QList types; diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index ef038f9..a22d0a9 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -295,10 +295,11 @@ namespace QmlParser void dump(int = 0) const; }; } -Q_DECLARE_METATYPE(QmlParser::Variant) QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlParser::Variant) + QT_END_HEADER #endif // QMLPARSER_P_H diff --git a/src/declarative/qml/qmlpropertyvaluesource.h b/src/declarative/qml/qmlpropertyvaluesource.h index c142095..4e5f1c5 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.h +++ b/src/declarative/qml/qmlpropertyvaluesource.h @@ -69,10 +69,11 @@ protected: private: Q_DISABLE_COPY(QmlPropertyValueSource) }; -QML_DECLARE_TYPE(QmlPropertyValueSource) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlPropertyValueSource) + QT_END_HEADER #endif // QMLPROPERTYVALUESOURCE_H diff --git a/src/declarative/qml/qmlproxymetaobject.cpp b/src/declarative/qml/qmlproxymetaobject.cpp index 5568bab..0baea31 100644 --- a/src/declarative/qml/qmlproxymetaobject.cpp +++ b/src/declarative/qml/qmlproxymetaobject.cpp @@ -41,6 +41,8 @@ #include "qmlproxymetaobject_p.h" +#include + QT_BEGIN_NAMESPACE QmlProxyMetaObject::QmlProxyMetaObject(QObject *obj, QList *mList) @@ -78,7 +80,6 @@ QmlProxyMetaObject::~QmlProxyMetaObject() proxies = 0; } -#include int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) { if ((c == QMetaObject::ReadProperty || diff --git a/src/declarative/test/qfxtestengine.h b/src/declarative/test/qfxtestengine.h index 44a140f..bce8eec 100644 --- a/src/declarative/test/qfxtestengine.h +++ b/src/declarative/test/qfxtestengine.h @@ -77,9 +77,9 @@ private: QFxTestEnginePrivate *d; }; -#endif // _QFXTESTENGINE_H_ - QT_END_NAMESPACE QT_END_HEADER + +#endif // _QFXTESTENGINE_H_ diff --git a/src/declarative/test/qfxtestobjects.cpp b/src/declarative/test/qfxtestobjects.cpp index 12fc7fb..5035b28 100644 --- a/src/declarative/test/qfxtestobjects.cpp +++ b/src/declarative/test/qfxtestobjects.cpp @@ -45,19 +45,19 @@ #include #include +QML_DECLARE_TYPE(TestObject) +QML_DECLARE_TYPE(TestFrame) +QML_DECLARE_TYPE(TestFullFrame) +QML_DECLARE_TYPE(TestMouse) +QML_DECLARE_TYPE(TestKey) +QML_DECLARE_TYPE(TestLog) QT_BEGIN_NAMESPACE -QML_DECLARE_TYPE(TestObject) QML_DEFINE_TYPE(TestObject,TestObject) -QML_DECLARE_TYPE(TestFrame) QML_DEFINE_TYPE(TestFrame,TestFrame) -QML_DECLARE_TYPE(TestFullFrame) QML_DEFINE_TYPE(TestFullFrame,TestFullFrame) -QML_DECLARE_TYPE(TestMouse) QML_DEFINE_TYPE(TestMouse,TestMouse) -QML_DECLARE_TYPE(TestKey) QML_DEFINE_TYPE(TestKey,TestKey) -QML_DECLARE_TYPE(TestLog) QML_DEFINE_TYPE(TestLog,TestLog) static QString padding(int pad) diff --git a/src/declarative/test/qfxtestobjects.h b/src/declarative/test/qfxtestobjects.h index 80fcfe7..c8686ad 100644 --- a/src/declarative/test/qfxtestobjects.h +++ b/src/declarative/test/qfxtestobjects.h @@ -204,9 +204,8 @@ private: QList _actions; }; -#endif // _QFXTESTOBJECTS_H_ - - QT_END_NAMESPACE QT_END_HEADER + +#endif // _QFXTESTOBJECTS_H_ diff --git a/src/declarative/test/qfxtestview.h b/src/declarative/test/qfxtestview.h index a8f78bf..353494d 100644 --- a/src/declarative/test/qfxtestview.h +++ b/src/declarative/test/qfxtestview.h @@ -66,9 +66,8 @@ private: QFxTestEngine *testEngine; }; -#endif // _QFXTESTVIEW_H_ - - QT_END_NAMESPACE QT_END_HEADER + +#endif // _QFXTESTVIEW_H_ diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 110c43e..12212df 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -134,8 +134,6 @@ private Q_SLOTS: void timelineComplete(); }; -QML_DECLARE_TYPE(QmlAbstractAnimation) - class QmlPauseAnimationPrivate; class QmlPauseAnimation : public QmlAbstractAnimation { @@ -158,7 +156,6 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlPauseAnimation) class QmlRunScriptActionPrivate; class QmlRunScriptAction : public QmlAbstractAnimation @@ -186,7 +183,6 @@ Q_SIGNALS: protected: virtual QAbstractAnimation *qtAnimation(); }; -QML_DECLARE_TYPE(QmlRunScriptAction) class QmlSetPropertyActionPrivate; class QmlSetPropertyAction : public QmlAbstractAnimation @@ -223,7 +219,6 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlSetPropertyAction) class QmlParentChangeActionPrivate; class QmlParentChangeAction : public QmlAbstractAnimation @@ -244,7 +239,6 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlParentChangeAction) class QmlPropertyAnimationPrivate; class QmlPropertyAnimation : public QmlAbstractAnimation @@ -296,7 +290,6 @@ Q_SIGNALS: void easingChanged(const QString &); void propertiesChanged(const QString &); }; -QML_DECLARE_TYPE(QmlPropertyAnimation) class QmlColorAnimation : public QmlPropertyAnimation { @@ -315,7 +308,6 @@ public: QColor to() const; void setTo(const QColor &); }; -QML_DECLARE_TYPE(QmlColorAnimation) class QmlNumberAnimation : public QmlPropertyAnimation { @@ -335,7 +327,6 @@ public: qreal to() const; void setTo(qreal); }; -QML_DECLARE_TYPE(QmlNumberAnimation) class QmlAnimationGroupPrivate; class QmlAnimationGroup : public QmlAbstractAnimation @@ -369,7 +360,6 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlSequentialAnimation) class QmlParallelAnimation : public QmlAnimationGroup { @@ -387,10 +377,20 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlParallelAnimation) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlAbstractAnimation) +QML_DECLARE_TYPE(QmlPauseAnimation) +QML_DECLARE_TYPE(QmlRunScriptAction) +QML_DECLARE_TYPE(QmlSetPropertyAction) +QML_DECLARE_TYPE(QmlParentChangeAction) +QML_DECLARE_TYPE(QmlPropertyAnimation) +QML_DECLARE_TYPE(QmlColorAnimation) +QML_DECLARE_TYPE(QmlNumberAnimation) +QML_DECLARE_TYPE(QmlSequentialAnimation) +QML_DECLARE_TYPE(QmlParallelAnimation) + QT_END_HEADER #endif // QMLANIMATION_H diff --git a/src/declarative/util/qmlbind.h b/src/declarative/util/qmlbind.h index b7b77f2..731cdf8 100644 --- a/src/declarative/util/qmlbind.h +++ b/src/declarative/util/qmlbind.h @@ -82,10 +82,11 @@ public: private: void eval(); }; -QML_DECLARE_TYPE(QmlBind) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlBind) + QT_END_HEADER #endif diff --git a/src/declarative/util/qmlconnection.h b/src/declarative/util/qmlconnection.h index d61659f..dcaac34 100644 --- a/src/declarative/util/qmlconnection.h +++ b/src/declarative/util/qmlconnection.h @@ -81,10 +81,11 @@ private: void connectIfValid(); void componentComplete(); }; -QML_DECLARE_TYPE(QmlConnection) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlConnection) + QT_END_HEADER #endif diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlfollow.h index 72d6df5..0953f2c 100644 --- a/src/declarative/util/qmlfollow.h +++ b/src/declarative/util/qmlfollow.h @@ -92,10 +92,10 @@ Q_SIGNALS: void valueChanged(qreal); }; -QML_DECLARE_TYPE(QmlFollow) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlFollow) + QT_END_HEADER #endif // QFXFOLLOW_H diff --git a/src/declarative/util/qmlfont.h b/src/declarative/util/qmlfont.h index c4c86e2..e85b8d3 100644 --- a/src/declarative/util/qmlfont.h +++ b/src/declarative/util/qmlfont.h @@ -83,10 +83,11 @@ public: Q_SIGNALS: void updated(); }; -QML_DECLARE_TYPE(QmlFont) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlFont) + QT_END_HEADER #endif // QMLFONT_H diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 1884e8b..c202a9f 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -49,6 +49,8 @@ #include #include "qmllistmodel.h" +Q_DECLARE_METATYPE(QListModelInterface *) + QT_BEGIN_NAMESPACE #define DATA_ROLE_ID 1 @@ -67,8 +69,6 @@ struct ListModelData ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); } }; -Q_DECLARE_METATYPE(QListModelInterface *) - /*! \qmlclass ListModel \brief The ListModel element defines a free-form list data source. @@ -243,7 +243,6 @@ struct ModelNode ListModel *modelCache; ModelObject *objectCache; }; -Q_DECLARE_METATYPE(ModelNode *) ModelObject::ModelObject(ModelNode *node) : _node(node), _haveProperties(false), _mo(new QmlOpenMetaObject(this)) @@ -519,7 +518,6 @@ void ListModelParser::setCustomData(QObject *obj, const QByteArray &d) } } -QML_DECLARE_TYPE(ListModel) QML_DEFINE_CUSTOM_TYPE(ListModel, ListModel, ListModelParser) // ### FIXME @@ -527,7 +525,6 @@ class ListElement : public QObject { Q_OBJECT }; -QML_DECLARE_TYPE(ListElement) QML_DEFINE_TYPE(ListElement,ListElement) static void dump(ModelNode *node, int ind) @@ -568,4 +565,8 @@ ModelNode::~ModelNode() QT_END_NAMESPACE +Q_DECLARE_METATYPE(ModelNode *) +QML_DECLARE_TYPE(ListModel) +QML_DECLARE_TYPE(ListElement) + #include "qmllistmodel.moc" diff --git a/src/declarative/util/qmlpackage.h b/src/declarative/util/qmlpackage.h index 9f1d94f..9f7a623 100644 --- a/src/declarative/util/qmlpackage.h +++ b/src/declarative/util/qmlpackage.h @@ -77,10 +77,11 @@ public: static QmlPackageAttached *qmlAttachedProperties(QObject *); }; -QML_DECLARE_TYPE(QmlPackage) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlPackage) + QT_END_HEADER #endif // QMLPACKAGE_H diff --git a/src/declarative/util/qmlscript.h b/src/declarative/util/qmlscript.h index 5b62da5..4ba4f6b 100644 --- a/src/declarative/util/qmlscript.h +++ b/src/declarative/util/qmlscript.h @@ -74,10 +74,11 @@ public: private Q_SLOTS: void replyFinished(); }; -QML_DECLARE_TYPE(QmlScript) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlScript) + QT_END_HEADER #endif diff --git a/src/declarative/util/qmlsetproperties.h b/src/declarative/util/qmlsetproperties.h index 717d0ee..3632816 100644 --- a/src/declarative/util/qmlsetproperties.h +++ b/src/declarative/util/qmlsetproperties.h @@ -74,10 +74,11 @@ public: virtual ActionList actions(); }; -QML_DECLARE_TYPE(QmlSetProperties) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlSetProperties) + QT_END_HEADER #endif // QMLSETPROPERTIES_H diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index b219b99..987c7ad 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -99,7 +99,6 @@ public: protected: QmlStateOperation(QObjectPrivate &dd, QObject *parent = 0); }; -QML_DECLARE_TYPE(QmlStateOperation) typedef QmlStateOperation::ActionList QmlStateActions; @@ -149,10 +148,12 @@ private: Q_DISABLE_COPY(QmlState) friend class QmlTransitionPrivate; }; -QML_DECLARE_TYPE(QmlState) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlStateOperation) +QML_DECLARE_TYPE(QmlState) + QT_END_HEADER #endif // QMLSTATE_H diff --git a/src/declarative/util/qmlstategroup.h b/src/declarative/util/qmlstategroup.h index 237b60e..a817bd0 100644 --- a/src/declarative/util/qmlstategroup.h +++ b/src/declarative/util/qmlstategroup.h @@ -85,10 +85,11 @@ private: friend class QmlState; void updateAutoState(); }; -QML_DECLARE_TYPE(QmlStateGroup) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlStateGroup) + QT_END_HEADER #endif // QMLSTATEGROUP_H diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h index c7a6d42..6e5de48 100644 --- a/src/declarative/util/qmlstateoperations.h +++ b/src/declarative/util/qmlstateoperations.h @@ -70,7 +70,6 @@ public: virtual ActionList actions(); }; -QML_DECLARE_TYPE(QmlParentChange) class QmlRunScriptPrivate; class Q_DECLARATIVE_EXPORT QmlRunScript : public QmlStateOperation, public ActionEvent @@ -95,7 +94,6 @@ public: virtual void execute(); }; -QML_DECLARE_TYPE(QmlRunScript) class QmlSetPropertyPrivate; class Q_DECLARATIVE_EXPORT QmlSetProperty : public QmlStateOperation @@ -123,10 +121,13 @@ public: virtual ActionList actions(); }; -QML_DECLARE_TYPE(QmlSetProperty) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlParentChange) +QML_DECLARE_TYPE(QmlRunScript) +QML_DECLARE_TYPE(QmlSetProperty) + QT_END_HEADER #endif // QMLSTATEOPERATIONS_H diff --git a/src/declarative/util/qmltransition.h b/src/declarative/util/qmltransition.h index 4462b4c..d6cd513 100644 --- a/src/declarative/util/qmltransition.h +++ b/src/declarative/util/qmltransition.h @@ -88,10 +88,11 @@ public: void setReversed(bool r); void stop(); }; -QML_DECLARE_TYPE(QmlTransition) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlTransition) + QT_END_HEADER #endif // QMLTRANSITION_H diff --git a/src/declarative/widgets/graphicslayouts.h b/src/declarative/widgets/graphicslayouts.h index 525a848..ab8ad90 100644 --- a/src/declarative/widgets/graphicslayouts.h +++ b/src/declarative/widgets/graphicslayouts.h @@ -52,9 +52,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) - class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem { Q_OBJECT @@ -64,7 +61,6 @@ public: virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; }; -QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) //TODO: // -content margins @@ -120,7 +116,6 @@ private: ChildList _children; }; -QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) //TODO: // -content margins @@ -181,10 +176,15 @@ private: ChildList _children; }; -QML_DECLARE_TYPE(QGraphicsGridLayoutObject) QT_END_NAMESPACE +QML_DECLARE_INTERFACE(QGraphicsLayoutItem) +QML_DECLARE_INTERFACE(QGraphicsLayout) +QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) +QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) +QML_DECLARE_TYPE(QGraphicsGridLayoutObject) + QT_END_HEADER #endif // GRAPHICSLAYOUTS_H diff --git a/src/declarative/widgets/graphicswidgets.h b/src/declarative/widgets/graphicswidgets.h index e29f1d6..8147400 100644 --- a/src/declarative/widgets/graphicswidgets.h +++ b/src/declarative/widgets/graphicswidgets.h @@ -48,13 +48,15 @@ #include #include -QT_BEGIN_NAMESPACE +QT_BEGIN_HEADER + +QT_MODULE(Declarative) QML_DECLARE_TYPE(QGraphicsView) QML_DECLARE_TYPE_HASMETATYPE(QGraphicsScene) QML_DECLARE_TYPE(QGraphicsWidget) QML_DECLARE_INTERFACE_HASMETATYPE(QGraphicsItem) -QT_END_NAMESPACE +QT_END_HEADER #endif // GRAPHICSWIDGETS_H diff --git a/tools/linguist/lupdate/qml.cpp b/tools/linguist/lupdate/qml.cpp index f33eae3..f66a6bd 100644 --- a/tools/linguist/lupdate/qml.cpp +++ b/tools/linguist/lupdate/qml.cpp @@ -47,8 +47,6 @@ #include #include -QT_BEGIN_NAMESPACE - #include "parser/qmljsengine_p.h" #include "parser/qmljsparser_p.h" #include "parser/qmljslexer_p.h" @@ -65,6 +63,8 @@ QT_BEGIN_NAMESPACE #include #include +QT_BEGIN_NAMESPACE + using namespace QmlJS; class FindTrCalls: protected AST::Visitor diff --git a/tools/qmldebugger/canvasframerate.cpp b/tools/qmldebugger/canvasframerate.cpp index 022aed5..f2a813d 100644 --- a/tools/qmldebugger/canvasframerate.cpp +++ b/tools/qmldebugger/canvasframerate.cpp @@ -14,6 +14,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QLineGraph : public QWidget { Q_OBJECT @@ -301,4 +303,6 @@ void CanvasFrameRate::stateChanged(int s) static_cast(m_plugin)->setEnabled(checked); } +QT_END_NAMESPACE + #include "canvasframerate.moc" diff --git a/tools/qmldebugger/canvasframerate.h b/tools/qmldebugger/canvasframerate.h index 543f233..cc40d4c 100644 --- a/tools/qmldebugger/canvasframerate.h +++ b/tools/qmldebugger/canvasframerate.h @@ -3,6 +3,8 @@ #include +QT_BEGIN_NAMESPACE + class QmlDebugClient; class QTabWidget; class CanvasFrameRate : public QWidget @@ -20,5 +22,7 @@ private: QObject *m_plugin; }; +QT_END_NAMESPACE + #endif // CANVASFRAMERATE_H diff --git a/tools/qmldebugger/canvasscene.cpp b/tools/qmldebugger/canvasscene.cpp index 2d5b764..95f3098 100644 --- a/tools/qmldebugger/canvasscene.cpp +++ b/tools/qmldebugger/canvasscene.cpp @@ -8,6 +8,8 @@ #include #include +QT_BEGIN_NAMESPACE + class CanvasSceneClientPlugin : public QmlDebugClientPlugin { public: @@ -243,3 +245,4 @@ void CanvasScene::setY(int y) m_canvasRoot->setY(y); } +QT_END_NAMESPACE diff --git a/tools/qmldebugger/canvasscene.h b/tools/qmldebugger/canvasscene.h index d980241..8b583e8 100644 --- a/tools/qmldebugger/canvasscene.h +++ b/tools/qmldebugger/canvasscene.h @@ -6,6 +6,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QmlDebugClient; class CanvasSceneClient; class QmlDebugClientPlugin; @@ -35,5 +37,7 @@ private: QTreeWidgetItem *m_selected; }; +QT_END_NAMESPACE + #endif // CANVASSCENE_H diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 21cadda..cb7d00c 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -41,6 +41,8 @@ #include #include +QT_BEGIN_NAMESPACE + class PreviewDeviceSkin : public DeviceSkin { Q_OBJECT @@ -711,4 +713,6 @@ void QmlViewer::setCacheEnabled(bool on) } } +QT_END_NAMESPACE + #include "qmlviewer.moc" diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 9de47a8..c533fe0 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -20,6 +20,7 @@ #include #include +QT_BEGIN_NAMESPACE class QFxView; class PreviewDeviceSkin; @@ -94,4 +95,6 @@ private: QFxTestEngine *testEngine; }; +QT_END_NAMESPACE + #endif -- cgit v0.12 From 927ba2101c3ebe8513558e74527da8db69ad1292 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 09:41:47 +1000 Subject: Fix compile-in-namespace. --- src/declarative/extra/qmlfolderlistmodel.cpp | 2 -- src/declarative/extra/qmlfolderlistmodel.h | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp index abec01e..e6f3b76 100644 --- a/src/declarative/extra/qmlfolderlistmodel.cpp +++ b/src/declarative/extra/qmlfolderlistmodel.cpp @@ -46,8 +46,6 @@ QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) - class QmlFolderListModelPrivate : public QObjectPrivate { public: diff --git a/src/declarative/extra/qmlfolderlistmodel.h b/src/declarative/extra/qmlfolderlistmodel.h index a6e8526..dc520f1 100644 --- a/src/declarative/extra/qmlfolderlistmodel.h +++ b/src/declarative/extra/qmlfolderlistmodel.h @@ -94,10 +94,10 @@ private: Q_DISABLE_COPY(QmlFolderListModel) }; -QML_DECLARE_TYPE(QmlFolderListModel) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlFolderListModel) + QT_END_HEADER #endif // QMLFOLDERLISTMODEL_H -- cgit v0.12 From 9a358c882ceaa573b82e7a29ef89566196d7d70b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 10:06:55 +1000 Subject: Fix warnings. --- src/declarative/qml/qmlcompiler.cpp | 10 +++++----- src/declarative/qml/qmlengine.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index cb0c571..c2b2fb4 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -633,7 +633,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isCustomParser) { // Custom parser types don't support signal properties if (testProperty(prop, obj)) { - if (deferred.contains(prop->name)) + if (deferred.contains(QString::fromLatin1(prop->name.constData()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -644,7 +644,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isSignalPropertyName(prop->name)) { COMPILE_CHECK(compileSignal(prop,obj)); } else { - if (deferred.contains(prop->name)) + if (deferred.contains(QString::fromLatin1(prop->name.constData()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -660,7 +660,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isCustomParser) { if (testProperty(prop, obj)) { QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject()); - if (deferred.contains(p.name())) + if (deferred.contains(QString::fromLatin1(p.name()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -669,7 +669,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) } } else { QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject()); - if (deferred.contains(p.name())) + if (deferred.contains(QString::fromLatin1(p.name()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -1683,7 +1683,7 @@ QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj) return QStringList(); QMetaClassInfo classInfo = mo->classInfo(idx); - QStringList rv = QString(QLatin1String(classInfo.value())).split(','); + QStringList rv = QString(QLatin1String(classInfo.value())).split(QLatin1Char(',')); return rv; } diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 9ee2f8d..294e333 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1551,7 +1551,7 @@ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine) { engine = bindEngine; prototypeObject = engine->scriptEngine()->newObject(); - prototypeObject.setProperty("destroy", + prototypeObject.setProperty(QLatin1String("destroy"), engine->scriptEngine()->newFunction(QmlObjectDestroy)); } -- cgit v0.12 From b46072ef890b63514721b3520890b9aee2536721 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 10:11:52 +1000 Subject: Correctly save/restore render hint. --- src/declarative/fx/qfxrect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index 0536f12..b521d00 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -617,7 +617,7 @@ void QFxRect::drawRect(QPainter &p) if (d->gradient && d->gradient->gradient() /*|| p.usingQt() */) { // XXX This path is still slower than the image path // Image path won't work for gradients though - QPainter::RenderHints oldHints = p.renderHints(); + bool oldAA = p.testRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing); if (d->pen && d->pen->isValid()) { QPen pn(QColor(d->pen->color()), d->pen->width()); @@ -630,7 +630,7 @@ void QFxRect::drawRect(QPainter &p) p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius); else p.drawRect(0, 0, width(), height()); - p.setRenderHints(oldHints); + p.setRenderHint(QPainter::Antialiasing, oldAA); } else { int offset = 0; const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0; -- cgit v0.12 From a7f15a05e7b0eda7af34ac472f8ac7a01d7cbcd7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 10:16:42 +1000 Subject: StateOperation doesn't need to be instantiated from Qml. --- src/declarative/util/qmlstate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index 8ac1b33..8b096f0 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -525,7 +525,7 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever d->applyBindings(); //### merge into above foreach? } -QML_DEFINE_TYPE(QmlStateOperation,StateOperation) +QML_DEFINE_NOCREATE_TYPE(QmlStateOperation) QmlStateOperation::ActionList QmlStateOperation::actions() { return ActionList(); -- cgit v0.12 From 793a06b159ee205752eb8a2d4e7155618af14220 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 10:20:51 +1000 Subject: Move particles to extra. --- src/declarative/extra/extra.pri | 2 + src/declarative/extra/qfxparticles.cpp | 1201 ++++++++++++++++++++++++++++++++ src/declarative/extra/qfxparticles.h | 241 +++++++ src/declarative/fx/fx.pri | 2 - src/declarative/fx/qfxparticles.cpp | 1201 -------------------------------- src/declarative/fx/qfxparticles.h | 241 ------- 6 files changed, 1444 insertions(+), 1444 deletions(-) create mode 100644 src/declarative/extra/qfxparticles.cpp create mode 100644 src/declarative/extra/qfxparticles.h delete mode 100644 src/declarative/fx/qfxparticles.cpp delete mode 100644 src/declarative/fx/qfxparticles.h diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index fde4e3a..fca8ec8 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -8,6 +8,7 @@ SOURCES += \ extra/qfxanimatedimageitem.cpp \ extra/qfxblendedimage.cpp \ extra/qfxflowview.cpp \ + extra/qfxparticles.cpp \ extra/qmlbehaviour.cpp \ extra/qbindablemap.cpp @@ -22,6 +23,7 @@ HEADERS += \ extra/qfxanimatedimageitem_p.h \ extra/qfxblendedimage.h \ extra/qfxflowview.h \ + extra/qfxparticles.h \ extra/qmlbehaviour.h \ extra/qbindablemap.h diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp new file mode 100644 index 0000000..4cd34c4 --- /dev/null +++ b/src/declarative/extra/qfxparticles.cpp @@ -0,0 +1,1201 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfxitem_p.h" +#if defined(QFX_RENDER_OPENGL) +#include "gltexture.h" +#endif + +#include +#include +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#define M_PI_2 (M_PI / 2.) +#endif +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif +#include +#include +#include + +#include "qfxparticles.h" + + +QT_BEGIN_NAMESPACE +#define PI_SQR 9.8696044 +// parabolic approximation +inline qreal fastSin(qreal theta) +{ + const qreal b = 4 / M_PI; + const qreal c = -4 / PI_SQR; + + qreal y = b * theta + c * theta * qAbs(theta); + return y; +} + +inline qreal fastCos(qreal theta) +{ + theta += M_PI_2; + if (theta > M_PI) + theta -= 2 * M_PI; + + return fastSin(theta); +} + +class QFxParticle +{ +public: + QFxParticle(int time) : lifeSpan(1000), fadeOutAge(800) + , opacity(0), birthTime(time), x_velocity(0), y_velocity(0) + , state(FadeIn), data(0) + { + } + + int lifeSpan; + int fadeOutAge; + qreal x; + qreal y; + qreal opacity; + int birthTime; + qreal x_velocity; + qreal y_velocity; + enum State { FadeIn, Solid, FadeOut }; + State state; + void *data; +}; + +//--------------------------------------------------------------------------- + +QML_DEFINE_TYPE(QFxParticleMotion,ParticleMotion) + +/*! + \class QFxParticleMotion + \ingroup group_effects + \brief The QFxParticleMotion class is the base class for particle motion. + + This class causes the particles to remain static. +*/ + +/*! + Constructs a QFxParticleMotion with parent object \a parent. +*/ +QFxParticleMotion::QFxParticleMotion(QObject *parent) : + QObject(parent) +{ +} + +/*! + Move the \a particle to its new position. \a interval is the number of + milliseconds elapsed since it was last moved. +*/ +void QFxParticleMotion::advance(QFxParticle &particle, int interval) +{ + Q_UNUSED(particle); + Q_UNUSED(interval); +} + +/*! + The \a particle has just been created. Some motion strategies require + additional state information. This can be allocated by this function. +*/ +void QFxParticleMotion::created(QFxParticle &particle) +{ + Q_UNUSED(particle); +} + +/*! + The \a particle is about to be destroyed. Any additional memory + that has been allocated for the particle should be freed. +*/ +void QFxParticleMotion::destroy(QFxParticle &particle) +{ + Q_UNUSED(particle); +} + +/*! + \qmlclass ParticleMotionLinear + \brief The ParticleMotionLinear object moves particles linearly. + + \sa Particles +*/ + +/*! + \internal + \class QFxParticleMotionLinear + \ingroup group_effects + \brief The QFxParticleMotionLinear class moves the particles linearly. +*/ + +QML_DEFINE_TYPE(QFxParticleMotionLinear,ParticleMotionLinear) + +void QFxParticleMotionLinear::advance(QFxParticle &p, int interval) +{ + p.x += interval * p.x_velocity; + p.y += interval * p.y_velocity; +} + +/*! + \qmlclass ParticleMotionGravity + \brief The ParticleMotionGravity object moves particles towards a point. + + \sa Particles +*/ + +/*! + \internal + \class QFxParticleMotionGravity + \ingroup group_effects + \brief The QFxParticleMotionGravity class moves the particles towards a point. +*/ + +QML_DEFINE_TYPE(QFxParticleMotionGravity,ParticleMotionGravity) + +/*! + \qmlproperty int ParticleMotionGravity::xattractor + \qmlproperty int ParticleMotionGravity::yattractor + These properties hold the x and y coordinates of the point attracting the particles. +*/ + +/*! + \qmlproperty int ParticleMotionGravity::acceleration + This property holds the acceleration to apply to the particles. +*/ + +/*! + \property QFxParticleMotionGravity::xattractor + \brief the x coordinate of the point attracting the particles. +*/ + +/*! + \property QFxParticleMotionGravity::yattractor + \brief the y coordinate of the point attracting the particles. +*/ + +/*! + \property QFxParticleMotionGravity::acceleration + \brief the acceleration to apply to the particles. +*/ + +void QFxParticleMotionGravity::advance(QFxParticle &p, int interval) +{ + qreal xdiff = p.x - _xAttr; + qreal ydiff = p.y - _yAttr; + + qreal xcomp = xdiff / (xdiff + ydiff); + qreal ycomp = ydiff / (xdiff + ydiff); + + p.x_velocity += xcomp * _accel * interval; + p.y_velocity += ycomp * _accel * interval; + + p.x += interval * p.x_velocity; + p.y += interval * p.y_velocity; +} + +/*! + \qmlclass ParticleMotionWander + \brief The ParticleMotionWander object moves particles in a somewhat random fashion. + + The particles will continue roughly in the original direction, however will randomly + drift to each side. + + The code below produces an effect similar to falling snow. + + \qml +Rect { + width: 240 + height: 320 + color: "black" + + Particles { + y: 0 + width: parent.width + height: 30 + source: "star.png" + lifeSpan: 5000 + count: 50 + angle: 70 + angleDeviation: 36 + velocity: 30 + velocityDeviation: 10 + ParticleMotionWander { + xvariance: 30 + pace: 100 + } + } +} + \endqml + + \sa Particles +*/ + +/*! + \internal + \class QFxParticleMotionWander + \ingroup group_effects + \brief The QFxParticleMotionWander class moves particles in a somewhat random fashion. + + The particles will continue roughly in the original direction, however will randomly + drift to each side. +*/ + +/*! + \qmlproperty int QFxParticleMotionWander::xvariance + \qmlproperty int QFxParticleMotionWander::yvariance + + These properties set the amount to wander in the x and y directions. +*/ + +/*! + \qmlproperty int QFxParticleMotionWander::pace + This property holds how quickly the paricles will move from side to side. +*/ + +QML_DEFINE_TYPE(QFxParticleMotionWander,ParticleMotionWander) + +void QFxParticleMotionWander::advance(QFxParticle &p, int interval) +{ + if (!particles) + particles = qobject_cast(parent()); + if (particles) { + Data *d = (Data*)p.data; + if (_xvariance != 0.) { + qreal xdiff = p.x_velocity - d->x_targetV; + if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) { + d->x_var = -d->x_var; + d->x_peak = _xvariance + _xvariance * qreal(rand()) / RAND_MAX; + } + p.x_velocity += d->x_var * interval; + } + p.x += interval * p.x_velocity; + + if (_yvariance != 0.) { + qreal ydiff = p.y_velocity - d->y_targetV; + if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) { + d->y_var = -d->y_var; + d->y_peak = _yvariance + _yvariance * qreal(rand()) / RAND_MAX; + } + p.y_velocity += d->y_var * interval; + } + p.y += interval * p.y_velocity; + } +} + +void QFxParticleMotionWander::created(QFxParticle &p) +{ + if (!p.data) { + Data *d = new Data; + p.data = (void*)d; + d->x_targetV = p.x_velocity; + d->y_targetV = p.y_velocity; + d->x_peak = _xvariance; + d->y_peak = _yvariance; + d->x_var = _pace * qreal(rand()) / RAND_MAX / 1000.0; + d->y_var = _pace * qreal(rand()) / RAND_MAX / 1000.0; + } +} + +void QFxParticleMotionWander::destroy(QFxParticle &p) +{ + if (p.data) + delete (Data*)p.data; +} + +//--------------------------------------------------------------------------- +class QFxParticlesPainter : public QFxItem +{ +public: + QFxParticlesPainter(QFxParticlesPrivate *p, QFxItem* parent) + : QFxItem(parent), d(p) + { + setOptions(HasContents); + maxX = minX = maxY = minY = 0; + } + +#if defined(QFX_RENDER_QPAINTER) + void paintContents(QPainter &p); +#elif defined(QFX_RENDER_OPENGL2) + void paintGLContents(GLPainter &); +#endif + + void updateSize(); + + qreal maxX; + qreal minX; + qreal maxY; + qreal minY; + QFxParticlesPrivate* d; +}; + +//--------------------------------------------------------------------------- +class QFxParticlesPrivate : public QFxItemPrivate +{ + Q_DECLARE_PUBLIC(QFxParticles) +public: + QFxParticlesPrivate() + : count(1), lifeSpan(1000), lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300) + , angle(0), angleDev(0), velocity(0), velocityDev(0) + , addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0) + , emitting(true), motion(0), clock(this) +#if defined(QFX_RENDER_OPENGL) + , texDirty(true) +#endif + { + } + + ~QFxParticlesPrivate() + { + } + + void init() + { + Q_Q(QFxParticles); + paintItem = new QFxParticlesPainter(this, q); + } + + void tick(int time); + void createParticle(int time); + void updateOpacity(QFxParticle &p, int age); + + QUrl url; + QPixmap image; + int count; + int lifeSpan; + int lifeSpanDev; + int fadeInDur; + int fadeOutDur; + qreal angle; + qreal angleDev; + qreal velocity; + qreal velocityDev; + int addParticleTime; + int addParticleCount; + int lastAdvTime; + bool stream; + int streamDelay; + bool emitting; + QFxParticleMotion *motion; + QFxParticlesPainter *paintItem; + + QList particles; + QTickAnimationProxy clock; + +#if defined(QFX_RENDER_OPENGL) + bool texDirty; + GLTexture tex; +#endif +}; + +//TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged) +void QFxParticlesPrivate::tick(int time) +{ + Q_Q(QFxParticles); + if (!motion) + motion = new QFxParticleMotionLinear(q); + + int oldCount = particles.count(); + int removed = 0; + int interval = time - lastAdvTime; + for (int i = 0; i < particles.count(); ) { + QFxParticle &particle = particles[i]; + int age = time - particle.birthTime; + if (age >= particle.lifeSpan) { + QFxParticle part = particles.takeAt(i); + motion->destroy(part); + ++removed; + } else { + updateOpacity(particle, age); + motion->advance(particle, interval); + ++i; + } + } + + while(removed-- && particles.count() < count && emitting) + createParticle(time); + + if (!addParticleTime) + addParticleTime = time; + + if (particles.count() < count && emitting) { + qreal perc = (lifeSpanDev <= 0)?(1.):(qreal(time - addParticleTime) / qreal(lifeSpanDev)); + int percCount = addParticleCount + (int)perc * (count - addParticleCount); + int streamWidth = -1; + if (stream){ + if (streamDelay > time){ + streamWidth = 0; + }else{ + int missed = time - streamDelay; + qreal streamWidthReal = qreal(count)/qreal(lifeSpan); + if (streamWidthReal < 1){ + streamDelay = time + (int)(1.0/streamWidthReal); + streamWidth = 1; + streamWidth += missed/streamDelay; + }else{ + streamWidth = qRound(streamWidthReal * (time-lastAdvTime)); + } + } + } + while(particles.count() < count && particles.count() < percCount && streamWidth--) + createParticle(time); + } + + lastAdvTime = time; + if (oldCount || particles.count()) { + if (q->itemParent()) + q->itemParent()->update(); + else + q->update(); + } else if (!count) { + lastAdvTime = 0; + clock.stop(); + } +} + +void QFxParticlesPrivate::createParticle(int time) +{ +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer x; +#endif + Q_Q(QFxParticles); + QFxParticle p(time); + p.x = q->x() + q->width() * qreal(rand()) / RAND_MAX - image.width()/2.0; + p.y = q->y() + q->height() * qreal(rand()) / RAND_MAX - image.height()/2.0; + p.lifeSpan = lifeSpan; + if (lifeSpanDev) + p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(rand()) / RAND_MAX); + p.fadeOutAge = p.lifeSpan - fadeOutDur; + if (fadeInDur == 0.) { + p.state= QFxParticle::Solid; + p.opacity = 1.0; + } + qreal a = angle; + if (angleDev) + a += angleDev/2 - angleDev * qreal(rand()) / RAND_MAX; + if (a > M_PI) + a = a - 2 * M_PI; + qreal v = velocity; + if (velocityDev) + v += velocityDev/2 - velocityDev * qreal(rand()) / RAND_MAX; + p.x_velocity = v * fastCos(a); + p.y_velocity = v * fastSin(a); + particles.append(p); + motion->created(particles.last()); +} + +void QFxParticlesPrivate::updateOpacity(QFxParticle &p, int age) +{ + switch (p.state) { + case QFxParticle::FadeIn: + if (age <= fadeInDur) { + p.opacity = qreal(age) / fadeInDur; + break; + } else { + p.opacity = 1.0; + p.state = QFxParticle::Solid; + // Fall through + } + case QFxParticle::Solid: + if (age <= p.fadeOutAge) { + break; + } else { + p.state = QFxParticle::FadeOut; + // Fall through + } + case QFxParticle::FadeOut: + p.opacity = qreal(p.lifeSpan - age) / fadeOutDur; + break; + } +} + +QML_DEFINE_TYPE(QFxParticles,Particles) + +/*! + \qmlclass Particles + \brief The Particles object generates and moves particles. + \inherits Item + + The particles created by this object cannot be dealt with directly, they can only be controlled through the parameters of the Particles object. The particles are all the same pixmap, specified by the user. + + The particles are painted relative to the parent of the Particles object. Moving the + Particles object will not move the particles already emitted. + + The below example creates two differently behaving particle sources. + The top one has particles falling from the top like snow, + the lower one has particles expelled up like a fountain. + + \qml +Rect { + width: 240 + height: 320 + color: "black" + Particles { + y: 0 + width: parent.width + height: 30 + source: "star.png" + lifeSpan: 5000 + count: 50 + angle: 70 + angleDeviation: 36 + velocity: 30 + velocityDeviation: 10 + ParticleMotionWander { + xvariance: 30 + pace: 100 + } + } + Particles { + y: 300 + x: 120 + width: 1 + height: 1 + source: "star.png" + lifeSpan: 5000 + count: 200 + angle: 270 + angleDeviation: 45 + velocity: 50 + velocityDeviation: 30 + ParticleMotionGravity { + yattractor: 1000 + xattractor: 0 + acceleration: 25 + } + } +} + \endqml + \image particles.gif +*/ + +/*! + \internal + \class QFxParticles + \ingroup group_effects + \brief The QFxParticles class generates and moves particles. +*/ + +QFxParticles::QFxParticles(QFxItem *parent) + : QFxItem(*(new QFxParticlesPrivate), parent) +{ + Q_D(QFxParticles); + d->init(); + setOptions(HasContents); +} + +QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent) + : QFxItem(dd, parent) +{ + Q_D(QFxParticles); + d->init(); + setOptions(HasContents); +} + +QFxParticles::~QFxParticles() +{ + Q_D(QFxParticles); + if (!d->url.isEmpty()) + QFxPixmap::cancelGet(d->url, this); +} + +/*! + \qmlproperty string Particles::src + This property holds the URL of the particle image. +*/ + +/*! + \property QFxParticles::source + \brief the URL of the particle image. +*/ +QUrl QFxParticles::source() const +{ + Q_D(const QFxParticles); + return d->url; +} + +void QFxParticles::imageLoaded() +{ + Q_D(QFxParticles); + d->image = QFxPixmap(d->url); +#if defined(QFX_RENDER_OPENGL) + d->texDirty = true; + d->tex.clear(); +#endif + update(); +} + +void QFxParticles::setSource(const QUrl &name) +{ + Q_D(QFxParticles); + + if (name == d->url) + return; + + if (!d->url.isEmpty()) + QFxPixmap::cancelGet(d->url, this); + if (name.isEmpty()) { + d->url = name; + d->image = QPixmap(); +#if defined(QFX_RENDER_OPENGL) + d->texDirty = true; + d->tex.clear(); +#endif + update(); + } else { + d->url = name; + Q_ASSERT(!name.isRelative()); + QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded())); + } +} + +/*! + \qmlproperty int Particles::count + This property holds the target number of particles +*/ + +/*! + \property QFxParticles::count + \brief the target number of particles +*/ +int QFxParticles::count() const +{ + Q_D(const QFxParticles); + return d->count; +} + +void QFxParticles::setCount(int cnt) +{ + Q_D(QFxParticles); + if (cnt != d->count) { + if (!d->count && d->clock.state() != QAbstractAnimation::Running) + d->clock.start(); // infinity?? + d->count = cnt; + d->addParticleTime = 0; + d->addParticleCount = d->particles.count(); + update(); + } +} + +/*! + \qmlproperty int Particles::lifeSpan + \qmlproperty int Particles::lifeSpanDeviation + + These properties describe the life span of each particle. + + The default lifespan for a particle is 1000ms. + + lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For + example, the following creates particles whose lifeSpan will vary + from 150ms to 250ms: + + \qml +Particles { + source: "star.png" + lifeSpan: 200 + lifeSpanDeviation: 100 +} + \endqml +*/ + +/*! + \property QFxParticles::lifeSpan + \brief the life span of each particle. + + Default value is 1000ms. + + \sa QFxParticles::lifeSpanDeviation +*/ +int QFxParticles::lifeSpan() const +{ + Q_D(const QFxParticles); + return d->lifeSpan; +} + +void QFxParticles::setLifeSpan(int ls) +{ + Q_D(QFxParticles); + d->lifeSpan = ls; +} + +/*! + \property QFxParticles::lifeSpanDeviation + \brief the maximum possible deviation from the set lifeSpan. + + Randomly varies the lifeSpan up to the specified variation. For + example, the following creates particles whose lifeSpan will vary + from 150ms to 250ms: + +\qml +Particles { + source: "star.png" + lifeSpan: 200 + lifeSpanDeviation: 100 +} +\endqml + + \sa QFxParticles::lifeSpan +*/ +int QFxParticles::lifeSpanDeviation() const +{ + Q_D(const QFxParticles); + return d->lifeSpanDev; +} + +void QFxParticles::setLifeSpanDeviation(int dev) +{ + Q_D(QFxParticles); + d->lifeSpanDev = dev; +} + +/*! + \qmlproperty int Particles::fadeInDuration + \qmlproperty int Particles::fadeOutDuration + These properties hold the time taken to fade the particles in and out. + + By default fade in is 200ms and fade out is 300ms. +*/ + +/*! + \property QFxParticles::fadeInDuration + \brief the time taken to fade in the particles. + + Default value is 200ms. +*/ +int QFxParticles::fadeInDuration() const +{ + Q_D(const QFxParticles); + return d->fadeInDur; +} + +void QFxParticles::setFadeInDuration(int dur) +{ + Q_D(QFxParticles); + if (dur >= 0.0) + d->fadeInDur = dur; +} + +/*! + \property QFxParticles::fadeOutDuration + \brief the time taken to fade out the particles. + + Default value is 300ms. +*/ +int QFxParticles::fadeOutDuration() const +{ + Q_D(const QFxParticles); + return d->fadeOutDur; +} + +void QFxParticles::setFadeOutDuration(int dur) +{ + Q_D(QFxParticles); + if (dur >= 0.0) + d->fadeOutDur = dur; +} + +/*! + \qmlproperty real Particles::angle + \qmlproperty real Particles::angleDeviation + + These properties control particle direction. + + angleDeviation randomly varies the direction up to the specified variation. For + example, the following creates particles whose initial direction will + vary from 15 degrees to 105 degrees: + + \qml +Particles { + source: "star.png" + angle: 60 + angleDeviation: 90 +} + \endqml +*/ + +/*! + \property QFxParticles::angle + \brief the initial angle of direction. + + \sa QFxParticles::angleDeviation +*/ +qreal QFxParticles::angle() const +{ + Q_D(const QFxParticles); + return d->angle * 180.0 / M_PI; +} + +void QFxParticles::setAngle(qreal angle) +{ + Q_D(QFxParticles); + d->angle = angle * M_PI / 180.0; +} + +/*! + \property QFxParticles::angleDeviation + \brief the maximum possible deviation from the set angle. + + Randomly varies the direction up to the specified variation. For + example, the following creates particles whose initial direction will + vary from 15 degrees to 105 degrees: + +\qml +Particles { + source: "star.png" + angle: 60 + angleDeviation: 90 +} +\endqml + + \sa QFxParticles::angle +*/ +qreal QFxParticles::angleDeviation() const +{ + Q_D(const QFxParticles); + return d->angleDev * 180.0 / M_PI; +} + +void QFxParticles::setAngleDeviation(qreal dev) +{ + Q_D(QFxParticles); + d->angleDev = dev * M_PI / 180.0;; +} + +/*! + \qmlproperty real Particles::velocity + \qmlproperty real Particles::velocityDeviation + + These properties control the velocity of the particles. + + velocityDeviation randomly varies the velocity up to the specified variation. For + example, the following creates particles whose initial velocity will + vary from 40 to 60. + + \qml +Particles { + source: "star.png" + velocity: 50 + velocityDeviation: 20 +} + \endqml +*/ + +/*! + \property QFxParticles::velocity + \brief the initial velocity of the particles. + + \sa QFxParticles::velocityDeviation +*/ +qreal QFxParticles::velocity() const +{ + Q_D(const QFxParticles); + return d->velocity * 1000.0; +} + +void QFxParticles::setVelocity(qreal velocity) +{ + Q_D(QFxParticles); + d->velocity = velocity / 1000.0; +} + +/*! + \property QFxParticles::velocityDeviation + \brief the maximum possible deviation from the set velocity. + + Randomly varies the velocity up to the specified variation. For + example, the following creates particles whose initial velocity will + vary from 40 to 60. + +\qml +Particles { + source: "star.png" + velocity: 50 + velocityDeviation: 20 +} +\endqml + + \sa QFxParticles::velocity +*/ +qreal QFxParticles::velocityDeviation() const +{ + Q_D(const QFxParticles); + return d->velocityDev * 1000.0; +} + +void QFxParticles::setVelocityDeviation(qreal velocity) +{ + Q_D(QFxParticles); + d->velocityDev = velocity / 1000.0; +} + +/*! + \qmlproperty bool Particles::streamIn + This property determines whether the particles stream in at a constant rate + + When stream is set to true the particles will stream in at a constant rate. + Otherwise the particles will appear as a clump. Note that this only affects the + start of the particle effect, variables such as lifespan deviation can cause the + particles to unclump over time. +*/ +/*! + \property QFxParticles::streamIn + \brief determines whether the particles stream in at a constant rate + + When stream is set to true the particles will stream in at a constant rate. + Otherwise the particles will appear as a clump. Note that this only affects the + start of the particle effect, variables such as lifespan deviation can cause the + +*/ +//The name may need a rethink +bool QFxParticles::streamIn() const +{ + Q_D(const QFxParticles); + return d->stream; +} + +void QFxParticles::setStreamIn(bool b) +{ + Q_D(QFxParticles); + d->stream = b; +} + +/*! + \qmlproperty bool Particles::emitting + This property determines whether new particles are created + + If emitting is set to false no new particles will be created. This means that + when a particle reaches the end of its lifespan it is not replaced. This + property can be used to turn particles on and off with a more natural look. + + The default setting is true. Note that if it initialized to false no particles + will be produced until it is set to true. +*/ +/*! + \property QFxParticles::emitting + If emitting is set to false no new particles will be created. This means that + when a particle reaches the end of its lifespan it is not replaced. This + property can be used to turn particles on and off with a more natural look. + + The default setting is true. Note that if it initialized to false no particles + will be produced until it is set to true. +*/ +bool QFxParticles::emitting() const +{ + Q_D(const QFxParticles); + return d->emitting; +} + +void QFxParticles::setEmitting(bool r) +{ + Q_D(QFxParticles); + d->emitting = r; +} +/*! + \qmlproperty ParticleMotion Particles::motion + This property sets the type of motion to apply to the particles. + + When a particle is created it will have an initial direction and velocity. + The motion of the particle during its lifeSpan is then influenced by the + motion property. + + Default motion is ParticleMotionLinear. +*/ + +/*! + \property QFxParticles::motion + \brief sets the type of motion to apply to the particles. + + When a particle is created it will have an initial direction and velocity. + The motion of the particle during its lifeSpan is then influenced by the + motion property. + + Default motion is QFxParticleMotionLinear. +*/ +QFxParticleMotion *QFxParticles::motion() const +{ + Q_D(const QFxParticles); + return d->motion; +} + +void QFxParticles::setMotion(QFxParticleMotion *motion) +{ + Q_D(QFxParticles); + d->motion = motion; +} + +void QFxParticles::dump(int depth) +{ + Q_D(QFxParticles); + QByteArray ba(depth * 4, ' '); + qWarning() << ba.constData() << "URL:" << d->url << "Count:" << d->count; + QFxItem::dump(depth); +} + +QString QFxParticles::propertyInfo() const +{ + Q_D(const QFxParticles); + return d->url.toString(); +} + +void QFxParticlesPainter::updateSize(){ + setX(-500); + setY(-500); + setWidth(1000); + setHeight(1000); + return ; + const int parentX = parent()->x(); + const int parentY = parent()->y(); + //Have to use statistical approach to needed size as arbitrary particle + //motions make it impossible to calculate. + //max/min vars stored to give a never shrinking rect + for (int i = 0; i < d->particles.count(); ++i) { + const QFxParticle &particle = d->particles.at(i); + if(particle.x > maxX) + maxX = particle.x; + if(particle.x < minX) + minX = particle.x; + if(particle.y > maxY) + maxY = particle.y; + if(particle.y < minY) + minY = particle.y; + } + + int myWidth = (int)(maxX-minX+0.5)+d->image.width(); + int myX = (int)(minX - parentX); + int myHeight = (int)(maxY-minY+0.5)+d->image.height(); + int myY = (int)(minY - parentY); + setWidth(myWidth); + setHeight(myHeight); + setX(myX); + setY(myY); +} + +#if defined(QFX_RENDER_QPAINTER) +void QFxParticles::paintContents(QPainter &p) +{ + Q_UNUSED(p); + //painting is done by the ParticlesPainter, so it can have the right size +} + +void QFxParticlesPainter::paintContents(QPainter &p) +{ + if (d->image.isNull()) + return; + + updateSize(); + const int myX = x() + parent()->x(); + const int myY = y() + parent()->y(); + + for (int i = 0; i < d->particles.count(); ++i) { + const QFxParticle &particle = d->particles.at(i); + p.setOpacity(particle.opacity); + p.drawPixmap(particle.x - myX, particle.y - myY, d->image); + } + update();//Should I need this? (GV does) +} +#elif defined(QFX_RENDER_OPENGL2) +void QFxParticles::paintGLContents(GLPainter &) +{ + //painting is done by the ParticlesPainter, so it can have the right size +} + +void QFxParticlesPainter::paintGLContents(GLPainter &p) +{ + + if (d->image.isNull()) + return; + + updateSize(); + + if (d->texDirty && !d->image.isNull()) { + d->tex.setImage(d->image.toImage()); + d->tex.setHorizontalWrap(GLTexture::Repeat); + d->tex.setVerticalWrap(GLTexture::Repeat); + } + d->texDirty = false; + + SingleTextureOpacityShader *shader = basicShaders()->singleTextureOpacity(); + shader->enable(); + shader->setTransform(p.activeTransform); + + glBindTexture(GL_TEXTURE_2D, d->tex.texture()); + + const int myX = (int)(x() + parent()->x()); + const int myY = (int)(y() + parent()->y()); + float widthV = d->image.width(); + float heightV = d->image.height(); + for (int i = 0; i < d->particles.count(); ++i) { + const QFxParticle &particle = d->particles.at(i); + float left = particle.x - myX; + float right = particle.x - myX + widthV; + float top = particle.y - myY; + float bottom = particle.y - myY + heightV; + + GLfloat vertices[] = { left, bottom, + right, bottom, + left, top, + right, top }; + + GLfloat texVertices[] = { 0, 0, + 1, 0, + 0, 1, + 1, 1 }; + + shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); + shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); + shader->setOpacity(particle.opacity * p.activeOpacity); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + + shader->disableAttributeArray(SingleTextureShader::Vertices); + shader->disableAttributeArray(SingleTextureShader::TextureCoords); +} +#endif + +void QFxParticles::componentComplete() +{ + Q_D(QFxParticles); + QFxItem::componentComplete(); + if (d->count) + d->clock.start(); // infinity?? + if (d->lifeSpanDev > d->lifeSpan) + d->lifeSpanDev = d->lifeSpan; +} + +QT_END_NAMESPACE diff --git a/src/declarative/extra/qfxparticles.h b/src/declarative/extra/qfxparticles.h new file mode 100644 index 0000000..cfaffa7 --- /dev/null +++ b/src/declarative/extra/qfxparticles.h @@ -0,0 +1,241 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFXPARTICLES_H +#define QFXPARTICLES_H + +#include + +#if defined(QFX_RENDER_OPENGL) +#include "gltexture.h" +#endif + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QFxParticle; +class QFxParticles; +class Q_DECLARATIVE_EXPORT QFxParticleMotion : public QObject +{ + Q_OBJECT +public: + QFxParticleMotion(QObject *parent=0); + + virtual void advance(QFxParticle &, int interval); + virtual void created(QFxParticle &); + virtual void destroy(QFxParticle &); +}; + +class Q_DECLARATIVE_EXPORT QFxParticleMotionLinear : public QFxParticleMotion +{ + Q_OBJECT +public: + QFxParticleMotionLinear(QObject *parent=0) + : QFxParticleMotion(parent) {} + + virtual void advance(QFxParticle &, int interval); +}; + +class Q_DECLARATIVE_EXPORT QFxParticleMotionGravity : public QFxParticleMotion +{ + 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) +public: + QFxParticleMotionGravity(QObject *parent=0) + : QFxParticleMotion(parent), _xAttr(0), _yAttr(0), _accel(0.00005) {} + + int xAttractor() const { return _xAttr; } + void setXAttractor(int x) { _xAttr = x; } + + int yAttractor() const { return _yAttr; } + void setYAttractor(int y) { _yAttr = y; } + + int acceleration() const { return int(_accel * 1000000); } + void setAcceleration(int accel) { _accel = qreal(accel)/1000000.0; } + + virtual void advance(QFxParticle &, int interval); + +private: + int _xAttr; + int _yAttr; + qreal _accel; +}; + +class Q_DECLARATIVE_EXPORT QFxParticleMotionWander : public QFxParticleMotion +{ + Q_OBJECT +public: + QFxParticleMotionWander() + : QFxParticleMotion(), particles(0), _xvariance(0), _yvariance(0) {} + + virtual void advance(QFxParticle &, int interval); + virtual void created(QFxParticle &); + virtual void destroy(QFxParticle &); + + struct Data { + qreal x_targetV; + qreal y_targetV; + qreal x_peak; + qreal y_peak; + qreal x_var; + 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(int yvariance READ yVariance WRITE setYVariance) + int yVariance() const { return int(_yvariance * 1000); } + void setYVariance(int var) { _yvariance = var / 1000.0; } + + Q_PROPERTY(int pace READ pace WRITE setPace) + int pace() const { return int(_pace * 1000); } + void setPace(int pace) { _pace = pace / 1000.0; } + +private: + QFxParticles *particles; + qreal _xvariance; + qreal _yvariance; + qreal _pace; +}; + +class QFxParticlesPrivate; +class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem +{ + Q_OBJECT + + Q_PROPERTY(QUrl source READ source WRITE setSource) + Q_PROPERTY(int count READ count WRITE setCount) + Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan) + Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation) + Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration) + Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration) + Q_PROPERTY(qreal angle READ angle WRITE setAngle) + Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation) + Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity) + Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation) + Q_PROPERTY(bool streamIn READ streamIn WRITE setStreamIn) + Q_PROPERTY(bool emitting READ emitting WRITE setEmitting) + Q_PROPERTY(QFxParticleMotion *motion READ motion WRITE setMotion) + Q_CLASSINFO("DefaultProperty", "motion") + +public: + QFxParticles(QFxItem *parent=0); + ~QFxParticles(); + + QUrl source() const; + void setSource(const QUrl &); + + int count() const; + void setCount(int cnt); + + int lifeSpan() const; + void setLifeSpan(int); + + int lifeSpanDeviation() const; + void setLifeSpanDeviation(int); + + int fadeInDuration() const; + void setFadeInDuration(int); + + int fadeOutDuration() const; + void setFadeOutDuration(int); + + qreal angle() const; + void setAngle(qreal); + + qreal angleDeviation() const; + void setAngleDeviation(qreal); + + qreal velocity() const; + void setVelocity(qreal); + + qreal velocityDeviation() const; + void setVelocityDeviation(qreal); + + bool streamIn() const; + void setStreamIn(bool); + + bool emitting() const; + void setEmitting(bool); + + QFxParticleMotion *motion() const; + void setMotion(QFxParticleMotion *); + + virtual void dump(int depth); + virtual QString propertyInfo() const; + +#if defined(QFX_RENDER_QPAINTER) + void paintContents(QPainter &p); +#elif defined(QFX_RENDER_OPENGL2) + void paintGLContents(GLPainter &); +#endif + +protected: + virtual void componentComplete(); + QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent); + +private Q_SLOTS: + void imageLoaded(); + +private: + Q_DISABLE_COPY(QFxParticles) + Q_DECLARE_PRIVATE(QFxParticles) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QFxParticleMotion) +QML_DECLARE_TYPE(QFxParticleMotionLinear) +QML_DECLARE_TYPE(QFxParticleMotionGravity) +QML_DECLARE_TYPE(QFxParticleMotionWander) +QML_DECLARE_TYPE(QFxParticles) + +QT_END_HEADER + +#endif diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 69fada0..fd6e480 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -26,7 +26,6 @@ HEADERS += \ fx/qfxlayouts_p.h \ fx/qfxmouseregion.h \ fx/qfxmouseregion_p.h \ - fx/qfxparticles.h \ fx/qfxpath.h \ fx/qfxpath_p.h \ fx/qfxpathview.h \ @@ -67,7 +66,6 @@ SOURCES += \ fx/qfxkeyproxy.cpp \ fx/qfxlayouts.cpp \ fx/qfxmouseregion.cpp \ - fx/qfxparticles.cpp \ fx/qfxpath.cpp \ fx/qfxpathview.cpp \ fx/qfxrect.cpp \ diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp deleted file mode 100644 index 4cd34c4..0000000 --- a/src/declarative/fx/qfxparticles.cpp +++ /dev/null @@ -1,1201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxitem_p.h" -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif - -#include -#include -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#define M_PI_2 (M_PI / 2.) -#endif -#ifndef INT_MAX -#define INT_MAX 2147483647 -#endif -#include -#include -#include - -#include "qfxparticles.h" - - -QT_BEGIN_NAMESPACE -#define PI_SQR 9.8696044 -// parabolic approximation -inline qreal fastSin(qreal theta) -{ - const qreal b = 4 / M_PI; - const qreal c = -4 / PI_SQR; - - qreal y = b * theta + c * theta * qAbs(theta); - return y; -} - -inline qreal fastCos(qreal theta) -{ - theta += M_PI_2; - if (theta > M_PI) - theta -= 2 * M_PI; - - return fastSin(theta); -} - -class QFxParticle -{ -public: - QFxParticle(int time) : lifeSpan(1000), fadeOutAge(800) - , opacity(0), birthTime(time), x_velocity(0), y_velocity(0) - , state(FadeIn), data(0) - { - } - - int lifeSpan; - int fadeOutAge; - qreal x; - qreal y; - qreal opacity; - int birthTime; - qreal x_velocity; - qreal y_velocity; - enum State { FadeIn, Solid, FadeOut }; - State state; - void *data; -}; - -//--------------------------------------------------------------------------- - -QML_DEFINE_TYPE(QFxParticleMotion,ParticleMotion) - -/*! - \class QFxParticleMotion - \ingroup group_effects - \brief The QFxParticleMotion class is the base class for particle motion. - - This class causes the particles to remain static. -*/ - -/*! - Constructs a QFxParticleMotion with parent object \a parent. -*/ -QFxParticleMotion::QFxParticleMotion(QObject *parent) : - QObject(parent) -{ -} - -/*! - Move the \a particle to its new position. \a interval is the number of - milliseconds elapsed since it was last moved. -*/ -void QFxParticleMotion::advance(QFxParticle &particle, int interval) -{ - Q_UNUSED(particle); - Q_UNUSED(interval); -} - -/*! - The \a particle has just been created. Some motion strategies require - additional state information. This can be allocated by this function. -*/ -void QFxParticleMotion::created(QFxParticle &particle) -{ - Q_UNUSED(particle); -} - -/*! - The \a particle is about to be destroyed. Any additional memory - that has been allocated for the particle should be freed. -*/ -void QFxParticleMotion::destroy(QFxParticle &particle) -{ - Q_UNUSED(particle); -} - -/*! - \qmlclass ParticleMotionLinear - \brief The ParticleMotionLinear object moves particles linearly. - - \sa Particles -*/ - -/*! - \internal - \class QFxParticleMotionLinear - \ingroup group_effects - \brief The QFxParticleMotionLinear class moves the particles linearly. -*/ - -QML_DEFINE_TYPE(QFxParticleMotionLinear,ParticleMotionLinear) - -void QFxParticleMotionLinear::advance(QFxParticle &p, int interval) -{ - p.x += interval * p.x_velocity; - p.y += interval * p.y_velocity; -} - -/*! - \qmlclass ParticleMotionGravity - \brief The ParticleMotionGravity object moves particles towards a point. - - \sa Particles -*/ - -/*! - \internal - \class QFxParticleMotionGravity - \ingroup group_effects - \brief The QFxParticleMotionGravity class moves the particles towards a point. -*/ - -QML_DEFINE_TYPE(QFxParticleMotionGravity,ParticleMotionGravity) - -/*! - \qmlproperty int ParticleMotionGravity::xattractor - \qmlproperty int ParticleMotionGravity::yattractor - These properties hold the x and y coordinates of the point attracting the particles. -*/ - -/*! - \qmlproperty int ParticleMotionGravity::acceleration - This property holds the acceleration to apply to the particles. -*/ - -/*! - \property QFxParticleMotionGravity::xattractor - \brief the x coordinate of the point attracting the particles. -*/ - -/*! - \property QFxParticleMotionGravity::yattractor - \brief the y coordinate of the point attracting the particles. -*/ - -/*! - \property QFxParticleMotionGravity::acceleration - \brief the acceleration to apply to the particles. -*/ - -void QFxParticleMotionGravity::advance(QFxParticle &p, int interval) -{ - qreal xdiff = p.x - _xAttr; - qreal ydiff = p.y - _yAttr; - - qreal xcomp = xdiff / (xdiff + ydiff); - qreal ycomp = ydiff / (xdiff + ydiff); - - p.x_velocity += xcomp * _accel * interval; - p.y_velocity += ycomp * _accel * interval; - - p.x += interval * p.x_velocity; - p.y += interval * p.y_velocity; -} - -/*! - \qmlclass ParticleMotionWander - \brief The ParticleMotionWander object moves particles in a somewhat random fashion. - - The particles will continue roughly in the original direction, however will randomly - drift to each side. - - The code below produces an effect similar to falling snow. - - \qml -Rect { - width: 240 - height: 320 - color: "black" - - Particles { - y: 0 - width: parent.width - height: 30 - source: "star.png" - lifeSpan: 5000 - count: 50 - angle: 70 - angleDeviation: 36 - velocity: 30 - velocityDeviation: 10 - ParticleMotionWander { - xvariance: 30 - pace: 100 - } - } -} - \endqml - - \sa Particles -*/ - -/*! - \internal - \class QFxParticleMotionWander - \ingroup group_effects - \brief The QFxParticleMotionWander class moves particles in a somewhat random fashion. - - The particles will continue roughly in the original direction, however will randomly - drift to each side. -*/ - -/*! - \qmlproperty int QFxParticleMotionWander::xvariance - \qmlproperty int QFxParticleMotionWander::yvariance - - These properties set the amount to wander in the x and y directions. -*/ - -/*! - \qmlproperty int QFxParticleMotionWander::pace - This property holds how quickly the paricles will move from side to side. -*/ - -QML_DEFINE_TYPE(QFxParticleMotionWander,ParticleMotionWander) - -void QFxParticleMotionWander::advance(QFxParticle &p, int interval) -{ - if (!particles) - particles = qobject_cast(parent()); - if (particles) { - Data *d = (Data*)p.data; - if (_xvariance != 0.) { - qreal xdiff = p.x_velocity - d->x_targetV; - if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) { - d->x_var = -d->x_var; - d->x_peak = _xvariance + _xvariance * qreal(rand()) / RAND_MAX; - } - p.x_velocity += d->x_var * interval; - } - p.x += interval * p.x_velocity; - - if (_yvariance != 0.) { - qreal ydiff = p.y_velocity - d->y_targetV; - if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) { - d->y_var = -d->y_var; - d->y_peak = _yvariance + _yvariance * qreal(rand()) / RAND_MAX; - } - p.y_velocity += d->y_var * interval; - } - p.y += interval * p.y_velocity; - } -} - -void QFxParticleMotionWander::created(QFxParticle &p) -{ - if (!p.data) { - Data *d = new Data; - p.data = (void*)d; - d->x_targetV = p.x_velocity; - d->y_targetV = p.y_velocity; - d->x_peak = _xvariance; - d->y_peak = _yvariance; - d->x_var = _pace * qreal(rand()) / RAND_MAX / 1000.0; - d->y_var = _pace * qreal(rand()) / RAND_MAX / 1000.0; - } -} - -void QFxParticleMotionWander::destroy(QFxParticle &p) -{ - if (p.data) - delete (Data*)p.data; -} - -//--------------------------------------------------------------------------- -class QFxParticlesPainter : public QFxItem -{ -public: - QFxParticlesPainter(QFxParticlesPrivate *p, QFxItem* parent) - : QFxItem(parent), d(p) - { - setOptions(HasContents); - maxX = minX = maxY = minY = 0; - } - -#if defined(QFX_RENDER_QPAINTER) - void paintContents(QPainter &p); -#elif defined(QFX_RENDER_OPENGL2) - void paintGLContents(GLPainter &); -#endif - - void updateSize(); - - qreal maxX; - qreal minX; - qreal maxY; - qreal minY; - QFxParticlesPrivate* d; -}; - -//--------------------------------------------------------------------------- -class QFxParticlesPrivate : public QFxItemPrivate -{ - Q_DECLARE_PUBLIC(QFxParticles) -public: - QFxParticlesPrivate() - : count(1), lifeSpan(1000), lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300) - , angle(0), angleDev(0), velocity(0), velocityDev(0) - , addParticleTime(0), addParticleCount(0), lastAdvTime(0), stream(false), streamDelay(0) - , emitting(true), motion(0), clock(this) -#if defined(QFX_RENDER_OPENGL) - , texDirty(true) -#endif - { - } - - ~QFxParticlesPrivate() - { - } - - void init() - { - Q_Q(QFxParticles); - paintItem = new QFxParticlesPainter(this, q); - } - - void tick(int time); - void createParticle(int time); - void updateOpacity(QFxParticle &p, int age); - - QUrl url; - QPixmap image; - int count; - int lifeSpan; - int lifeSpanDev; - int fadeInDur; - int fadeOutDur; - qreal angle; - qreal angleDev; - qreal velocity; - qreal velocityDev; - int addParticleTime; - int addParticleCount; - int lastAdvTime; - bool stream; - int streamDelay; - bool emitting; - QFxParticleMotion *motion; - QFxParticlesPainter *paintItem; - - QList particles; - QTickAnimationProxy clock; - -#if defined(QFX_RENDER_OPENGL) - bool texDirty; - GLTexture tex; -#endif -}; - -//TODO: Stop the clock if no visible particles and not emitting (restart on emittingChanged) -void QFxParticlesPrivate::tick(int time) -{ - Q_Q(QFxParticles); - if (!motion) - motion = new QFxParticleMotionLinear(q); - - int oldCount = particles.count(); - int removed = 0; - int interval = time - lastAdvTime; - for (int i = 0; i < particles.count(); ) { - QFxParticle &particle = particles[i]; - int age = time - particle.birthTime; - if (age >= particle.lifeSpan) { - QFxParticle part = particles.takeAt(i); - motion->destroy(part); - ++removed; - } else { - updateOpacity(particle, age); - motion->advance(particle, interval); - ++i; - } - } - - while(removed-- && particles.count() < count && emitting) - createParticle(time); - - if (!addParticleTime) - addParticleTime = time; - - if (particles.count() < count && emitting) { - qreal perc = (lifeSpanDev <= 0)?(1.):(qreal(time - addParticleTime) / qreal(lifeSpanDev)); - int percCount = addParticleCount + (int)perc * (count - addParticleCount); - int streamWidth = -1; - if (stream){ - if (streamDelay > time){ - streamWidth = 0; - }else{ - int missed = time - streamDelay; - qreal streamWidthReal = qreal(count)/qreal(lifeSpan); - if (streamWidthReal < 1){ - streamDelay = time + (int)(1.0/streamWidthReal); - streamWidth = 1; - streamWidth += missed/streamDelay; - }else{ - streamWidth = qRound(streamWidthReal * (time-lastAdvTime)); - } - } - } - while(particles.count() < count && particles.count() < percCount && streamWidth--) - createParticle(time); - } - - lastAdvTime = time; - if (oldCount || particles.count()) { - if (q->itemParent()) - q->itemParent()->update(); - else - q->update(); - } else if (!count) { - lastAdvTime = 0; - clock.stop(); - } -} - -void QFxParticlesPrivate::createParticle(int time) -{ -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer x; -#endif - Q_Q(QFxParticles); - QFxParticle p(time); - p.x = q->x() + q->width() * qreal(rand()) / RAND_MAX - image.width()/2.0; - p.y = q->y() + q->height() * qreal(rand()) / RAND_MAX - image.height()/2.0; - p.lifeSpan = lifeSpan; - if (lifeSpanDev) - p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(rand()) / RAND_MAX); - p.fadeOutAge = p.lifeSpan - fadeOutDur; - if (fadeInDur == 0.) { - p.state= QFxParticle::Solid; - p.opacity = 1.0; - } - qreal a = angle; - if (angleDev) - a += angleDev/2 - angleDev * qreal(rand()) / RAND_MAX; - if (a > M_PI) - a = a - 2 * M_PI; - qreal v = velocity; - if (velocityDev) - v += velocityDev/2 - velocityDev * qreal(rand()) / RAND_MAX; - p.x_velocity = v * fastCos(a); - p.y_velocity = v * fastSin(a); - particles.append(p); - motion->created(particles.last()); -} - -void QFxParticlesPrivate::updateOpacity(QFxParticle &p, int age) -{ - switch (p.state) { - case QFxParticle::FadeIn: - if (age <= fadeInDur) { - p.opacity = qreal(age) / fadeInDur; - break; - } else { - p.opacity = 1.0; - p.state = QFxParticle::Solid; - // Fall through - } - case QFxParticle::Solid: - if (age <= p.fadeOutAge) { - break; - } else { - p.state = QFxParticle::FadeOut; - // Fall through - } - case QFxParticle::FadeOut: - p.opacity = qreal(p.lifeSpan - age) / fadeOutDur; - break; - } -} - -QML_DEFINE_TYPE(QFxParticles,Particles) - -/*! - \qmlclass Particles - \brief The Particles object generates and moves particles. - \inherits Item - - The particles created by this object cannot be dealt with directly, they can only be controlled through the parameters of the Particles object. The particles are all the same pixmap, specified by the user. - - The particles are painted relative to the parent of the Particles object. Moving the - Particles object will not move the particles already emitted. - - The below example creates two differently behaving particle sources. - The top one has particles falling from the top like snow, - the lower one has particles expelled up like a fountain. - - \qml -Rect { - width: 240 - height: 320 - color: "black" - Particles { - y: 0 - width: parent.width - height: 30 - source: "star.png" - lifeSpan: 5000 - count: 50 - angle: 70 - angleDeviation: 36 - velocity: 30 - velocityDeviation: 10 - ParticleMotionWander { - xvariance: 30 - pace: 100 - } - } - Particles { - y: 300 - x: 120 - width: 1 - height: 1 - source: "star.png" - lifeSpan: 5000 - count: 200 - angle: 270 - angleDeviation: 45 - velocity: 50 - velocityDeviation: 30 - ParticleMotionGravity { - yattractor: 1000 - xattractor: 0 - acceleration: 25 - } - } -} - \endqml - \image particles.gif -*/ - -/*! - \internal - \class QFxParticles - \ingroup group_effects - \brief The QFxParticles class generates and moves particles. -*/ - -QFxParticles::QFxParticles(QFxItem *parent) - : QFxItem(*(new QFxParticlesPrivate), parent) -{ - Q_D(QFxParticles); - d->init(); - setOptions(HasContents); -} - -QFxParticles::QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent) - : QFxItem(dd, parent) -{ - Q_D(QFxParticles); - d->init(); - setOptions(HasContents); -} - -QFxParticles::~QFxParticles() -{ - Q_D(QFxParticles); - if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); -} - -/*! - \qmlproperty string Particles::src - This property holds the URL of the particle image. -*/ - -/*! - \property QFxParticles::source - \brief the URL of the particle image. -*/ -QUrl QFxParticles::source() const -{ - Q_D(const QFxParticles); - return d->url; -} - -void QFxParticles::imageLoaded() -{ - Q_D(QFxParticles); - d->image = QFxPixmap(d->url); -#if defined(QFX_RENDER_OPENGL) - d->texDirty = true; - d->tex.clear(); -#endif - update(); -} - -void QFxParticles::setSource(const QUrl &name) -{ - Q_D(QFxParticles); - - if (name == d->url) - return; - - if (!d->url.isEmpty()) - QFxPixmap::cancelGet(d->url, this); - if (name.isEmpty()) { - d->url = name; - d->image = QPixmap(); -#if defined(QFX_RENDER_OPENGL) - d->texDirty = true; - d->tex.clear(); -#endif - update(); - } else { - d->url = name; - Q_ASSERT(!name.isRelative()); - QFxPixmap::get(qmlEngine(this), d->url, this, SLOT(imageLoaded())); - } -} - -/*! - \qmlproperty int Particles::count - This property holds the target number of particles -*/ - -/*! - \property QFxParticles::count - \brief the target number of particles -*/ -int QFxParticles::count() const -{ - Q_D(const QFxParticles); - return d->count; -} - -void QFxParticles::setCount(int cnt) -{ - Q_D(QFxParticles); - if (cnt != d->count) { - if (!d->count && d->clock.state() != QAbstractAnimation::Running) - d->clock.start(); // infinity?? - d->count = cnt; - d->addParticleTime = 0; - d->addParticleCount = d->particles.count(); - update(); - } -} - -/*! - \qmlproperty int Particles::lifeSpan - \qmlproperty int Particles::lifeSpanDeviation - - These properties describe the life span of each particle. - - The default lifespan for a particle is 1000ms. - - lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For - example, the following creates particles whose lifeSpan will vary - from 150ms to 250ms: - - \qml -Particles { - source: "star.png" - lifeSpan: 200 - lifeSpanDeviation: 100 -} - \endqml -*/ - -/*! - \property QFxParticles::lifeSpan - \brief the life span of each particle. - - Default value is 1000ms. - - \sa QFxParticles::lifeSpanDeviation -*/ -int QFxParticles::lifeSpan() const -{ - Q_D(const QFxParticles); - return d->lifeSpan; -} - -void QFxParticles::setLifeSpan(int ls) -{ - Q_D(QFxParticles); - d->lifeSpan = ls; -} - -/*! - \property QFxParticles::lifeSpanDeviation - \brief the maximum possible deviation from the set lifeSpan. - - Randomly varies the lifeSpan up to the specified variation. For - example, the following creates particles whose lifeSpan will vary - from 150ms to 250ms: - -\qml -Particles { - source: "star.png" - lifeSpan: 200 - lifeSpanDeviation: 100 -} -\endqml - - \sa QFxParticles::lifeSpan -*/ -int QFxParticles::lifeSpanDeviation() const -{ - Q_D(const QFxParticles); - return d->lifeSpanDev; -} - -void QFxParticles::setLifeSpanDeviation(int dev) -{ - Q_D(QFxParticles); - d->lifeSpanDev = dev; -} - -/*! - \qmlproperty int Particles::fadeInDuration - \qmlproperty int Particles::fadeOutDuration - These properties hold the time taken to fade the particles in and out. - - By default fade in is 200ms and fade out is 300ms. -*/ - -/*! - \property QFxParticles::fadeInDuration - \brief the time taken to fade in the particles. - - Default value is 200ms. -*/ -int QFxParticles::fadeInDuration() const -{ - Q_D(const QFxParticles); - return d->fadeInDur; -} - -void QFxParticles::setFadeInDuration(int dur) -{ - Q_D(QFxParticles); - if (dur >= 0.0) - d->fadeInDur = dur; -} - -/*! - \property QFxParticles::fadeOutDuration - \brief the time taken to fade out the particles. - - Default value is 300ms. -*/ -int QFxParticles::fadeOutDuration() const -{ - Q_D(const QFxParticles); - return d->fadeOutDur; -} - -void QFxParticles::setFadeOutDuration(int dur) -{ - Q_D(QFxParticles); - if (dur >= 0.0) - d->fadeOutDur = dur; -} - -/*! - \qmlproperty real Particles::angle - \qmlproperty real Particles::angleDeviation - - These properties control particle direction. - - angleDeviation randomly varies the direction up to the specified variation. For - example, the following creates particles whose initial direction will - vary from 15 degrees to 105 degrees: - - \qml -Particles { - source: "star.png" - angle: 60 - angleDeviation: 90 -} - \endqml -*/ - -/*! - \property QFxParticles::angle - \brief the initial angle of direction. - - \sa QFxParticles::angleDeviation -*/ -qreal QFxParticles::angle() const -{ - Q_D(const QFxParticles); - return d->angle * 180.0 / M_PI; -} - -void QFxParticles::setAngle(qreal angle) -{ - Q_D(QFxParticles); - d->angle = angle * M_PI / 180.0; -} - -/*! - \property QFxParticles::angleDeviation - \brief the maximum possible deviation from the set angle. - - Randomly varies the direction up to the specified variation. For - example, the following creates particles whose initial direction will - vary from 15 degrees to 105 degrees: - -\qml -Particles { - source: "star.png" - angle: 60 - angleDeviation: 90 -} -\endqml - - \sa QFxParticles::angle -*/ -qreal QFxParticles::angleDeviation() const -{ - Q_D(const QFxParticles); - return d->angleDev * 180.0 / M_PI; -} - -void QFxParticles::setAngleDeviation(qreal dev) -{ - Q_D(QFxParticles); - d->angleDev = dev * M_PI / 180.0;; -} - -/*! - \qmlproperty real Particles::velocity - \qmlproperty real Particles::velocityDeviation - - These properties control the velocity of the particles. - - velocityDeviation randomly varies the velocity up to the specified variation. For - example, the following creates particles whose initial velocity will - vary from 40 to 60. - - \qml -Particles { - source: "star.png" - velocity: 50 - velocityDeviation: 20 -} - \endqml -*/ - -/*! - \property QFxParticles::velocity - \brief the initial velocity of the particles. - - \sa QFxParticles::velocityDeviation -*/ -qreal QFxParticles::velocity() const -{ - Q_D(const QFxParticles); - return d->velocity * 1000.0; -} - -void QFxParticles::setVelocity(qreal velocity) -{ - Q_D(QFxParticles); - d->velocity = velocity / 1000.0; -} - -/*! - \property QFxParticles::velocityDeviation - \brief the maximum possible deviation from the set velocity. - - Randomly varies the velocity up to the specified variation. For - example, the following creates particles whose initial velocity will - vary from 40 to 60. - -\qml -Particles { - source: "star.png" - velocity: 50 - velocityDeviation: 20 -} -\endqml - - \sa QFxParticles::velocity -*/ -qreal QFxParticles::velocityDeviation() const -{ - Q_D(const QFxParticles); - return d->velocityDev * 1000.0; -} - -void QFxParticles::setVelocityDeviation(qreal velocity) -{ - Q_D(QFxParticles); - d->velocityDev = velocity / 1000.0; -} - -/*! - \qmlproperty bool Particles::streamIn - This property determines whether the particles stream in at a constant rate - - When stream is set to true the particles will stream in at a constant rate. - Otherwise the particles will appear as a clump. Note that this only affects the - start of the particle effect, variables such as lifespan deviation can cause the - particles to unclump over time. -*/ -/*! - \property QFxParticles::streamIn - \brief determines whether the particles stream in at a constant rate - - When stream is set to true the particles will stream in at a constant rate. - Otherwise the particles will appear as a clump. Note that this only affects the - start of the particle effect, variables such as lifespan deviation can cause the - -*/ -//The name may need a rethink -bool QFxParticles::streamIn() const -{ - Q_D(const QFxParticles); - return d->stream; -} - -void QFxParticles::setStreamIn(bool b) -{ - Q_D(QFxParticles); - d->stream = b; -} - -/*! - \qmlproperty bool Particles::emitting - This property determines whether new particles are created - - If emitting is set to false no new particles will be created. This means that - when a particle reaches the end of its lifespan it is not replaced. This - property can be used to turn particles on and off with a more natural look. - - The default setting is true. Note that if it initialized to false no particles - will be produced until it is set to true. -*/ -/*! - \property QFxParticles::emitting - If emitting is set to false no new particles will be created. This means that - when a particle reaches the end of its lifespan it is not replaced. This - property can be used to turn particles on and off with a more natural look. - - The default setting is true. Note that if it initialized to false no particles - will be produced until it is set to true. -*/ -bool QFxParticles::emitting() const -{ - Q_D(const QFxParticles); - return d->emitting; -} - -void QFxParticles::setEmitting(bool r) -{ - Q_D(QFxParticles); - d->emitting = r; -} -/*! - \qmlproperty ParticleMotion Particles::motion - This property sets the type of motion to apply to the particles. - - When a particle is created it will have an initial direction and velocity. - The motion of the particle during its lifeSpan is then influenced by the - motion property. - - Default motion is ParticleMotionLinear. -*/ - -/*! - \property QFxParticles::motion - \brief sets the type of motion to apply to the particles. - - When a particle is created it will have an initial direction and velocity. - The motion of the particle during its lifeSpan is then influenced by the - motion property. - - Default motion is QFxParticleMotionLinear. -*/ -QFxParticleMotion *QFxParticles::motion() const -{ - Q_D(const QFxParticles); - return d->motion; -} - -void QFxParticles::setMotion(QFxParticleMotion *motion) -{ - Q_D(QFxParticles); - d->motion = motion; -} - -void QFxParticles::dump(int depth) -{ - Q_D(QFxParticles); - QByteArray ba(depth * 4, ' '); - qWarning() << ba.constData() << "URL:" << d->url << "Count:" << d->count; - QFxItem::dump(depth); -} - -QString QFxParticles::propertyInfo() const -{ - Q_D(const QFxParticles); - return d->url.toString(); -} - -void QFxParticlesPainter::updateSize(){ - setX(-500); - setY(-500); - setWidth(1000); - setHeight(1000); - return ; - const int parentX = parent()->x(); - const int parentY = parent()->y(); - //Have to use statistical approach to needed size as arbitrary particle - //motions make it impossible to calculate. - //max/min vars stored to give a never shrinking rect - for (int i = 0; i < d->particles.count(); ++i) { - const QFxParticle &particle = d->particles.at(i); - if(particle.x > maxX) - maxX = particle.x; - if(particle.x < minX) - minX = particle.x; - if(particle.y > maxY) - maxY = particle.y; - if(particle.y < minY) - minY = particle.y; - } - - int myWidth = (int)(maxX-minX+0.5)+d->image.width(); - int myX = (int)(minX - parentX); - int myHeight = (int)(maxY-minY+0.5)+d->image.height(); - int myY = (int)(minY - parentY); - setWidth(myWidth); - setHeight(myHeight); - setX(myX); - setY(myY); -} - -#if defined(QFX_RENDER_QPAINTER) -void QFxParticles::paintContents(QPainter &p) -{ - Q_UNUSED(p); - //painting is done by the ParticlesPainter, so it can have the right size -} - -void QFxParticlesPainter::paintContents(QPainter &p) -{ - if (d->image.isNull()) - return; - - updateSize(); - const int myX = x() + parent()->x(); - const int myY = y() + parent()->y(); - - for (int i = 0; i < d->particles.count(); ++i) { - const QFxParticle &particle = d->particles.at(i); - p.setOpacity(particle.opacity); - p.drawPixmap(particle.x - myX, particle.y - myY, d->image); - } - update();//Should I need this? (GV does) -} -#elif defined(QFX_RENDER_OPENGL2) -void QFxParticles::paintGLContents(GLPainter &) -{ - //painting is done by the ParticlesPainter, so it can have the right size -} - -void QFxParticlesPainter::paintGLContents(GLPainter &p) -{ - - if (d->image.isNull()) - return; - - updateSize(); - - if (d->texDirty && !d->image.isNull()) { - d->tex.setImage(d->image.toImage()); - d->tex.setHorizontalWrap(GLTexture::Repeat); - d->tex.setVerticalWrap(GLTexture::Repeat); - } - d->texDirty = false; - - SingleTextureOpacityShader *shader = basicShaders()->singleTextureOpacity(); - shader->enable(); - shader->setTransform(p.activeTransform); - - glBindTexture(GL_TEXTURE_2D, d->tex.texture()); - - const int myX = (int)(x() + parent()->x()); - const int myY = (int)(y() + parent()->y()); - float widthV = d->image.width(); - float heightV = d->image.height(); - for (int i = 0; i < d->particles.count(); ++i) { - const QFxParticle &particle = d->particles.at(i); - float left = particle.x - myX; - float right = particle.x - myX + widthV; - float top = particle.y - myY; - float bottom = particle.y - myY + heightV; - - GLfloat vertices[] = { left, bottom, - right, bottom, - left, top, - right, top }; - - GLfloat texVertices[] = { 0, 0, - 1, 0, - 0, 1, - 1, 1 }; - - shader->setAttributeArray(SingleTextureShader::Vertices, vertices, 2); - shader->setAttributeArray(SingleTextureShader::TextureCoords, texVertices, 2); - shader->setOpacity(particle.opacity * p.activeOpacity); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - - shader->disableAttributeArray(SingleTextureShader::Vertices); - shader->disableAttributeArray(SingleTextureShader::TextureCoords); -} -#endif - -void QFxParticles::componentComplete() -{ - Q_D(QFxParticles); - QFxItem::componentComplete(); - if (d->count) - d->clock.start(); // infinity?? - if (d->lifeSpanDev > d->lifeSpan) - d->lifeSpanDev = d->lifeSpan; -} - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h deleted file mode 100644 index cfaffa7..0000000 --- a/src/declarative/fx/qfxparticles.h +++ /dev/null @@ -1,241 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (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 either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** 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.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QFXPARTICLES_H -#define QFXPARTICLES_H - -#include - -#if defined(QFX_RENDER_OPENGL) -#include "gltexture.h" -#endif - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QFxParticle; -class QFxParticles; -class Q_DECLARATIVE_EXPORT QFxParticleMotion : public QObject -{ - Q_OBJECT -public: - QFxParticleMotion(QObject *parent=0); - - virtual void advance(QFxParticle &, int interval); - virtual void created(QFxParticle &); - virtual void destroy(QFxParticle &); -}; - -class Q_DECLARATIVE_EXPORT QFxParticleMotionLinear : public QFxParticleMotion -{ - Q_OBJECT -public: - QFxParticleMotionLinear(QObject *parent=0) - : QFxParticleMotion(parent) {} - - virtual void advance(QFxParticle &, int interval); -}; - -class Q_DECLARATIVE_EXPORT QFxParticleMotionGravity : public QFxParticleMotion -{ - 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) -public: - QFxParticleMotionGravity(QObject *parent=0) - : QFxParticleMotion(parent), _xAttr(0), _yAttr(0), _accel(0.00005) {} - - int xAttractor() const { return _xAttr; } - void setXAttractor(int x) { _xAttr = x; } - - int yAttractor() const { return _yAttr; } - void setYAttractor(int y) { _yAttr = y; } - - int acceleration() const { return int(_accel * 1000000); } - void setAcceleration(int accel) { _accel = qreal(accel)/1000000.0; } - - virtual void advance(QFxParticle &, int interval); - -private: - int _xAttr; - int _yAttr; - qreal _accel; -}; - -class Q_DECLARATIVE_EXPORT QFxParticleMotionWander : public QFxParticleMotion -{ - Q_OBJECT -public: - QFxParticleMotionWander() - : QFxParticleMotion(), particles(0), _xvariance(0), _yvariance(0) {} - - virtual void advance(QFxParticle &, int interval); - virtual void created(QFxParticle &); - virtual void destroy(QFxParticle &); - - struct Data { - qreal x_targetV; - qreal y_targetV; - qreal x_peak; - qreal y_peak; - qreal x_var; - 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(int yvariance READ yVariance WRITE setYVariance) - int yVariance() const { return int(_yvariance * 1000); } - void setYVariance(int var) { _yvariance = var / 1000.0; } - - Q_PROPERTY(int pace READ pace WRITE setPace) - int pace() const { return int(_pace * 1000); } - void setPace(int pace) { _pace = pace / 1000.0; } - -private: - QFxParticles *particles; - qreal _xvariance; - qreal _yvariance; - qreal _pace; -}; - -class QFxParticlesPrivate; -class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem -{ - Q_OBJECT - - Q_PROPERTY(QUrl source READ source WRITE setSource) - Q_PROPERTY(int count READ count WRITE setCount) - Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan) - Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation) - Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration) - Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration) - Q_PROPERTY(qreal angle READ angle WRITE setAngle) - Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation) - Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity) - Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation) - Q_PROPERTY(bool streamIn READ streamIn WRITE setStreamIn) - Q_PROPERTY(bool emitting READ emitting WRITE setEmitting) - Q_PROPERTY(QFxParticleMotion *motion READ motion WRITE setMotion) - Q_CLASSINFO("DefaultProperty", "motion") - -public: - QFxParticles(QFxItem *parent=0); - ~QFxParticles(); - - QUrl source() const; - void setSource(const QUrl &); - - int count() const; - void setCount(int cnt); - - int lifeSpan() const; - void setLifeSpan(int); - - int lifeSpanDeviation() const; - void setLifeSpanDeviation(int); - - int fadeInDuration() const; - void setFadeInDuration(int); - - int fadeOutDuration() const; - void setFadeOutDuration(int); - - qreal angle() const; - void setAngle(qreal); - - qreal angleDeviation() const; - void setAngleDeviation(qreal); - - qreal velocity() const; - void setVelocity(qreal); - - qreal velocityDeviation() const; - void setVelocityDeviation(qreal); - - bool streamIn() const; - void setStreamIn(bool); - - bool emitting() const; - void setEmitting(bool); - - QFxParticleMotion *motion() const; - void setMotion(QFxParticleMotion *); - - virtual void dump(int depth); - virtual QString propertyInfo() const; - -#if defined(QFX_RENDER_QPAINTER) - void paintContents(QPainter &p); -#elif defined(QFX_RENDER_OPENGL2) - void paintGLContents(GLPainter &); -#endif - -protected: - virtual void componentComplete(); - QFxParticles(QFxParticlesPrivate &dd, QFxItem *parent); - -private Q_SLOTS: - void imageLoaded(); - -private: - Q_DISABLE_COPY(QFxParticles) - Q_DECLARE_PRIVATE(QFxParticles) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QFxParticleMotion) -QML_DECLARE_TYPE(QFxParticleMotionLinear) -QML_DECLARE_TYPE(QFxParticleMotionGravity) -QML_DECLARE_TYPE(QFxParticleMotionWander) -QML_DECLARE_TYPE(QFxParticles) - -QT_END_HEADER - -#endif -- cgit v0.12 From 04c4735798cb7ed811c034c3e097dbbf53f28c9e Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 11:07:32 +1000 Subject: Fix animation crash. --- src/declarative/util/qmlanimation.cpp | 4 ++++ .../declarative/animations/data/badproperty1.qml | 22 ++++++++++++++++++++++ .../declarative/animations/data/dotproperty.qml | 22 ++++++++++++++++++++++ .../auto/declarative/animations/tst_animations.cpp | 15 +++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 tests/auto/declarative/animations/data/badproperty1.qml create mode 100644 tests/auto/declarative/animations/data/dotproperty.qml diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index da26bdd..c4eabfe 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1072,6 +1072,8 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, for (int jj = 0; jj < props.count(); ++jj) { Action myAction; myAction.property = d->createProperty(obj, props.at(jj)); + if (!myAction.property.isValid()) + continue; myAction.toValue = d->value; data->actions << myAction; } @@ -1895,6 +1897,8 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, for (int jj = 0; jj < props.count(); ++jj) { Action myAction; myAction.property = d->createProperty(obj, props.at(jj)); + if (!myAction.property.isValid()) + continue; if (d->fromIsDefined) { d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); diff --git a/tests/auto/declarative/animations/data/badproperty1.qml b/tests/auto/declarative/animations/data/badproperty1.qml new file mode 100644 index 0000000..dc35775 --- /dev/null +++ b/tests/auto/declarative/animations/data/badproperty1.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; pen.color: "blue" } + } + transitions: Transition { + ColorAnimation { target: MyRect; to: "red"; properties: "pen.colr"; duration: 1000 } + } +} diff --git a/tests/auto/declarative/animations/data/dotproperty.qml b/tests/auto/declarative/animations/data/dotproperty.qml new file mode 100644 index 0000000..2cfcefe --- /dev/null +++ b/tests/auto/declarative/animations/data/dotproperty.qml @@ -0,0 +1,22 @@ +Rect { + id: Wrapper + width: 240 + height: 320 + Rect { + id: MyRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseRegion { + anchors.fill: parent + onClicked: if (Wrapper.state == "state1") Wrapper.state = ""; else Wrapper.state = "state1"; + } + } + states: State { + name: "state1" + SetProperties { target: MyRect; pen.color: "blue" } + } + transitions: Transition { + ColorAnimation { properties: "pen.color"; duration: 1000 } + } +} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index 1895cef2..a493454 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -12,6 +12,7 @@ public: private slots: void badTypes(); + void badProperties(); //void mixedTypes(); }; @@ -51,6 +52,20 @@ void tst_animations::badTypes() } } +void tst_animations::badProperties() +{ + //don't crash (should be runtime error) + { + QFxView *view = new QFxView; + view->setUrl(QUrl("file://" SRCDIR "/data/badproperty1.qml")); + + view->execute(); + qApp->processEvents(); + + delete view; + } +} + /*//test animating mixed types with property animation //for example, int + real; color + real; etc void tst_animations::mixedTypes() -- cgit v0.12 From 6863162d579310e66694832ce1c1468cd1b7b169 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 11:25:46 +1000 Subject: Make compile. --- src/declarative/extra/qfxparticles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 4cd34c4..62fe4c1 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qfxitem_p.h" +#include "private/qfxitem_p.h" #if defined(QFX_RENDER_OPENGL) #include "gltexture.h" #endif -- cgit v0.12