summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-03-05 04:01:03 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-03-05 04:01:03 (GMT)
commitcb486319b599eccbc40166d0b3d057d11d92759c (patch)
treecfa2d0f3bb88e266a96f5a8218c3ac70a823cf08 /src/declarative
parent09e39c9c86e8ed346aff348b28c512710862e70e (diff)
parent0c558e05f880cb51078b2d5e5281227352c1de3f (diff)
downloadQt-cb486319b599eccbc40166d0b3d057d11d92759c.zip
Qt-cb486319b599eccbc40166d0b3d057d11d92759c.tar.gz
Qt-cb486319b599eccbc40166d0b3d057d11d92759c.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp54
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp1
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp1
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h321
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp9
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h2
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp34
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h2
-rw-r--r--src/declarative/util/qdeclarativetimer.cpp3
-rw-r--r--src/declarative/util/qdeclarativetimer_p.h9
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp14
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h41
15 files changed, 330 insertions, 171 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 2fdd720..63c97e0 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -154,7 +154,6 @@ void QDeclarativeFlickablePrivate::init()
*/
qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size)
{
- Q_Q(QDeclarativeFlickable);
if (maxVelocity <= 0)
return 0.0;
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 3bee5b8..b0a7570 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -43,6 +43,7 @@
#include "qdeclarativeitem.h"
#include "qdeclarativeevents_p_p.h"
+#include <private/qdeclarativeengine_p.h>
#include <qfxperf_p_p.h>
#include <qdeclarativeengine.h>
@@ -51,6 +52,7 @@
#include <qdeclarativeview.h>
#include <qdeclarativestategroup_p.h>
#include <qdeclarativecomponent.h>
+#include <qdeclarativeinfo.h>
#include <QDebug>
#include <QPen>
@@ -2212,6 +2214,58 @@ void QDeclarativeItem::setKeepMouseGrab(bool keep)
}
/*!
+ \qmlmethod object Item::mapFromItem(Item item, int x, int y)
+
+ Maps the point (\a x, \a y), which is in \a item's coordinate system, to
+ this item's coordinate system, and returns an object with \c x and \c y
+ properties matching the mapped cooordinate.
+
+ If \a item is a \c null value, this maps the point from the coordinate
+ system of the root QML view.
+*/
+QScriptValue QDeclarativeItem::mapFromItem(const QScriptValue &item, int x, int y) const
+{
+ QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
+ QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
+ if (!itemObj && !item.isNull()) {
+ qWarning().nospace() << "mapFromItem() given argument " << item.toString() << " which is neither null nor an Item";
+ return 0;
+ }
+
+ // If QGraphicsItem::mapFromItem() is called with 0, behaves the same as mapFromScene()
+ QPointF p = qobject_cast<QGraphicsItem*>(this)->mapFromItem(itemObj, x, y);
+ sv.setProperty("x", p.x());
+ sv.setProperty("y", p.y());
+ return sv;
+}
+
+/*!
+ \qmlmethod object Item::mapToItem(Item item, int x, int y)
+
+ Maps the point (\a x, \a y), which is in this item's coordinate system, to
+ \a item's coordinate system, and returns an object with \c x and \c y
+ properties matching the mapped cooordinate.
+
+ If \a item is a \c null value, this maps \a x and \a y to the coordinate
+ system of the root QML view.
+*/
+QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, int x, int y) const
+{
+ QScriptValue sv = QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(this))->newObject();
+ QDeclarativeItem *itemObj = qobject_cast<QDeclarativeItem*>(item.toQObject());
+ if (!itemObj && !item.isNull()) {
+ qWarning().nospace() << "mapToItem() given argument " << item.toString() << " which is neither null nor an Item";
+ return 0;
+ }
+
+ // If QGraphicsItem::mapToItem() is called with 0, behaves the same as mapToScene()
+ QPointF p = qobject_cast<QGraphicsItem*>(this)->mapToItem(itemObj, x, y);
+ sv.setProperty("x", p.x());
+ sv.setProperty("y", p.y());
+ return sv;
+}
+
+/*!
\internal
This function emits the \e focusChanged signal.
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 3ae404d..f6fedc7 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -159,6 +159,9 @@ public:
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
+ Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, int x, int y) const;
+ Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, int x, int y) const;
+
QDeclarativeAnchorLine left() const;
QDeclarativeAnchorLine right() const;
QDeclarativeAnchorLine horizontalCenter() const;
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index e0ae2eb..25660f8 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -106,7 +106,6 @@ void QDeclarativeItemModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QDeclarativeLayoutItem);
QML_REGISTER_TYPE(Qt,4,6,ListView,QDeclarativeListView);
QML_REGISTER_TYPE(Qt,4,6,Loader,QDeclarativeLoader);
- QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QDeclarativeMouseArea);
QML_REGISTER_TYPE(Qt,4,6,MouseArea,QDeclarativeMouseArea);
QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect);
QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QDeclarativeParticleMotion);
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 5a2f3b5..3c6c949 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -561,9 +561,11 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine,
QDeclarativeCompositeTypeData::TypeReference &tref = unit->types[ii];
QDeclarativeCompiledData::TypeReference ref;
QDeclarativeScriptParser::TypeReference *parserRef = unit->data.referencedTypes().at(ii);
- if (tref.type)
+ if (tref.type) {
ref.type = tref.type;
- else if (tref.unit) {
+ if (!ref.type->isCreatable())
+ COMPILE_EXCEPTION(parserRef->refObjects.first(), QCoreApplication::translate("QDeclarativeCompiler", "Element is not creatable."));
+ } else if (tref.unit) {
ref.component = tref.unit->toComponent(engine);
if (ref.component->isError()) {
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 7ce2d0b..1e60df4 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -167,6 +167,7 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
QDeclarativeItemModule::defineModule();
QDeclarativeUtilModule::defineModule();
QDeclarativeEnginePrivate::defineModule();
+ QDeclarativeValueTypeFactory::registerValueTypes();
}
globalClass = new QDeclarativeGlobalScriptClass(&scriptEngine);
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index c41b14f..ec32b35 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -161,155 +161,180 @@ public:
Type type;
unsigned short line;
+
+ struct InitInstruction {
+ int bindingsSize;
+ int parserStatusSize;
+ int contextCache;
+ int compiledBinding;
+ };
+ struct CreateInstruction {
+ int type;
+ int data;
+ int bindingBits;
+ ushort column;
+ };
+ struct StoreMetaInstruction {
+ int data;
+ int aliasData;
+ int propertyCache;
+ };
+ struct SetIdInstruction {
+ int value;
+ int index;
+ };
+ struct AssignValueSourceInstruction {
+ int property;
+ int owner;
+ int castValue;
+ };
+ struct AssignValueInterceptorInstruction {
+ int property;
+ int owner;
+ int castValue;
+ };
+ struct AssignBindingInstruction {
+ unsigned int property;
+ int value;
+ short context;
+ short owner;
+ };
+ struct FetchInstruction {
+ int property;
+ };
+ struct FetchValueInstruction {
+ int property;
+ int type;
+ };
+ struct FetchQmlListInstruction {
+ int property;
+ int type;
+ };
+ struct BeginInstruction {
+ int castValue;
+ };
+ struct StoreFloatInstruction {
+ int propertyIndex;
+ float value;
+ };
+ struct StoreDoubleInstruction {
+ int propertyIndex;
+ double value;
+ };
+ struct StoreIntegerInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreBoolInstruction {
+ int propertyIndex;
+ bool value;
+ };
+ struct StoreStringInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreScriptStringInstruction {
+ int propertyIndex;
+ int value;
+ int scope;
+ };
+ struct StoreScriptInstruction {
+ int value;
+ };
+ struct StoreUrlInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreColorInstruction {
+ int propertyIndex;
+ unsigned int value;
+ };
+ struct StoreDateInstruction {
+ int propertyIndex;
+ int value;
+ };
+ struct StoreTimeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreDateTimeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreRealPairInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreRectInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreVector3DInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreObjectInstruction {
+ int propertyIndex;
+ };
+ struct AssignCustomTypeInstruction {
+ int propertyIndex;
+ int valueIndex;
+ };
+ struct StoreSignalInstruction {
+ int signalIndex;
+ int value;
+ int context;
+ };
+ struct AssignSignalObjectInstruction {
+ int signal;
+ };
+ struct CreateComponentInstruction {
+ int count;
+ ushort column;
+ int endLine;
+ int metaObject;
+ };
+ struct FetchAttachedInstruction {
+ int id;
+ };
+ struct DeferInstruction {
+ int deferCount;
+ };
+
union {
- struct {
- int bindingsSize;
- int parserStatusSize;
- int contextCache;
- int compiledBinding;
- } init;
- struct {
- int type;
- int data;
- int bindingBits;
- ushort column;
- } create;
- struct {
- int data;
- int aliasData;
- int propertyCache;
- } storeMeta;
- struct {
- int value;
- int index;
- } setId;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueSource;
- struct {
- int property;
- int owner;
- int castValue;
- } assignValueInterceptor;
- struct {
- unsigned int property;
- int value;
- short context;
- short owner;
- } assignBinding;
- struct {
- int property;
- int id;
- } assignIdOptBinding;
- struct {
- int property;
- int contextIdx;
- short context;
- short notifyIdx;
- } assignObjPropBinding;
- struct {
- int property;
- } fetch;
- struct {
- int property;
- int type;
- } fetchValue;
- struct {
- int property;
- int type;
- } fetchQmlList;
- struct {
- int castValue;
- } begin;
- struct {
- int propertyIndex;
- float value;
- } storeFloat;
- struct {
- int propertyIndex;
- double value;
- } storeDouble;
- struct {
- int propertyIndex;
- int value;
- } storeInteger;
- struct {
- int propertyIndex;
- bool value;
- } storeBool;
- struct {
- int propertyIndex;
- int value;
- } storeString;
- struct {
- int propertyIndex;
- int value;
- int scope;
- } storeScriptString;
- struct {
- int value;
- } storeScript;
- struct {
- int propertyIndex;
- int value;
- } storeUrl;
- struct {
- int propertyIndex;
- unsigned int value;
- } storeColor;
- struct {
- int propertyIndex;
- int value;
- } storeDate;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeDateTime;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRealPair;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeRect;
- struct {
- int propertyIndex;
- int valueIndex;
- } storeVector3D;
- struct {
- int propertyIndex;
- } storeObject;
- struct {
- int propertyIndex;
- int valueIndex;
- } assignCustomType;
- struct {
- int signalIndex;
- int value;
- int context;
- } storeSignal;
- struct {
- int signal;
- } assignSignalObject;
- struct {
- int count;
- ushort column;
- int endLine;
- int metaObject;
- } createComponent;
- struct {
- int id;
- } fetchAttached;
- struct {
- int deferCount;
- } defer;
+ InitInstruction init;
+ CreateInstruction create;
+ StoreMetaInstruction storeMeta;
+ SetIdInstruction setId;
+ AssignValueSourceInstruction assignValueSource;
+ AssignValueInterceptorInstruction assignValueInterceptor;
+ AssignBindingInstruction assignBinding;
+ FetchInstruction fetch;
+ FetchValueInstruction fetchValue;
+ FetchQmlListInstruction fetchQmlList;
+ BeginInstruction begin;
+ StoreFloatInstruction storeFloat;
+ StoreDoubleInstruction storeDouble;
+ StoreIntegerInstruction storeInteger;
+ StoreBoolInstruction storeBool;
+ StoreStringInstruction storeString;
+ StoreScriptStringInstruction storeScriptString;
+ StoreScriptInstruction storeScript;
+ StoreUrlInstruction storeUrl;
+ StoreColorInstruction storeColor;
+ StoreDateInstruction storeDate;
+ StoreTimeInstruction storeTime;
+ StoreDateTimeInstruction storeDateTime;
+ StoreRealPairInstruction storeRealPair;
+ StoreRectInstruction storeRect;
+ StoreVector3DInstruction storeVector3D;
+ StoreObjectInstruction storeObject;
+ AssignCustomTypeInstruction assignCustomType;
+ StoreSignalInstruction storeSignal;
+ AssignSignalObjectInstruction assignSignalObject;
+ CreateComponentInstruction createComponent;
+ FetchAttachedInstruction fetchAttached;
+ DeferInstruction defer;
};
void dump(QDeclarativeCompiledData *);
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index abbb9d6..50ab56b 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -286,6 +286,11 @@ QDeclarativeCustomParser *QDeclarativeType::customParser() const
return d->m_customParser;
}
+bool QDeclarativeType::isCreatable() const
+{
+ return d->m_newFunc != 0;
+}
+
bool QDeclarativeType::isInterface() const
{
return d->m_isInterface;
@@ -402,7 +407,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
data->types.append(dtype);
data->idToType.insert(dtype->typeId(), dtype);
- data->idToType.insert(dtype->qListTypeId(), dtype);
+ if (dtype->qListTypeId()) data->idToType.insert(dtype->qListTypeId(), dtype);
if (!dtype->qmlTypeName().isEmpty())
data->nameToType.insertMulti(dtype->qmlTypeName(), dtype);
@@ -414,7 +419,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
if (data->lists.size() <= type.listId)
data->lists.resize(type.listId + 16);
data->objects.setBit(type.typeId, true);
- data->lists.setBit(type.listId, true);
+ if (type.listId) data->lists.setBit(type.listId, true);
return index;
}
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index ec5c045..cf8946d 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -114,6 +114,8 @@ public:
QDeclarativeCustomParser *customParser() const;
+ bool isCreatable() const;
+
bool isInterface() const;
int typeId() const;
int qListTypeId() const;
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 34d3795..c070123 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -41,6 +41,8 @@
#include "qdeclarativevaluetype_p.h"
+#include "qdeclarativemetatype_p.h"
+
#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
@@ -49,6 +51,32 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_METATYPE(QEasingCurve);
#endif
+template<typename T>
+int qmlRegisterValueTypeEnums(const char *qmlName)
+{
+ QByteArray name(T::staticMetaObject.className());
+
+ QByteArray pointerName(name + '*');
+
+ QDeclarativePrivate::RegisterType type = {
+ 0,
+
+ qRegisterMetaType<T *>(pointerName.constData()), 0, 0,
+
+ "Qt", 4, 6, qmlName, &T::staticMetaObject,
+
+ 0, 0,
+
+ 0, 0, 0,
+
+ 0, 0,
+
+ 0
+ };
+
+ return QDeclarativePrivate::registerType(type);
+}
+
QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
{
// ### Optimize
@@ -80,6 +108,12 @@ bool QDeclarativeValueTypeFactory::isValueType(int idx)
return false;
}
+void QDeclarativeValueTypeFactory::registerValueTypes()
+{
+ qmlRegisterValueTypeEnums<QDeclarativeEasingValueType>("Easing");
+ qmlRegisterValueTypeEnums<QDeclarativeFontValueType>("Font");
+}
+
QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const
{
#if (QT_VERSION < QT_VERSION_CHECK(4,7,0))
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index e69f161..ad2f6c4 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -84,6 +84,8 @@ public:
static bool isValueType(int);
static QDeclarativeValueType *valueType(int);
+ static void registerValueTypes();
+
QDeclarativeValueType *operator[](int idx) const;
private:
diff --git a/src/declarative/util/qdeclarativetimer.cpp b/src/declarative/util/qdeclarativetimer.cpp
index d7e02b1..104e3ae 100644
--- a/src/declarative/util/qdeclarativetimer.cpp
+++ b/src/declarative/util/qdeclarativetimer.cpp
@@ -123,6 +123,7 @@ void QDeclarativeTimer::setInterval(int interval)
if (interval != d->interval) {
d->interval = interval;
update();
+ emit intervalChanged();
}
}
@@ -183,6 +184,7 @@ void QDeclarativeTimer::setRepeating(bool repeating)
if (repeating != d->repeating) {
d->repeating = repeating;
update();
+ emit repeatChanged();
}
}
@@ -215,6 +217,7 @@ void QDeclarativeTimer::setTriggeredOnStart(bool triggeredOnStart)
if (d->triggeredOnStart != triggeredOnStart) {
d->triggeredOnStart = triggeredOnStart;
update();
+ emit triggeredOnStartChanged();
}
}
diff --git a/src/declarative/util/qdeclarativetimer_p.h b/src/declarative/util/qdeclarativetimer_p.h
index e063657..d1e6630 100644
--- a/src/declarative/util/qdeclarativetimer_p.h
+++ b/src/declarative/util/qdeclarativetimer_p.h
@@ -59,10 +59,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTimer : public QObject, public QDeclarati
Q_OBJECT
Q_DECLARE_PRIVATE(QDeclarativeTimer)
Q_INTERFACES(QDeclarativeParserStatus)
- Q_PROPERTY(int interval READ interval WRITE setInterval)
+ Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged)
Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged)
- Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating)
- Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart)
+ Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged)
+ Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged)
public:
QDeclarativeTimer(QObject *parent=0);
@@ -91,6 +91,9 @@ public Q_SLOTS:
Q_SIGNALS:
void triggered();
void runningChanged();
+ void intervalChanged();
+ void repeatChanged();
+ void triggeredOnStartChanged();
private:
void update();
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index d260ada..53e08b0 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -571,9 +571,10 @@ void QDeclarativeXmlListModel::setSource(const QUrl &src)
{
Q_D(QDeclarativeXmlListModel);
if (d->src != src) {
- d->src = src;
reload();
- }
+ d->src = src;
+ emit sourceChanged();
+ }
}
/*!
@@ -593,8 +594,11 @@ QString QDeclarativeXmlListModel::xml() const
void QDeclarativeXmlListModel::setXml(const QString &xml)
{
Q_D(QDeclarativeXmlListModel);
- d->xml = xml;
- reload();
+ if (d->xml != xml) {
+ d->xml = xml;
+ reload();
+ emit xmlChanged();
+ }
}
/*!
@@ -619,6 +623,7 @@ void QDeclarativeXmlListModel::setQuery(const QString &query)
if (d->query != query) {
d->query = query;
reload();
+ emit queryChanged();
}
}
@@ -638,6 +643,7 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati
if (d->namespaces != declarations) {
d->namespaces = declarations;
reload();
+ emit namespaceDeclarationsChanged();
}
}
diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h
index f0ad4b8..23ff7ce 100644
--- a/src/declarative/util/qdeclarativexmllistmodel_p.h
+++ b/src/declarative/util/qdeclarativexmllistmodel_p.h
@@ -68,10 +68,10 @@ class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModel : public QListModelInterface
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
- Q_PROPERTY(QUrl source READ source WRITE setSource)
- Q_PROPERTY(QString xml READ xml WRITE setXml)
- Q_PROPERTY(QString query READ query WRITE setQuery)
- Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations)
+ Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
+ Q_PROPERTY(QString xml READ xml WRITE setXml NOTIFY xmlChanged)
+ Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
+ Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations NOTIFY namespaceDeclarationsChanged)
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeXmlListModelRole> roles READ roleObjects)
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_CLASSINFO("DefaultProperty", "roles")
@@ -111,6 +111,10 @@ Q_SIGNALS:
void statusChanged(Status);
void progressChanged(qreal progress);
void countChanged();
+ void sourceChanged();
+ void xmlChanged();
+ void queryChanged();
+ void namespaceDeclarationsChanged();
public Q_SLOTS:
// ### need to use/expose Expiry to guess when to call this?
@@ -132,16 +136,20 @@ private:
class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModelRole : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QString query READ query WRITE setQuery)
- Q_PROPERTY(bool isKey READ isKey WRITE setIsKey)
-
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
+ Q_PROPERTY(bool isKey READ isKey WRITE setIsKey NOTIFY isKeyChanged)
public:
QDeclarativeXmlListModelRole() : m_isKey(false) {}
~QDeclarativeXmlListModelRole() {}
QString name() const { return m_name; }
- void setName(const QString &name) { m_name = name; }
+ void setName(const QString &name) {
+ if (name == m_name)
+ return;
+ m_name = name;
+ emit nameChanged();
+ }
QString query() const { return m_query; }
void setQuery(const QString &query)
@@ -150,16 +158,29 @@ public:
qmlInfo(this) << tr("An XmlRole query must not start with '/'");
return;
}
+ if (m_query == query)
+ return;
m_query = query;
+ emit queryChanged();
}
bool isKey() const { return m_isKey; }
- void setIsKey(bool b) { m_isKey = b; }
+ void setIsKey(bool b) {
+ if (m_isKey == b)
+ return;
+ m_isKey = b;
+ emit isKeyChanged();
+ }
bool isValid() {
return !m_name.isEmpty() && !m_query.isEmpty();
}
+Q_SIGNALS:
+ void nameChanged();
+ void queryChanged();
+ void isKeyChanged();
+
private:
QString m_name;
QString m_query;