bool when : 1;
bool componentComplete : 1;
QObject *obj;
- QString prop;
+ QString propName;
QDeclarativeNullableValue<QVariant> value;
+ QDeclarativeProperty prop;
};
{
Q_D(QDeclarativeBind);
d->obj = obj;
+ if (d->componentComplete)
+ d->prop = QDeclarativeProperty(d->obj, d->propName);
eval();
}
QString QDeclarativeBind::property() const
{
Q_D(const QDeclarativeBind);
- return d->prop;
+ return d->propName;
}
void QDeclarativeBind::setProperty(const QString &p)
{
Q_D(QDeclarativeBind);
- d->prop = p;
+ d->propName = p;
+ if (d->componentComplete)
+ d->prop = QDeclarativeProperty(d->obj, d->propName);
eval();
}
eval();
}
+void QDeclarativeBind::setTarget(const QDeclarativeProperty &p)
+{
+ Q_D(QDeclarativeBind);
+ d->prop = p;
+}
+
void QDeclarativeBind::classBegin()
{
Q_D(QDeclarativeBind);
{
Q_D(QDeclarativeBind);
d->componentComplete = true;
+ if (!d->prop.isValid())
+ d->prop = QDeclarativeProperty(d->obj, d->propName);
eval();
}
void QDeclarativeBind::eval()
{
Q_D(QDeclarativeBind);
- if (!d->obj || d->value.isNull || !d->when || !d->componentComplete)
+ if (!d->prop.isValid() || d->value.isNull || !d->when || !d->componentComplete)
return;
- QDeclarativeProperty prop(d->obj, d->prop);
- prop.write(d->value.value);
+ d->prop.write(d->value.value);
}
QT_END_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeBindPrivate;
-class Q_AUTOTEST_EXPORT QDeclarativeBind : public QObject, public QDeclarativeParserStatus
+class Q_AUTOTEST_EXPORT QDeclarativeBind : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus
{
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeBind)
Q_INTERFACES(QDeclarativeParserStatus)
+ Q_INTERFACES(QDeclarativePropertyValueSource)
Q_PROPERTY(QObject *target READ object WRITE setObject)
Q_PROPERTY(QString property READ property WRITE setProperty)
Q_PROPERTY(QVariant value READ value WRITE setValue)
void setValue(const QVariant &);
protected:
+ virtual void setTarget(const QDeclarativeProperty &);
virtual void classBegin();
virtual void componentComplete();