From 2472959ba8c0dbd404ab038710e5df74723a1780 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 5 Aug 2009 10:23:26 +1000 Subject: More QFxItem cleanup. --- src/declarative/fx/qfxitem.cpp | 9 +-------- src/declarative/fx/qfxitem.h | 1 - src/declarative/fx/qfxmouseregion.cpp | 22 +++++++++++++--------- src/declarative/fx/qfxmouseregion.h | 2 +- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 2d3fa8d..d5c231b 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1619,10 +1619,7 @@ QPointF QFxItemPrivate::computeTransformOrigin() const bool QFxItem::sceneEvent(QEvent *event) { - bool rv = QGraphicsItem::sceneEvent(event); - if (event->type() == QEvent::UngrabMouse) - mouseUngrabEvent(); - return rv; + return QGraphicsItem::sceneEvent(event); } QVariant QFxItem::itemChange(GraphicsItemChange change, @@ -1635,10 +1632,6 @@ QVariant QFxItem::itemChange(GraphicsItemChange change, return QGraphicsItem::itemChange(change, value); } -void QFxItem::mouseUngrabEvent() -{ -} - QRectF QFxItem::boundingRect() const { Q_D(const QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index b1676e4..e1bcb2f 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -226,7 +226,6 @@ protected: virtual bool sceneEvent(QEvent *); virtual bool event(QEvent *); virtual QVariant itemChange(GraphicsItemChange, const QVariant &); - virtual void mouseUngrabEvent(); void setImplicitWidth(qreal); bool widthValid() const; // ### better name? diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp index e4e7442..42e024d 100644 --- a/src/declarative/fx/qfxmouseregion.cpp +++ b/src/declarative/fx/qfxmouseregion.cpp @@ -437,17 +437,21 @@ void QFxMouseRegion::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } } -void QFxMouseRegion::mouseUngrabEvent() +bool QFxMouseRegion::sceneEvent(QEvent *event) { - Q_D(QFxMouseRegion); - if (d->pressed) { - // if our mouse grab has been removed (probably by Flickable), fix our - // state - d->pressed = false; - setKeepMouseGrab(false); - emit pressedChanged(); - //emit hoveredChanged(); + bool rv = QFxItem::sceneEvent(event); + if (event->type() == QEvent::UngrabMouse) { + Q_D(QFxMouseRegion); + if (d->pressed) { + // if our mouse grab has been removed (probably by Flickable), fix our + // state + d->pressed = false; + setKeepMouseGrab(false); + emit pressedChanged(); + //emit hoveredChanged(); + } } + return rv; } void QFxMouseRegion::timerEvent(QTimerEvent *event) diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h index 6d85cea..418434a 100644 --- a/src/declarative/fx/qfxmouseregion.h +++ b/src/declarative/fx/qfxmouseregion.h @@ -137,7 +137,7 @@ protected: void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); - void mouseUngrabEvent(); + bool sceneEvent(QEvent *); void timerEvent(QTimerEvent *event); private: -- cgit v0.12 From dba4cce953113926b0473dbe167f983a4aed0d08 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 5 Aug 2009 11:05:08 +1000 Subject: Add qDebug support for QFxItem*. --- src/declarative/fx/qfxitem.cpp | 14 ++++++++++++++ src/declarative/fx/qfxitem.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index d5c231b..02466d0 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1876,4 +1876,18 @@ bool QFxItem::event(QEvent *ev) return QGraphicsObject::event(ev); } +QDebug operator<<(QDebug debug, QFxItem *item) +{ + if (!item) { + debug << "QFxItem(0)"; + return debug; + } + + debug << item->metaObject()->className() << "(this =" << ((void*)item) + << ", parent =" << ((void*)item->parentItem()) + << ", geometry =" << QRectF(item->pos(), QSizeF(item->width(), item->height())) + << ", z =" << item->zValue() << ")"; + return debug; +} + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index e1bcb2f..c3607ef 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -274,6 +274,8 @@ T qobject_cast(QGraphicsItem *item) return qobject_cast(o); } +QDebug Q_DECLARATIVE_EXPORT operator<<(QDebug debug, QFxItem *item); + QT_END_NAMESPACE QML_DECLARE_TYPE(QFxContents) -- cgit v0.12 From 304238b586b75ee73d46d2de4ffdb0ed40218b70 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 5 Aug 2009 11:43:16 +1000 Subject: QmlMetaProperty::binding() should only return a binding if it is enabled. --- src/declarative/qml/qmlmetaproperty.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index e6ffd50..afd28bb 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -490,7 +490,7 @@ QmlBinding *QmlMetaProperty::binding() const QObject *child = *iter; if (child->metaObject() == &QmlBinding::staticMetaObject) { QmlBinding *v = static_cast(child); - if (v->property() == *this) + if (v->property() == *this && v->enabled()) return v; } } -- cgit v0.12 From a19afebf6acee64aa4a5c804a87846c91650a474 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 6 Aug 2009 13:01:12 +1000 Subject: Fix expression linked list. --- src/declarative/qml/qmlexpression.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 3206734..a9175ea 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -66,6 +66,7 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, const QString &expr, if (ctxt) { QmlContextPrivate *cp = ctxt->d_func(); nextExpression = cp->expressions; + if (nextExpression) nextExpression->prevExpression = &nextExpression; prevExpression = &cp->expressions; cp->expressions = this; } @@ -91,6 +92,7 @@ void QmlExpressionPrivate::init(QmlContext *ctxt, void *expr, QmlRefCount *rc, if (ctxt) { QmlContextPrivate *cp = ctxt->d_func(); nextExpression = cp->expressions; + if (nextExpression) nextExpression->prevExpression = &nextExpression; prevExpression = &cp->expressions; cp->expressions = this; } -- cgit v0.12 From d4ebb04b8f0db7821f5059fc31020362f85c7c30 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 6 Aug 2009 13:11:21 +1000 Subject: Don't leak bindings. Make sure we clean up bindings for a cancelled state change. --- src/declarative/util/qmlsetproperties.cpp | 1 + src/declarative/util/qmlstate.cpp | 11 ++++------- src/declarative/util/qmlstate.h | 1 + src/declarative/util/qmltransitionmanager.cpp | 16 ++++++++++++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index bbbc6a9..1cd4a79 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -335,6 +335,7 @@ QmlSetProperties::ActionList QmlSetProperties::actions() a.toValue = d->expressions.at(ii).second->value(); } else { a.toBinding = new QmlBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); + a.deletableToBinding = true; a.toBinding->setTarget(prop); } diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index b5ba909..9967486 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -54,14 +54,14 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); Action::Action() -: restore(true), actionDone(false), reverseEvent(false), fromBinding(0), toBinding(0), event(0), +: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), toBinding(0), event(0), specifiedObject(0) { } Action::Action(QObject *target, const QString &propertyName, const QVariant &value) -: restore(true), actionDone(false), reverseEvent(false), toValue(value), fromBinding(0), +: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), toValue(value), fromBinding(0), toBinding(0), event(0), specifiedObject(target), specifiedProperty(propertyName) { @@ -413,11 +413,8 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever SimpleAction r(action); additionalReverts << r; } - } else { - - if (!found || d->revertList.at(jj).binding != action.fromBinding) { - action.deleteFromBinding(); - } + } else if (d->revertList.at(jj).binding != action.fromBinding) { + action.deleteFromBinding(); } } diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 7c62768..9eb7aee 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -64,6 +64,7 @@ public: bool restore:1; bool actionDone:1; bool reverseEvent:1; + bool deletableToBinding:1; QmlMetaProperty property; QVariant fromValue; diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp index b2d9414..be082f8 100644 --- a/src/declarative/util/qmltransitionmanager.cpp +++ b/src/declarative/util/qmltransitionmanager.cpp @@ -239,10 +239,10 @@ void QmlTransitionManager::transition(const QList &list, } } if (!transition) - d->applyBindings(); //### merge into above foreach? + d->applyBindings(); } - +#include void QmlTransitionManager::cancel() { if (d->transition) { @@ -251,6 +251,18 @@ void QmlTransitionManager::cancel() d->transition = 0; } + for(int i = 0; i < d->bindingsList.count(); ++i) { + Action action = d->bindingsList[i]; + if (action.toBinding && action.deletableToBinding) { + action.property.setBinding(0); + delete action.toBinding; + action.toBinding = 0; + action.deletableToBinding = false; + } else if (action.event) { + //### what do we do here? + } + + } d->bindingsList.clear(); d->completeList.clear(); -- cgit v0.12 From f132fde07d0d852f2aa61dbc80d5d5f89ae5dcfa Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 6 Aug 2009 13:26:13 +1000 Subject: Don't init Number/Color animations twice. --- src/declarative/util/qmlanimation.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 27caf20..3240360 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -723,7 +723,6 @@ QmlColorAnimation::QmlColorAnimation(QObject *parent) : QmlPropertyAnimation(parent) { Q_D(QmlPropertyAnimation); - d->init(); d->interpolatorType = QMetaType::QColor; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); d->defaultToInterpolatorType = true; @@ -1199,7 +1198,6 @@ QmlNumberAnimation::QmlNumberAnimation(QObject *parent) : QmlPropertyAnimation(parent) { Q_D(QmlPropertyAnimation); - d->init(); d->interpolatorType = QMetaType::QReal; d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); } -- cgit v0.12 From 28a8c6b02e52bce8b2ac14961997b9c2cc0e01fd Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 6 Aug 2009 14:10:50 +1000 Subject: Use meta property cache for property restores --- src/declarative/qml/qmlengine_p.h | 4 ++ src/declarative/qml/qmlmetaproperty.cpp | 103 +++++++++++++++++++++----------- src/declarative/qml/qmlmetaproperty_p.h | 13 +++- 3 files changed, 84 insertions(+), 36 deletions(-) diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index dffae6c..602321d 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -179,6 +179,10 @@ public: QmlValueTypeFactory valueTypes; QHash propertyCache; + static QmlMetaObjectCache *cache(QmlEnginePrivate *priv, QObject *obj) { + if (!priv || !obj || QObjectPrivate::get(obj)->metaObject) return 0; + return &priv->propertyCache[obj->metaObject()]; + } struct Imports { Imports(); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 350d84b..c445599 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -56,25 +56,53 @@ Q_DECLARE_METATYPE(QList); QT_BEGIN_NAMESPACE -QmlMetaObjectCache::Data -QmlMetaObjectCache::property(const QString &name, const QMetaObject *metaObject) +QmlMetaObjectCache::QmlMetaObjectCache() +: propertyCache(0) { - QHash::ConstIterator iter = properties.find(name); - if (iter != properties.end()) { - return *iter; - } else { - Data cacheData = { -1, -1 }; +} + +void QmlMetaObjectCache::init(const QMetaObject *metaObject) +{ + if (propertyCache || !metaObject) + return; + + int propCount = metaObject->propertyCount(); + + propertyCache = new Data[propCount]; + for (int ii = 0; ii < propCount; ++ii) { + QMetaProperty p = metaObject->property(ii); + propertyCache[ii].propType = p.userType(); + propertyCache[ii].coreIndex = ii; + propertyCache[ii].name = QLatin1String(p.name()); + + propertyNameCache.insert(propertyCache[ii].name, ii); + } +} + +QmlMetaObjectCache::~QmlMetaObjectCache() +{ + delete [] propertyCache; +} + +QmlMetaObjectCache::Data * +QmlMetaObjectCache::property(int index, const QMetaObject *metaObject) +{ + init(metaObject); - int idx = metaObject->indexOfProperty(name.toUtf8().constData()); - if (idx == -1) - return cacheData; + return propertyCache + index; +} + +QmlMetaObjectCache::Data * +QmlMetaObjectCache::property(const QString &name, const QMetaObject *metaObject) +{ + init(metaObject); - QMetaProperty property = metaObject->property(idx); - cacheData.propType = property.userType(); - cacheData.coreIndex = idx; - properties.insert(name, cacheData); + QHash::ConstIterator iter = propertyNameCache.find(name); - return cacheData; + if (iter != propertyNameCache.end()) { + return propertyCache + *iter; + } else { + return 0; } } @@ -99,14 +127,6 @@ QmlMetaProperty::~QmlMetaProperty() delete d; d = 0; } -struct CachedPropertyData { - CachedPropertyData(const QString &n, int pt, int ci) - : name(n), propType(pt), coreIdx(ci) {} - QString name; - int propType; - int coreIdx; -}; - /*! Creates a QmlMetaProperty for the default property of \a obj. If there is no default property, an invalid QmlMetaProperty will be created. @@ -218,15 +238,14 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) } // Property - if (!QObjectPrivate::get(obj)->metaObject && enginePrivate) { - // Can cache - QmlMetaObjectCache &cache = - enginePrivate->propertyCache[obj->metaObject()]; - QmlMetaObjectCache::Data data = cache.property(name, obj->metaObject()); - if (data.coreIndex != -1) { + QmlMetaObjectCache *cache = QmlEnginePrivate::cache(enginePrivate, obj); + if (cache) { + QmlMetaObjectCache::Data *data = + cache->property(name, obj->metaObject()); + if (data) { type = QmlMetaProperty::Property; - propType = data.propType; - coreIdx = data.coreIndex; + propType = data->propType; + coreIdx = data->coreIndex; } } else { // Can't cache @@ -1015,6 +1034,10 @@ quint32 QmlMetaPropertyPrivate::saveProperty(int core) */ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) { + QmlEnginePrivate *enginePrivate = 0; + if (ctxt && ctxt->engine()) + enginePrivate = QmlEnginePrivate::get(ctxt->engine()); + d->object = obj; d->context = ctxt; @@ -1042,10 +1065,22 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj, QmlContext *ctxt) d->valueTypeId = p.type(); } else if (d->type & Property) { - QMetaProperty p(obj->metaObject()->property(id)); - d->name = QLatin1String(p.name()); - d->propType = p.userType(); + + QmlMetaObjectCache *cache = QmlEnginePrivate::cache(enginePrivate, obj); + d->coreIdx = id; + + if (cache) { + QmlMetaObjectCache::Data *data = + cache->property(id, obj->metaObject()); + d->propType = data->propType; + d->name = data->name; + } else { + QMetaProperty p(obj->metaObject()->property(id)); + d->name = QLatin1String(p.name()); + d->propType = p.userType(); + } + } else if (d->type & SignalProperty) { d->signal = obj->metaObject()->method(id); d->coreIdx = id; diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 0410dd6..8e8966e 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -61,14 +61,23 @@ QT_BEGIN_NAMESPACE class QmlMetaObjectCache { public: + QmlMetaObjectCache(); + ~QmlMetaObjectCache(); + struct Data { int propType; int coreIndex; + QString name; }; - QHash properties; + Data *property(const QString &, const QMetaObject *); + Data *property(int, const QMetaObject *); + +private: + void init(const QMetaObject *); - Data property(const QString &, const QMetaObject *); + Data *propertyCache; + QHash propertyNameCache; }; class QmlContext; -- cgit v0.12 From 9fcf4d49ca04b6dab94b19530899a452521e91de Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 6 Aug 2009 14:56:08 +1000 Subject: Remove debug. --- src/declarative/util/qmltransitionmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp index be082f8..f04a821 100644 --- a/src/declarative/util/qmltransitionmanager.cpp +++ b/src/declarative/util/qmltransitionmanager.cpp @@ -242,7 +242,7 @@ void QmlTransitionManager::transition(const QList &list, d->applyBindings(); } -#include + void QmlTransitionManager::cancel() { if (d->transition) { -- cgit v0.12 From 3270c41c1e1f78b403a4d587d726203520eb707b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 6 Aug 2009 15:50:49 +1000 Subject: Add a QmlMetaType::typeCategory() method QmlMetaProperty was calling isObject(), isList() and isQmlList() to determine its property category, resulting in acquiring and releasing three locks (one for each call). This call allows QmlMetaProperty to do the same with only one lock. --- src/declarative/qml/qmlmetaproperty.cpp | 25 +++++++++++++++++-------- src/declarative/qml/qmlmetatype.cpp | 16 ++++++++++++++++ src/declarative/qml/qmlmetatype.h | 3 +++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index c445599..09ca872 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -310,14 +310,23 @@ QmlMetaPropertyPrivate::propertyCategory() const category = QmlMetaProperty::Normal; else if (type == qMetaTypeId()) category = QmlMetaProperty::Bindable; - else if (QmlMetaType::isList(type)) - category = QmlMetaProperty::List; - else if (QmlMetaType::isQmlList(type)) - category = QmlMetaProperty::QmlList; - else if (QmlMetaType::isObject(type)) - category = QmlMetaProperty::Object; - else - category = QmlMetaProperty::Normal; + else { + QmlMetaType::TypeCategory tc = QmlMetaType::typeCategory(type); + switch(tc) { + case QmlMetaType::Object: + category = QmlMetaProperty::Object; + break; + case QmlMetaType::QmlList: + category = QmlMetaProperty::QmlList; + break; + case QmlMetaType::List: + category = QmlMetaProperty::List; + break; + case QmlMetaType::Unknown: + category = QmlMetaProperty::Normal; + break; + } + } } return category; } diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 29fe026..50bc676 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -794,6 +794,22 @@ QMetaProperty QmlMetaType::property(QObject *obj, const char *name) return metaObject->property(idx); } +QmlMetaType::TypeCategory QmlMetaType::typeCategory(int userType) +{ + if (userType < 0) + return Unknown; + QReadLocker lock(metaTypeDataLock()); + QmlMetaTypeData *data = metaTypeData(); + if (userType < data->objects.size() && data->objects.testBit(userType)) + return Object; + else if (userType < data->qmllists.size() && data->qmllists.testBit(userType)) + return QmlList; + else if (userType < data->lists.size() && data->lists.testBit(userType)) + return List; + else + return Unknown; +} + bool QmlMetaType::isObject(int userType) { QReadLocker lock(metaTypeDataLock()); diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index e023e83..9cbf7f3 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -94,6 +94,9 @@ public: static QmlAttachedPropertiesFunc attachedPropertiesFuncById(int); static QmlAttachedPropertiesFunc attachedPropertiesFunc(const QByteArray &); + enum TypeCategory { Unknown, Object, List, QmlList }; + static TypeCategory typeCategory(int); + static bool isInterface(int); static const char *interfaceIId(int); static bool isObject(int); -- cgit v0.12 From 5eec63013bafc3b737c1375158128b3288ce7d70 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 6 Aug 2009 16:44:58 +1000 Subject: Mico-optimization for animations. --- src/declarative/util/qmlanimation.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 3240360..f3691ea 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1494,7 +1494,9 @@ QmlPropertyAnimation::~QmlPropertyAnimation() void QmlPropertyAnimationPrivate::init() { Q_Q(QmlPropertyAnimation); - va = new QmlTimeLineValueAnimator(q); + va = new QmlTimeLineValueAnimator; + QFx_setParent_noEvent(va, q); + va->setStartValue(QVariant(0.0f)); va->setEndValue(QVariant(1.0f)); } -- cgit v0.12 From 0be2e2205412d7147f6dd937aa870b0060d76100 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 6 Aug 2009 17:59:43 +1000 Subject: Add QFxLayoutItem The LayoutItem allows fluid parts to be resized using classical Qt layouts. --- src/declarative/fx/fx.pri | 2 + src/declarative/fx/qfxlayoutitem.cpp | 105 +++++++++++++++++++++++++++++++++++ src/declarative/fx/qfxlayoutitem.h | 93 +++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 src/declarative/fx/qfxlayoutitem.cpp create mode 100644 src/declarative/fx/qfxlayoutitem.h diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index bbb09fb..a6c5281 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -42,6 +42,7 @@ HEADERS += \ fx/qfxvisualitemmodel.h \ fx/qfxlistview.h \ fx/qfxgraphicsobjectcontainer.h \ + fx/qfxlayoutitem.h \ SOURCES += \ fx/qfxanchors.cpp \ @@ -71,6 +72,7 @@ SOURCES += \ fx/qfxvisualitemmodel.cpp \ fx/qfxlistview.cpp \ fx/qfxgraphicsobjectcontainer.cpp \ + fx/qfxlayoutitem.cpp \ contains(QT_CONFIG, webkit) { QT+=webkit diff --git a/src/declarative/fx/qfxlayoutitem.cpp b/src/declarative/fx/qfxlayoutitem.cpp new file mode 100644 index 0000000..446a8d7 --- /dev/null +++ b/src/declarative/fx/qfxlayoutitem.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** 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 "qfxlayoutitem.h" +#include +#include + +QT_BEGIN_NAMESPACE + +QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,LayoutItem,QFxLayoutItem) + +/*! + \qmlclass LayoutItem QFxLayoutItem + \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout. +*/ + +/*! + \internal + \class QFxLayoutItem + \brief The QFxLayoutItem class allows you to place your Fluid UI elements inside a classical Qt layout. +*/ + + +/*! + \qmlproperty QSizeF LayoutItem::maximumSize + + The maximumSize property can be set to specify the maximum desired size of this LayoutItem +*/ + +/*! + \qmlproperty QSizeF LayoutItem::minimumSize + + The minimumSize property can be set to specify the minimum desired size of this LayoutItem +*/ + +/*! + \qmlproperty QSizeF LayoutItem::preferredSize + + The preferredSize property can be set to specify the preferred size of this LayoutItem +*/ + +QFxLayoutItem::QFxLayoutItem(QFxItem* parent) + : QFxItem(parent), m_maximumSize(INT_MAX,INT_MAX), m_preferredSize(100,100), m_minimumSize(0,0) +{ + setGraphicsItem(this); +} + +void QFxLayoutItem::setGeometry(const QRectF & rect) +{ + setX(rect.x()); + setY(rect.y()); + setWidth(rect.width()); + setHeight(rect.height()); +} + +QSizeF QFxLayoutItem::sizeHint(Qt::SizeHint w, const QSizeF &constraint) const +{ + if(w == Qt::MinimumSize){ + return m_minimumSize; + }else if(w == Qt::MaximumSize){ + return m_maximumSize; + }else{ + return m_preferredSize; + } +} + +QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxlayoutitem.h b/src/declarative/fx/qfxlayoutitem.h new file mode 100644 index 0000000..7150554 --- /dev/null +++ b/src/declarative/fx/qfxlayoutitem.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 QFXGRAPHICSLAYOUTITEM_H +#define QFXGRAPHICSLAYOUTITEM_H +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QFxLayoutItem : public QFxItem, public QGraphicsLayoutItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayoutItem) + Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize NOTIFY maximumSizeChanged) + Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged) + Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize NOTIFY preferredSizeChanged) +public: + QFxLayoutItem(QFxItem* parent=0); + + QSizeF maximumSize() const { return m_maximumSize; } + void setMaximumSize(const QSizeF &s) { if(s==m_maximumSize) return; m_maximumSize = s; emit maximumSizeChanged(); } + + QSizeF minimumSize() const { return m_minimumSize; } + void setMinimumSize(const QSizeF &s) { if(s==m_minimumSize) return; m_minimumSize = s; emit minimumSizeChanged(); } + + QSizeF preferredSize() const { return m_preferredSize; } + void setPreferredSize(const QSizeF &s) { if(s==m_preferredSize) return; m_preferredSize = s; emit preferredSizeChanged(); } + + virtual void setGeometry(const QRectF & rect); +protected: + virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; + +Q_SIGNALS: + void maximumSizeChanged(); + void minimumSizeChanged(); + void preferredSizeChanged(); + +private: + QSizeF m_maximumSize; + QSizeF m_minimumSize; + QSizeF m_preferredSize; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QFxLayoutItem) + +QT_END_HEADER +#endif -- cgit v0.12