From 4c26e112f59d6f5305717b70886b845bc904b889 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 26 Feb 2010 14:48:11 +1000 Subject: Polish QDeclarativeProperty API --- src/declarative/qml/qdeclarativebinding.cpp | 4 +- src/declarative/qml/qdeclarativeproperty.cpp | 111 +++++++-- src/declarative/qml/qdeclarativeproperty.h | 54 +++-- src/declarative/qml/qdeclarativeproperty_p.h | 9 +- src/declarative/qml/qdeclarativevme.cpp | 6 +- src/declarative/util/qdeclarativestate_p.h | 2 + .../tst_qdeclarativeproperty.cpp | 251 ++++++++++----------- 7 files changed, 247 insertions(+), 190 deletions(-) diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index cecca65..88ca5cd 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -130,7 +130,7 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags) if (data->property.propertyType() == qMetaTypeId()) { - int idx = data->property.coreIndex(); + int idx = data->property.index(); Q_ASSERT(idx != -1); @@ -223,7 +223,7 @@ void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteF int QDeclarativeBinding::propertyIndex() { Q_D(QDeclarativeBinding); - return d->bindingData()->property.coreIndex(); + return d->bindingData()->property.index(); } bool QDeclarativeBinding::enabled() const diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index fbea6ac..9ed760e 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -115,7 +115,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj) } /*! - \internal Creates a QDeclarativeProperty for the default property of \a obj. If there is no default property, an invalid QDeclarativeProperty will be created. */ @@ -124,6 +123,20 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeContext *ct { d->q = this; d->context = ctxt; + d->engine = ctxt?ctxt->engine():0; + d->initDefault(obj); +} + +/*! + Creates a QDeclarativeProperty for the default property of \a obj. If there is no + default property, an invalid QDeclarativeProperty will be created. + */ +QDeclarativeProperty::QDeclarativeProperty(QObject *obj, QDeclarativeEngine *engine) +: d(new QDeclarativePropertyPrivate) +{ + d->q = this; + d->context = 0; + d->engine = engine; d->initDefault(obj); } @@ -137,10 +150,8 @@ void QDeclarativePropertyPrivate::initDefault(QObject *obj) QMetaProperty p = QDeclarativeMetaType::defaultProperty(obj); core.load(p); - if (core.isValid()) { - isDefaultProperty = true; + if (core.isValid()) object = obj; - } } /*! @@ -155,7 +166,6 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name) } /*! - \internal Creates a QDeclarativeProperty for the property \a name of \a obj. */ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeContext *ctxt) @@ -163,8 +173,22 @@ QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QD { d->q = this; d->context = ctxt; + d->engine = ctxt?ctxt->engine():0; + d->initProperty(obj, name); + if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; } +} + +/*! + Creates a QDeclarativeProperty for the property \a name of \a obj. + */ +QDeclarativeProperty::QDeclarativeProperty(QObject *obj, const QString &name, QDeclarativeEngine *engine) +: d(new QDeclarativePropertyPrivate) +{ + d->q = this; + d->context = 0; + d->engine = engine; d->initProperty(obj, name); - if (!isValid()) { d->object = 0; d->context = 0; } + if (!isValid()) { d->object = 0; d->context = 0; d->engine = 0; } } Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes); @@ -173,7 +197,6 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name { if (!obj) return; - QDeclarativeEngine *engine = context?context->engine():0; QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0; QStringList path = name.split(QLatin1Char('.')); @@ -267,7 +290,7 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name // Property QDeclarativePropertyCache::Data local; QDeclarativePropertyCache::Data *property = - QDeclarativePropertyCache::property(context?context->engine():0, currentObject, terminal, local); + QDeclarativePropertyCache::property(engine, currentObject, terminal, local); if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction)) { object = currentObject; core = *property; @@ -302,7 +325,6 @@ QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other) \value Invalid The property is invalid. \value Property The property is a regular Qt property. \value SignalProperty The property is a signal property. - \value Default The property is the default property. */ /*! @@ -413,7 +435,7 @@ QDeclarativeProperty::Type QDeclarativeProperty::type() const if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction) return SignalProperty; else if (d->core.isValid()) - return (Type)(Property | ((d->isDefaultProperty)?Default:0)); + return Property; else return Invalid; } @@ -427,11 +449,11 @@ bool QDeclarativeProperty::isProperty() const } /*! - Returns true if this QDeclarativeProperty represents a default property. + Returns true if this QDeclarativeProperty represents a QML signal property. */ -bool QDeclarativeProperty::isDefault() const +bool QDeclarativeProperty::isSignalProperty() const { - return type() & Default; + return type() & SignalProperty; } /*! @@ -448,9 +470,9 @@ QObject *QDeclarativeProperty::object() const QDeclarativeProperty &QDeclarativeProperty::operator=(const QDeclarativeProperty &other) { d->context = other.d->context; + d->engine = other.d->engine; d->object = other.d->object; - d->isDefaultProperty = other.d->isDefaultProperty; d->isNameCached = other.d->isNameCached; d->core = other.d->core; d->nameCache = other.d->nameCache; @@ -521,7 +543,7 @@ QString QDeclarativeProperty::name() const } else if (d->isValueType()) { QString rv = d->core.name(d->object) + QLatin1Char('.'); - QDeclarativeEnginePrivate *ep = d->context?QDeclarativeEnginePrivate::get(d->context->engine()):0; + QDeclarativeEnginePrivate *ep = d->engine?QDeclarativeEnginePrivate::get(d->engine):0; QDeclarativeValueType *valueType = 0; if (ep) valueType = ep->valueTypes[d->core.propType]; else valueType = QDeclarativeValueTypeFactory::valueType(d->core.propType); @@ -669,7 +691,7 @@ QDeclarativePropertyPrivate::signalExpression(const QDeclarativeProperty &that) QObject *child = children.at(ii); QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child); - if (signal && signal->index() == that.coreIndex()) + if (signal && signal->index() == that.index()) return signal->expression(); } @@ -698,7 +720,7 @@ QDeclarativePropertyPrivate::setSignalExpression(const QDeclarativeProperty &tha QObject *child = children.at(ii); QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child); - if (signal && signal->index() == that.coreIndex()) + if (signal && signal->index() == that.index()) return signal->setExpression(expr); } @@ -730,6 +752,24 @@ QVariant QDeclarativeProperty::read() const return QVariant(); } +QVariant QDeclarativeProperty::read(QObject *object, const QString &name) +{ + QDeclarativeProperty p(object, name); + return p.read(); +} + +QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeContext *ctxt) +{ + QDeclarativeProperty p(object, name, ctxt); + return p.read(); +} + +QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeEngine *engine) +{ + QDeclarativeProperty p(object, name, engine); + return p.read(); +} + QVariant QDeclarativePropertyPrivate::readValueProperty() { if(isValueType()) { @@ -753,7 +793,7 @@ QVariant QDeclarativePropertyPrivate::readValueProperty() QDeclarativeListProperty prop; void *args[] = { &prop, 0 }; QMetaObject::metacall(object, QMetaObject::ReadProperty, core.coreIndex, args); - return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, context?context->engine():0)); + return QVariant::fromValue(QDeclarativeListReferencePrivate::init(prop, core.propType, engine)); } else { @@ -952,13 +992,13 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope for (int ii = 0; ii < list.count(); ++ii) { QObject *o = list.at(ii); - if (!canConvert(o->metaObject(), listType)) + if (o && !canConvert(o->metaObject(), listType)) o = 0; prop.append(&prop, (void *)o); } } else { QObject *o = enginePriv?enginePriv->toQObject(value):QDeclarativeMetaType::toQObject(value); - if (!canConvert(o->metaObject(), listType)) + if (o && !canConvert(o->metaObject(), listType)) o = 0; prop.append(&prop, (void *)o); } @@ -1014,6 +1054,26 @@ bool QDeclarativeProperty::write(const QVariant &value) const return QDeclarativePropertyPrivate::write(*this, value, 0); } +bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value) +{ + QDeclarativeProperty p(object, name); + return p.write(value); +} + +bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value, + QDeclarativeContext *ctxt) +{ + QDeclarativeProperty p(object, name, ctxt); + return p.write(value); +} + +bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value, + QDeclarativeEngine *engine) +{ + QDeclarativeProperty p(object, name, engine); + return p.write(value); +} + /*! Resets the property value. */ @@ -1041,7 +1101,7 @@ bool QDeclarativePropertyPrivate::write(const QDeclarativeProperty &that, /*! Returns true if the property has a change notifier signal, otherwise false. */ -bool QDeclarativeProperty::hasChangedNotifier() const +bool QDeclarativeProperty::hasNotifySignal() const { if (type() & Property && d->object) { return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal(); @@ -1056,7 +1116,7 @@ bool QDeclarativeProperty::hasChangedNotifier() const Some properties, such as attached properties or those whose value never changes, do not require a change notifier. */ -bool QDeclarativeProperty::needsChangedNotifier() const +bool QDeclarativeProperty::needsNotifySignal() const { return type() & Property && !property().isConstant(); } @@ -1069,7 +1129,7 @@ bool QDeclarativeProperty::needsChangedNotifier() const change notifier signal, or if the \a dest object does not have the specified \a method. */ -bool QDeclarativeProperty::connectNotifier(QObject *dest, int method) const +bool QDeclarativeProperty::connectNotifySignal(QObject *dest, int method) const { if (!(type() & Property) || !d->object) return false; @@ -1090,7 +1150,7 @@ bool QDeclarativeProperty::connectNotifier(QObject *dest, int method) const change notifier signal, or if the \a dest object does not have the specified \a slot. */ -bool QDeclarativeProperty::connectNotifier(QObject *dest, const char *slot) const +bool QDeclarativeProperty::connectNotifySignal(QObject *dest, const char *slot) const { if (!(type() & Property) || !d->object) return false; @@ -1107,7 +1167,7 @@ bool QDeclarativeProperty::connectNotifier(QObject *dest, const char *slot) cons /*! Return the Qt metaobject index of the property. */ -int QDeclarativeProperty::coreIndex() const +int QDeclarativeProperty::index() const { return d->core.coreIndex; } @@ -1164,6 +1224,7 @@ QDeclarativePropertyPrivate::restore(const QByteArray &data, QObject *object, QD prop.d->object = object; prop.d->context = ctxt; + prop.d->engine = ctxt?ctxt->engine():0; const SerializedData *sd = (const SerializedData *)data.constData(); if (sd->isValueType) { diff --git a/src/declarative/qml/qdeclarativeproperty.h b/src/declarative/qml/qdeclarativeproperty.h index 3504a15..73bccf3 100644 --- a/src/declarative/qml/qdeclarativeproperty.h +++ b/src/declarative/qml/qdeclarativeproperty.h @@ -51,11 +51,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QObject; -class QDeclarativeAbstractBinding; -class QDeclarativeExpression; -class QStringList; class QVariant; -struct QMetaObject; class QDeclarativeContext; class QDeclarativeEngine; @@ -70,10 +66,10 @@ public: Normal }; - enum Type { Invalid = 0x00, - Property = 0x01, - SignalProperty = 0x02, - Default = 0x08 + enum Type { + Invalid, + Property, + SignalProperty }; QDeclarativeProperty(); @@ -81,45 +77,55 @@ public: QDeclarativeProperty(QObject *); QDeclarativeProperty(QObject *, QDeclarativeContext *); + QDeclarativeProperty(QObject *, QDeclarativeEngine *); QDeclarativeProperty(QObject *, const QString &); QDeclarativeProperty(QObject *, const QString &, QDeclarativeContext *); + QDeclarativeProperty(QObject *, const QString &, QDeclarativeEngine *); QDeclarativeProperty(const QDeclarativeProperty &); QDeclarativeProperty &operator=(const QDeclarativeProperty &); + bool operator==(const QDeclarativeProperty &) const; + + Type type() const; + bool isValid() const; + bool isProperty() const; + bool isSignalProperty() const; + + int propertyType() const; + PropertyTypeCategory propertyTypeCategory() const; + const char *propertyTypeName() const; + QString name() const; QVariant read() const; + static QVariant read(QObject *, const QString &); + static QVariant read(QObject *, const QString &, QDeclarativeContext *); + static QVariant read(QObject *, const QString &, QDeclarativeEngine *); + bool write(const QVariant &) const; + static bool write(QObject *, const QString &, const QVariant &); + static bool write(QObject *, const QString &, const QVariant &, QDeclarativeContext *); + static bool write(QObject *, const QString &, const QVariant &, QDeclarativeEngine *); + bool reset() const; - bool hasChangedNotifier() const; - bool needsChangedNotifier() const; - bool connectNotifier(QObject *dest, const char *slot) const; - bool connectNotifier(QObject *dest, int method) const; + bool hasNotifySignal() const; + bool needsNotifySignal() const; + bool connectNotifySignal(QObject *dest, const char *slot) const; + bool connectNotifySignal(QObject *dest, int method) const; - Type type() const; - bool isProperty() const; - bool isDefault() const; bool isWritable() const; bool isDesignable() const; bool isResettable() const; - bool isValid() const; QObject *object() const; - int propertyType() const; - PropertyTypeCategory propertyTypeCategory() const; - const char *propertyTypeName() const; - - bool operator==(const QDeclarativeProperty &) const; - - int coreIndex() const; + int index() const; QMetaProperty property() const; QMetaMethod method() const; private: - friend class QDeclarativeEnginePrivate; friend class QDeclarativePropertyPrivate; QDeclarativePropertyPrivate *d; }; diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index eb5fa9a..1fda7f4 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -64,6 +64,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeContext; class QDeclarativeEnginePrivate; +class QDeclarativeExpression; class Q_AUTOTEST_EXPORT QDeclarativePropertyPrivate { public: @@ -71,20 +72,20 @@ public: Q_DECLARE_FLAGS(WriteFlags, WriteFlag) QDeclarativePropertyPrivate() - : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false) {} + : q(0), context(0), engine(0), object(0), isNameCached(false) {} QDeclarativePropertyPrivate(const QDeclarativePropertyPrivate &other) - : q(0), context(other.context), object(other.object), - isDefaultProperty(other.isDefaultProperty), isNameCached(other.isNameCached), + : q(0), context(other.context), engine(other.engine), object(other.object), + isNameCached(other.isNameCached), core(other.core), nameCache(other.nameCache), valueType(other.valueType) {} QDeclarativeProperty *q; QDeclarativeContext *context; + QDeclarativeEngine *engine; QDeclarativeGuard object; - bool isDefaultProperty:1; bool isNameCached:1; QDeclarativePropertyCache::Data core; QString nameCache; diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index baa98bd..720b496 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -525,7 +525,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, QDeclarati if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature())) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature()))); - QMetaObject::connect(target, prop.coreIndex(), assign, method.methodIndex()); + QMetaObject::connect(target, prop.index(), assign, method.methodIndex()); } else { VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr))); @@ -593,7 +593,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, QDeclarati QDeclarativeProperty mp = QDeclarativePropertyPrivate::restore(datas.at(instr.assignBinding.property), target, ctxt); - int coreIndex = mp.coreIndex(); + int coreIndex = mp.index(); if (stack.count() == 1 && bindingSkipList.testBit(coreIndex)) break; @@ -648,7 +648,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, QDeclarati obj->setParent(target); vi->setTarget(prop); QDeclarativeVMEMetaObject *mo = static_cast((QMetaObject*)target->metaObject()); - mo->registerInterceptor(prop.coreIndex(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi); + mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi); } break; diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h index abdbec5..0c6e7a3 100644 --- a/src/declarative/util/qdeclarativestate_p.h +++ b/src/declarative/util/qdeclarativestate_p.h @@ -53,7 +53,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QDeclarativeActionEvent; +class QDeclarativeAbstractBinding; class QDeclarativeBinding; +class QDeclarativeExpression; class Q_DECLARATIVE_EXPORT QDeclarativeAction { public: diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index c72c9e7..0333d98 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -140,18 +140,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty() QCOMPARE(prop.name(), QString()); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -167,7 +166,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), -1); + QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -234,18 +233,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() QCOMPARE(prop.name(), QString()); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -261,7 +259,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), -1); + QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -281,18 +279,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() QCOMPARE(prop.name(), QString("defaultProperty")); QCOMPARE(prop.read(), QVariant(10)); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), true); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), (QDeclarativeProperty::Type)(QDeclarativeProperty::Property | QDeclarativeProperty::Default)); + QCOMPARE(prop.type(), QDeclarativeProperty::Property); QCOMPARE(prop.isProperty(), true); - QCOMPARE(prop.isDefault(), true); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); QCOMPARE(prop.isResettable(), false); @@ -310,7 +307,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -335,18 +332,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.name(), QString()); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -362,7 +358,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), -1); + QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -382,18 +378,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.name(), QString("defaultProperty")); QCOMPARE(prop.read(), QVariant(10)); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), true); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); QCOMPARE(prop.type(), QDeclarativeProperty::Property); QCOMPARE(prop.isProperty(), true); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); QCOMPARE(prop.isResettable(), false); @@ -411,7 +406,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -431,18 +426,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.name(), QString("onClicked")); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant("Hello")), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QCOMPARE(QString(prop.method().signature()), QString("clicked()")); QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -459,7 +453,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -479,18 +473,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal")); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant("Hello")), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -507,7 +500,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string() QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -532,18 +525,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() QCOMPARE(prop.name(), QString()); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -559,7 +551,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), -1); + QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -579,18 +571,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() QCOMPARE(prop.name(), QString("defaultProperty")); QCOMPARE(prop.read(), QVariant(10)); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), true); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); - QCOMPARE(prop.type(), (QDeclarativeProperty::Type)(QDeclarativeProperty::Property | QDeclarativeProperty::Default)); + QCOMPARE(prop.type(), QDeclarativeProperty::Property); QCOMPARE(prop.isProperty(), true); - QCOMPARE(prop.isDefault(), true); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); QCOMPARE(prop.isResettable(), false); @@ -608,7 +599,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_context() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -633,18 +624,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.name(), QString()); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); QCOMPARE(prop.type(), QDeclarativeProperty::Invalid); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -660,7 +650,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), -1); + QCOMPARE(prop.index(), -1); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -680,18 +670,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.name(), QString("defaultProperty")); QCOMPARE(prop.read(), QVariant(10)); QCOMPARE(prop.write(QVariant()), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), true); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), true); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QVERIFY(prop.method().signature() == 0); QCOMPARE(prop.type(), QDeclarativeProperty::Property); QCOMPARE(prop.isProperty(), true); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), true); QCOMPARE(prop.isResettable(), false); @@ -709,7 +698,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0); QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression == 0); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfProperty("defaultProperty")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -729,18 +718,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.name(), QString("onClicked")); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant("Hello")), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QCOMPARE(QString(prop.method().signature()), QString("clicked()")); QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -757,7 +745,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("clicked()")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; @@ -777,18 +765,17 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal")); QCOMPARE(prop.read(), QVariant()); QCOMPARE(prop.write(QVariant("Hello")), false); - QCOMPARE(prop.hasChangedNotifier(), false); - QCOMPARE(prop.needsChangedNotifier(), false); - QCOMPARE(prop.connectNotifier(0, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, SLOT(deleteLater())), false); - QCOMPARE(prop.connectNotifier(obj, 0), false); - QCOMPARE(prop.connectNotifier(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); - QCOMPARE(prop.connectNotifier(obj, -1), false); + QCOMPARE(prop.hasNotifySignal(), false); + QCOMPARE(prop.needsNotifySignal(), false); + QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false); + QCOMPARE(prop.connectNotifySignal(obj, 0), false); + QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false); + QCOMPARE(prop.connectNotifySignal(obj, -1), false); QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()")); QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty); QCOMPARE(prop.isProperty(), false); - QCOMPARE(prop.isDefault(), false); QCOMPARE(prop.isWritable(), false); QCOMPARE(prop.isDesignable(), false); QCOMPARE(prop.isResettable(), false); @@ -805,7 +792,7 @@ void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context() QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression) == 0); QVERIFY(expression != 0); QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression); - QCOMPARE(prop.coreIndex(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); + QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1); delete obj; -- cgit v0.12 From 1156821731078b0f0b31066632de091754bc6d52 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 26 Feb 2010 16:29:43 +1000 Subject: update painted geometry on pixmapChanged rather than sourceChanged --- src/declarative/graphicsitems/qdeclarativeimage.cpp | 12 +++--------- src/declarative/graphicsitems/qdeclarativeimage_p.h | 1 - 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index 338b086..99ab053 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -127,7 +127,7 @@ QT_BEGIN_NAMESPACE QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent) : QDeclarativeImageBase(*(new QDeclarativeImagePrivate), parent) { - connect(this, SIGNAL(sourceChanged(QUrl)), this, SLOT(updatePaintedGeometry())); + connect(this, SIGNAL(pixmapChanged()), this, SLOT(updatePaintedGeometry())); } QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent) @@ -139,12 +139,6 @@ QDeclarativeImage::~QDeclarativeImage() { } -void QDeclarativeImage::setSource(const QUrl &url) -{ - QDeclarativeImageBase::setSource(url); - updatePaintedGeometry(); -} - /*! \qmlproperty QPixmap Image::pixmap @@ -268,10 +262,10 @@ void QDeclarativeImage::updatePaintedGeometry() Q_D(QDeclarativeImage); if (d->fillMode == PreserveAspectFit) { - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); if (!d->pix.width() || !d->pix.height()) return; + qreal widthScale = width() / qreal(d->pix.width()); + qreal heightScale = height() / qreal(d->pix.height()); if (widthScale <= heightScale) { d->paintedWidth = width(); d->paintedHeight = widthScale * qreal(d->pix.height()); diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/declarative/graphicsitems/qdeclarativeimage_p.h index 5b365e7..fb77ac9 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimage_p.h @@ -76,7 +76,6 @@ public: qreal paintedWidth() const; qreal paintedHeight() const; - void setSource(const QUrl &url); void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); Q_SIGNALS: -- cgit v0.12 From bd0f827713187c95df3a5cf0e496fe18a1489971 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 26 Feb 2010 16:47:50 +1000 Subject: Doc --- src/declarative/qml/qdeclarativelist.cpp | 113 +++++++++++++++++++++++++-- src/declarative/qml/qdeclarativeproperty.cpp | 50 ++++++++++-- 2 files changed, 150 insertions(+), 13 deletions(-) diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp index af720d7..9691f32 100644 --- a/src/declarative/qml/qdeclarativelist.cpp +++ b/src/declarative/qml/qdeclarativelist.cpp @@ -85,18 +85,57 @@ void QDeclarativeListReferencePrivate::release() delete this; } +/*! +\class QDeclarativeListReference +\brief The QDeclarativeListReference class allows the manipulation of QDeclarativeListProperty properties. + +QDeclarativeListReference allows programs to read from, and assign values to a QML list property in a +simple and type safe way. A QDeclarativeListReference can be created by passing an object and property +name or through a QDeclarativeProperty instance. These two are equivalant: + +\code +QDeclarativeListReference ref1(object, "children"); + +QDeclarativeProperty ref2(object, "children"); +QDeclarativeListReference ref2 = qvariant_cast(ref2.read()); +\endcode + +Not all QML list properties support all operations. A set of methods, canAppend(), canAt(), canClear() and +canCount() allow programs to query whether an operation is supported on a given property. + +QML list properties are typesafe. Only QObject's that derive from the correct base class can be assigned to +the list. The listElementType() method can be used to query the QMetaObject of the QObject type supported. +Attempting to add objects of the incorrect type to a list property will fail. + +Like with normal lists, when accessing a list element by index, it is the callers responsibility to ensure +that it does not request an out of range element using the count() method before calling at(). +*/ + +/*! +Constructs an invalid instance. +*/ QDeclarativeListReference::QDeclarativeListReference() : d(0) { } -QDeclarativeListReference::QDeclarativeListReference(QObject *o, const char *property, QDeclarativeEngine *engine) +/*! +Constructs a QDeclarativeListReference for \a object's \a property. If \a property is not a list +property, an invalid QDeclarativeListReference is created. If \a object is destroyed after +the reference is constructed, it will automatically become invalid. That is, it is safe to hold +QDeclarativeListReference instances even after \a object is deleted. + +Passing \a engine is required to access some QML created list properties. If in doubt, and an engine +is available, pass it. +*/ +QDeclarativeListReference::QDeclarativeListReference(QObject *object, const char *property, QDeclarativeEngine *engine) : d(0) { - if (!o || !property) return; + if (!object || !property) return; QDeclarativePropertyCache::Data local; - QDeclarativePropertyCache::Data *data = QDeclarativePropertyCache::property(engine, o, QLatin1String(property), local); + QDeclarativePropertyCache::Data *data = + QDeclarativePropertyCache::property(engine, object, QLatin1String(property), local); if (!data || !(data->flags & QDeclarativePropertyCache::Data::IsQList)) return; @@ -106,20 +145,22 @@ QDeclarativeListReference::QDeclarativeListReference(QObject *o, const char *pro if (listType == -1) return; d = new QDeclarativeListReferencePrivate; - d->object = o; + d->object = object; d->elementType = p?p->rawMetaObjectForType(listType):QDeclarativeMetaType::qmlType(listType)->baseMetaObject(); d->propertyType = data->propType; void *args[] = { &d->property, 0 }; - QMetaObject::metacall(o, QMetaObject::ReadProperty, data->coreIndex, args); + QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex, args); } +/*! \internal */ QDeclarativeListReference::QDeclarativeListReference(const QDeclarativeListReference &o) : d(o.d) { if (d) d->addref(); } +/*! \internal */ QDeclarativeListReference &QDeclarativeListReference::operator=(const QDeclarativeListReference &o) { if (o.d) o.d->addref(); @@ -128,60 +169,108 @@ QDeclarativeListReference &QDeclarativeListReference::operator=(const QDeclarati return *this; } +/*! \internal */ QDeclarativeListReference::~QDeclarativeListReference() { if (d) d->release(); } +/*! +Returns true if the instance refers to a valid list property, otherwise false. +*/ bool QDeclarativeListReference::isValid() const { return d && d->object; } +/*! +Returns the list property's object. Returns 0 if the reference is invalid. +*/ QObject *QDeclarativeListReference::object() const { if (isValid()) return d->object; else return 0; } +/*! +Returns the QMetaObject for the elements stored in the list property. Returns 0 if the reference +is invalid. + +The QMetaObject can be used ahead of time to determine whether a given instance can be added +to a list. +*/ const QMetaObject *QDeclarativeListReference::listElementType() const { if (isValid()) return d->elementType; else return 0; } +/*! +Returns true if the list property can be appended to, otherwise false. Returns false if the +reference is invalid. + +\sa append() +*/ bool QDeclarativeListReference::canAppend() const { return (isValid() && d->property.append); } +/*! +Returns true if the list property can queried by index, otherwise false. Returns false if the +reference is invalid. + +\sa at() +*/ bool QDeclarativeListReference::canAt() const { return (isValid() && d->property.at); } +/*! +Returns true if the list property can be cleared, otherwise false. Returns false if the +reference is invalid. + +\sa clear() +*/ bool QDeclarativeListReference::canClear() const { return (isValid() && d->property.clear); } +/*! +Returns true if the list property can be queried for its element count, otherwise false. +Returns false if the reference is invalid. + +\sa count() +*/ bool QDeclarativeListReference::canCount() const { return (isValid() && d->property.count); } -bool QDeclarativeListReference::append(QObject *o) const +/*! +Appends \a object to the list. Returns true if the operation succeeded, otherwise false. + +\sa canAppend() +*/ +bool QDeclarativeListReference::append(QObject *object) const { if (!canAppend()) return false; - if (o && !QDeclarativePropertyPrivate::canConvert(o->metaObject(), d->elementType)) + if (object && !QDeclarativePropertyPrivate::canConvert(object->metaObject(), d->elementType)) return false; - d->property.append(&d->property, o); + d->property.append(&d->property, object); return true; } +/*! +Returns the list element at \a index, or 0 if the operation failed. + +\sa canAt() +*/ QObject *QDeclarativeListReference::at(int index) const { if (!canAt()) return 0; @@ -189,6 +278,11 @@ QObject *QDeclarativeListReference::at(int index) const return d->property.at(&d->property, index); } +/*! +Clears the list. Returns true if the operation succeeded, otherwise false. + +\sa canClear() +*/ bool QDeclarativeListReference::clear() const { if (!canClear()) return false; @@ -198,6 +292,9 @@ bool QDeclarativeListReference::clear() const return true; } +/*! +Returns the number of objects in the list, or 0 if the operation failed. +*/ int QDeclarativeListReference::count() const { if (!canCount()) return 0; diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 9ed760e..e1ec2cd 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -311,10 +311,10 @@ QDeclarativeProperty::QDeclarativeProperty(const QDeclarativeProperty &other) This enum specifies a category of QML property. - \value InvalidCategory The property is invalid. - \value List The property is a QList pointer + \value InvalidCategory The property is invalid, or is a signal property. + \value List The property is a QDeclarativeListProperty list property \value Object The property is a QObject derived type pointer - \value Normal The property is none of the above. + \value Normal The property is a normal value property. */ /*! @@ -752,18 +752,39 @@ QVariant QDeclarativeProperty::read() const return QVariant(); } +/*! +Return the \a name property value of \a object. This method is equivalent to: +\code + QDeclarativeProperty p(object, name); + p.read(); +\endcode +*/ QVariant QDeclarativeProperty::read(QObject *object, const QString &name) { QDeclarativeProperty p(object, name); return p.read(); } +/*! +Return the \a name property value of \a object. This method is equivalent to: +\code + QDeclarativeProperty p(object, name, context); + p.read(); +\endcode +*/ QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeContext *ctxt) { QDeclarativeProperty p(object, name, ctxt); return p.read(); } +/*! +Return the \a name property value of \a object. This method is equivalent to: +\code + QDeclarativeProperty p(object, name, engine); + p.read(); +\endcode +*/ QVariant QDeclarativeProperty::read(QObject *object, const QString &name, QDeclarativeEngine *engine) { QDeclarativeProperty p(object, name, engine); @@ -802,9 +823,7 @@ QVariant QDeclarativePropertyPrivate::readValueProperty() } } -//### //writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC! -//### bool QDeclarativePropertyPrivate::writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags) { if (!object || !prop.isWritable()) @@ -1054,12 +1073,26 @@ bool QDeclarativeProperty::write(const QVariant &value) const return QDeclarativePropertyPrivate::write(*this, value, 0); } +/*! +Writes \a value to the \a name property of \a object. This method is equivalent to: +\code + QDeclarativeProperty p(object, name); + p.write(value); +\endcode +*/ bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value) { QDeclarativeProperty p(object, name); return p.write(value); } +/*! +Writes \a value to the \a name property of \a object. This method is equivalent to: +\code + QDeclarativeProperty p(object, name, ctxt); + p.write(value); +\endcode +*/ bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value, QDeclarativeContext *ctxt) { @@ -1067,6 +1100,13 @@ bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVa return p.write(value); } +/*! +Writes \a value to the \a name property of \a object. This method is equivalent to: +\code + QDeclarativeProperty p(object, name, engine); + p.write(value); +\endcode +*/ bool QDeclarativeProperty::write(QObject *object, const QString &name, const QVariant &value, QDeclarativeEngine *engine) { -- cgit v0.12