summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-02-09 05:09:42 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-02-09 05:42:41 (GMT)
commitd914555badcd4761864657e1e335e657b791453f (patch)
treee2038d1adea4efada31c4732cd36a71fbec2fbb7 /src/declarative/util
parent2f653cc06b97b443b9832d0121dbf92b35dd32c2 (diff)
downloadQt-d914555badcd4761864657e1e335e657b791453f.zip
Qt-d914555badcd4761864657e1e335e657b791453f.tar.gz
Qt-d914555badcd4761864657e1e335e657b791453f.tar.bz2
Replace QList<>* support with QmlListProperty
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qmlanimation.cpp16
-rw-r--r--src/declarative/util/qmlanimation_p.h16
-rw-r--r--src/declarative/util/qmllistaccessor.cpp41
-rw-r--r--src/declarative/util/qmllistaccessor_p.h2
4 files changed, 38 insertions, 37 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index ba096b3..2d1d3b9 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -939,10 +939,10 @@ void QmlPropertyAction::setProperties(const QString &p)
\sa exclude matchProperties PropertyAnimation::matchTargets
*/
-QList<QObject *> *QmlPropertyAction::targets()
+QmlListProperty<QObject> QmlPropertyAction::targets()
{
Q_D(QmlPropertyAction);
- return &d->targets;
+ return QmlListProperty<QObject>(this, d->targets);
}
/*!
@@ -950,10 +950,10 @@ QList<QObject *> *QmlPropertyAction::targets()
This property holds the objects not to be affected by this animation.
\sa matchTargets
*/
-QList<QObject *> *QmlPropertyAction::exclude()
+QmlListProperty<QObject> QmlPropertyAction::exclude()
{
Q_D(QmlPropertyAction);
- return &d->exclude;
+ return QmlListProperty<QObject>(this, d->exclude);
}
/*!
@@ -2089,10 +2089,10 @@ void QmlPropertyAnimation::setProperties(const QString &prop)
\sa exclude matchProperties
*/
-QList<QObject *> *QmlPropertyAnimation::targets()
+QmlListProperty<QObject> QmlPropertyAnimation::targets()
{
Q_D(QmlPropertyAnimation);
- return &d->targets;
+ return QmlListProperty<QObject>(this, d->targets);
}
/*!
@@ -2100,10 +2100,10 @@ QList<QObject *> *QmlPropertyAnimation::targets()
This property holds the items not to be affected by this animation.
\sa matchTargets
*/
-QList<QObject *> *QmlPropertyAnimation::exclude()
+QmlListProperty<QObject> QmlPropertyAnimation::exclude()
{
Q_D(QmlPropertyAnimation);
- return &d->exclude;
+ return QmlListProperty<QObject>(this, d->exclude);
}
void QmlPropertyAnimationPrivate::valueChanged(qreal r)
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 6a69e4d..a566074 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -187,8 +187,8 @@ class QmlPropertyAction : public QmlAbstractAnimation
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* matchTargets READ targets)
- Q_PROPERTY(QList<QObject *>* exclude READ exclude)
+ Q_PROPERTY(QmlListProperty<QObject> matchTargets READ targets)
+ Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
public:
@@ -204,8 +204,8 @@ public:
QString properties() const;
void setProperties(const QString &);
- QList<QObject *> *targets();
- QList<QObject *> *exclude();
+ QmlListProperty<QObject> targets();
+ QmlListProperty<QObject> exclude();
QVariant value() const;
void setValue(const QVariant &);
@@ -267,8 +267,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation
Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged)
Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged)
Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged)
- Q_PROPERTY(QList<QObject *>* matchTargets READ targets)
- Q_PROPERTY(QList<QObject *>* exclude READ exclude)
+ Q_PROPERTY(QmlListProperty<QObject> matchTargets READ targets)
+ Q_PROPERTY(QmlListProperty<QObject> exclude READ exclude)
public:
QmlPropertyAnimation(QObject *parent=0);
@@ -295,8 +295,8 @@ public:
QString properties() const;
void setProperties(const QString &);
- QList<QObject *> *targets();
- QList<QObject *> *exclude();
+ QmlListProperty<QObject> targets();
+ QmlListProperty<QObject> exclude();
protected:
virtual void transition(QmlStateActions &actions,
diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp
index 00b8220..e060097 100644
--- a/src/declarative/util/qmllistaccessor.cpp
+++ b/src/declarative/util/qmllistaccessor.cpp
@@ -89,7 +89,7 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine)
(enginePrivate && enginePrivate->isQmlList(d.userType()))) {
m_type = QmlList;
} else if (QmlMetaType::isList(d.userType())) {
- m_type = QListPtr;
+ m_type = ListProperty;
} else {
m_type = Instance;
}
@@ -107,10 +107,11 @@ int QmlListAccessor::count() const
QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData();
return li->count();
}
- case QListPtr:
+ case ListProperty:
{
- QList<void *> *li = *(QList<void *> **)d.constData();
- return li->count();
+ QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
+ if (li->count) return li->count(li);
+ else return 0;
}
case Instance:
return 1;
@@ -137,11 +138,11 @@ QVariant QmlListAccessor::at(int idx) const
li->at(idx, ptr);
return QVariant::fromValue((QObject*)ptr[0]);
}
- case QListPtr:
+ case ListProperty:
{
- QList<void *> *li = *(QList<void *> **)d.constData();
- void *ptr = li->at(idx);
- return QVariant::fromValue((QObject*)ptr);
+ QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
+ if (li->at) return QVariant::fromValue((QObject *)li->at(li, idx));
+ else return QVariant();
}
case Instance:
return d;
@@ -162,10 +163,10 @@ bool QmlListAccessor::append(const QVariant &value)
li->append(const_cast<void *>(value.constData())); //XXX Typesafety
return true;
}
- case QListPtr:
+ case ListProperty:
{
- QList<void *> *li = *(QList<void *> **)d.constData();
- li->append(*reinterpret_cast<void **>(const_cast<void *>(value.constData()))); //XXX Typesafety
+ QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
+ if (li->append) li->append(li, *(void **)value.constData()); // XXX Typesafety
return true;
}
case StringList:
@@ -187,10 +188,10 @@ bool QmlListAccessor::insert(int index, const QVariant &value)
li->insert(index, const_cast<void *>(value.constData())); //XXX Typesafety
return true;
}
- case QListPtr:
+ case ListProperty:
{
- QList<void *> *li = *(QList<void *>**)d.constData();
- li->insert(index, *reinterpret_cast<void **>(const_cast<void *>(value.constData()))); //XXX Typesafety
+ QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
+ if (li->insert) li->insert(li, index, *(void **)value.constData()); // XXX Typesafety
return true;
}
case StringList:
@@ -212,10 +213,10 @@ bool QmlListAccessor::removeAt(int index)
li->removeAt(index);
return true;
}
- case QListPtr:
+ case ListProperty:
{
- QList<void *> *li = *(QList<void *>**)d.constData();
- li->removeAt(index);
+ QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
+ if (li->removeAt) li->removeAt(li, index);
return true;
}
case StringList:
@@ -237,10 +238,10 @@ bool QmlListAccessor::clear()
li->clear();
return true;
}
- case QListPtr:
+ case ListProperty:
{
- QList<void *> *li = *(QList<void *>**)d.constData();
- li->clear();
+ QmlListProperty<void> *li = (QmlListProperty<void>*)d.constData();
+ if (li->clear) li->clear(li);
return true;
}
case StringList:
diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h
index 3c67e3a..6866150 100644
--- a/src/declarative/util/qmllistaccessor_p.h
+++ b/src/declarative/util/qmllistaccessor_p.h
@@ -70,7 +70,7 @@ public:
bool removeAt(int);
bool clear();
- enum Type { Invalid, StringList, VariantList, QmlList, QListPtr, Instance, Integer };
+ enum Type { Invalid, StringList, VariantList, QmlList, ListProperty, Instance, Integer };
Type type() const { return m_type; }
private: