summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-02-25 02:45:38 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-02-25 02:46:48 (GMT)
commita645ab52a7ba10018419b552b8f50ce4b7ad9cd8 (patch)
tree38b3267a4258331ffe22508949869b07f0887c33 /src/declarative
parent35f6b95744164e635fb8a03e34b2dd6177a50ccf (diff)
downloadQt-a645ab52a7ba10018419b552b8f50ce4b7ad9cd8.zip
Qt-a645ab52a7ba10018419b552b8f50ce4b7ad9cd8.tar.gz
Qt-a645ab52a7ba10018419b552b8f50ce4b7ad9cd8.tar.bz2
Move private QDeclarativeMetaProperty functions into the private class
We don't want to allow manipulation of bindings and signal properties through the public API. Equivalents of the public functions now exist in QDeclarativeMetaPropertyPrivate for internal use.
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp4
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.cpp43
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty.h7
-rw-r--r--src/declarative/qml/qdeclarativemetaproperty_p.h27
-rw-r--r--src/declarative/qml/qdeclarativepropertycache_p.h2
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp11
-rw-r--r--src/declarative/util/qdeclarativestate.cpp7
-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
10 files changed, 69 insertions, 49 deletions
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..3bbc337 100644
--- a/src/declarative/qml/qdeclarativemetaproperty.cpp
+++ b/src/declarative/qml/qdeclarativemetaproperty.cpp
@@ -502,22 +502,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.type() & QDeclarativeMetaProperty::Attached) || !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 +539,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.type() & QDeclarativeMetaProperty::Attached) || !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 +580,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 +611,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;
@@ -758,7 +765,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();
}
diff --git a/src/declarative/qml/qdeclarativemetaproperty.h b/src/declarative/qml/qdeclarativemetaproperty.h
index 4dd6668..9a3a793 100644
--- a/src/declarative/qml/qdeclarativemetaproperty.h
+++ b/src/declarative/qml/qdeclarativemetaproperty.h
@@ -121,13 +121,6 @@ public:
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;
diff --git a/src/declarative/qml/qdeclarativemetaproperty_p.h b/src/declarative/qml/qdeclarativemetaproperty_p.h
index 9fd5ed2..b769e42 100644
--- a/src/declarative/qml/qdeclarativemetaproperty_p.h
+++ b/src/declarative/qml/qdeclarativemetaproperty_p.h
@@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE
class QDeclarativeContext;
class QDeclarativeEnginePrivate;
-class QDeclarativeMetaPropertyPrivate
+class Q_AUTOTEST_EXPORT QDeclarativeMetaPropertyPrivate
{
public:
QDeclarativeMetaPropertyPrivate()
@@ -105,19 +105,32 @@ public:
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/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 5907ddb..ad39574 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)
diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp
index 5c3b909..d1dd318 100644
--- a/src/declarative/util/qdeclarativestate.cpp
+++ b/src/declarative/util/qdeclarativestate.cpp
@@ -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;