From 3c6648385e8637536292c1351ef0d52708bd07d2 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 12:55:10 +1000 Subject: Support animating dot properties. Make sure we can handle things like PropertyAnimation { property: "anchors.leftMargin" } --- src/declarative/qml/qmlmetaproperty.cpp | 30 +++++++++++++++++++ src/declarative/qml/qmlmetaproperty.h | 1 + src/declarative/util/qmlanimation.cpp | 48 +++++++++++++++++++++++-------- src/declarative/util/qmlanimation_p.h | 2 ++ src/declarative/util/qmlsetproperties.cpp | 37 +++++++----------------- src/declarative/util/qmlstate.cpp | 4 ++- src/declarative/util/qmlstate.h | 3 ++ src/declarative/util/qmlstate_p.h | 4 +++ 8 files changed, 89 insertions(+), 40 deletions(-) diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 30e818b..682b8ad 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -1035,4 +1035,34 @@ QMetaMethod QmlMetaProperty::method() const return d->signal; } +/*! + \internal + + Creates a QmlMetaProperty for the property \a name of \a obj. Unlike + the QmlMetaProperty(QObject*, QString) constructor, this static function + will correctly handle dot properties. +*/ +QmlMetaProperty QmlMetaProperty::createProperty(QObject *obj, const QString &name) +{ + QStringList path = name.split('.'); + + QObject *object = obj; + + for (int jj = 0; jj < path.count() - 1; ++jj) { + const QString &pathName = path.at(jj); + QmlMetaProperty prop(object, pathName); + QObject *objVal = QmlMetaType::toQObject(prop.read()); + if (!objVal) + return QmlMetaProperty(); + object = objVal; + } + + const QString &propName = path.last(); + QmlMetaProperty prop(object, propName); + if (!prop.isValid()) + return QmlMetaProperty(); + else + return prop; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index ce2fbcf..6c28a86 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -127,6 +127,7 @@ public: QmlBindableValue *setBinding(QmlBindableValue *) const; static int findSignal(const QObject *, const char *); + static QmlMetaProperty createProperty(QObject *, const QString &); int coreIndex() const; private: diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4ee5545..da26bdd 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -45,6 +45,7 @@ #include "qfile.h" #include "qmlpropertyvaluesource.h" #include "qml.h" +#include "qmlinfo.h" #include "qmlanimation_p.h" #include "qmlbehaviour.h" #include @@ -225,6 +226,21 @@ void QmlAbstractAnimationPrivate::commence() } } +//### make static? +QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str) +{ + Q_Q(QmlAbstractAnimation); + QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str); + if (!prop.isValid()) { + qmlInfo(q) << "Cannot animate non-existant property" << str; + return QmlMetaProperty(); + } else if (!prop.isWritable()) { + qmlInfo(q) << "Cannot animate read-only property" << str; + return QmlMetaProperty(); + } + return prop; +} + void QmlAbstractAnimation::setRunning(bool r) { Q_D(QmlAbstractAnimation); @@ -434,7 +450,7 @@ void QmlAbstractAnimation::setTarget(QObject *o) d->target = o; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = QmlMetaProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName); } else { d->userProperty.invalidate(); } @@ -463,7 +479,7 @@ void QmlAbstractAnimation::setProperty(const QString &n) d->propertyName = n; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = QmlMetaProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName); } else { d->userProperty.invalidate(); } @@ -1031,10 +1047,14 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QObject *obj = action.property.object(); QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && + (!target() || target() == obj || (!same && target() == sObj))) { objs.insert(obj); Action myAction = action; @@ -1051,7 +1071,7 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QObject *obj = target(); for (int jj = 0; jj < props.count(); ++jj) { Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); + myAction.property = d->createProperty(obj, props.at(jj)); myAction.toValue = d->value; data->actions << myAction; } @@ -1841,10 +1861,14 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QObject *obj = action.property.object(); QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && + (!target() || target() == obj || (!same && target() == sObj))) { objs.insert(obj); Action myAction = action; @@ -1870,7 +1894,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QObject *obj = target(); for (int jj = 0; jj < props.count(); ++jj) { Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); + myAction.property = d->createProperty(obj, props.at(jj)); if (d->fromIsDefined) { d->convertVariant(d->from, (QVariant::Type)(d->interpolatorType ? d->interpolatorType : myAction.property.propertyType())); diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index da5ed97..b801d01 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -193,6 +193,8 @@ public: QmlMetaProperty property; QmlAnimationGroup *group; + + QmlMetaProperty createProperty(QObject *obj, const QString &str); }; class QmlPauseAnimationPrivate : public QmlAbstractAnimationPrivate diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 240e37b..7ceed5e 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -282,39 +282,19 @@ void QmlSetProperties::setRestoreEntryValues(bool v) d->restore = v; } -QmlMetaProperty -QmlSetPropertiesPrivate::property(const QByteArray &property) +QmlMetaProperty +QmlSetPropertiesPrivate::property(const QByteArray &property) { Q_Q(QmlSetProperties); - QList path = property.split('.'); - - QObject *obj = this->object; - - for (int jj = 0; jj < path.count() - 1; ++jj) { - const QByteArray &pathName = path.at(jj); - QmlMetaProperty prop(obj, QLatin1String(pathName)); - QObject *objVal = QmlMetaType::toQObject(prop.read()); - if (!objVal) { - qmlInfo(q) << obj->metaObject()->className() - << "has no object property named" << pathName; - return QmlMetaProperty(); - } - obj = objVal; - } - - const QByteArray &name = path.last(); - QmlMetaProperty prop(obj, QLatin1String(name)); + QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromLatin1(property)); if (!prop.isValid()) { - qmlInfo(q) << obj->metaObject()->className() - << "has no property named" << name; + qmlInfo(q) << "Cannot assign to non-existant property" << property; return QmlMetaProperty(); } else if (!prop.isWritable()) { - qmlInfo(q) << obj->metaObject()->className() - << name << "is not writable, and cannot be set."; + qmlInfo(q) << "Cannot assign to read-only property" << property; return QmlMetaProperty(); - } else { - return prop; } + return prop; } QmlSetProperties::ActionList QmlSetProperties::actions() @@ -336,6 +316,8 @@ QmlSetProperties::ActionList QmlSetProperties::actions() a.property = prop; a.fromValue = a.property.read(); a.toValue = d->properties.at(ii).second; + a.specifiedObject = d->object; + a.specifiedProperty = QString::fromLatin1(property); list << a; } @@ -351,6 +333,8 @@ QmlSetProperties::ActionList QmlSetProperties::actions() a.restore = restoreEntryValues(); a.property = prop; a.fromValue = a.property.read(); + a.specifiedObject = d->object; + a.specifiedProperty = QString::fromLatin1(property); if (d->isExplicit) { a.toValue = d->expressions.at(ii).second->value(); @@ -361,7 +345,6 @@ QmlSetProperties::ActionList QmlSetProperties::actions() list << a; } - } return list; diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index fe215e7..8ac1b33 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -Action::Action() : restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0) +Action::Action() : restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0), specifiedObject(0) { } @@ -403,6 +403,8 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever a.fromValue = cur; a.toValue = d->revertList.at(ii).value; a.toBinding = d->revertList.at(ii).binding; + a.specifiedObject = d->revertList.at(ii).specifiedObject; //### + a.specifiedProperty = d->revertList.at(ii).specifiedProperty; applyList << a; // Store these special reverts in the reverting list d->reverting << d->revertList.at(ii).property; diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index e9a173c..b219b99 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -71,6 +71,9 @@ public: QmlBindableValue *toBinding; ActionEvent *event; + QObject *specifiedObject; + QString specifiedProperty; + void deleteFromBinding(); }; diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index b4ec476..2f6ff42 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -55,6 +55,8 @@ public: SimpleAction(const Action &a, State state = StartState) { property = a.property; + specifiedObject = a.specifiedObject; + specifiedProperty = a.specifiedProperty; if (state == StartState) { value = a.fromValue; binding = property.binding(); @@ -67,6 +69,8 @@ public: QmlMetaProperty property; QVariant value; QmlBindableValue *binding; + QObject *specifiedObject; + QString specifiedProperty; }; class QmlStatePrivate : public QObjectPrivate -- cgit v0.12 From 518cbf7d241cdbd2a4414df289f4bc91e7583edc Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 13:13:55 +1000 Subject: Change geometry-related properties from int to qreal. Most related properties were already qreal. --- src/declarative/fx/qfxanchors.cpp | 25 +++++++------ src/declarative/fx/qfxanchors.h | 45 +++++++++++------------- src/declarative/fx/qfxanchors_p.h | 14 ++++---- src/declarative/fx/qfxitem.cpp | 74 ++++++++++++++++++++------------------- src/declarative/fx/qfxitem.h | 26 +++++++------- src/declarative/fx/qfxitem_p.h | 2 +- 6 files changed, 92 insertions(+), 94 deletions(-) diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 84ccadf..9a5c516 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -51,7 +51,6 @@ QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxAnchors,Anchors) //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? -//TODO: baseline support //TODO: support non-parent, non-sibling (need to find lowest common ancestor) //### const item? @@ -760,13 +759,13 @@ void QFxAnchors::resetHorizontalCenter() d->updateHorizontalAnchors(); } -int QFxAnchors::leftMargin() const +qreal QFxAnchors::leftMargin() const { Q_D(const QFxAnchors); return d->leftMargin; } -void QFxAnchors::setLeftMargin(int offset) +void QFxAnchors::setLeftMargin(qreal offset) { Q_D(QFxAnchors); if (d->leftMargin == offset) @@ -776,13 +775,13 @@ void QFxAnchors::setLeftMargin(int offset) emit leftMarginChanged(); } -int QFxAnchors::rightMargin() const +qreal QFxAnchors::rightMargin() const { Q_D(const QFxAnchors); return d->rightMargin; } -void QFxAnchors::setRightMargin(int offset) +void QFxAnchors::setRightMargin(qreal offset) { Q_D(QFxAnchors); if (d->rightMargin == offset) @@ -792,13 +791,13 @@ void QFxAnchors::setRightMargin(int offset) emit rightMarginChanged(); } -int QFxAnchors::horizontalCenterOffset() const +qreal QFxAnchors::horizontalCenterOffset() const { Q_D(const QFxAnchors); return d->hCenterOffset; } -void QFxAnchors::setHorizontalCenterOffset(int offset) +void QFxAnchors::setHorizontalCenterOffset(qreal offset) { Q_D(QFxAnchors); if (d->hCenterOffset == offset) @@ -808,13 +807,13 @@ void QFxAnchors::setHorizontalCenterOffset(int offset) emit horizontalCenterOffsetChanged(); } -int QFxAnchors::topMargin() const +qreal QFxAnchors::topMargin() const { Q_D(const QFxAnchors); return d->topMargin; } -void QFxAnchors::setTopMargin(int offset) +void QFxAnchors::setTopMargin(qreal offset) { Q_D(QFxAnchors); if (d->topMargin == offset) @@ -824,13 +823,13 @@ void QFxAnchors::setTopMargin(int offset) emit topMarginChanged(); } -int QFxAnchors::bottomMargin() const +qreal QFxAnchors::bottomMargin() const { Q_D(const QFxAnchors); return d->bottomMargin; } -void QFxAnchors::setBottomMargin(int offset) +void QFxAnchors::setBottomMargin(qreal offset) { Q_D(QFxAnchors); if (d->bottomMargin == offset) @@ -840,13 +839,13 @@ void QFxAnchors::setBottomMargin(int offset) emit bottomMarginChanged(); } -int QFxAnchors::verticalCenterOffset() const +qreal QFxAnchors::verticalCenterOffset() const { Q_D(const QFxAnchors); return d->vCenterOffset; } -void QFxAnchors::setVerticalCenterOffset(int offset) +void QFxAnchors::setVerticalCenterOffset(qreal offset) { Q_D(QFxAnchors); if (d->vCenterOffset == offset) diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 206a05c..94c22a6 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -46,15 +46,13 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QFxItem; -class QFxAnchorsPrivate; +class QFxItem; class QFxAnchorLine { public: @@ -93,12 +91,12 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom) Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) Q_PROPERTY(QFxAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline) - Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) - Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) - Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) - Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) - Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) - Q_PROPERTY(int verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) + Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) + Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) + Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) + Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) + Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) + Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) Q_PROPERTY(QFxItem *fill READ fill WRITE setFill) Q_PROPERTY(QFxItem *centeredIn READ centeredIn WRITE setCenteredIn) @@ -121,7 +119,7 @@ public: QFxAnchorLine left() const; void setLeft(const QFxAnchorLine &edge); - Q_INVOKABLE void resetLeft(); //### temporarily invokable for testing + void resetLeft(); QFxAnchorLine right() const; void setRight(const QFxAnchorLine &edge); @@ -147,23 +145,23 @@ public: void setBaseline(const QFxAnchorLine &edge); void resetBaseline(); - int leftMargin() const; - void setLeftMargin(int); + qreal leftMargin() const; + void setLeftMargin(qreal); - int rightMargin() const; - void setRightMargin(int); + qreal rightMargin() const; + void setRightMargin(qreal); - int horizontalCenterOffset() const; - void setHorizontalCenterOffset(int); + qreal horizontalCenterOffset() const; + void setHorizontalCenterOffset(qreal); - int topMargin() const; - void setTopMargin(int); + qreal topMargin() const; + void setTopMargin(qreal); - int bottomMargin() const; - void setBottomMargin(int); + qreal bottomMargin() const; + void setBottomMargin(qreal); - int verticalCenterOffset() const; - void setVerticalCenterOffset(int); + qreal verticalCenterOffset() const; + void setVerticalCenterOffset(qreal); QFxItem *fill() const; void setFill(QFxItem *); @@ -188,11 +186,10 @@ private: Q_DISABLE_COPY(QFxAnchors) Q_DECLARE_PRIVATE(QFxAnchors) }; - QML_DECLARE_TYPE(QFxAnchors) - QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index 9ff6869..a7c904b 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -56,8 +56,8 @@ #include "qfxanchors.h" #include "private/qobject_p.h" - QT_BEGIN_NAMESPACE + class QFxAnchorsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QFxAnchors) @@ -119,12 +119,12 @@ public: QFxAnchorLine hCenter; QFxAnchorLine baseline; - int leftMargin; - int rightMargin; - int topMargin; - int bottomMargin; - int vCenterOffset; - int hCenterOffset; + qreal leftMargin; + qreal rightMargin; + qreal topMargin; + qreal bottomMargin; + qreal vCenterOffset; + qreal hCenterOffset; }; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 73786a8..3764e3d 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -65,10 +65,10 @@ #include #include - QT_BEGIN_NAMESPACE -#ifndef INT_MAX -#define INT_MAX 2147483647 + +#ifndef FLT_MAX +#define FLT_MAX 1E+37 #endif QML_DEFINE_NOCREATE_TYPE(QFxContents) @@ -123,7 +123,7 @@ QML_DEFINE_NOCREATE_TYPE(QSimpleCanvasFilter) */ -QFxContents::QFxContents() : _height(0), _width(0) +QFxContents::QFxContents() : m_height(0), m_width(0) { } @@ -131,70 +131,71 @@ QFxContents::QFxContents() : _height(0), _width(0) \property QFxContents::height \brief The height of the contents. */ -int QFxContents::height() const +qreal QFxContents::height() const { - return _height; + return m_height; } /*! \property QFxContents::width \brief The width of the contents. */ -int QFxContents::width() const +qreal QFxContents::width() const { - return _width; + return m_width; } //TODO: optimization: only check sender(), if there is one void QFxContents::calcHeight() { - int oldheight = _height; + qreal oldheight = m_height; - int top = INT_MAX; - int bottom = 0; + qreal top = FLT_MAX; + qreal bottom = 0; - const QList &children = _item->QSimpleCanvasItem::children(); + const QList &children = m_item->QSimpleCanvasItem::children(); for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); - int y = int(child->y()); + qreal y = child->y(); if (y + child->height() > bottom) bottom = y + child->height(); if (y < top) top = y; } - _height = bottom - top; + m_height = qMax(bottom - top, qreal(0.0)); - if (_height != oldheight) + if (m_height != oldheight) emit heightChanged(); } //TODO: optimization: only check sender(), if there is one void QFxContents::calcWidth() { - int oldwidth = _width; + qreal oldwidth = m_width; + + qreal left = FLT_MAX; + qreal right = 0; - int left = INT_MAX; - int right = 0; - const QList &children = _item->QSimpleCanvasItem::children(); + const QList &children = m_item->QSimpleCanvasItem::children(); for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); - int x = int(child->x()); + qreal x = int(child->x()); if (x + child->width() > right) right = x + child->width(); if (x < left) left = x; } - _width = right - left; + m_width = qMax(right - left, qreal(0.0)); - if (_width != oldwidth) + if (m_width != oldwidth) emit widthChanged(); } void QFxContents::setItem(QFxItem *item) { - _item = item; + m_item = item; - const QList &children = _item->QSimpleCanvasItem::children(); + const QList &children = m_item->QSimpleCanvasItem::children(); for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); @@ -925,8 +926,8 @@ void QFxItem::qmlLoaded() /*! \qmlproperty real Item::x \qmlproperty real Item::y - \qmlproperty int Item::width - \qmlproperty int Item::height + \qmlproperty real Item::width + \qmlproperty real Item::height Defines the item's position and size relative to its parent. @@ -1346,13 +1347,14 @@ QFxAnchorLine QFxItem::baseline() const \qmlproperty AnchorLine Item::anchors.baseline \qmlproperty Item Item::anchors.fill - - \qmlproperty int Item::anchors.topMargin - \qmlproperty int Item::anchors.bottomMargin - \qmlproperty int Item::anchors.leftMargin - \qmlproperty int Item::anchors.rightMargin - \qmlproperty int Item::anchors.horizontalCenterOffset - \qmlproperty int Item::anchors.verticalCenterOffset + \qmlproperty Item Item::anchors.centeredIn + + \qmlproperty real Item::anchors.topMargin + \qmlproperty real Item::anchors.bottomMargin + \qmlproperty real Item::anchors.leftMargin + \qmlproperty real Item::anchors.rightMargin + \qmlproperty real Item::anchors.horizontalCenterOffset + \qmlproperty real Item::anchors.verticalCenterOffset Anchors provide a way to position an item by specifying its relationship with other items. @@ -1411,11 +1413,11 @@ QFxAnchorLine QFxItem::baseline() const For non-text items, a default baseline offset of 0 is used. */ -int QFxItem::baselineOffset() const +qreal QFxItem::baselineOffset() const { Q_D(const QFxItem); if (!d->_baselineOffset.isValid()) { - return 0; + return 0.0; } else return d->_baselineOffset; } @@ -1423,7 +1425,7 @@ int QFxItem::baselineOffset() const /*! \internal */ -void QFxItem::setBaselineOffset(int offset) +void QFxItem::setBaselineOffset(qreal offset) { Q_D(QFxItem); if (offset == d->_baselineOffset) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 3c872e1..f0f1177 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -53,7 +53,6 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -63,14 +62,14 @@ QT_MODULE(Declarative) class Q_DECLARATIVE_EXPORT QFxContents : public QObject { Q_OBJECT - Q_PROPERTY(int height READ height NOTIFY heightChanged) - Q_PROPERTY(int width READ width NOTIFY widthChanged) + Q_PROPERTY(qreal height READ height NOTIFY heightChanged) + Q_PROPERTY(qreal width READ width NOTIFY widthChanged) public: QFxContents(); - int height() const; + qreal height() const; - int width() const; + qreal width() const; void setItem(QFxItem *item); @@ -83,9 +82,9 @@ Q_SIGNALS: void widthChanged(); private: - QFxItem *_item; - int _height; - int _width; + QFxItem *m_item; + qreal m_height; + qreal m_width; }; QML_DECLARE_TYPE(QFxContents) Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors) @@ -116,11 +115,11 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(qreal x READ x WRITE setX NOTIFY leftChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged) Q_PROPERTY(qreal z READ z WRITE setZ) - Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally) - Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) + Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged) + Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) Q_PROPERTY(QFxAnchorLine left READ left) Q_PROPERTY(QFxAnchorLine right READ right) Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter) @@ -179,8 +178,8 @@ public: bool flipHorizontally() const; void setFlipHorizontally(bool); - int baselineOffset() const; - void setBaselineOffset(int); + qreal baselineOffset() const; + void setBaselineOffset(qreal); qreal rotation() const; void setRotation(qreal); @@ -274,4 +273,5 @@ QML_DECLARE_TYPE(QSimpleCanvasFilter) QT_END_NAMESPACE QT_END_HEADER + #endif // QFXITEM_H diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index b38d877..32e8aef 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -138,7 +138,7 @@ public: QList _qmlnewloading; QList _qmlnewcomp; - QmlNullableValue _baselineOffset; + QmlNullableValue _baselineOffset; float _rotation; bool _classComplete:1; -- cgit v0.12 From 1674eeb1b331f000a6dc651ec12b682ba5b7fd77 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 13:29:26 +1000 Subject: Rename notifiers: topChanged -> yChanged; leftChanged -> xChanged. --- examples/declarative/follow/pong.qml | 2 +- src/declarative/fx/qfxflickable.cpp | 4 ++-- src/declarative/fx/qfxgridview.cpp | 12 ++++++------ src/declarative/fx/qfxitem.cpp | 16 ++++++++-------- src/declarative/fx/qfxitem.h | 8 ++++---- src/declarative/fx/qfxlistview.cpp | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml index 93ee6a7..c101d8d 100644 --- a/examples/declarative/follow/pong.qml +++ b/examples/declarative/follow/pong.qml @@ -26,7 +26,7 @@ Rect { y: Follow { source: Ball.targetY; velocity: 200 } // Detect the ball hitting the top or bottom of the view and bounce it - onTopChanged: { + onYChanged: { if (y <= 0) targetY = Page.height-20; else if (y >= Page.height-20) diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index bc4a5fc..3580edb 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -112,8 +112,8 @@ void QFxFlickablePrivate::init() QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding())); q->setAcceptedMouseButtons(Qt::LeftButton); q->setOptions(QSimpleCanvasItem::ChildMouseFilter | QSimpleCanvasItem::MouseEvents); - QObject::connect(_flick, SIGNAL(leftChanged()), q, SIGNAL(positionChanged())); - QObject::connect(_flick, SIGNAL(topChanged()), q, SIGNAL(positionChanged())); + QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged())); + QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged())); QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(&elasticY, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange())); diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index a6ffbb9..11b630a 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -368,8 +368,8 @@ void QFxGridViewPrivate::releaseItem(FxGridItem *item) if (!item) return; if (trackedItem == item) { - QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); trackedItem = 0; } if (model->release(item->item) == 0) { @@ -548,15 +548,15 @@ void QFxGridViewPrivate::updateTrackedItem() item = highlight; if (trackedItem && item != trackedItem) { - QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); trackedItem = 0; } if (!trackedItem && item) { trackedItem = item; - QObject::connect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::connect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); q->trackedPositionChanged(); } if (trackedItem) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 3764e3d..5ef6106 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -199,9 +199,9 @@ void QFxContents::setItem(QFxItem *item) for (int i = 0; i < children.count(); ++i) { const QSimpleCanvasItem *child = children.at(i); connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); - connect(child, SIGNAL(topChanged()), this, SLOT(calcHeight())); + connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight())); connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth())); - connect(child, SIGNAL(leftChanged()), this, SLOT(calcWidth())); + connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth())); } calcHeight(); @@ -269,15 +269,15 @@ void QFxContents::setItem(QFxItem *item) */ /*! - \fn void QFxItem::leftChanged() + \fn void QFxItem::xChanged() - This signal is emitted when the left coordinate of the item changes. + This signal is emitted when the x coordinate of the item changes. */ /*! - \fn void QFxItem::topChanged() + \fn void QFxItem::yChanged() - This signal is emitted when the top coordinate of the item changes. + This signal is emitted when the y coordinate of the item changes. */ /*! @@ -1068,11 +1068,11 @@ void QFxItem::geometryChanged(const QRectF &newGeometry, } if (newGeometry.x() != oldGeometry.x()) - emit leftChanged(); + emit xChanged(); if (newGeometry.width() != oldGeometry.width()) emit widthChanged(); if (newGeometry.y() != oldGeometry.y()) - emit topChanged(); + emit yChanged(); if (newGeometry.height() != oldGeometry.height()) emit heightChanged(); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index f0f1177..d66d24b 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -112,8 +112,8 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY leftChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(qreal z READ z WRITE setZ) Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) @@ -212,10 +212,10 @@ public Q_SLOTS: void newChild(const QString &url); Q_SIGNALS: - void leftChanged(); + void xChanged(); + void yChanged(); void widthChanged(); void heightChanged(); - void topChanged(); void baselineOffsetChanged(); void stateChanged(const QString &); void focusChanged(); diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index a8c0747..889cfdd 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -444,7 +444,7 @@ void QFxListViewPrivate::releaseItem(FxListItem *item) else QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); if (trackedItem == item) { - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged()); + const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); @@ -588,7 +588,7 @@ void QFxListViewPrivate::updateTrackedItem() if (highlight) item = highlight; - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged()); + const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); if (trackedItem && item != trackedItem) { -- cgit v0.12 From a77153a64e8559b21a7e6ea53fe26eb2719ce9f5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 30 Jun 2009 14:26:23 +1000 Subject: Cleanup Fix up license headers and private warnings, as well as other general cleanups. --- src/declarative/debugger/qmldebugclient.cpp | 4 +- src/declarative/debugger/qmldebugger.cpp | 3 ++ src/declarative/debugger/qmldebugger.h | 1 - src/declarative/debugger/qmldebuggerstatus.h | 1 - src/declarative/debugger/qmldebugserver.cpp | 4 +- src/declarative/debugger/qmlobjecttree.cpp | 3 ++ src/declarative/debugger/qmlobjecttree_p.h | 15 ++++++++ src/declarative/debugger/qmlpropertyview.cpp | 4 ++ src/declarative/debugger/qmlpropertyview_p.h | 11 ++++++ src/declarative/debugger/qmlwatches.cpp | 4 ++ src/declarative/debugger/qmlwatches_p.h | 11 ++++++ src/declarative/debugger/qpacketprotocol.cpp | 41 ++++++++++++++++++-- src/declarative/debugger/qpacketprotocol.h | 47 +++++++++++++++++++++-- src/declarative/fx/qfxevents_p.h | 11 ++++++ src/declarative/fx/qfxitem.cpp | 7 ++++ src/declarative/fx/qfxitem.h | 6 +-- src/declarative/qml/parser/qmljs.g | 2 +- src/declarative/qml/parser/qmljsast_p.h | 2 +- src/declarative/qml/parser/qmljsengine_p.cpp | 38 +++++++++++------- src/declarative/qml/parser/qmljsengine_p.h | 49 +++++++++++++++++------- src/declarative/qml/parser/qmljslexer.cpp | 2 +- src/declarative/qml/parser/qmljsmemorypool_p.h | 2 +- src/declarative/qml/parser/qmljsnodepool_p.h | 2 +- src/declarative/qml/parser/qmljsprettypretty.cpp | 2 +- src/declarative/qml/parser/qmljsprettypretty_p.h | 2 +- src/declarative/qml/qmlbasicscript.cpp | 34 +++++++++++++++- src/declarative/qml/qmlbasicscript_p.h | 47 +++++++++++++++++++++-- src/declarative/qml/qmlbindablevalue.h | 4 +- src/declarative/qml/qmlbindablevalue_p.h | 11 ++++++ src/declarative/qml/qmlboundsignal_p.h | 15 +++++++- src/declarative/qml/qmlclassfactory.cpp | 3 ++ src/declarative/qml/qmlclassfactory_p.h | 11 ++++++ src/declarative/qml/qmlcompiledcomponent_p.h | 15 +++++++- src/declarative/qml/qmlcompiler_p.h | 12 ++++++ src/declarative/qml/qmlcomponent.cpp | 2 + src/declarative/qml/qmlcomponent.h | 1 + src/declarative/qml/qmlcomponent_p.h | 15 +++++++- src/declarative/qml/qmlcompositetypemanager.cpp | 4 ++ src/declarative/qml/qmlcompositetypemanager_p.h | 11 ++++++ src/declarative/qml/qmlcontext.h | 1 - src/declarative/qml/qmlcontext_p.h | 13 +++++++ src/declarative/qml/qmlcustomparser_p.h | 11 ++++++ src/declarative/qml/qmlcustomparser_p_p.h | 11 ++++++ src/declarative/qml/qmldeclarativedata_p.h | 11 ++++++ src/declarative/qml/qmldom.cpp | 1 - src/declarative/qml/qmldom_p.h | 11 ++++++ src/declarative/qml/qmlengine_p.h | 14 ++++++- src/declarative/qml/qmlexpression.h | 1 - src/declarative/qml/qmlinstruction.cpp | 1 + src/declarative/qml/qmlinstruction_p.h | 17 ++++++-- src/declarative/qml/qmllist.h | 1 - src/declarative/qml/qmlmetaproperty.cpp | 1 - src/declarative/qml/qmlmetaproperty_p.h | 12 +++++- src/declarative/qml/qmlmetatype.cpp | 1 + src/declarative/qml/qmlparser_p.h | 11 ++++++ src/declarative/qml/qmlparserstatus.h | 1 - src/declarative/qml/qmlprivate.h | 6 +-- src/declarative/qml/qmlpropertyvaluesource.cpp | 2 +- src/declarative/qml/qmlpropertyvaluesource.h | 7 ++-- src/declarative/qml/qmlproxymetaobject.cpp | 2 +- src/declarative/qml/qmlproxymetaobject_p.h | 12 ++++++ src/declarative/qml/qmlrefcount.cpp | 4 ++ src/declarative/qml/qmlrefcount_p.h | 11 ++++++ src/declarative/qml/qmlscriptparser.cpp | 1 - src/declarative/qml/qmlscriptparser_p.h | 14 ++++++- src/declarative/qml/qmlstringconverters_p.h | 11 ++++++ src/declarative/qml/qmlvme_p.h | 13 +++++++ src/declarative/qml/qmlvmemetaobject.cpp | 2 +- src/declarative/qml/qmlvmemetaobject_p.h | 12 ++++++ src/declarative/qml/qpodvector_p.h | 12 ++++++ src/declarative/util/qfxglobal.h | 4 +- src/declarative/util/qfxperf.cpp | 3 +- src/declarative/util/qfxperf.h | 11 +++--- src/declarative/util/qfxview.cpp | 3 +- src/declarative/util/qmlanimation_p.h | 15 +++++++- src/declarative/util/qmlbind.cpp | 1 + src/declarative/util/qmlconnection.cpp | 2 +- src/declarative/util/qmlfollow.cpp | 2 +- src/declarative/util/qmlfont.cpp | 3 +- src/declarative/util/qmllistmodel.cpp | 1 + src/declarative/util/qmllistmodel.h | 1 - src/declarative/util/qmlnullablevalue_p.h | 16 +++++++- src/declarative/util/qmlopenmetaobject.cpp | 1 - src/declarative/util/qmlpackage.cpp | 3 +- src/declarative/util/qmlscript.h | 3 ++ src/declarative/util/qmlsetproperties.cpp | 2 +- src/declarative/util/qmlsetproperties.h | 1 - src/declarative/util/qmlstate_p.h | 11 ++++++ src/declarative/util/qmlstategroup.cpp | 2 +- src/declarative/util/qperformancelog.cpp | 3 ++ src/declarative/util/qperformancelog.h | 5 +++ src/declarative/widgets/graphicslayouts.h | 4 +- src/declarative/widgets/graphicswidgets.cpp | 4 +- 93 files changed, 677 insertions(+), 111 deletions(-) diff --git a/src/declarative/debugger/qmldebugclient.cpp b/src/declarative/debugger/qmldebugclient.cpp index 3dacf01..e442333 100644 --- a/src/declarative/debugger/qmldebugclient.cpp +++ b/src/declarative/debugger/qmldebugclient.cpp @@ -185,6 +185,6 @@ void QmlDebugClientPlugin::messageReceived(const QByteArray &) { } -#include "qmldebugclient.moc" - QT_END_NAMESPACE + +#include "qmldebugclient.moc" diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp index 9ab3247..aad11de 100644 --- a/src/declarative/debugger/qmldebugger.cpp +++ b/src/declarative/debugger/qmldebugger.cpp @@ -62,6 +62,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlDebugger::QmlDebugger(QWidget *parent) : QWidget(parent), m_tree(0), m_warnings(0), m_watchTable(0), m_watches(0), m_properties(0), m_text(0), m_highlightedItem(0) @@ -353,3 +355,4 @@ void QmlDebugger::setDebugObject(QObject *obj) item->setExpanded(true); } +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h index 10b2f9a..03efeb6 100644 --- a/src/declarative/debugger/qmldebugger.h +++ b/src/declarative/debugger/qmldebugger.h @@ -101,4 +101,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QMLDEBUGGER_H - diff --git a/src/declarative/debugger/qmldebuggerstatus.h b/src/declarative/debugger/qmldebuggerstatus.h index 62336de..a8480f4 100644 --- a/src/declarative/debugger/qmldebuggerstatus.h +++ b/src/declarative/debugger/qmldebuggerstatus.h @@ -64,4 +64,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QLMDEBUGGERSTATUS_P_H - diff --git a/src/declarative/debugger/qmldebugserver.cpp b/src/declarative/debugger/qmldebugserver.cpp index 23e59e0..e055ad5 100644 --- a/src/declarative/debugger/qmldebugserver.cpp +++ b/src/declarative/debugger/qmldebugserver.cpp @@ -294,6 +294,6 @@ void QmlDebugServerPlugin::messageReceived(const QByteArray &) { } -#include "qmldebugserver.moc" - QT_END_NAMESPACE + +#include "qmldebugserver.moc" diff --git a/src/declarative/debugger/qmlobjecttree.cpp b/src/declarative/debugger/qmlobjecttree.cpp index 27dc000..8a2358a 100644 --- a/src/declarative/debugger/qmlobjecttree.cpp +++ b/src/declarative/debugger/qmlobjecttree.cpp @@ -48,6 +48,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlObjectTree::QmlObjectTree(QWidget *parent) : QTreeWidget(parent) { @@ -73,3 +75,4 @@ void QmlObjectTree::mousePressEvent(QMouseEvent *me) } } +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmlobjecttree_p.h b/src/declarative/debugger/qmlobjecttree_p.h index 4e6d484..54d6d8e 100644 --- a/src/declarative/debugger/qmlobjecttree_p.h +++ b/src/declarative/debugger/qmlobjecttree_p.h @@ -42,10 +42,23 @@ #ifndef QMLOBJECTTREE_P_H #define QMLOBJECTTREE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include +QT_BEGIN_NAMESPACE + class QmlBindableValue; class QmlDebuggerItem : public QTreeWidgetItem { @@ -82,5 +95,7 @@ protected: virtual void mousePressEvent(QMouseEvent *); }; +QT_END_NAMESPACE + #endif // QMLOBJECTTREE_P_H diff --git a/src/declarative/debugger/qmlpropertyview.cpp b/src/declarative/debugger/qmlpropertyview.cpp index abe1902..76a192d 100644 --- a/src/declarative/debugger/qmlpropertyview.cpp +++ b/src/declarative/debugger/qmlpropertyview.cpp @@ -47,6 +47,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlPropertyView::QmlPropertyView(QmlWatches *watches, QWidget *parent) : QWidget(parent), m_tree(0), m_watches(watches) { @@ -221,4 +223,6 @@ void QmlPropertyView::refresh() setObject(m_object); } +QT_END_NAMESPACE + #include "qmlpropertyview.moc" diff --git a/src/declarative/debugger/qmlpropertyview_p.h b/src/declarative/debugger/qmlpropertyview_p.h index 469a08d..4694482 100644 --- a/src/declarative/debugger/qmlpropertyview_p.h +++ b/src/declarative/debugger/qmlpropertyview_p.h @@ -42,6 +42,17 @@ #ifndef QMLPROPERTYVIEW_P_H #define QMLPROPERTYVIEW_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/debugger/qmlwatches.cpp b/src/declarative/debugger/qmlwatches.cpp index bac4cbd..8fc9e89 100644 --- a/src/declarative/debugger/qmlwatches.cpp +++ b/src/declarative/debugger/qmlwatches.cpp @@ -46,6 +46,8 @@ #include #include +QT_BEGIN_NAMESPACE + QString QmlWatches::objectToString(QObject *obj) { if(!obj) @@ -301,4 +303,6 @@ QVariant QmlWatches::data(const QModelIndex &idx, int role) const } } +QT_END_NAMESPACE + #include "qmlwatches.moc" diff --git a/src/declarative/debugger/qmlwatches_p.h b/src/declarative/debugger/qmlwatches_p.h index 6c383a1..dfec979 100644 --- a/src/declarative/debugger/qmlwatches_p.h +++ b/src/declarative/debugger/qmlwatches_p.h @@ -42,6 +42,17 @@ #ifndef QMLWATCHES_P_H #define QMLWATCHES_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp index 6911b89..7be23b7 100644 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ b/src/declarative/debugger/qpacketprotocol.cpp @@ -1,16 +1,49 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtDeclarative 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qpacketprotocol.h" #include +QT_BEGIN_NAMESPACE + #define MAX_PACKET_SIZE 0x7FFFFFFF /*! @@ -458,5 +491,7 @@ QPacketAutoSend::~QPacketAutoSend() p->send(*this); } +QT_END_NAMESPACE + #include "qpacketprotocol.moc" diff --git a/src/declarative/debugger/qpacketprotocol.h b/src/declarative/debugger/qpacketprotocol.h index 6dd8bda..f3fb44b 100644 --- a/src/declarative/debugger/qpacketprotocol.h +++ b/src/declarative/debugger/qpacketprotocol.h @@ -1,10 +1,41 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtDeclarative 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 qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -14,6 +45,12 @@ #include #include +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + class QIODevice; class QBuffer; class QPacket; @@ -78,4 +115,8 @@ private: QPacketProtocol * p; }; +QT_END_NAMESPACE + +QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h index 2eb29af..60494e6 100644 --- a/src/declarative/fx/qfxevents_p.h +++ b/src/declarative/fx/qfxevents_p.h @@ -42,6 +42,17 @@ #ifndef QFXEVENTS_P_H #define QFXEVENTS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 5ef6106..1c35290 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -128,6 +128,13 @@ QFxContents::QFxContents() : m_height(0), m_width(0) } /*! + \qmlproperty qreal Item::contents.width + \qmlproperty qreal Item::contents.height + + 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. +/*! \property QFxContents::height \brief The height of the contents. */ diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index d66d24b..67a4553 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -116,10 +116,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(qreal z READ z WRITE setZ) Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) - Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) - Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally) Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) Q_PROPERTY(QFxAnchorLine left READ left) Q_PROPERTY(QFxAnchorLine right READ right) Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter) @@ -127,6 +124,9 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QSimpleCanvasItem, public QmlParserS Q_PROPERTY(QFxAnchorLine bottom READ bottom) Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter) Q_PROPERTY(QFxAnchorLine baseline READ baseline) + Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) + Q_PROPERTY(bool flipVertically READ flipVertically WRITE setFlipVertically) + Q_PROPERTY(bool flipHorizontally READ flipHorizontally WRITE setFlipHorizontally) Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index 907ca52..ed5f653 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -3,7 +3,7 @@ -- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -- Contact: Qt Software Information (qt-info@nokia.com) -- --- This file is part of the QtScript module of the Qt Toolkit. +-- This file is part of the QtDeclarative module of the Qt Toolkit. -- -- $QT_BEGIN_LICENSE:LGPL$ -- No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsast_p.h b/src/declarative/qml/parser/qmljsast_p.h index 8dc32ed..1db037a 100644 --- a/src/declarative/qml/parser/qmljsast_p.h +++ b/src/declarative/qml/parser/qmljsast_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp index 42885d8..02d9b9c 100644 --- a/src/declarative/qml/parser/qmljsengine_p.cpp +++ b/src/declarative/qml/parser/qmljsengine_p.cpp @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $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 @@ -22,10 +20,24 @@ ** 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 "qmljsengine_p.h" #include "qmljsnodepool_p.h" diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h index b9ff042..5aea983 100644 --- a/src/declarative/qml/parser/qmljsengine_p.h +++ b/src/declarative/qml/parser/qmljsengine_p.h @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $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 @@ -22,14 +20,39 @@ ** 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 QMLJSENGINE_P_H #define QMLJSENGINE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp index 843f6ae..e0de71a 100644 --- a/src/declarative/qml/parser/qmljslexer.cpp +++ b/src/declarative/qml/parser/qmljslexer.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsmemorypool_p.h b/src/declarative/qml/parser/qmljsmemorypool_p.h index d7506be..6bd21f8 100644 --- a/src/declarative/qml/parser/qmljsmemorypool_p.h +++ b/src/declarative/qml/parser/qmljsmemorypool_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsnodepool_p.h b/src/declarative/qml/parser/qmljsnodepool_p.h index 1a5b7f6..e2f0a3c 100644 --- a/src/declarative/qml/parser/qmljsnodepool_p.h +++ b/src/declarative/qml/parser/qmljsnodepool_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsprettypretty.cpp b/src/declarative/qml/parser/qmljsprettypretty.cpp index 1045792..b6733e5 100644 --- a/src/declarative/qml/parser/qmljsprettypretty.cpp +++ b/src/declarative/qml/parser/qmljsprettypretty.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsprettypretty_p.h b/src/declarative/qml/parser/qmljsprettypretty_p.h index fe82ca2..3227e7d 100644 --- a/src/declarative/qml/parser/qmljsprettypretty_p.h +++ b/src/declarative/qml/parser/qmljsprettypretty_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index f02a176..80ca5a9 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -3,9 +3,39 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $TROLLTECH_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 qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/declarative/qml/qmlbasicscript_p.h b/src/declarative/qml/qmlbasicscript_p.h index 43c0d36..c7ab280 100644 --- a/src/declarative/qml/qmlbasicscript_p.h +++ b/src/declarative/qml/qmlbasicscript_p.h @@ -3,15 +3,56 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $TROLLTECH_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 qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QMLBASICSCRIPT_P_H #define QMLBASICSCRIPT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -109,5 +150,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QMLBASICSCRIPT_P_H - - diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h index 50bbf36..00da57e 100644 --- a/src/declarative/qml/qmlbindablevalue.h +++ b/src/declarative/qml/qmlbindablevalue.h @@ -48,12 +48,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlExpression; class QmlContext; class QmlBindableValuePrivate; @@ -90,8 +90,8 @@ private: }; QML_DECLARE_TYPE(QmlBindableValue) - QT_END_NAMESPACE QT_END_HEADER + #endif // QMLBINDABLEVALUE_H diff --git a/src/declarative/qml/qmlbindablevalue_p.h b/src/declarative/qml/qmlbindablevalue_p.h index b55a314..a37b2c0 100644 --- a/src/declarative/qml/qmlbindablevalue_p.h +++ b/src/declarative/qml/qmlbindablevalue_p.h @@ -42,6 +42,17 @@ #ifndef QMLBINDABLEVALUE_P_H #define QMLBINDABLEVALUE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlboundsignal_p.h b/src/declarative/qml/qmlboundsignal_p.h index 2c05770..39c0c46 100644 --- a/src/declarative/qml/qmlboundsignal_p.h +++ b/src/declarative/qml/qmlboundsignal_p.h @@ -42,10 +42,22 @@ #ifndef QMLBOUNDSIGNAL_P_H #define QMLBOUNDSIGNAL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include QT_BEGIN_NAMESPACE + class QmlBoundSignal : public QmlExpressionObject { Q_OBJECT @@ -98,7 +110,6 @@ private: QmlBoundSignalParameters *params; }; +QT_END_NAMESPACE #endif // QMLBOUNDSIGNAL_P_H - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlclassfactory.cpp b/src/declarative/qml/qmlclassfactory.cpp index 7e5b929..ddfbd78 100644 --- a/src/declarative/qml/qmlclassfactory.cpp +++ b/src/declarative/qml/qmlclassfactory.cpp @@ -41,7 +41,10 @@ #include "qmlclassfactory_p.h" +QT_BEGIN_NAMESPACE + QmlClassFactory::~QmlClassFactory() { } +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlclassfactory_p.h b/src/declarative/qml/qmlclassfactory_p.h index e3e71c9..cd80ffc 100644 --- a/src/declarative/qml/qmlclassfactory_p.h +++ b/src/declarative/qml/qmlclassfactory_p.h @@ -42,6 +42,17 @@ #ifndef QMLCLASSFACTORY_P_H #define QMLCLASSFACTORY_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qmlcompiledcomponent_p.h b/src/declarative/qml/qmlcompiledcomponent_p.h index 2201423..0945892 100644 --- a/src/declarative/qml/qmlcompiledcomponent_p.h +++ b/src/declarative/qml/qmlcompiledcomponent_p.h @@ -42,13 +42,26 @@ #ifndef QMLCOMPILEDCOMPONENT_P_H #define QMLCOMPILEDCOMPONENT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include #include QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE + namespace QmlParser { class Property; class Object; @@ -72,8 +85,8 @@ private: friend class QmlDomDocument; }; - QT_END_NAMESPACE + QT_END_HEADER #endif // QMLCOMPILEDCOMPONENT_P_H diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 2559b14..2c722b9 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPILER_P_H #define QMLCOMPILER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -215,4 +226,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLCOMPILER_P_H diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 3429813..1144639 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -58,6 +58,7 @@ #include "qmlscriptparser_p.h" QT_BEGIN_NAMESPACE + class QByteArray; int statusId = qRegisterMetaType("QmlComponent::Status"); @@ -564,4 +565,5 @@ void QmlComponent::completeCreate() d->completePending = false; } } + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index ae2f362..2e80b6b 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -54,6 +54,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlCompiledComponent; class QByteArray; class QmlComponentPrivate; diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h index 254d9ba..0be3dc6 100644 --- a/src/declarative/qml/qmlcomponent_p.h +++ b/src/declarative/qml/qmlcomponent_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPONENT_P_H #define QMLCOMPONENT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -87,6 +98,6 @@ public: void clear(); }; -#endif // QMLCOMPONENT_P_H - QT_END_NAMESPACE + +#endif // QMLCOMPONENT_P_H diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 9950b48..ef77803 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -50,6 +50,8 @@ #include #include +QT_BEGIN_NAMESPACE + QmlCompositeTypeData::QmlCompositeTypeData() : status(Invalid), errorType(NoError), component(0), compiledComponent(0) { @@ -365,3 +367,5 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) doComplete(unit); } } + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index 9312819..96e77d6 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPOSITETYPEMANAGER_P_H #define QMLCOMPOSITETYPEMANAGER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index 935c7ca..ce5fe52 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -99,7 +99,6 @@ private: QmlContext(QmlEngine *); }; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index 4d88fc2..569b320 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -42,6 +42,17 @@ #ifndef QMLCONTEXT_P_H #define QMLCONTEXT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -50,6 +61,7 @@ #include QT_BEGIN_NAMESPACE + class QmlContext; class QmlExpression; class QmlEngine; @@ -99,6 +111,7 @@ public: QmlSimpleDeclarativeData contextData; QObjectList contextObjects; }; + QT_END_NAMESPACE #endif // QMLCONTEXT_P_H diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 75da579..67f39d9 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -42,6 +42,17 @@ #ifndef QMLCUSTOMPARSER_H #define QMLCUSTOMPARSER_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlcustomparser_p_p.h b/src/declarative/qml/qmlcustomparser_p_p.h index 96e9b32..0011c3b 100644 --- a/src/declarative/qml/qmlcustomparser_p_p.h +++ b/src/declarative/qml/qmlcustomparser_p_p.h @@ -42,6 +42,17 @@ #ifndef QMLCUSTOMPARSER_P_H #define QMLCUSTOMPARSER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include "qmlcustomparser_p.h" diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h index 85a80fa..559f0ee 100644 --- a/src/declarative/qml/qmldeclarativedata_p.h +++ b/src/declarative/qml/qmldeclarativedata_p.h @@ -42,6 +42,17 @@ #ifndef QMLDECLARATIVEDATA_P_H #define QMLDECLARATIVEDATA_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 5271dc5..8497bea 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -1571,4 +1571,3 @@ void QmlDomComponent::setComponentRoot(const QmlDomObject &root) } QT_END_NAMESPACE - diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index 441269c..a7c3cc7 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -42,6 +42,17 @@ #ifndef QMLDOM_P_H #define QMLDOM_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_HEADER diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index a1028e6..93ae704 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -42,6 +42,17 @@ #ifndef QMLENGINE_P_H #define QMLENGINE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -61,6 +72,7 @@ #include QT_BEGIN_NAMESPACE + class QmlContext; class QmlEngine; class QmlContextPrivate; @@ -288,7 +300,7 @@ public: void addLog(const QmlExpressionLog &); QList *log; }; + QT_END_NAMESPACE #endif // QMLENGINE_P_H - diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h index 15d026a..e8cac7a 100644 --- a/src/declarative/qml/qmlexpression.h +++ b/src/declarative/qml/qmlexpression.h @@ -109,7 +109,6 @@ Q_SIGNALS: void valueChanged(); }; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index a618fe7..1647a12 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -44,6 +44,7 @@ #include QT_BEGIN_NAMESPACE + void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) { QByteArray lineNumber = QByteArray::number(instr->line); diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index e3b0dfe..f2f3ac2 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -42,10 +42,21 @@ #ifndef QMLINSTRUCTION_P_H #define QMLINSTRUCTION_P_H -#include +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// +#include QT_BEGIN_NAMESPACE + class QmlCompiledComponent; class Q_DECLARATIVE_EXPORT QmlInstruction { @@ -283,6 +294,6 @@ public: void dump(QmlCompiledComponent *); }; -#endif // QMLINSTRUCTION_P_H - QT_END_NAMESPACE + +#endif // QMLINSTRUCTION_P_H diff --git a/src/declarative/qml/qmllist.h b/src/declarative/qml/qmllist.h index cc13924..80c3138 100644 --- a/src/declarative/qml/qmllist.h +++ b/src/declarative/qml/qmllist.h @@ -119,7 +119,6 @@ class Qml_ProxyList_ ##ListName : public QmlList \ friend class Qml_ProxyList_ ##ListName ; \ Qml_ProxyList_##ListName ListName; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 682b8ad..218fdf8 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -50,7 +50,6 @@ #include #include - QT_BEGIN_NAMESPACE class QMetaPropertyEx : public QMetaProperty diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 738bfec..3bd9089 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -42,6 +42,17 @@ #ifndef QMLMETAPROPERTY_P_H #define QMLMETAPROPERTY_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qmlmetaproperty.h" class QmlContext; @@ -79,4 +90,3 @@ public: }; #endif // QMLMETAPROPERTY_P_H - diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 8ce8571..f69e5e5 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -60,6 +60,7 @@ #include QT_BEGIN_NAMESPACE + #ifdef QT_BOOTSTRAPPED # ifndef QT_NO_GEOM_VARIANT # define QT_NO_GEOM_VARIANT diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 78040da..ef038f9 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -42,6 +42,17 @@ #ifndef QMLPARSER_P_H #define QMLPARSER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/qml/qmlparserstatus.h b/src/declarative/qml/qmlparserstatus.h index 7c2e141..4db6d8c 100644 --- a/src/declarative/qml/qmlparserstatus.h +++ b/src/declarative/qml/qmlparserstatus.h @@ -68,7 +68,6 @@ private: }; Q_DECLARE_INTERFACE(QmlParserStatus, "com.trolltech.qml.QmlParserStatus") - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index ed1304a..3d5fa61 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -394,10 +394,8 @@ int QmlPrivate::list_interface_op(QmlPrivate::ListOp op, int val, return 0; } - -#endif // QMLPRIVATE_H - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QMLPRIVATE_H diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp index 18092c8..c6ff596 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.cpp +++ b/src/declarative/qml/qmlpropertyvaluesource.cpp @@ -42,8 +42,8 @@ #include "qmlpropertyvaluesource.h" #include "qml.h" - QT_BEGIN_NAMESPACE + /*! \class QmlPropertyValueSource \brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings. diff --git a/src/declarative/qml/qmlpropertyvaluesource.h b/src/declarative/qml/qmlpropertyvaluesource.h index 9cef150..c142095 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.h +++ b/src/declarative/qml/qmlpropertyvaluesource.h @@ -46,12 +46,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QObjectPrivate; class QmlMetaProperty; class Q_DECLARATIVE_EXPORT QmlPropertyValueSource : public QObject @@ -71,9 +71,8 @@ private: }; QML_DECLARE_TYPE(QmlPropertyValueSource) -#endif // QMLPROPERTYVALUESOURCE_H - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QMLPROPERTYVALUESOURCE_H diff --git a/src/declarative/qml/qmlproxymetaobject.cpp b/src/declarative/qml/qmlproxymetaobject.cpp index 06d8a50..5568bab 100644 --- a/src/declarative/qml/qmlproxymetaobject.cpp +++ b/src/declarative/qml/qmlproxymetaobject.cpp @@ -41,8 +41,8 @@ #include "qmlproxymetaobject_p.h" - QT_BEGIN_NAMESPACE + QmlProxyMetaObject::QmlProxyMetaObject(QObject *obj, QList *mList) : metaObjects(mList), proxies(0), parent(0), object(obj) { diff --git a/src/declarative/qml/qmlproxymetaobject_p.h b/src/declarative/qml/qmlproxymetaobject_p.h index c0ce36e..736bd91 100644 --- a/src/declarative/qml/qmlproxymetaobject_p.h +++ b/src/declarative/qml/qmlproxymetaobject_p.h @@ -42,6 +42,17 @@ #ifndef QMLPROXYMETAOBJECT_P_H #define QMLPROXYMETAOBJECT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -53,6 +64,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlProxyMetaObject : public QAbstractDynamicMetaObject { public: diff --git a/src/declarative/qml/qmlrefcount.cpp b/src/declarative/qml/qmlrefcount.cpp index 8f71f1b..6c409e1 100644 --- a/src/declarative/qml/qmlrefcount.cpp +++ b/src/declarative/qml/qmlrefcount.cpp @@ -41,6 +41,8 @@ #include "qmlrefcount_p.h" +QT_BEGIN_NAMESPACE + QmlRefCount::QmlRefCount() : refCount(1) { @@ -64,3 +66,5 @@ void QmlRefCount::release() delete this; } +QT_END_NAMESPACE + diff --git a/src/declarative/qml/qmlrefcount_p.h b/src/declarative/qml/qmlrefcount_p.h index 1355c86..a87d596 100644 --- a/src/declarative/qml/qmlrefcount_p.h +++ b/src/declarative/qml/qmlrefcount_p.h @@ -42,6 +42,17 @@ #ifndef QMLREFCOUNT_P_H #define QMLREFCOUNT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_HEADER diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index fb7492d..24e26de 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -886,5 +886,4 @@ void QmlScriptParser::addNamespacePath(const QString &path) _nameSpacePaths.insertMulti(QString(), path); } - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index b057e2b..15f165c 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -41,13 +41,24 @@ #ifndef QMLSCRIPTPARSER_P_H #define QMLSCRIPTPARSER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include #include "qmlparser_p.h" - QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -107,6 +118,7 @@ public: }; QT_END_NAMESPACE + QT_END_HEADER #endif // QMLSCRIPTPARSER_P_H diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h index ed1f959..52426a7 100644 --- a/src/declarative/qml/qmlstringconverters_p.h +++ b/src/declarative/qml/qmlstringconverters_p.h @@ -42,6 +42,17 @@ #ifndef QMLSTRINGCONVERTERS_P_H #define QMLSTRINGCONVERTERS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include class QColor; class QPointF; diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h index 149c82c..2da7bb4 100644 --- a/src/declarative/qml/qmlvme_p.h +++ b/src/declarative/qml/qmlvme_p.h @@ -42,11 +42,23 @@ #ifndef QMLVME_P_H #define QMLVME_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include QT_BEGIN_NAMESPACE + class QObject; class QmlInstruction; class QmlCompiledComponent; @@ -70,4 +82,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLVME_P_H diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp index 4b2c64c..3b784a4 100644 --- a/src/declarative/qml/qmlvmemetaobject.cpp +++ b/src/declarative/qml/qmlvmemetaobject.cpp @@ -48,8 +48,8 @@ #include #include - QT_BEGIN_NAMESPACE + QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj, const QMetaObject *other, QList *strData, diff --git a/src/declarative/qml/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h index 17140ef..7b6fd2d 100644 --- a/src/declarative/qml/qmlvmemetaobject_p.h +++ b/src/declarative/qml/qmlvmemetaobject_p.h @@ -42,6 +42,17 @@ #ifndef QMLVMEMETAOBJECT_P_H #define QMLVMEMETAOBJECT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -73,4 +84,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLVMEMETAOBJECT_P_H diff --git a/src/declarative/qml/qpodvector_p.h b/src/declarative/qml/qpodvector_p.h index 55c04e7..101c62d 100644 --- a/src/declarative/qml/qpodvector_p.h +++ b/src/declarative/qml/qpodvector_p.h @@ -42,6 +42,17 @@ #ifndef QPODVECTOR_P_H #define QPODVECTOR_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include QT_BEGIN_NAMESPACE @@ -119,6 +130,7 @@ private: int m_capacity; T *m_data; }; + QT_END_NAMESPACE #endif diff --git a/src/declarative/util/qfxglobal.h b/src/declarative/util/qfxglobal.h index 6ba9409..6f2a9fb 100644 --- a/src/declarative/util/qfxglobal.h +++ b/src/declarative/util/qfxglobal.h @@ -45,12 +45,12 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + #if defined(QT_OPENGL_ES_1) #define QFX_CONFIGURATION_OPENGL1 #elif defined(QT_OPENGL_ES_2) @@ -117,8 +117,8 @@ inline void QFx_setParent_noEvent(QObject *object, QObject *parent) static_cast(object)->setParent_noEvent(parent); } - QT_END_NAMESPACE QT_END_HEADER + #endif // QFXGLOBAL_H diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp index e4f0c53..9ac9e8d 100644 --- a/src/declarative/util/qfxperf.cpp +++ b/src/declarative/util/qfxperf.cpp @@ -41,8 +41,8 @@ #include "qfxperf.h" - QT_BEGIN_NAMESPACE + Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(QmlParsing, "Compilation: QML Parsing") Q_DEFINE_PERFORMANCE_METRIC(Compilation, " QML Compilation") @@ -64,4 +64,5 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText") Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QmlScript::addScriptToEngine") } + QT_END_NAMESPACE diff --git a/src/declarative/util/qfxperf.h b/src/declarative/util/qfxperf.h index 9fcf1d6..0bc0cc9 100644 --- a/src/declarative/util/qfxperf.h +++ b/src/declarative/util/qfxperf.h @@ -38,17 +38,17 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef _QFXPERF_H_ -#define _QFXPERF_H_ +#ifndef QFXPERF_H +#define QFXPERF_H #include "qperformancelog.h" - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + Q_DECLARE_PERFORMANCE_LOG(QFxPerf) { Q_DECLARE_PERFORMANCE_METRIC(QmlParsing) @@ -73,9 +73,8 @@ Q_DECLARE_PERFORMANCE_LOG(QFxPerf) { Q_DECLARE_PERFORMANCE_METRIC(AddScript) } -#endif // _QFXPERF_H_ - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QFXPERF_H diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index d8d9ba1..0855224 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -62,8 +62,8 @@ #include #include - QT_BEGIN_NAMESPACE + DEFINE_BOOL_CONFIG_OPTION(itemTreeDump, ITEMTREE_DUMP); DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER); @@ -561,4 +561,5 @@ void QFxView::dumpRoot() { root()->dump(); } + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index b801d01..051516d 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -42,6 +42,17 @@ #ifndef QMLANIMATION_P_H #define QMLANIMATION_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include @@ -336,6 +347,6 @@ public: static void convertVariant(QVariant &variant, QVariant::Type type); }; -#endif // QMLANIMATION_P_H - QT_END_NAMESPACE + +#endif // QMLANIMATION_P_H diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index b45d07d..bb342bc 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -52,6 +52,7 @@ #include "qmlbind.h" QT_BEGIN_NAMESPACE + class QmlBindPrivate : public QObjectPrivate { public: diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp index 6c7b158..95f4573 100644 --- a/src/declarative/util/qmlconnection.cpp +++ b/src/declarative/util/qmlconnection.cpp @@ -46,8 +46,8 @@ #include #include - QT_BEGIN_NAMESPACE + class QmlConnectionPrivate : public QObjectPrivate { public: diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index d3b3617..c6d806a 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -45,8 +45,8 @@ #include "qmlfollow.h" #include "private/qmlanimation_p.h" - QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QmlFollow,Follow) class QmlFollowPrivate : public QObjectPrivate diff --git a/src/declarative/util/qmlfont.cpp b/src/declarative/util/qmlfont.cpp index c537a83..3075b82 100644 --- a/src/declarative/util/qmlfont.cpp +++ b/src/declarative/util/qmlfont.cpp @@ -43,8 +43,8 @@ #include "qfont.h" #include "qmlfont.h" - QT_BEGIN_NAMESPACE + class QmlFontPrivate : public QObjectPrivate { public: @@ -144,4 +144,5 @@ QFont QmlFont::font() const Q_D(const QmlFont); return d->font; } + QT_END_NAMESPACE diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index cc85661..1884e8b 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -567,4 +567,5 @@ ModelNode::~ModelNode() } QT_END_NAMESPACE + #include "qmllistmodel.moc" diff --git a/src/declarative/util/qmllistmodel.h b/src/declarative/util/qmllistmodel.h index ddf1e13..56ed8fb 100644 --- a/src/declarative/util/qmllistmodel.h +++ b/src/declarative/util/qmllistmodel.h @@ -51,7 +51,6 @@ #include #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qmlnullablevalue_p.h b/src/declarative/util/qmlnullablevalue_p.h index f16ddd6..6455642 100644 --- a/src/declarative/util/qmlnullablevalue_p.h +++ b/src/declarative/util/qmlnullablevalue_p.h @@ -42,6 +42,19 @@ #ifndef QMLNULLABLEVALUE_P_H #define QMLNULLABLEVALUE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + template struct QmlNullableValue { @@ -63,5 +76,6 @@ struct QmlNullableValue T value; }; -#endif // QMLNULLABLEVALUE_P_H +QT_END_NAMESPACE +#endif // QMLNULLABLEVALUE_P_H diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp index d0dd817..7305362 100644 --- a/src/declarative/util/qmlopenmetaobject.cpp +++ b/src/declarative/util/qmlopenmetaobject.cpp @@ -43,7 +43,6 @@ #include "private/qmetaobjectbuilder_p.h" #include - QT_BEGIN_NAMESPACE class QmlOpenMetaObjectPrivate diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp index e527c1f..eec769e 100644 --- a/src/declarative/util/qmlpackage.cpp +++ b/src/declarative/util/qmlpackage.cpp @@ -42,8 +42,8 @@ #include "private/qobject_p.h" #include "qmlpackage.h" - QT_BEGIN_NAMESPACE + class QmlPackagePrivate : public QObjectPrivate { public: @@ -150,4 +150,5 @@ QmlPackageAttached *QmlPackage::qmlAttachedProperties(QObject *o) QML_DEFINE_TYPE(QmlPackage, Package) QT_END_NAMESPACE + #include "qmlpackage.moc" diff --git a/src/declarative/util/qmlscript.h b/src/declarative/util/qmlscript.h index 09ebc2c..5b62da5 100644 --- a/src/declarative/util/qmlscript.h +++ b/src/declarative/util/qmlscript.h @@ -47,6 +47,7 @@ #include QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -76,5 +77,7 @@ private Q_SLOTS: QML_DECLARE_TYPE(QmlScript) QT_END_NAMESPACE + QT_END_HEADER + #endif diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 7ceed5e..7a68ba2 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -49,8 +49,8 @@ #include #include - QT_BEGIN_NAMESPACE + /*! \qmlclass SetProperties QmlSetProperties \brief The SetProperties element describes new property values for a state. diff --git a/src/declarative/util/qmlsetproperties.h b/src/declarative/util/qmlsetproperties.h index fe98900..717d0ee 100644 --- a/src/declarative/util/qmlsetproperties.h +++ b/src/declarative/util/qmlsetproperties.h @@ -44,7 +44,6 @@ #include - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index 2f6ff42..1b784f3 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -42,6 +42,17 @@ #ifndef QMLSTATE_P_H #define QMLSTATE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include #include #include diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 57ccd37..2b1cf7d 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -45,8 +45,8 @@ #include "qmltransition.h" #include - QT_BEGIN_NAMESPACE + DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); QML_DEFINE_TYPE(QmlStateGroup,StateGroup) diff --git a/src/declarative/util/qperformancelog.cpp b/src/declarative/util/qperformancelog.cpp index 8065f9d..932e4b3 100644 --- a/src/declarative/util/qperformancelog.cpp +++ b/src/declarative/util/qperformancelog.cpp @@ -43,6 +43,7 @@ #include #include +QT_BEGIN_NAMESPACE #ifdef Q_ENABLE_PERFORMANCE_LOG @@ -175,3 +176,5 @@ void QPerformanceLog::clear() } #endif // Q_ENABLE_PERFORMANCE_LOG + +QT_END_NAMESPACE diff --git a/src/declarative/util/qperformancelog.h b/src/declarative/util/qperformancelog.h index 3203685..6655a8d 100644 --- a/src/declarative/util/qperformancelog.h +++ b/src/declarative/util/qperformancelog.h @@ -43,6 +43,9 @@ #define QPERFORMANCELOG_H #include + +QT_BEGIN_NAMESPACE + namespace QPerformanceLog { Q_DECLARATIVE_EXPORT void displayData(); @@ -133,4 +136,6 @@ namespace QPerformanceLog #endif // Q_ENABLE_PERFORMANCE_LOG +QT_END_NAMESPACE + #endif // QPERFORMANCELOG_H diff --git a/src/declarative/widgets/graphicslayouts.h b/src/declarative/widgets/graphicslayouts.h index 303f749..525a848 100644 --- a/src/declarative/widgets/graphicslayouts.h +++ b/src/declarative/widgets/graphicslayouts.h @@ -183,8 +183,8 @@ private: }; QML_DECLARE_TYPE(QGraphicsGridLayoutObject) -#endif // GRAPHICSLAYOUTS_H - QT_END_NAMESPACE QT_END_HEADER + +#endif // GRAPHICSLAYOUTS_H diff --git a/src/declarative/widgets/graphicswidgets.cpp b/src/declarative/widgets/graphicswidgets.cpp index 86509f5..e7d01e3 100644 --- a/src/declarative/widgets/graphicswidgets.cpp +++ b/src/declarative/widgets/graphicswidgets.cpp @@ -168,6 +168,6 @@ QML_DEFINE_EXTENDED_TYPE(QGraphicsWidget,QGraphicsWidget,QGraphicsWidgetDeclarat QML_DEFINE_INTERFACE(QGraphicsItem) -#include "graphicswidgets.moc" - QT_END_NAMESPACE + +#include "graphicswidgets.moc" -- cgit v0.12 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 dba327eec1a308e61c2bd21941ba982fb9283827 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 30 Jun 2009 14:39:52 +1000 Subject: Add a simple folder model. --- src/declarative/extra/extra.pri | 2 + src/declarative/extra/qmlfolderlistmodel.cpp | 178 +++++++++++++++++++++++++++ src/declarative/extra/qmlfolderlistmodel.h | 100 +++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 src/declarative/extra/qmlfolderlistmodel.cpp create mode 100644 src/declarative/extra/qmlfolderlistmodel.h diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index 2590fbc..7244f98 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -2,12 +2,14 @@ SOURCES += \ extra/qnumberformat.cpp \ extra/qmlnumberformatter.cpp \ extra/qfxintegermodel.cpp \ + extra/qmlfolderlistmodel.cpp \ extra/qmltimer.cpp HEADERS += \ extra/qnumberformat.h \ extra/qmlnumberformatter.h \ extra/qfxintegermodel.h \ + extra/qmlfolderlistmodel.h \ extra/qmltimer.h contains(QT_CONFIG, xmlpatterns) { diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp new file mode 100644 index 0000000..43ffd5c --- /dev/null +++ b/src/declarative/extra/qmlfolderlistmodel.cpp @@ -0,0 +1,178 @@ +/**************************************************************************** +** +** 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 "private/qobject_p.h" +#include +#include +#include "qmlfolderlistmodel.h" + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlFolderListModelPrivate : public QObjectPrivate +{ +public: + QmlFolderListModelPrivate() { + folderIndex = model.index(0,0); + } + + QDirModel model; + QString folder; + QStringList nameFilters; + QModelIndex folderIndex; +}; + +QmlFolderListModel::QmlFolderListModel(QObject *parent) + : QListModelInterface(*(new QmlFolderListModelPrivate), parent) +{ + Q_D(QmlFolderListModel); + d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives); + connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int)) + , this, SLOT(inserted(const QModelIndex&,int,int))); +} + +QmlFolderListModel::~QmlFolderListModel() +{ +} + +QHash QmlFolderListModel::data(int index, const QList &roles) const +{ + Q_D(const QmlFolderListModel); + QHash folderData; + QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex); + if (modelIndex.isValid()) { + folderData[QDirModel::FileNameRole] = d->model.data(modelIndex, QDirModel::FileNameRole); + folderData[QDirModel::FilePathRole] = d->model.data(modelIndex, QDirModel::FilePathRole); + } + + return folderData; +} + +int QmlFolderListModel::count() const +{ + Q_D(const QmlFolderListModel); + if (!d->folderIndex.isValid()) + return 0; + return d->model.rowCount(d->folderIndex); +} + +QList QmlFolderListModel::roles() const +{ + QList r; + r << QDirModel::FileNameRole; + r << QDirModel::FilePathRole; + return r; +} + +QString QmlFolderListModel::toString(int role) const +{ + switch (role) { + case QDirModel::FileNameRole: + return QLatin1String("fileName"); + case QDirModel::FilePathRole: + return QLatin1String("filePath"); + } + + return QString(); +} + +QString QmlFolderListModel::folder() const +{ + Q_D(const QmlFolderListModel); + return d->folder; +} + +void QmlFolderListModel::setFolder(const QString &folder) +{ + Q_D(QmlFolderListModel); + QModelIndex index = d->model.index(folder); + if (index.isValid() && d->model.isDir(index)) { + d->folder = folder; + QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); + } +} + +QStringList QmlFolderListModel::nameFilters() const +{ + Q_D(const QmlFolderListModel); + return d->nameFilters; +} + +void QmlFolderListModel::setNameFilters(const QStringList &filters) +{ + Q_D(QmlFolderListModel); + d->nameFilters = filters; + QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); +} + +void QmlFolderListModel::classComplete() +{ +} + +bool QmlFolderListModel::isFolder(int index) const +{ + Q_D(const QmlFolderListModel); + return d->model.isDir(d->model.index(index, 0, d->folderIndex)); +} + +void QmlFolderListModel::refresh() +{ + Q_D(QmlFolderListModel); + int prevCount = count(); + d->folderIndex = QModelIndex(); + emit itemsRemoved(0, prevCount); + d->folderIndex = d->model.index(d->folder); + emit itemsInserted(0, count()); +} + +void QmlFolderListModel::inserted(const QModelIndex &index, int start, int end) +{ + Q_D(QmlFolderListModel); + qDebug() << "inserted" << start << end; + if (index == d->folderIndex) + emit itemsInserted(start, end - start + 1); +} + +QML_DEFINE_TYPE(QmlFolderListModel,FolderListModel) + +QT_END_NAMESPACE + diff --git a/src/declarative/extra/qmlfolderlistmodel.h b/src/declarative/extra/qmlfolderlistmodel.h new file mode 100644 index 0000000..c8b605a --- /dev/null +++ b/src/declarative/extra/qmlfolderlistmodel.h @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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 QMLFOLDERLISTMODEL_H +#define QMLFOLDERLISTMODEL_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlContext; +class QModelIndex; + +class QmlFolderListModelPrivate; +class Q_DECLARATIVE_EXPORT QmlFolderListModel : public QListModelInterface, public QmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QmlParserStatus) + + Q_PROPERTY(QString folder READ folder WRITE setFolder) + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters) + +public: + QmlFolderListModel(QObject *parent = 0); + ~QmlFolderListModel(); + + virtual QHash data(int index, const QList &roles = (QList())) const; + virtual int count() const; + virtual QList roles() const; + virtual QString toString(int role) const; + + QString folder() const; + void setFolder(const QString &folder); + + QStringList nameFilters() const; + void setNameFilters(const QStringList &filters); + + virtual void classComplete(); + + Q_INVOKABLE bool isFolder(int index) const; + +private Q_SLOTS: + void refresh(); + void inserted(const QModelIndex &index, int start, int end); + +private: + Q_DECLARE_PRIVATE(QmlFolderListModel) + Q_DISABLE_COPY(QmlFolderListModel) +}; + +QML_DECLARE_TYPE(QmlFolderListModel) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMLFOLDERLISTMODEL_H -- cgit v0.12 From 5732bf283683f0444dbec740cc26c995d9464de6 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 30 Jun 2009 16:26:44 +1000 Subject: Simple QML browser/loader. --- examples/declarative/loader/loader.pro | 9 ++++++ examples/declarative/loader/loader.qml | 41 ++++++++++++++++++++++++++++ examples/declarative/loader/loader.qrc | 5 ++++ examples/declarative/loader/main.cpp | 18 ++++++++++++ src/declarative/extra/qmlfolderlistmodel.cpp | 18 +++++++++--- src/declarative/extra/qmlfolderlistmodel.h | 5 +++- 6 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 examples/declarative/loader/loader.pro create mode 100644 examples/declarative/loader/loader.qml create mode 100644 examples/declarative/loader/loader.qrc create mode 100644 examples/declarative/loader/main.cpp diff --git a/examples/declarative/loader/loader.pro b/examples/declarative/loader/loader.pro new file mode 100644 index 0000000..baa5b8c --- /dev/null +++ b/examples/declarative/loader/loader.pro @@ -0,0 +1,9 @@ +SOURCES = main.cpp +RESOURCES = loader.qrc + +QT += script declarative + +target.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS loader.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/loader +INSTALLS += target sources diff --git a/examples/declarative/loader/loader.qml b/examples/declarative/loader/loader.qml new file mode 100644 index 0000000..4dd7a03 --- /dev/null +++ b/examples/declarative/loader/loader.qml @@ -0,0 +1,41 @@ +Rect { + id: Root + width: 300 + height: 400 + FolderListModel { + id: folders + nameFilters: [ "*.qml" ] + } + + Component { + id: FolderDelegate + Text { + id: Wrapper + width: Root.width + text: fileName + font.bold: true + font.size: 14 + MouseRegion { + anchors.fill: parent + onClicked: { + if (folders.isFolder(index)) { + folders.folder = filePath; + } else { + Root.qml = filePath; + } + } + } + } + } + + Text { id: DirText; text: folders.folder } + + ListView { + anchors.top: DirText.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + model: folders + delegate: FolderDelegate + } +} diff --git a/examples/declarative/loader/loader.qrc b/examples/declarative/loader/loader.qrc new file mode 100644 index 0000000..8c80052 --- /dev/null +++ b/examples/declarative/loader/loader.qrc @@ -0,0 +1,5 @@ + + + loader.qml + + diff --git a/examples/declarative/loader/main.cpp b/examples/declarative/loader/main.cpp new file mode 100644 index 0000000..31bff07 --- /dev/null +++ b/examples/declarative/loader/main.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QFxView *canvas = new QFxView; + canvas->setUrl(QUrl("qrc:/loader.qml")); + canvas->execute(); + canvas->resize(210,240); + canvas->show(); + + return app.exec(); +} + + diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp index 43ffd5c..abec01e 100644 --- a/src/declarative/extra/qmlfolderlistmodel.cpp +++ b/src/declarative/extra/qmlfolderlistmodel.cpp @@ -52,7 +52,8 @@ class QmlFolderListModelPrivate : public QObjectPrivate { public: QmlFolderListModelPrivate() { - folderIndex = model.index(0,0); + folder = QDir::currentPath(); + nameFilters << "*"; } QDirModel model; @@ -124,10 +125,13 @@ QString QmlFolderListModel::folder() const void QmlFolderListModel::setFolder(const QString &folder) { Q_D(QmlFolderListModel); + if (folder == d->folder) + return; QModelIndex index = d->model.index(folder); if (index.isValid() && d->model.isDir(index)) { d->folder = folder; QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); + emit folderChanged(); } } @@ -141,11 +145,14 @@ void QmlFolderListModel::setNameFilters(const QStringList &filters) { Q_D(QmlFolderListModel); d->nameFilters = filters; - QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); + d->model.setNameFilters(d->nameFilters); } void QmlFolderListModel::classComplete() { + Q_D(QmlFolderListModel); + if (!d->folderIndex.isValid()) + QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); } bool QmlFolderListModel::isFolder(int index) const @@ -159,9 +166,12 @@ void QmlFolderListModel::refresh() Q_D(QmlFolderListModel); int prevCount = count(); d->folderIndex = QModelIndex(); - emit itemsRemoved(0, prevCount); + if (prevCount) + emit itemsRemoved(0, prevCount); d->folderIndex = d->model.index(d->folder); - emit itemsInserted(0, count()); + qDebug() << "count" << count(); + if (count()) + emit itemsInserted(0, count()); } void QmlFolderListModel::inserted(const QModelIndex &index, int start, int end) diff --git a/src/declarative/extra/qmlfolderlistmodel.h b/src/declarative/extra/qmlfolderlistmodel.h index c8b605a..a6e8526 100644 --- a/src/declarative/extra/qmlfolderlistmodel.h +++ b/src/declarative/extra/qmlfolderlistmodel.h @@ -60,7 +60,7 @@ class Q_DECLARATIVE_EXPORT QmlFolderListModel : public QListModelInterface, publ Q_OBJECT Q_INTERFACES(QmlParserStatus) - Q_PROPERTY(QString folder READ folder WRITE setFolder) + Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged) Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters) public: @@ -82,6 +82,9 @@ public: Q_INVOKABLE bool isFolder(int index) const; +Q_SIGNALS: + void folderChanged(); + private Q_SLOTS: void refresh(); void inserted(const QModelIndex &index, int start, int end); -- 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 1971dbdde166f6e21da6bdceac582ca7bb5c5542 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 1 Jul 2009 09:22:30 +1000 Subject: Replace browser with loaded QML. --- examples/declarative/loader/Browser.qml | 41 +++++++++++++++++++++++++++++++++ examples/declarative/loader/loader.qml | 39 ++----------------------------- examples/declarative/loader/loader.qrc | 1 + 3 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 examples/declarative/loader/Browser.qml diff --git a/examples/declarative/loader/Browser.qml b/examples/declarative/loader/Browser.qml new file mode 100644 index 0000000..af5538e --- /dev/null +++ b/examples/declarative/loader/Browser.qml @@ -0,0 +1,41 @@ +Rect { + id: Root + width: parent.width + height: parent.height + FolderListModel { + id: folders + nameFilters: [ "*.qml" ] + } + + Component { + id: FolderDelegate + Text { + id: Wrapper + width: Root.width + text: fileName + font.bold: true + font.size: 14 + MouseRegion { + anchors.fill: parent + onClicked: { + if (folders.isFolder(index)) { + folders.folder = filePath; + } else { + Shell.qml = filePath; + } + } + } + } + } + + Text { id: DirText; text: folders.folder } + + ListView { + anchors.top: DirText.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + model: folders + delegate: FolderDelegate + } +} diff --git a/examples/declarative/loader/loader.qml b/examples/declarative/loader/loader.qml index 4dd7a03..6e4d6ec 100644 --- a/examples/declarative/loader/loader.qml +++ b/examples/declarative/loader/loader.qml @@ -1,41 +1,6 @@ Rect { - id: Root + id: Shell width: 300 height: 400 - FolderListModel { - id: folders - nameFilters: [ "*.qml" ] - } - - Component { - id: FolderDelegate - Text { - id: Wrapper - width: Root.width - text: fileName - font.bold: true - font.size: 14 - MouseRegion { - anchors.fill: parent - onClicked: { - if (folders.isFolder(index)) { - folders.folder = filePath; - } else { - Root.qml = filePath; - } - } - } - } - } - - Text { id: DirText; text: folders.folder } - - ListView { - anchors.top: DirText.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - model: folders - delegate: FolderDelegate - } + qml: "Browser.qml" } diff --git a/examples/declarative/loader/loader.qrc b/examples/declarative/loader/loader.qrc index 8c80052..1f0925f 100644 --- a/examples/declarative/loader/loader.qrc +++ b/examples/declarative/loader/loader.qrc @@ -1,5 +1,6 @@ loader.qml + Browser.qml -- 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 From 0200260487c888b62d7761d6f358543602b53994 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 11:31:10 +1000 Subject: Cleanup. --- src/declarative/util/qmlanimation.cpp | 16 ++-------------- src/declarative/util/qmlanimation.h | 1 - 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index c4eabfe..620739f 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -97,13 +97,11 @@ QEasingCurve stringToCurve(const QString &curve) if (normalizedCurve.startsWith(QLatin1String("ease"))) normalizedCurve = normalizedCurve.mid(4); - //XXX optimize? - int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type"); - QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index); + static int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type"); + static QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index); int value = me.keyToValue(normalizedCurve.toLatin1().constData()); if (value < 0) { - //XXX print line number qWarning("QEasingCurve: Unknown easing curve '%s'", curve.toLatin1().constData()); value = 0; @@ -130,7 +128,6 @@ QEasingCurve stringToCurve(const QString &curve) return easingCurve; } - //XXX optimize if (propName == QLatin1String("amplitude")) { easingCurve.setAmplitude(propValue); } else if (propName == QLatin1String("period")) { @@ -698,15 +695,6 @@ void QmlPauseAnimation::setDuration(int duration) emit durationChanged(duration); } -void QmlPauseAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlPauseAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; -} - QAbstractAnimation *QmlPauseAnimation::qtAnimation() { Q_D(QmlPauseAnimation); diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 12212df..91c1898 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -154,7 +154,6 @@ Q_SIGNALS: protected: virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; class QmlRunScriptActionPrivate; -- cgit v0.12 From ee44073a48392972f704d36f8794171700dceba4 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 1 Jul 2009 11:57:37 +1000 Subject: FolderListModel fixes. --- src/declarative/extra/qmlfolderlistmodel.cpp | 48 +++++++++++++++++++++------- src/declarative/extra/qmlfolderlistmodel.h | 2 ++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp index abec01e..649169b 100644 --- a/src/declarative/extra/qmlfolderlistmodel.cpp +++ b/src/declarative/extra/qmlfolderlistmodel.cpp @@ -51,7 +51,7 @@ QT_MODULE(Declarative) class QmlFolderListModelPrivate : public QObjectPrivate { public: - QmlFolderListModelPrivate() { + QmlFolderListModelPrivate() : count(0) { folder = QDir::currentPath(); nameFilters << "*"; } @@ -60,6 +60,7 @@ public: QString folder; QStringList nameFilters; QModelIndex folderIndex; + int count; }; QmlFolderListModel::QmlFolderListModel(QObject *parent) @@ -69,6 +70,11 @@ QmlFolderListModel::QmlFolderListModel(QObject *parent) d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives); connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int)) , this, SLOT(inserted(const QModelIndex&,int,int))); + connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int)) + , this, SLOT(removed(const QModelIndex&,int,int))); + connect(&d->model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)) + , this, SLOT(dataChanged(const QModelIndex&,const QModelIndex&))); + connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh())); } QmlFolderListModel::~QmlFolderListModel() @@ -91,9 +97,7 @@ QHash QmlFolderListModel::data(int index, const QList &roles) int QmlFolderListModel::count() const { Q_D(const QmlFolderListModel); - if (!d->folderIndex.isValid()) - return 0; - return d->model.rowCount(d->folderIndex); + return d->count; } QList QmlFolderListModel::roles() const @@ -164,22 +168,42 @@ bool QmlFolderListModel::isFolder(int index) const void QmlFolderListModel::refresh() { Q_D(QmlFolderListModel); - int prevCount = count(); d->folderIndex = QModelIndex(); - if (prevCount) - emit itemsRemoved(0, prevCount); + if (d->count) { + int tmpCount = d->count; + d->count = 0; + emit itemsRemoved(0, tmpCount); + } d->folderIndex = d->model.index(d->folder); - qDebug() << "count" << count(); - if (count()) - emit itemsInserted(0, count()); + d->count = d->model.rowCount(d->folderIndex); + if (d->count) { + emit itemsInserted(0, d->count); + } } void QmlFolderListModel::inserted(const QModelIndex &index, int start, int end) { Q_D(QmlFolderListModel); - qDebug() << "inserted" << start << end; - if (index == d->folderIndex) + if (index == d->folderIndex) { + d->count = d->model.rowCount(d->folderIndex); emit itemsInserted(start, end - start + 1); + } +} + +void QmlFolderListModel::removed(const QModelIndex &index, int start, int end) +{ + Q_D(QmlFolderListModel); + if (index == d->folderIndex) { + d->count = d->model.rowCount(d->folderIndex); + emit itemsRemoved(start, end - start + 1); + } +} + +void QmlFolderListModel::dataChanged(const QModelIndex &start, const QModelIndex &end) +{ + Q_D(QmlFolderListModel); + if (start.parent() == d->folderIndex) + emit itemsChanged(start.row(), end.row() - start.row() + 1, roles()); } QML_DEFINE_TYPE(QmlFolderListModel,FolderListModel) diff --git a/src/declarative/extra/qmlfolderlistmodel.h b/src/declarative/extra/qmlfolderlistmodel.h index a6e8526..d46ec79 100644 --- a/src/declarative/extra/qmlfolderlistmodel.h +++ b/src/declarative/extra/qmlfolderlistmodel.h @@ -88,6 +88,8 @@ Q_SIGNALS: private Q_SLOTS: void refresh(); void inserted(const QModelIndex &index, int start, int end); + void removed(const QModelIndex &index, int start, int end); + void dataChanged(const QModelIndex &start, const QModelIndex &end); private: Q_DECLARE_PRIVATE(QmlFolderListModel) -- cgit v0.12 From e44a16c440a56ccd6d9a001f01c45d7327ce8e62 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 12:35:25 +1000 Subject: Change reversible transition semantics. The new semantics match those of playing a QAbstractionAnimation backward. (i.e. it is now an exact visual reverse) --- src/declarative/util/qmlanimation.cpp | 12 ++++-------- src/declarative/util/qmltransition.cpp | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 620739f..0c8f55f 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1347,17 +1347,9 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, d->animations.at(i)->setTarget(d->userProperty); } - //XXX removing and readding isn't ideal; we do it to get around the problem mentioned below. - for (int i = d->ag->animationCount()-1; i >= 0; --i) - d->ag->takeAnimationAt(i); - for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) { d->animations.at(ii)->transition(actions, modified, direction); - d->ag->addAnimation(d->animations.at(ii)->qtAnimation()); } - - //XXX changing direction means all the animations play in reverse, while we only want the ordering reversed. - //d->ag->setDirection(direction == Backward ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); } QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation) @@ -1797,8 +1789,11 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, int interpolatorType; //for Number/ColorAnimation int prevInterpolatorType; //for generic QVariantAnimation::Interpolator interpolator; + bool reverse; void setValue(qreal v) { + if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 + v = 1 - v; QmlTimeLineValue::setValue(v); for (int ii = 0; ii < actions.count(); ++ii) { Action &action = actions[ii]; @@ -1844,6 +1839,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, PropertyUpdater *data = new PropertyUpdater; data->interpolatorType = d->interpolatorType; data->interpolator = d->interpolator; + data->reverse = direction == Backward ? true : false; QSet objs; for (int ii = 0; ii < actions.count(); ++ii) { diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index 5931075..43a4605 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -176,6 +176,7 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, } d->endState = endState; + d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); d->group->start(); } -- cgit v0.12 From 5bb4fe79e92a4882977f64c03654e707721c59a9 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 13:24:24 +1000 Subject: Add a Scale transform object. --- doc/src/declarative/elements.qdoc | 1 + src/declarative/fx/qfxtransform.cpp | 133 ++++++++++++++++++++++++++++++++++++ src/declarative/fx/qfxtransform.h | 43 ++++++++++++ 3 files changed, 177 insertions(+) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index 63566f6..eda9079 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -139,6 +139,7 @@ The following table lists the Qml elements provided by the Qt Declarative module \o \list +\o \l Scale \o \l Rotation \o \l Squish \o \l Rotation3D diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index 2c4f842..0f0ce80 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -84,6 +84,139 @@ void QFxTransform::update() } /*! + \qmlclass Scale + \brief A Scale object provides a way to scale an Item. + + The scale object gives more control over scaling than using Item's scale property. Specifically, + it allows a different scale for the x and y axes, and allows the scale to be relative to an + arbitrary point. + + The following example scales the X axis of the Rect, relative to its interior point 25, 25: + \qml + Rect { + width: 100; height: 100 + color: "blue" + transform: Scale { originX: 25; originY: 25; xScale: 3} + } + \endqml +*/ + +QFxScale::QFxScale(QObject *parent) +: QFxTransform(parent), _originX(0), _originY(0), _xScale(1), _yScale(1), _dirty(true) +{ +} + +QFxScale::~QFxScale() +{ +} + +/*! + \qmlproperty real Scale::originX + \qmlproperty real Scale::originY + + The origin point for the scale. The scale will be relative to this point. +*/ +qreal QFxScale::originX() const +{ + return _originX; +} + +void QFxScale::setOriginX(qreal ox) +{ + _originX = ox; + update(); +} + +qreal QFxScale::originY() const +{ + return _originY; +} + +void QFxScale::setOriginY(qreal oy) +{ + _originY = oy; + update(); +} + +/*! + \qmlproperty real Scale::xScale + + The scaling factor for the X axis. +*/ +qreal QFxScale::xScale() const +{ + return _xScale; +} + +void QFxScale::setXScale(qreal scale) +{ + if (_xScale == scale) + return; + _xScale = scale; + update(); + emit scaleChanged(); +} + +/*! + \qmlproperty real Scale::yScale + + The scaling factor for the Y axis. +*/ +qreal QFxScale::yScale() const +{ + return _yScale; +} + +void QFxScale::setYScale(qreal scale) +{ + if (_yScale == scale) + return; + _yScale = scale; + update(); + emit scaleChanged(); +} + +bool QFxScale::isIdentity() const +{ + return (_xScale == 1. && _yScale == 1.); +} + +#if defined(QFX_RENDER_QPAINTER) +QTransform QFxScale::transform() const +{ + if (_dirty) { + _transform = QTransform(); + _dirty = false; + _transform.translate(_originX, _originY); + _transform.scale(_xScale, _yScale); + _transform.translate(-_originX, -_originY); + } + return _transform; +} +#elif defined(QFX_RENDER_OPENGL) +QMatrix4x4 QFxScale::transform() const +{ + if (_dirty) { + _transform = QMatrix4x4(); + _dirty = false; + _transform.translate(_originX, _originY); + _transform.scale(_xScale, _yScale); + _transform.translate(-_originX, -_originY); + } + return _transform; +} +#endif + +void QFxScale::update() +{ + _dirty = true; + QFxTransform::update(); +} + +QML_DEFINE_TYPE(QFxScale, Scale) + + +/*! \qmlclass Axis \brief A Axis object defines an axis that can be used for rotation or translation. diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h index 8693e7b..e0bd276 100644 --- a/src/declarative/fx/qfxtransform.h +++ b/src/declarative/fx/qfxtransform.h @@ -68,6 +68,48 @@ public: virtual QSimpleCanvas::Matrix transform() const; }; +class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform +{ + Q_OBJECT + + Q_PROPERTY(qreal originX READ originX WRITE setOriginX) + Q_PROPERTY(qreal originY READ originY WRITE setOriginY) + Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged()) + Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged()) +public: + QFxScale(QObject *parent=0); + ~QFxScale(); + + qreal originX() const; + void setOriginX(qreal); + + qreal originY() const; + void setOriginY(qreal); + + qreal xScale() const; + void setXScale(qreal); + + qreal yScale() const; + void setYScale(qreal); + + virtual bool isIdentity() const; + virtual QSimpleCanvas::Matrix transform() const; + +Q_SIGNALS: + void scaleChanged(); + +private Q_SLOTS: + void update(); +private: + qreal _originX; + qreal _originY; + qreal _xScale; + qreal _yScale; + + mutable bool _dirty; + mutable QSimpleCanvas::Matrix _transform; +}; + class Q_DECLARATIVE_EXPORT QFxAxis : public QObject { Q_OBJECT @@ -308,6 +350,7 @@ private: QT_END_NAMESPACE QML_DECLARE_TYPE(QFxTransform) +QML_DECLARE_TYPE(QFxScale) QML_DECLARE_TYPE(QFxAxis) QML_DECLARE_TYPE(QFxRotation) QML_DECLARE_TYPE(QFxRotation3D) -- cgit v0.12 From 10c1e4a09d8e2fa671f5538bde5f9126954272ed Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 15:01:28 +1000 Subject: ListModel code cleanup. --- src/declarative/util/qmllistmodel.cpp | 70 ++++++++++++----------------------- src/declarative/util/qmllistmodel.h | 28 ++++++++++++++ 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index c202a9f..f5f76b0 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -169,31 +169,6 @@ struct ListModelData */ -struct ModelNode; -class ListModel : public QListModelInterface -{ - Q_OBJECT -public: - ListModel(QObject *parent=0); - - virtual QList roles() const; - virtual QString toString(int role) const; - Q_PROPERTY(int count READ count) - virtual int count() const; - virtual QHash data(int index, const QList &roles = (QList())) const; - -private: - QVariant valueForNode(ModelNode *) const; - mutable QStringList roleStrings; - friend class ListModelParser; - friend struct ModelNode; - - void checkRoles() const; - void addRole(const QString &) const; - mutable bool _rolesOk; - ModelNode *_root; -}; - class ModelObject : public QObject { Q_OBJECT @@ -220,9 +195,9 @@ struct ModelNode QList values; QHash properties; - ListModel *model() { + QmlListModel *model() { if (!modelCache) { - modelCache = new ListModel; + modelCache = new QmlListModel; modelCache->_root = this; } return modelCache; @@ -240,7 +215,7 @@ struct ModelNode return objectCache; } - ListModel *modelCache; + QmlListModel *modelCache; ModelObject *objectCache; }; @@ -249,12 +224,16 @@ ModelObject::ModelObject(ModelNode *node) { } -ListModel::ListModel(QObject *parent) +QmlListModel::QmlListModel(QObject *parent) : QListModelInterface(parent), _rolesOk(false), _root(0) { } -void ListModel::checkRoles() const +QmlListModel::~QmlListModel() +{ +} + +void QmlListModel::checkRoles() const { if (_rolesOk) return; @@ -270,13 +249,13 @@ void ListModel::checkRoles() const _rolesOk = true; } -void ListModel::addRole(const QString &role) const +void QmlListModel::addRole(const QString &role) const { if (!roleStrings.contains(role)) roleStrings << role; } -QList ListModel::roles() const +QList QmlListModel::roles() const { checkRoles(); QList rv; @@ -285,7 +264,7 @@ QList ListModel::roles() const return rv; } -QString ListModel::toString(int role) const +QString QmlListModel::toString(int role) const { checkRoles(); if (role < roleStrings.count()) @@ -294,7 +273,7 @@ QString ListModel::toString(int role) const return QString(); } -QVariant ListModel::valueForNode(ModelNode *node) const +QVariant QmlListModel::valueForNode(ModelNode *node) const { QObject *rv = 0; @@ -327,7 +306,7 @@ QVariant ListModel::valueForNode(ModelNode *node) const return QVariant(); } -QHash ListModel::data(int index, const QList &roles) const +QHash QmlListModel::data(int index, const QList &roles) const { checkRoles(); QHash rv; @@ -352,13 +331,13 @@ QHash ListModel::data(int index, const QList &roles) const return rv; } -int ListModel::count() const +int QmlListModel::count() const { if (!_root) return 0; return _root->values.count(); } -class ListModelParser : public QmlCustomParser +class QmlListModelParser : public QmlCustomParser { public: QByteArray compile(const QList &, bool *ok); @@ -366,7 +345,7 @@ public: void setCustomData(QObject *, const QByteArray &); }; -bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList &instr, QByteArray &data) +bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList &instr, QByteArray &data) { QList values = prop.assignedValues(); for(int ii = 0; ii < values.count(); ++ii) { @@ -433,7 +412,7 @@ bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList return true; } -QByteArray ListModelParser::compile(const QList &customProps, bool *ok) +QByteArray QmlListModelParser::compile(const QList &customProps, bool *ok) { *ok = true; QList instr; @@ -470,9 +449,9 @@ QByteArray ListModelParser::compile(const QList &custom return rv; } -void ListModelParser::setCustomData(QObject *obj, const QByteArray &d) +void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) { - ListModel *rv = static_cast(obj); + QmlListModel *rv = static_cast(obj); ModelNode *root = new ModelNode; rv->_root = root; @@ -518,14 +497,14 @@ void ListModelParser::setCustomData(QObject *obj, const QByteArray &d) } } -QML_DEFINE_CUSTOM_TYPE(ListModel, ListModel, ListModelParser) +QML_DEFINE_CUSTOM_TYPE(QmlListModel, ListModel, QmlListModelParser) // ### FIXME -class ListElement : public QObject +class QmlListElement : public QObject { Q_OBJECT }; -QML_DEFINE_TYPE(ListElement,ListElement) +QML_DEFINE_TYPE(QmlListElement,ListElement) static void dump(ModelNode *node, int ind) { @@ -566,7 +545,6 @@ ModelNode::~ModelNode() QT_END_NAMESPACE Q_DECLARE_METATYPE(ModelNode *) -QML_DECLARE_TYPE(ListModel) -QML_DECLARE_TYPE(ListElement) +QML_DECLARE_TYPE(QmlListElement) #include "qmllistmodel.moc" diff --git a/src/declarative/util/qmllistmodel.h b/src/declarative/util/qmllistmodel.h index 56ed8fb..39edbe4 100644 --- a/src/declarative/util/qmllistmodel.h +++ b/src/declarative/util/qmllistmodel.h @@ -57,9 +57,37 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +struct ModelNode; +class QmlListModel : public QListModelInterface +{ + Q_OBJECT + Q_PROPERTY(int count READ count) + +public: + QmlListModel(QObject *parent=0); + ~QmlListModel(); + + virtual QList roles() const; + virtual QString toString(int role) const; + virtual int count() const; + virtual QHash data(int index, const QList &roles = (QList())) const; + +private: + QVariant valueForNode(ModelNode *) const; + mutable QStringList roleStrings; + friend class QmlListModelParser; + friend struct ModelNode; + + void checkRoles() const; + void addRole(const QString &) const; + mutable bool _rolesOk; + ModelNode *_root; +}; QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlListModel) + QT_END_HEADER #endif // QMLLISTMODEL_H -- cgit v0.12 From 9fdcef95dfb369ef490d5be8e4621485d11cddda Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 1 Jul 2009 15:47:19 +1000 Subject: Implement edge resistance for flickable dragging horizontally. --- src/declarative/fx/qfxflickable.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 3580edb..a82385a 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -597,7 +597,13 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) int dx = int(event->pos().x() - pressPos.x()); if (qAbs(dx) > FlickThreshold || pressTime.elapsed() > 200) { qreal newX = dx + pressX; - if (q->overShoot() || (newX <= q->minXExtent() && newX >= q->maxXExtent())) { + const qreal minX = q->minXExtent(); + const qreal maxX = q->maxXExtent(); + if (newX > minX) + newX = minX + (newX - minX) / 2; + if (newX < maxX && maxX - minX < 0) + newX = maxX + (newX - maxX) / 2; + if (q->overShoot() || (newX <= minX && newX >= maxX)) { if (dragMode == QFxFlickable::Hard) _moveX.setValue(newX); else -- cgit v0.12 From f1b6711ab742c9ab56304861f2bef01a8beecebc Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 1 Jul 2009 15:52:50 +1000 Subject: Have ColorAnimation select all properties of type QColor by default. This allows you to write ColorAnimation {} in a transition and all colors that are changing will be handled by default. --- src/declarative/util/qmlanimation.cpp | 11 ++++++++--- src/declarative/util/qmlanimation_p.h | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 0c8f55f..6ad47f5 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -709,6 +709,10 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() \code ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 } \endcode + + When used in a transition, ColorAnimation will by default animate + all properties of type color that are changing. If a property or properties + are explicity set for the animation, then those will be used instead. */ /*! \internal @@ -728,6 +732,7 @@ QmlColorAnimation::QmlColorAnimation(QObject *parent) d->init(); d->interpolatorType = QMetaType::QColor; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + d->defaultToInterpolatorType = true; } QmlColorAnimation::~QmlColorAnimation() @@ -1828,8 +1833,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, if (!d->propertyName.isEmpty() && !props.contains(d->propertyName)) props.append(d->propertyName); - /* ### we used to select properties of name 'color' by default for color animations - props << QLatin1String("color");*/ + bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false; if (d->userProperty.isValid() && props.isEmpty() && !target()) { props.append(d->userProperty.value.name()); @@ -1853,7 +1857,8 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && - (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName)) + || (useType && action.property.propertyType() == d->interpolatorType)) && (!target() || target() == obj || (!same && target() == sObj))) { objs.insert(obj); Action myAction = action; diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 051516d..fce5eca 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -319,7 +319,8 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate public: QmlPropertyAnimationPrivate() : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), - interpolatorType(0), interpolator(0), va(0), value(this, &QmlPropertyAnimationPrivate::valueChanged) {} + defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), + value(this, &QmlPropertyAnimationPrivate::valueChanged) {} void init(); @@ -335,6 +336,7 @@ public: bool fromSourced; bool fromIsDefined; bool toIsDefined; + bool defaultToInterpolatorType; int interpolatorType; QVariantAnimation::Interpolator interpolator; -- cgit v0.12