summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-25 05:51:22 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-25 05:51:22 (GMT)
commitb915bc2d710e365e7c9083ba65d08de08ea02f74 (patch)
tree8e87760b9154493372f1f8b499b52e661547e3ca /src/declarative
parent950f3849e3bd2edd6bcc2784dbeadcb604c38e2d (diff)
parentd022acd47350f61d3959b076d7bc92df86015b16 (diff)
downloadQt-b915bc2d710e365e7c9083ba65d08de08ea02f74.zip
Qt-b915bc2d710e365e7c9083ba65d08de08ea02f74.tar.gz
Qt-b915bc2d710e365e7c9083ba65d08de08ea02f74.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp4
-rw-r--r--src/declarative/qml/qdeclarative.h26
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp4
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.cpp291
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.h40
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty_p.h39
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h2
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp2
-rw-r--r--src/declarative/util/qdeclarativegraphicswidget.cpp457
-rw-r--r--src/declarative/util/qdeclarativegraphicswidget.h113
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp13
-rw-r--r--src/declarative/util/qdeclarativestate.cpp15
-rw-r--r--src/declarative/util/qdeclarativestate_p_p.h3
-rw-r--r--src/declarative/util/qdeclarativestategroup.cpp4
-rw-r--r--src/declarative/util/qdeclarativetransitionmanager.cpp10
-rw-r--r--src/declarative/util/util.pri6
17 files changed, 215 insertions, 816 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 307b674..ca253df 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -811,8 +811,8 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
break;
}
- bool needClip = !clip() && (d->imgCache.width() > width() ||
- d->imgCache.height() > height());
+ bool needClip = clip() && (d->imgCache.width() > width() ||
+ d->imgCache.height() > height());
if (needClip) {
p->save();
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 3133d27..77b7484 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -87,9 +87,9 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
template<typename T>
-int qmlRegisterType(const char *typeName)
+int qmlRegisterType()
{
- QByteArray name(typeName);
+ QByteArray name(T::staticMetaObject.className());
QByteArray pointerName(name + '*');
QByteArray listName("QDeclarativeListProperty<" + name + ">");
@@ -119,9 +119,9 @@ int qmlRegisterType(const char *typeName)
}
template<typename T>
-int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const char *typeName)
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{
- QByteArray name(typeName);
+ QByteArray name(T::staticMetaObject.className());
QByteArray pointerName(name + '*');
QByteArray listName("QDeclarativeListProperty<" + name + ">");
@@ -151,9 +151,9 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
}
template<typename T, typename E>
-int qmlRegisterExtendedType(const char *typeName)
+int qmlRegisterExtendedType()
{
- QByteArray name(typeName);
+ QByteArray name(T::staticMetaObject.className());
QByteArray pointerName(name + '*');
QByteArray listName("QDeclarativeListProperty<" + name + ">");
@@ -184,9 +184,9 @@ int qmlRegisterExtendedType(const char *typeName)
template<typename T, typename E>
int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
- const char *qmlName, const char *typeName)
+ const char *qmlName)
{
- QByteArray name(typeName);
+ QByteArray name(T::staticMetaObject.className());
QByteArray pointerName(name + '*');
QByteArray listName("QDeclarativeListProperty<" + name + ">");
@@ -278,14 +278,14 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
#define QML_REGISTER_INTERFACE(INTERFACE) \
qmlRegisterInterface<INTERFACE>(#INTERFACE)
-#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \
- qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)
+#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, CLASS, EXTENSION) \
+ qmlRegisterExtendedType<CLASS,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME)
-#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \
- qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS)
+#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,NAME,CLASS) \
+ qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #NAME)
#define QML_REGISTER_NOCREATE_TYPE(CLASS) \
- qmlRegisterType<CLASS>(#CLASS)
+ qmlRegisterType<CLASS>()
class QDeclarativeContext;
class QDeclarativeEngine;
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 5ac5701..bde01ae 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -128,7 +128,7 @@ void QDeclarativeBinding::update(QDeclarativeMetaProperty::WriteFlags flags)
if (!data->updating) {
data->updating = true;
- if (data->property.propertyCategory() == QDeclarativeMetaProperty::Bindable) {
+ if (data->property.propertyType() == qMetaTypeId<QDeclarativeBinding *>()) {
int idx = data->property.coreIndex();
Q_ASSERT(idx != -1);
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 6a81e52..2ae0b54 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -45,6 +45,7 @@
#include "qdeclarativeengine.h"
#include "qdeclarativemetatype_p.h"
#include "qdeclarativemetaproperty.h"
+#include "qdeclarativemetaproperty_p.h"
#include "qdeclarativebinding_p.h"
#include "qdeclarativecontext_p.h"
#include "qdeclarativewatcher_p.h"
@@ -108,7 +109,8 @@ QDeclarativeEngineDebugServer::propertyData(QObject *obj, int propIdx)
rv.valueTypeName = QString::fromUtf8(prop.typeName());
rv.name = QString::fromUtf8(prop.name());
rv.hasNotifySignal = prop.hasNotifySignal();
- QDeclarativeAbstractBinding *binding = QDeclarativeMetaProperty(obj, rv.name).binding();
+ QDeclarativeAbstractBinding *binding =
+ QDeclarativeMetaPropertyPrivate::binding(QDeclarativeMetaProperty(obj, rv.name));
if (binding)
rv.binding = binding->expression();
diff --git a/src/declarative/qml/qdeclarativemetaproperty.cpp b/src/declarative/qml/qdeclarativemetaproperty.cpp
index e94ce8c..f4c930f 100644
--- a/src/declarative/qml/qdeclarativemetaproperty.cpp
+++ b/src/declarative/qml/qdeclarativemetaproperty.cpp
@@ -146,50 +146,111 @@ QDeclarativeMetaProperty::QDeclarativeMetaProperty(QObject *obj, const QString &
if (!isValid()) { d->object = 0; d->context = 0; }
}
+Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
+
void QDeclarativeMetaPropertyPrivate::initProperty(QObject *obj, const QString &name)
{
- QDeclarativeEnginePrivate *enginePrivate = 0;
- if (context && context->engine())
- enginePrivate = QDeclarativeEnginePrivate::get(context->engine());
+ if (!obj) return;
- object = obj;
+ QDeclarativeEngine *engine = context?context->engine():0;
+ QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0;
- if (name.isEmpty() || !obj)
- return;
+ QStringList path = name.split(QLatin1Char('.'));
+ if (path.isEmpty()) return;
+
+ QObject *currentObject = obj;
+
+ // Everything up to the last property must be an "object type" property
+ for (int ii = 0; ii < path.count() - 1; ++ii) {
+ const QString &pathName = path.at(ii);
+
+ if (QDeclarativeTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
+ if (data->type) {
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(data->type->index(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+ } else {
+ Q_ASSERT(data->typeNamespace);
+ if ((ii + 1) == path.count()) return; // No type following the namespace
+
+ ++ii; data = data->typeNamespace->data(path.at(ii));
+ if (!data || !data->type) return; // Invalid type in namespace
+
+ QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
+ if (!func) return; // Not an attachable type
+
+ currentObject = qmlAttachedPropertiesObjectById(data->type->index(), currentObject);
+ if (!currentObject) return; // Something is broken with the attachable type
+ }
+ } else {
+
+ QDeclarativePropertyCache::Data local;
+ QDeclarativePropertyCache::Data *property =
+ QDeclarativePropertyCache::property(engine, obj, pathName, local);
+
+ if (!property) return; // Not a property
+ if (property->flags & QDeclarativePropertyCache::Data::IsFunction)
+ return; // Not an object property
+
+ if (ii == (path.count() - 2) && property->propType < (int)QVariant::UserType) {
+ // We're now at a value type property. We can use a global valuetypes array as we
+ // never actually use the objects, just look up their properties.
+ QObject *typeObject = qmlValueTypes()->valueTypes[property->propType];
+ if (!typeObject) return; // Not a value type
+
+ int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
+ if (idx == -1) return; // Value type property does not exist
+
+ QMetaProperty vtProp = typeObject->metaObject()->property(idx);
+
+ object = currentObject;
+ core = *property;
+ valueType.flags = QDeclarativePropertyCache::Data::flagsForProperty(vtProp);
+ valueType.valueTypeCoreIdx = idx;
+ valueType.valueTypePropType = vtProp.userType();
+
+ return;
+ } else {
+ if (!(property->flags & QDeclarativePropertyCache::Data::IsQObjectDerived))
+ return; // Not an object property
+
+ void *args[] = { &currentObject, 0 };
+ QMetaObject::metacall(currentObject, QMetaObject::ReadProperty, property->coreIndex, args);
+ if (!currentObject) return; // No value
- if (enginePrivate && name.at(0).isUpper()) {
- // Attached property
- // ### What about qualified types?
- QDeclarativeTypeNameCache *tnCache = QDeclarativeContextPrivate::get(context)->imports;
- if (tnCache) {
- QDeclarativeTypeNameCache::Data *d = tnCache->data(name);
- if (d && d->type && d->type->attachedPropertiesFunction()) {
- attachedFunc = d->type->index();
}
}
- return;
- } else if (name.count() >= 3 &&
- name.at(0) == QChar(QLatin1Char('o')) &&
- name.at(1) == QChar(QLatin1Char('n')) &&
- name.at(2).isUpper()) {
- // Signal
- QString signalName = name.mid(2);
+ }
+
+ const QString &terminal = path.last();
+
+ if (terminal.count() >= 3 &&
+ terminal.at(0) == QLatin1Char('o') &&
+ terminal.at(1) == QLatin1Char('n') &&
+ terminal.at(2).isUpper()) {
+
+ QString signalName = terminal.mid(2);
signalName[0] = signalName.at(0).toLower();
- QMetaMethod method = findSignal(obj, signalName);
+ QMetaMethod method = findSignal(currentObject, signalName);
if (method.signature()) {
+ object = currentObject;
core.load(method);
return;
}
- }
+ }
// Property
QDeclarativePropertyCache::Data local;
QDeclarativePropertyCache::Data *property =
- QDeclarativePropertyCache::property(context?context->engine():0, obj, name, local);
- if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction))
+ QDeclarativePropertyCache::property(context?context->engine():0, currentObject, terminal, local);
+ if (property && !(property->flags & QDeclarativePropertyCache::Data::IsFunction)) {
+ object = currentObject;
core = *property;
+ }
}
/*!
@@ -202,13 +263,11 @@ QDeclarativeMetaProperty::QDeclarativeMetaProperty(const QDeclarativeMetaPropert
}
/*!
- \enum QDeclarativeMetaProperty::PropertyCategory
+ \enum QDeclarativeMetaProperty::PropertyTypeCategory
This enum specifies a category of QML property.
- \value Unknown The category is unknown. This will never be returned from propertyCategory()
- \value InvalidProperty The property is invalid.
- \value Bindable The property is a QDeclarativeBinding.
+ \value InvalidCategory The property is invalid.
\value List The property is a QList pointer
\value Object The property is a QObject derived type pointer
\value Normal The property is none of the above.
@@ -223,34 +282,29 @@ QDeclarativeMetaProperty::QDeclarativeMetaProperty(const QDeclarativeMetaPropert
\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.
- \value Attached The property is an attached property.
*/
/*!
Returns the property category.
*/
-QDeclarativeMetaProperty::PropertyCategory QDeclarativeMetaProperty::propertyCategory() const
+QDeclarativeMetaProperty::PropertyTypeCategory QDeclarativeMetaProperty::propertyTypeCategory() const
{
- return d->propertyCategory();
+ return d->propertyTypeCategory();
}
-QDeclarativeMetaProperty::PropertyCategory
-QDeclarativeMetaPropertyPrivate::propertyCategory() const
+QDeclarativeMetaProperty::PropertyTypeCategory
+QDeclarativeMetaPropertyPrivate::propertyTypeCategory() const
{
uint type = q->type();
if (type & QDeclarativeMetaProperty::ValueTypeProperty) {
return QDeclarativeMetaProperty::Normal;
- } else if (type & QDeclarativeMetaProperty::Attached) {
- return QDeclarativeMetaProperty::Object;
} else if (type & QDeclarativeMetaProperty::Property) {
int type = propertyType();
if (type == QVariant::Invalid)
- return QDeclarativeMetaProperty::InvalidProperty;
+ return QDeclarativeMetaProperty::InvalidCategory;
else if ((uint)type < QVariant::UserType)
return QDeclarativeMetaProperty::Normal;
- else if (type == qMetaTypeId<QDeclarativeBinding *>())
- return QDeclarativeMetaProperty::Bindable;
else if (core.flags & QDeclarativePropertyCache::Data::IsQObjectDerived)
return QDeclarativeMetaProperty::Object;
else if (core.flags & QDeclarativePropertyCache::Data::IsQList)
@@ -258,7 +312,7 @@ QDeclarativeMetaPropertyPrivate::propertyCategory() const
else
return QDeclarativeMetaProperty::Normal;
} else {
- return QDeclarativeMetaProperty::InvalidProperty;
+ return QDeclarativeMetaProperty::InvalidCategory;
}
}
@@ -298,8 +352,7 @@ bool QDeclarativeMetaProperty::operator==(const QDeclarativeMetaProperty &other)
// from the other members
return d->object == other.d->object &&
d->core == other.d->core &&
- d->valueType == other.d->valueType &&
- d->attachedFunc == other.d->attachedFunc;
+ d->valueType == other.d->valueType;
}
/*!
@@ -316,8 +369,6 @@ int QDeclarativeMetaPropertyPrivate::propertyType() const
uint type = q->type();
if (type & QDeclarativeMetaProperty::ValueTypeProperty) {
return valueType.valueTypePropType;
- } else if (type & QDeclarativeMetaProperty::Attached) {
- return qMetaTypeId<QObject *>();
} else if (type & QDeclarativeMetaProperty::Property) {
if (core.propType == (int)QVariant::LastType)
return qMetaTypeId<QVariant>();
@@ -335,8 +386,6 @@ QDeclarativeMetaProperty::Type QDeclarativeMetaProperty::type() const
{
if (d->core.flags & QDeclarativePropertyCache::Data::IsFunction)
return SignalProperty;
- else if (d->attachedFunc != -1)
- return Attached;
else if (d->valueType.valueTypeCoreIdx != -1)
return (Type)(Property | ValueTypeProperty);
else if (d->core.isValid())
@@ -384,7 +433,6 @@ QDeclarativeMetaProperty &QDeclarativeMetaProperty::operator=(const QDeclarative
d->valueType = other.d->valueType;
- d->attachedFunc = other.d->attachedFunc;
return *this;
}
@@ -393,7 +441,7 @@ QDeclarativeMetaProperty &QDeclarativeMetaProperty::operator=(const QDeclarative
*/
bool QDeclarativeMetaProperty::isWritable() const
{
- QDeclarativeMetaProperty::PropertyCategory category = propertyCategory();
+ QDeclarativeMetaProperty::PropertyTypeCategory category = propertyTypeCategory();
if (!d->object)
return false;
@@ -502,22 +550,23 @@ QMetaMethod QDeclarativeMetaProperty::method() const
Returns the binding associated with this property, or 0 if no binding
exists.
*/
-QDeclarativeAbstractBinding *QDeclarativeMetaProperty::binding() const
+QDeclarativeAbstractBinding *
+QDeclarativeMetaPropertyPrivate::binding(const QDeclarativeMetaProperty &that)
{
- if (!isProperty() || (type() & Attached) || !d->object)
+ if (!that.isProperty() || !that.d->object)
return 0;
- QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(d->object);
+ QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(that.d->object);
if (!data)
return 0;
- if (!data->hasBindingBit(d->core.coreIndex))
+ if (!data->hasBindingBit(that.d->core.coreIndex))
return 0;
QDeclarativeAbstractBinding *binding = data->bindings;
while (binding) {
// ### This wont work for value types
- if (binding->propertyIndex() == d->core.coreIndex)
+ if (binding->propertyIndex() == that.d->core.coreIndex)
return binding;
binding = binding->m_nextBinding;
}
@@ -538,15 +587,17 @@ QDeclarativeAbstractBinding *QDeclarativeMetaProperty::binding() const
the binding sets the intial value, it will use these flags for the write).
*/
QDeclarativeAbstractBinding *
-QDeclarativeMetaProperty::setBinding(QDeclarativeAbstractBinding *newBinding, QDeclarativeMetaProperty::WriteFlags flags) const
+QDeclarativeMetaPropertyPrivate::setBinding(const QDeclarativeMetaProperty &that,
+ QDeclarativeAbstractBinding *newBinding,
+ QDeclarativeMetaProperty::WriteFlags flags)
{
- if (!isProperty() || (type() & Attached) || !d->object) {
+ if (!that.isProperty() || !that.d->object) {
if (newBinding)
newBinding->destroy();
return 0;
}
- return d->setBinding(d->object, d->core, newBinding, flags);
+ return that.d->setBinding(that.d->object, that.d->core, newBinding, flags);
}
QDeclarativeAbstractBinding *
@@ -577,22 +628,24 @@ QDeclarativeMetaPropertyPrivate::setBinding(QObject *object, const QDeclarativeP
return 0;
}
+
/*!
Returns the expression associated with this signal property, or 0 if no
signal expression exists.
*/
-QDeclarativeExpression *QDeclarativeMetaProperty::signalExpression() const
+QDeclarativeExpression *
+QDeclarativeMetaPropertyPrivate::signalExpression(const QDeclarativeMetaProperty &that)
{
- if (!(type() & SignalProperty))
+ if (!(that.type() & QDeclarativeMetaProperty::SignalProperty))
return 0;
- const QObjectList &children = d->object->children();
+ const QObjectList &children = that.d->object->children();
for (int ii = 0; ii < children.count(); ++ii) {
QObject *child = children.at(ii);
QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == coreIndex())
+ if (signal && signal->index() == that.coreIndex())
return signal->expression();
}
@@ -606,25 +659,27 @@ QDeclarativeExpression *QDeclarativeMetaProperty::signalExpression() const
Ownership of \a expr transfers to QML. Ownership of the return value is
assumed by the caller.
*/
-QDeclarativeExpression *QDeclarativeMetaProperty::setSignalExpression(QDeclarativeExpression *expr) const
+QDeclarativeExpression *
+QDeclarativeMetaPropertyPrivate::setSignalExpression(const QDeclarativeMetaProperty &that,
+ QDeclarativeExpression *expr)
{
- if (!(type() & SignalProperty)) {
+ if (!(that.type() & QDeclarativeMetaProperty::SignalProperty)) {
delete expr;
return 0;
}
- const QObjectList &children = d->object->children();
+ const QObjectList &children = that.d->object->children();
for (int ii = 0; ii < children.count(); ++ii) {
QObject *child = children.at(ii);
QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child);
- if (signal && signal->index() == coreIndex())
+ if (signal && signal->index() == that.coreIndex())
return signal->setExpression(expr);
}
if (expr) {
- QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(d->object, method(), d->object);
+ QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(that.d->object, that.method(), that.d->object);
return signal->setExpression(expr);
} else {
return 0;
@@ -648,14 +703,6 @@ QMetaMethod QDeclarativeMetaPropertyPrivate::findSignal(QObject *obj, const QStr
return QMetaMethod();
}
-QObject *QDeclarativeMetaPropertyPrivate::attachedObject() const
-{
- if (attachedFunc == -1)
- return 0;
- else
- return qmlAttachedPropertiesObjectById(attachedFunc, object);
-}
-
/*!
Returns the property value.
*/
@@ -668,7 +715,7 @@ QVariant QDeclarativeMetaProperty::read() const
return QVariant();
- } else if (type() & Property || type() & Attached) {
+ } else if (type() & Property) {
return d->readValueProperty();
@@ -679,11 +726,7 @@ QVariant QDeclarativeMetaProperty::read() const
QVariant QDeclarativeMetaPropertyPrivate::readValueProperty()
{
uint type = q->type();
- if (type & QDeclarativeMetaProperty::Attached) {
-
- return QVariant::fromValue(attachedObject());
-
- } else if(type & QDeclarativeMetaProperty::ValueTypeProperty) {
+ if(type & QDeclarativeMetaProperty::ValueTypeProperty) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context);
QDeclarativeValueType *valueType = 0;
@@ -758,7 +801,7 @@ bool QDeclarativeMetaPropertyPrivate::writeValueProperty(const QVariant &value,
{
// Remove any existing bindings on this property
if (!(flags & QDeclarativeMetaProperty::DontRemoveBinding)) {
- QDeclarativeAbstractBinding *binding = q->setBinding(0);
+ QDeclarativeAbstractBinding *binding = setBinding(*q, 0);
if (binding) binding->destroy();
}
@@ -994,7 +1037,7 @@ bool QDeclarativeMetaProperty::write(const QVariant &value, QDeclarativeMetaProp
*/
bool QDeclarativeMetaProperty::hasChangedNotifier() const
{
- if (type() & Property && !(type() & Attached) && d->object) {
+ if (type() & Property && d->object) {
return d->object->metaObject()->property(d->core.coreIndex).hasNotifySignal();
}
return false;
@@ -1009,8 +1052,7 @@ bool QDeclarativeMetaProperty::hasChangedNotifier() const
*/
bool QDeclarativeMetaProperty::needsChangedNotifier() const
{
- return type() & Property && !(type() & Attached) &&
- !property().isConstant();
+ return type() & Property && !property().isConstant();
}
/*!
@@ -1023,7 +1065,7 @@ bool QDeclarativeMetaProperty::needsChangedNotifier() const
*/
bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, int method) const
{
- if (!(type() & Property) || (type() & Attached) || !d->object)
+ if (!(type() & Property) || !d->object)
return false;
QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
@@ -1044,7 +1086,7 @@ bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, int method) const
*/
bool QDeclarativeMetaProperty::connectNotifier(QObject *dest, const char *slot) const
{
- if (!(type() & Property) || (type() & Attached) || !d->object)
+ if (!(type() & Property) || !d->object)
return false;
QMetaProperty prop = d->object->metaObject()->property(d->core.coreIndex);
@@ -1070,8 +1112,6 @@ int QDeclarativeMetaProperty::valueTypeCoreIndex() const
return d->valueType.valueTypeCoreIdx;
}
-Q_GLOBAL_STATIC(QDeclarativeValueTypeFactory, qmlValueTypes);
-
struct SerializedData {
QDeclarativeMetaProperty::Type type;
@@ -1134,83 +1174,6 @@ QDeclarativeMetaPropertyPrivate::restore(const QByteArray &data, QObject *object
}
/*!
- \internal
-
- Creates a QDeclarativeMetaProperty for the property \a name of \a obj. Unlike
- the QDeclarativeMetaProperty(QObject*, QString, QDeclarativeContext*) constructor, this static function
- will correctly handle dot properties, including value types and attached properties.
-*/
-QDeclarativeMetaProperty QDeclarativeMetaProperty::createProperty(QObject *obj,
- const QString &name,
- QDeclarativeContext *context)
-{
- QDeclarativeTypeNameCache *typeNameCache = context?QDeclarativeContextPrivate::get(context)->imports:0;
-
- QStringList path = name.split(QLatin1Char('.'));
- QObject *object = obj;
-
- for (int jj = 0; jj < path.count() - 1; ++jj) {
- const QString &pathName = path.at(jj);
-
- if (QDeclarativeTypeNameCache::Data *data = typeNameCache?typeNameCache->data(pathName):0) {
- if (data->type) {
- QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
- if (!func)
- return QDeclarativeMetaProperty();
- object = qmlAttachedPropertiesObjectById(data->type->index(), object);
- if (!object)
- return QDeclarativeMetaProperty();
- continue;
- } else {
- Q_ASSERT(data->typeNamespace);
- ++jj;
- data = data->typeNamespace->data(path.at(jj));
- if (!data || !data->type)
- return QDeclarativeMetaProperty();
- QDeclarativeAttachedPropertiesFunc func = data->type->attachedPropertiesFunction();
- if (!func)
- return QDeclarativeMetaProperty();
- object = qmlAttachedPropertiesObjectById(data->type->index(), object);
- if (!object)
- return QDeclarativeMetaProperty();
- continue;
- }
- }
-
- QDeclarativeMetaProperty prop(object, pathName, context);
-
- if (jj == path.count() - 2 && prop.propertyType() < (int)QVariant::UserType &&
- qmlValueTypes()->valueTypes[prop.propertyType()]) {
- // We're now at a value type property. We can use a global valuetypes array as we
- // never actually use the objects, just look up their properties.
- QObject *typeObject =
- qmlValueTypes()->valueTypes[prop.propertyType()];
- int idx = typeObject->metaObject()->indexOfProperty(path.last().toUtf8().constData());
- if (idx == -1)
- return QDeclarativeMetaProperty();
- QMetaProperty vtProp = typeObject->metaObject()->property(idx);
-
- QDeclarativeMetaProperty p = prop;
- p.d->valueType.valueTypeCoreIdx = idx;
- p.d->valueType.valueTypePropType = vtProp.userType();
- return p;
- }
-
- QObject *objVal = QDeclarativeMetaType::toQObject(prop.read());
- if (!objVal)
- return QDeclarativeMetaProperty();
- object = objVal;
- }
-
- const QString &propName = path.last();
- QDeclarativeMetaProperty prop(object, propName, context);
- if (!prop.isValid())
- return QDeclarativeMetaProperty();
- else
- return prop;
-}
-
-/*!
Returns true if lhs and rhs refer to the same metaobject data
*/
bool QDeclarativeMetaPropertyPrivate::equal(const QMetaObject *lhs, const QMetaObject *rhs)
diff --git a/src/declarative/qml/qdeclarativemetaproperty.h b/src/declarative/qml/qdeclarativemetaproperty.h
index 4dd6668..900d1cd 100644
--- a/src/declarative/qml/qdeclarativemetaproperty.h
+++ b/src/declarative/qml/qdeclarativemetaproperty.h
@@ -63,22 +63,31 @@ class QDeclarativeMetaPropertyPrivate;
class Q_DECLARATIVE_EXPORT QDeclarativeMetaProperty
{
public:
- enum PropertyCategory {
- Unknown,
- InvalidProperty,
- Bindable,
+ enum PropertyTypeCategory {
+ InvalidCategory,
List,
Object,
Normal
};
+
+ enum Type { Invalid = 0x00,
+ Property = 0x01,
+ SignalProperty = 0x02,
+ Default = 0x08,
+ ValueTypeProperty = 0x10
+ };
+
QDeclarativeMetaProperty();
+ ~QDeclarativeMetaProperty();
+
QDeclarativeMetaProperty(QObject *);
- QDeclarativeMetaProperty(QObject *, const QString &);
QDeclarativeMetaProperty(QObject *, QDeclarativeContext *);
+
+ QDeclarativeMetaProperty(QObject *, const QString &);
QDeclarativeMetaProperty(QObject *, const QString &, QDeclarativeContext *);
+
QDeclarativeMetaProperty(const QDeclarativeMetaProperty &);
QDeclarativeMetaProperty &operator=(const QDeclarativeMetaProperty &);
- ~QDeclarativeMetaProperty();
QString name() const;
@@ -96,13 +105,6 @@ public:
QMetaMethod method() const;
- enum Type { Invalid = 0x00,
- Property = 0x01,
- SignalProperty = 0x02,
- Default = 0x08,
- Attached = 0x10,
- ValueTypeProperty = 0x20 };
-
Type type() const;
bool isProperty() const;
bool isDefault() const;
@@ -112,24 +114,14 @@ public:
bool isValid() const;
QObject *object() const;
- PropertyCategory propertyCategory() const;
-
int propertyType() const;
+ PropertyTypeCategory propertyTypeCategory() const;
const char *propertyTypeName() const;
bool operator==(const QDeclarativeMetaProperty &) const;
QMetaProperty property() const;
- QDeclarativeAbstractBinding *binding() const;
- QDeclarativeAbstractBinding *setBinding(QDeclarativeAbstractBinding *,
- QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding) const;
-
- QDeclarativeExpression *signalExpression() const;
- QDeclarativeExpression *setSignalExpression(QDeclarativeExpression *) const;
-
- static QDeclarativeMetaProperty createProperty(QObject *, const QString &, QDeclarativeContext *context=0);
-
int coreIndex() const;
int valueTypeCoreIndex() const;
private:
diff --git a/src/declarative/qml/qdeclarativemetaproperty_p.h b/src/declarative/qml/qdeclarativemetaproperty_p.h
index 9fd5ed2..937cfd7 100644
--- a/src/declarative/qml/qdeclarativemetaproperty_p.h
+++ b/src/declarative/qml/qdeclarativemetaproperty_p.h
@@ -64,18 +64,18 @@ QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeEnginePrivate;
-class QDeclarativeMetaPropertyPrivate
+class Q_AUTOTEST_EXPORT QDeclarativeMetaPropertyPrivate
{
public:
QDeclarativeMetaPropertyPrivate()
- : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false),
- attachedFunc(-1) {}
+ : q(0), context(0), object(0), isDefaultProperty(false), isNameCached(false) {}
+
QDeclarativeMetaPropertyPrivate(const QDeclarativeMetaPropertyPrivate &other)
: q(0), context(other.context), object(other.object),
isDefaultProperty(other.isDefaultProperty), isNameCached(other.isNameCached),
core(other.core), nameCache(other.nameCache),
- valueType(other.valueType), attachedFunc(other.attachedFunc) {}
+ valueType(other.valueType) {}
QDeclarativeMetaProperty *q;
QDeclarativeContext *context;
@@ -89,35 +89,44 @@ public:
// Describes the "virtual" value-type sub-property.
QDeclarativePropertyCache::ValueTypeData valueType;
- // The attached property accessor
- int attachedFunc;
-
void initProperty(QObject *obj, const QString &name);
void initDefault(QObject *obj);
- QObject *attachedObject() const;
QMetaMethod findSignal(QObject *, const QString &);
int propertyType() const;
- QDeclarativeMetaProperty::PropertyCategory propertyCategory() const;
+ QDeclarativeMetaProperty::PropertyTypeCategory propertyTypeCategory() const;
QVariant readValueProperty();
bool writeValueProperty(const QVariant &, QDeclarativeMetaProperty::WriteFlags);
static const QMetaObject *rawMetaObjectForType(QDeclarativeEnginePrivate *, int);
- static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, const QVariant &value, int flags);
- static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContext *,
- QDeclarativeMetaProperty::WriteFlags flags = 0);
- static QDeclarativeAbstractBinding *setBinding(QObject *, const QDeclarativePropertyCache::Data &, QDeclarativeAbstractBinding *,
- QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding);
+ static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
+ const QVariant &value, int flags);
+ static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &,
+ QDeclarativeContext *, QDeclarativeMetaProperty::WriteFlags flags = 0);
+ static QDeclarativeAbstractBinding *setBinding(QObject *, const QDeclarativePropertyCache::Data &,
+ QDeclarativeAbstractBinding *,
+ QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding);
static QByteArray saveValueType(const QMetaObject *, int,
const QMetaObject *, int);
static QByteArray saveProperty(const QMetaObject *, int);
- static QDeclarativeMetaProperty restore(const QByteArray &, QObject *, QDeclarativeContext * = 0);
+ static QDeclarativeMetaProperty restore(const QByteArray &, QObject *, QDeclarativeContext *);
static bool equal(const QMetaObject *, const QMetaObject *);
static bool canConvert(const QMetaObject *from, const QMetaObject *to);
+
+
+ // "Public" (to QML) methods
+ static QDeclarativeAbstractBinding *binding(const QDeclarativeMetaProperty &that);
+ static QDeclarativeAbstractBinding *setBinding(const QDeclarativeMetaProperty &that,
+ QDeclarativeAbstractBinding *,
+ QDeclarativeMetaProperty::WriteFlags flags = QDeclarativeMetaProperty::DontRemoveBinding);
+ static QDeclarativeExpression *signalExpression(const QDeclarativeMetaProperty &that);
+ static QDeclarativeExpression *setSignalExpression(const QDeclarativeMetaProperty &that,
+ QDeclarativeExpression *) ;
+
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h
index 7f4b174..68e6e6b 100644
--- a/src/declarative/qml/qdeclarativepropertycache_p.h
+++ b/src/declarative/qml/qdeclarativepropertycache_p.h
@@ -58,7 +58,7 @@
#include <QtCore/qvector.h>
-#include <private/qscriptdeclarativeclass_p.h>
+#include <QtScript/private/qscriptdeclarativeclass_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index eb3a376..9e777a0 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -156,7 +156,7 @@ void QDeclarativeAbstractAnimationPrivate::commence()
QDeclarativeMetaProperty QDeclarativeAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj)
{
- QDeclarativeMetaProperty prop = QDeclarativeMetaProperty::createProperty(obj, str, qmlContext(infoObj));
+ QDeclarativeMetaProperty prop(obj, str, qmlContext(infoObj));
if (!prop.isValid()) {
qmlInfo(infoObj) << QDeclarativeAbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str);
return QDeclarativeMetaProperty();
diff --git a/src/declarative/util/qdeclarativegraphicswidget.cpp b/src/declarative/util/qdeclarativegraphicswidget.cpp
deleted file mode 100644
index 1d0d468..0000000
--- a/src/declarative/util/qdeclarativegraphicswidget.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdeclarativegraphicswidget.h"
-
-#include "qperformancelog_p_p.h"
-#include "qfxperf_p_p.h"
-
-#include <qdeclarative.h>
-#include <qdeclarativeitem.h>
-#include <qdeclarativeengine.h>
-#include <qdeclarativecontext.h>
-#include <qdeclarativedebug_p.h>
-#include <qdeclarativedebugservice_p.h>
-#include <qdeclarativeglobal_p.h>
-#include <qdeclarativeerror.h>
-
-#include <qscriptvalueiterator.h>
-#include <qdebug.h>
-#include <qtimer.h>
-#include <qevent.h>
-#include <qdir.h>
-#include <qcoreapplication.h>
-#include <qfontdatabase.h>
-#include <qicon.h>
-#include <qurl.h>
-#include <qboxlayout.h>
-#include <qbasictimer.h>
-#include <QtCore/qabstractanimation.h>
-#include <private/qguard_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeclarativeGraphicsWidgetSharedQDeclarativeEngine
-{
-public:
- QDeclarativeGraphicsWidgetSharedQDeclarativeEngine(){}
-
- static QDeclarativeEngine* sharedEngine(){
- if(!references)
- return 0;
- return &QDeclarativeGraphicsWidgetSharedQDeclarativeEngine::m_instance->engine;
- }
- static void attach(){
- if(!references++)
- m_instance = new QDeclarativeGraphicsWidgetSharedQDeclarativeEngine();
- }
-
- static void detach(){
- if(!--references)
- delete m_instance;
- }
-
-private:
- static QDeclarativeGraphicsWidgetSharedQDeclarativeEngine* m_instance;
- static int references;
- QDeclarativeEngine engine;
-};
-
-int QDeclarativeGraphicsWidgetSharedQDeclarativeEngine::references = 0;
-QDeclarativeGraphicsWidgetSharedQDeclarativeEngine* QDeclarativeGraphicsWidgetSharedQDeclarativeEngine::m_instance = 0;
-
-class QDeclarativeGraphicsWidgetPrivate
-{
-public:
- QDeclarativeGraphicsWidgetPrivate()
- : root(0), component(0),
- resizeMode(QDeclarativeGraphicsWidget::SizeViewToRootObject)
- {
- QDeclarativeGraphicsWidgetSharedQDeclarativeEngine::attach();
- engine = QDeclarativeGraphicsWidgetSharedQDeclarativeEngine::sharedEngine();
- }
-
- ~QDeclarativeGraphicsWidgetPrivate()
- {
- QDeclarativeGraphicsWidgetSharedQDeclarativeEngine::detach();
- }
-
- QGuard<QGraphicsObject> root;
- QGuard<QDeclarativeItem> declarativeRoot;
-
- QUrl source;
-
- QDeclarativeEngine* engine;
- QDeclarativeComponent *component;
- QBasicTimer resizetimer;
-
- mutable QSize initialSize;
- QDeclarativeGraphicsWidget::ResizeMode resizeMode;
-
- void init();
-
-};
-
-/*!
- \class QDeclarativeGraphicsWidget
- \brief The QDeclarativeGraphicsWidget class provides a QGraphicsWidget for displaying a Qt Declarative user interface.
-
- Any QGraphicsObject or QDeclarativeGraphicsItem
- created via Qt Declarative can be placed on a standard QGraphicsScene and viewed with a standard
- QGraphicsView.
-
- QDeclarativeGraphicsWidget is a convenience class which handles QDeclarativeComponent loading and object creation.
- It shares the same QDeclarativeEngine between all QDeclarativeGraphicsWidgets in the application, to minimize overhead.
-
- QDeclarativeGraphicsWidget is ideal for when you have many small components styled with Qt Declarative, and want to integrate
- them into a larger QGraphicsItem based scene. If your interface is primarily Qt Declarative based, consider using QDeclarativeView
- instead.
-
- Note that the following settings on your QGraphicsScene/View are recommended for optimal performance with Qt Declarative:
- \list
- \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState);
- \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex);
- \endlist
- Also note that the following settings on your QGraphicsScene/View are required for key handling in Qt Declarative to work:
- \list
- \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
- \o QGraphicsScene::setStickyFocus(true);
- \endlist
-
- To receive errors related to loading and executing declarative files with QDeclarativeGraphicsWidget,
- you can connect to the statusChanged() signal and monitor for QDeclarativeGraphicsWidget::Error.
- The errors are available via QDeclarativeGraphicsWidget::errors().
-*/
-
-
-/*! \fn void QDeclarativeGraphicsWidget::sceneResized(QSize size)
- This signal is emitted when the view is resized to \a size.
-*/
-
-/*! \fn void QDeclarativeGraphicsWidget::statusChanged(QDeclarativeGraphicsWidget::Status status)
- This signal is emitted when the component's current \l{QDeclarativeGraphicsWidget::Status} {status} changes.
-*/
-
-/*!
- \fn QDeclarativeGraphicsWidget::QDeclarativeGraphicsWidget(QGraphicsItem *parent)
-
- Constructs a QDeclarativeGraphicsWidget with the given \a parent.
-*/
-QDeclarativeGraphicsWidget::QDeclarativeGraphicsWidget(QGraphicsItem *parent)
-: QGraphicsWidget(parent), d(new QDeclarativeGraphicsWidgetPrivate)
-{
- setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
- d->init();
-}
-
-void QDeclarativeGraphicsWidgetPrivate::init()
-{
-}
-
-/*!
- The destructor clears the view's \l {QGraphicsObject} {items} and
- deletes the internal representation.
- */
-QDeclarativeGraphicsWidget::~QDeclarativeGraphicsWidget()
-{
- delete d->root;
- delete d;
-}
-
-/*!
- Sets the source to the \a url.
-
- Will also load the QML file and instantiate the component.
-
- */
-void QDeclarativeGraphicsWidget::setSource(const QUrl& url)
-{
- d->source = url;
-
- //Execute
- if(d->root)
- delete d->root;
- if(d->component)
- delete d->component;
- d->component = new QDeclarativeComponent(d->engine, d->source, this);
-
- if (!d->component->isLoading()) {
- continueExecute();
- } else {
- connect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
- }
-}
-
-/*!
- Returns the source URL, if set.
-
- \sa setSource()
- */
-QUrl QDeclarativeGraphicsWidget::source() const
-{
- return d->source;
-}
-
-/*!
- Returns a pointer to the QDeclarativeEngine used for instantiating
- Qt Declarative Components.
- */
-QDeclarativeEngine* QDeclarativeGraphicsWidget::engine()
-{
- return d->engine;
-}
-
-/*!
- This function returns the root of the context hierarchy. Each declarative
- component is instantiated in a QDeclarativeContext. QDeclarativeContext's are
- essential for passing data to declarative components. In Qt Declarative, contexts are
- arranged hierarchically and this hierarchy is managed by the
- QDeclarativeEngine.
- */
-QDeclarativeContext* QDeclarativeGraphicsWidget::rootContext()
-{
- return d->engine->rootContext();
-}
-
-
-/*!
- \enum QDeclarativeGraphicsWidget::Status
-
- Specifies the loading status of the QDeclarativeGraphicsWidget.
-
- \value Null This QDeclarativeGraphicsWidget has no source set.
- \value Ready This QDeclarativeGraphicsWidget has loaded and created the declarative component.
- \value Loading This QDeclarativeGraphicsWidget is loading network data.
- \value Error An error has occured. Calling errorDescription() to retrieve a description.
-*/
-
-/*!
- \property QDeclarativeGraphicsWidget::status
- The component's current \l{QDeclarativeGraphicsWidget::Status} {status}.
-*/
-
-QDeclarativeGraphicsWidget::Status QDeclarativeGraphicsWidget::status() const
-{
- if (!d->component)
- return QDeclarativeGraphicsWidget::Null;
-
- return QDeclarativeGraphicsWidget::Status(d->component->status());
-}
-
-/*!
- Return the list of errors that occured during the last compile or create
- operation. An empty list is returned if isError() is not set.
-*/
-QList<QDeclarativeError> QDeclarativeGraphicsWidget::errors() const
-{
- if (d->component)
- return d->component->errors();
- return QList<QDeclarativeError>();
-}
-
-
-/*!
- \property QDeclarativeGraphicsWidget::resizeMode
- \brief whether the view should resize the canvas contents
-
- If this property is set to SizeViewToRootObject (the default), the view
- resizes with the root item in the declarative file.
-
- If this property is set to SizeRootObjectToView, the view will
- automatically resize the root item.
-
- Regardless of this property, the sizeHint of the view
- is the initial size of the root item. Note though that
- since declarative files may load dynamically, that size may change.
-
- \sa initialSize()
-*/
-
-void QDeclarativeGraphicsWidget::setResizeMode(ResizeMode mode)
-{
- if (d->resizeMode == mode)
- return;
-
- d->resizeMode = mode;
- if (d->declarativeRoot) {
- if (d->resizeMode == SizeRootObjectToView) {
- d->declarativeRoot->setWidth(size().width());
- d->declarativeRoot->setHeight(size().height());
- } else {
- d->declarativeRoot->setWidth(d->initialSize.width());
- d->declarativeRoot->setHeight(d->initialSize.height());
- }
- }
-}
-
-QDeclarativeGraphicsWidget::ResizeMode QDeclarativeGraphicsWidget::resizeMode() const
-{
- return d->resizeMode;
-}
-
-/*!
- \internal
- */
-void QDeclarativeGraphicsWidget::continueExecute()
-{
-
- disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute()));
-
- if (d->component->isError()) {
- QList<QDeclarativeError> errorList = d->component->errors();
- foreach (const QDeclarativeError &error, errorList) {
- qWarning() << error;
- }
- emit statusChanged(status());
- return;
- }
-
- QObject *obj = d->component->create();
-
- if(d->component->isError()) {
- QList<QDeclarativeError> errorList = d->component->errors();
- foreach (const QDeclarativeError &error, errorList) {
- qWarning() << error;
- }
- emit statusChanged(status());
- return;
- }
-
- if (obj) {
- if (QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(obj)) {
-
- item->QGraphicsItem::setParentItem(this);
- item->QObject::setParent(this);
-
- d->root = item;
- d->declarativeRoot = item;
- connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged()));
- connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged()));
- if (d->initialSize.height() <= 0 && d->declarativeRoot->width() > 0)
- d->initialSize.setWidth(d->declarativeRoot->width());
- if (d->initialSize.height() <= 0 && d->declarativeRoot->height() > 0)
- d->initialSize.setHeight(d->declarativeRoot->height());
- resize(d->initialSize);
-
- if (d->resizeMode == SizeRootObjectToView) {
- d->declarativeRoot->setWidth(size().width());
- d->declarativeRoot->setHeight(size().height());
- } else {
- QSizeF sz(d->declarativeRoot->width(),d->declarativeRoot->height());
- emit sceneResized(sz);
- resize(sz);
- }
- updateGeometry();
- } else if (QGraphicsObject *item = qobject_cast<QGraphicsObject *>(obj)) {
- item->setParent(this);
- qWarning() << "QDeclarativeGraphicsWidget::resizeMode is not honored for components of type QGraphicsObject";
- } else if (qobject_cast<QWidget *>(obj)) {
- qWarning() << "QDeclarativeGraphicsWidget does not support loading QML files containing QWidgets";
- }
- }
- emit statusChanged(status());
-}
-
-/*!
- \internal
- */
-void QDeclarativeGraphicsWidget::sizeChanged()
-{
- // delay, so we catch both width and height changing.
- d->resizetimer.start(0,this);
-}
-
-/*!
- \internal
- If the \l {QTimerEvent} {timer event} \a e is this
- view's resize timer, sceneResized() is emitted.
- */
-void QDeclarativeGraphicsWidget::timerEvent(QTimerEvent* e)
-{
- if (!e || e->timerId() == d->resizetimer.timerId()) {
- if (d->declarativeRoot) {
- QSize sz(d->declarativeRoot->width(),d->declarativeRoot->height());
- emit sceneResized(sz);
- }
- d->resizetimer.stop();
- updateGeometry();
- }
-}
-
-/*!
- \internal
- The size hint is the size of the root item.
-*/
-QSizeF QDeclarativeGraphicsWidget::sizeHint() const
-{
- if (d->declarativeRoot) {
- if (d->initialSize.width() <= 0)
- d->initialSize.setWidth(d->declarativeRoot->width());
- if (d->initialSize.height() <= 0)
- d->initialSize.setHeight(d->declarativeRoot->height());
- }
- return d->initialSize;
-}
-
-/*!
- Returns the view's root \l {QGraphicsObject} {item}.
- */
-QGraphicsObject *QDeclarativeGraphicsWidget::rootObject() const
-{
- return d->root;
-}
-
-/*!
- \internal
- This function handles the \l {QGraphicsSceneResizeEvent} {resize event}
- \a e.
- */
-void QDeclarativeGraphicsWidget::resizeEvent(QGraphicsSceneResizeEvent *e)
-{
- if (d->resizeMode == SizeRootObjectToView && d->declarativeRoot) {
- d->declarativeRoot->setWidth(size().width());
- d->declarativeRoot->setHeight(size().height());
- }
- QGraphicsWidget::resizeEvent(e);
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativegraphicswidget.h b/src/declarative/util/qdeclarativegraphicswidget.h
deleted file mode 100644
index 33ebc7b..0000000
--- a/src/declarative/util/qdeclarativegraphicswidget.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECLARATIVEGRAPHICSWIDGET_H
-#define QDECLARATIVEGRAPHICSWIDGET_H
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qurl.h>
-#include <QtGui/qgraphicssceneevent.h>
-#include <QtGui/qgraphicswidget.h>
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QGraphicsObject;
-class QDeclarativeEngine;
-class QDeclarativeContext;
-class QDeclarativeError;
-
-class QDeclarativeGraphicsWidgetPrivate;
-
-class Q_DECLARATIVE_EXPORT QDeclarativeGraphicsWidget : public QGraphicsWidget
-{
- Q_OBJECT
- Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
- Q_PROPERTY(Status status READ status NOTIFY statusChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource)
-
-public:
- explicit QDeclarativeGraphicsWidget(QGraphicsItem *parent = 0);
- virtual ~QDeclarativeGraphicsWidget();
-
- QUrl source() const;
- void setSource(const QUrl&);
-
- QDeclarativeEngine* engine();
- QDeclarativeContext* rootContext();
-
- QGraphicsObject *rootObject() const;
-
- enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView };
- ResizeMode resizeMode() const;
- void setResizeMode(ResizeMode);
- QSizeF sizeHint() const;
-
- enum Status { Null, Ready, Loading, Error };
- Status status() const;
-
- QList<QDeclarativeError> errors() const;
-
-Q_SIGNALS:
- void sceneResized(QSizeF size);
- void statusChanged(QDeclarativeGraphicsWidget::Status);
-
-private Q_SLOTS:
- void continueExecute();
- void sizeChanged();
-
-protected:
- virtual void resizeEvent(QGraphicsSceneResizeEvent *);
- void timerEvent(QTimerEvent*);
-
-private:
- QDeclarativeGraphicsWidgetPrivate* d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECLARATIVEGRAPHICSWIDGET_H
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 5907ddb..6c2e256 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -50,6 +50,7 @@
#include <qdeclarativebinding_p.h>
#include <qdeclarativecontext.h>
#include <qdeclarativeguard_p.h>
+#include <qdeclarativemetaproperty_p.h>
#include <QtCore/qdebug.h>
@@ -132,12 +133,12 @@ public:
QDeclarativeGuard<QDeclarativeExpression> ownedExpression;
virtual void execute() {
- ownedExpression = property.setSignalExpression(expression);
+ ownedExpression = QDeclarativeMetaPropertyPrivate::setSignalExpression(property, expression);
}
virtual bool isReversable() { return true; }
virtual void reverse() {
- ownedExpression = property.setSignalExpression(reverseExpression);
+ ownedExpression = QDeclarativeMetaPropertyPrivate::setSignalExpression(property, reverseExpression);
}
virtual void saveOriginals() {
@@ -146,9 +147,11 @@ public:
}
virtual void rewind() {
- ownedExpression = property.setSignalExpression(rewindExpression);
+ ownedExpression = QDeclarativeMetaPropertyPrivate::setSignalExpression(property, rewindExpression);
+ }
+ virtual void saveCurrentValues() {
+ rewindExpression = QDeclarativeMetaPropertyPrivate::signalExpression(property);
}
- virtual void saveCurrentValues() { rewindExpression = property.signalExpression(); }
virtual bool override(QDeclarativeActionEvent*other) {
if (other == this)
@@ -345,7 +348,7 @@ QDeclarativeMetaProperty
QDeclarativePropertyChangesPrivate::property(const QByteArray &property)
{
Q_Q(QDeclarativePropertyChanges);
- QDeclarativeMetaProperty prop = QDeclarativeMetaProperty::createProperty(object, QString::fromUtf8(property));
+ QDeclarativeMetaProperty prop(object, QString::fromUtf8(property));
if (!prop.isValid()) {
qmlInfo(q) << QDeclarativePropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(QString::fromUtf8(property));
return QDeclarativeMetaProperty();
diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp
index 5c3b909..3b06e33 100644
--- a/src/declarative/util/qdeclarativestate.cpp
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -65,11 +65,11 @@ QDeclarativeAction::QDeclarativeAction()
QDeclarativeAction::QDeclarativeAction(QObject *target, const QString &propertyName,
const QVariant &value)
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), toValue(value), fromBinding(0),
- toBinding(0), event(0), specifiedObject(target),
- specifiedProperty(propertyName)
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
+ property(target, propertyName), toValue(value),
+ fromBinding(0), toBinding(0), event(0),
+ specifiedObject(target), specifiedProperty(propertyName)
{
- property = QDeclarativeMetaProperty::createProperty(target, propertyName);
if (property.isValid())
fromValue = property.read();
}
@@ -334,7 +334,7 @@ void QDeclarativeState::cancel()
void QDeclarativeAction::deleteFromBinding()
{
if (fromBinding) {
- property.setBinding(0);
+ QDeclarativeMetaPropertyPrivate::setBinding(property, 0);
fromBinding->destroy();
fromBinding = 0;
}
@@ -388,7 +388,7 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit
else if (action.event->isRewindable())
action.event->saveCurrentValues();
} else {
- action.fromBinding = action.property.binding();
+ action.fromBinding = QDeclarativeMetaPropertyPrivate::binding(action.property);
for (jj = 0; jj < d->revertList.count(); ++jj) {
if (d->revertList.at(jj).property == action.property) {
@@ -436,7 +436,8 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit
}
if (!found) {
QVariant cur = d->revertList.at(ii).property.read();
- QDeclarativeAbstractBinding *delBinding = d->revertList.at(ii).property.setBinding(0);
+ QDeclarativeAbstractBinding *delBinding =
+ QDeclarativeMetaPropertyPrivate::setBinding(d->revertList.at(ii).property, 0);
if (delBinding)
delBinding->destroy();
diff --git a/src/declarative/util/qdeclarativestate_p_p.h b/src/declarative/util/qdeclarativestate_p_p.h
index dd925f2..6b32f04 100644
--- a/src/declarative/util/qdeclarativestate_p_p.h
+++ b/src/declarative/util/qdeclarativestate_p_p.h
@@ -58,6 +58,7 @@
#include "qdeclarativeanimation_p_p.h"
#include "qdeclarativetransitionmanager_p_p.h"
+#include <qdeclarativemetaproperty_p.h>
#include <qdeclarativeguard_p.h>
#include <private/qobject_p.h>
@@ -76,7 +77,7 @@ public:
event = a.event;
if (state == StartState) {
value = a.fromValue;
- binding = property.binding();
+ binding = QDeclarativeMetaPropertyPrivate::binding(property);
reverseEvent = true;
} else {
value = a.toValue;
diff --git a/src/declarative/util/qdeclarativestategroup.cpp b/src/declarative/util/qdeclarativestategroup.cpp
index 0b81a53..1a7c256 100644
--- a/src/declarative/util/qdeclarativestategroup.cpp
+++ b/src/declarative/util/qdeclarativestategroup.cpp
@@ -59,7 +59,7 @@ class QDeclarativeStateGroupPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeStateGroup)
public:
- QDeclarativeStateGroupPrivate(QDeclarativeStateGroup *p)
+ QDeclarativeStateGroupPrivate()
: nullState(0), componentComplete(true),
ignoreTrans(false), applyingState(false) {}
@@ -111,7 +111,7 @@ public:
*/
QDeclarativeStateGroup::QDeclarativeStateGroup(QObject *parent)
- : QObject(*(new QDeclarativeStateGroupPrivate(this)), parent)
+ : QObject(*(new QDeclarativeStateGroupPrivate), parent)
{
}
diff --git a/src/declarative/util/qdeclarativetransitionmanager.cpp b/src/declarative/util/qdeclarativetransitionmanager.cpp
index b5841dc..9fa1488 100644
--- a/src/declarative/util/qdeclarativetransitionmanager.cpp
+++ b/src/declarative/util/qdeclarativetransitionmanager.cpp
@@ -98,7 +98,7 @@ void QDeclarativeTransitionManagerPrivate::applyBindings()
{
foreach(const QDeclarativeAction &action, bindingsList) {
if (action.toBinding) {
- action.property.setBinding(action.toBinding);
+ QDeclarativeMetaPropertyPrivate::setBinding(action.property, action.toBinding);
} else if (action.event) {
if (action.reverseEvent)
action.event->reverse();
@@ -122,7 +122,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &
if (action.toBinding)
d->bindingsList << action;
if (action.fromBinding)
- action.property.setBinding(0); // Disable current binding
+ QDeclarativeMetaPropertyPrivate::setBinding(action.property, 0); // Disable current binding
if (action.event && action.event->changesBindings()) { //### assume isReversable()?
d->bindingsList << action;
if (action.reverseEvent)
@@ -149,7 +149,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &
for (int ii = 0; ii < applyList.size(); ++ii) {
const QDeclarativeAction &action = applyList.at(ii);
if (action.toBinding) {
- action.property.setBinding(action.toBinding, QDeclarativeMetaProperty::BypassInterceptor | QDeclarativeMetaProperty::DontRemoveBinding);
+ QDeclarativeMetaPropertyPrivate::setBinding(action.property, action.toBinding, QDeclarativeMetaProperty::BypassInterceptor | QDeclarativeMetaProperty::DontRemoveBinding);
} else if (!action.event) {
action.property.write(action.toValue, QDeclarativeMetaProperty::BypassInterceptor | QDeclarativeMetaProperty::DontRemoveBinding);
} else if (action.event->isReversable()) {
@@ -190,7 +190,7 @@ void QDeclarativeTransitionManager::transition(const QList<QDeclarativeAction> &
}
if (action.toBinding)
- action.property.setBinding(0); // Make sure this is disabled during the transition
+ QDeclarativeMetaPropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition
action.property.write(action.fromValue, QDeclarativeMetaProperty::BypassInterceptor | QDeclarativeMetaProperty::DontRemoveBinding);
}
@@ -266,7 +266,7 @@ void QDeclarativeTransitionManager::cancel()
for(int i = 0; i < d->bindingsList.count(); ++i) {
QDeclarativeAction action = d->bindingsList[i];
if (action.toBinding && action.deletableToBinding) {
- action.property.setBinding(0);
+ QDeclarativeMetaPropertyPrivate::setBinding(action.property, 0);
action.toBinding->destroy();
action.toBinding = 0;
action.deletableToBinding = false;
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 46126e5..610eb3f 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -30,8 +30,7 @@ SOURCES += \
$$PWD/qdeclarativedatetimeformatter.cpp \
$$PWD/qdeclarativebehavior.cpp \
$$PWD/qdeclarativefontloader.cpp \
- $$PWD/qdeclarativestyledtext.cpp \
- $$PWD/qdeclarativegraphicswidget.cpp
+ $$PWD/qdeclarativestyledtext.cpp
HEADERS += \
$$PWD/qdeclarativeutilmodule_p.h\
@@ -66,8 +65,7 @@ HEADERS += \
$$PWD/qdeclarativedatetimeformatter_p.h \
$$PWD/qdeclarativebehavior_p.h \
$$PWD/qdeclarativefontloader_p.h \
- $$PWD/qdeclarativestyledtext_p.h \
- $$PWD/qdeclarativegraphicswidget.h
+ $$PWD/qdeclarativestyledtext_p.h
contains(QT_CONFIG, xmlpatterns) {
QT+=xmlpatterns