summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/QmlChanges.txt2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp54
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h3
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp6
-rw-r--r--src/declarative/qml/qdeclarativecontextscriptclass.cpp5
-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/qdeclarativeobjectscriptclass.cpp81
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass_p.h12
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp34
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h2
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp19
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp147
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h2
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter.cpp373
-rw-r--r--src/declarative/util/qdeclarativedatetimeformatter_p.h117
-rw-r--r--src/declarative/util/qdeclarativenumberformatter.cpp261
-rw-r--r--src/declarative/util/qdeclarativenumberformatter_p.h93
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp22
-rw-r--r--src/declarative/util/qdeclarativetimer.cpp3
-rw-r--r--src/declarative/util/qdeclarativetimer_p.h9
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp6
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp14
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel_p.h41
-rw-r--r--src/declarative/util/qnumberformat.cpp224
-rw-r--r--src/declarative/util/qnumberformat_p.h174
-rw-r--r--src/declarative/util/util.pri6
29 files changed, 592 insertions, 1451 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 6e77abf..591fb3d 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -7,6 +7,8 @@ Flickable: renamed viewportX -> contentX
Flickable: renamed viewportY -> contentY
Removed Flickable.reportedVelocitySmoothing
Removed Qt.playSound (replaced by SoundEffect element)
+Removed NumberFormatter
+Removed DateTimeFormatter (use Qt.formatDateTime() instead)
Renamed MouseRegion -> MouseArea
Connection: syntax and rename:
Connection { sender: a; signal: foo(); script: xxx }
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/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/qdeclarativecontextscriptclass.cpp b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
index d6305d8..5fcf4e2 100644
--- a/src/declarative/qml/qdeclarativecontextscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativecontextscriptclass.cpp
@@ -262,8 +262,9 @@ QDeclarativeContextScriptClass::property(Object *object, const Identifier &name)
}
}
- ep->capturedProperties <<
- QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex);
+ if (ep->captureProperties)
+ ep->capturedProperties << QDeclarativeEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex);
+
return Value(scriptEngine, rv);
} else if(lastDefaultObject != -1) {
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/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index 2e4ffa7..e6f6e5f 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -442,6 +442,13 @@ QDeclarativeObjectMethodScriptClass::QDeclarativeObjectMethodScriptClass(QDeclar
engine(bindEngine)
{
setSupportsCall(true);
+
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ m_connect = scriptEngine->newFunction(connect);
+ m_connectId = createPersistentIdentifier(QLatin1String("connect"));
+ m_disconnect = scriptEngine->newFunction(disconnect);
+ m_disconnectId = createPersistentIdentifier(QLatin1String("disconnect"));
}
QDeclarativeObjectMethodScriptClass::~QDeclarativeObjectMethodScriptClass()
@@ -455,6 +462,80 @@ QScriptValue QDeclarativeObjectMethodScriptClass::newMethod(QObject *object, con
return newObject(scriptEngine, this, new MethodData(object, *method));
}
+QScriptValue QDeclarativeObjectMethodScriptClass::connect(QScriptContext *context, QScriptEngine *engine)
+{
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+
+ QScriptValue that = context->thisObject();
+ if (&p->objectClass->methods != scriptClass(that))
+ return engine->undefinedValue();
+
+ MethodData *data = (MethodData *)object(that);
+
+ if (!data->object || context->argumentCount() == 0)
+ return engine->undefinedValue();
+
+ QByteArray signal("2");
+ signal.append(data->object->metaObject()->method(data->data.coreIndex).signature());
+
+ if (context->argumentCount() == 1) {
+ qScriptConnect(data->object, signal.constData(), QScriptValue(), context->argument(0));
+ } else {
+ qScriptConnect(data->object, signal.constData(), context->argument(0), context->argument(1));
+ }
+
+ return engine->undefinedValue();
+}
+
+QScriptValue QDeclarativeObjectMethodScriptClass::disconnect(QScriptContext *context, QScriptEngine *engine)
+{
+ QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine);
+
+ QScriptValue that = context->thisObject();
+ if (&p->objectClass->methods != scriptClass(that))
+ return engine->undefinedValue();
+
+ MethodData *data = (MethodData *)object(that);
+
+ if (!data->object || context->argumentCount() == 0)
+ return engine->undefinedValue();
+
+ QByteArray signal("2");
+ signal.append(data->object->metaObject()->method(data->data.coreIndex).signature());
+
+ if (context->argumentCount() == 1) {
+ qScriptDisconnect(data->object, signal.constData(), QScriptValue(), context->argument(0));
+ } else {
+ qScriptDisconnect(data->object, signal.constData(), context->argument(0), context->argument(1));
+ }
+
+ return engine->undefinedValue();
+}
+
+QScriptClass::QueryFlags
+QDeclarativeObjectMethodScriptClass::queryProperty(Object *, const Identifier &name,
+ QScriptClass::QueryFlags flags)
+{
+ if (name == m_connectId.identifier || name == m_disconnectId.identifier)
+ return QScriptClass::HandlesReadAccess;
+ else
+ return 0;
+
+}
+
+QDeclarativeObjectScriptClass::ScriptValue
+QDeclarativeObjectMethodScriptClass::property(Object *, const Identifier &name)
+{
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
+ if (name == m_connectId.identifier)
+ return Value(scriptEngine, m_connect);
+ else if (name == m_disconnectId.identifier)
+ return Value(scriptEngine, m_disconnect);
+ else
+ return Value();
+}
+
namespace {
struct MetaCallArgument {
inline MetaCallArgument();
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
index 8023756..04e760f 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
@@ -73,10 +73,21 @@ public:
~QDeclarativeObjectMethodScriptClass();
QScriptValue newMethod(QObject *, const QDeclarativePropertyCache::Data *);
+
protected:
virtual Value call(Object *, QScriptContext *);
+ virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags);
+ virtual Value property(Object *, const Identifier &);
private:
+ PersistentIdentifier m_connectId;
+ PersistentIdentifier m_disconnectId;
+ QScriptValue m_connect;
+ QScriptValue m_disconnect;
+
+ static QScriptValue connect(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue disconnect(QScriptContext *context, QScriptEngine *engine);
+
QDeclarativeEngine *engine;
};
#endif
@@ -119,6 +130,7 @@ protected:
private:
#if (QT_VERSION > QT_VERSION_CHECK(4, 6, 2)) || defined(QT_HAVE_QSCRIPTDECLARATIVECLASS_VALUE)
+ friend class QDeclarativeObjectMethodScriptClass;
QDeclarativeObjectMethodScriptClass methods;
#endif
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/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index 3ba53f0..87cab85 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -52,6 +52,7 @@
#include <QtScript/qscriptcontext.h>
#include <QtScript/qscriptengine.h>
#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qtextcodec.h>
#include <QtCore/qxmlstream.h>
#include <QtCore/qstack.h>
#include <QtCore/qdebug.h>
@@ -312,7 +313,7 @@ public:
// C++ API
static QScriptValue prototype(QScriptEngine *);
- static QScriptValue load(QScriptEngine *engine, const QString &data);
+ static QScriptValue load(QScriptEngine *engine, const QByteArray &data);
};
QT_END_NAMESPACE
@@ -619,7 +620,7 @@ QScriptValue Document::prototype(QScriptEngine *engine)
return proto;
}
-QScriptValue Document::load(QScriptEngine *engine, const QString &data)
+QScriptValue Document::load(QScriptEngine *engine, const QByteArray &data)
{
Q_ASSERT(engine);
@@ -960,6 +961,7 @@ public:
QScriptValue abort(QScriptValue *me);
QString responseBody() const;
+ const QByteArray & rawResponseBody() const;
private slots:
void downloadProgress(qint64);
void error(QNetworkReply::NetworkError);
@@ -1279,9 +1281,20 @@ void QDeclarativeXMLHttpRequest::finished()
QString QDeclarativeXMLHttpRequest::responseBody() const
{
+ QXmlStreamReader reader(m_responseEntityBody);
+ reader.readNext();
+ QTextCodec *codec = QTextCodec::codecForName(reader.documentEncoding().toString().toUtf8());
+ if (codec)
+ return codec->toUnicode(m_responseEntityBody);
+
return QString::fromUtf8(m_responseEntityBody);
}
+const QByteArray &QDeclarativeXMLHttpRequest::rawResponseBody() const
+{
+ return m_responseEntityBody;
+}
+
QScriptValue QDeclarativeXMLHttpRequest::dispatchCallback(QScriptValue *me)
{
QScriptValue v = me->property(QLatin1String("callback"));
@@ -1538,7 +1551,7 @@ static QScriptValue qmlxmlhttprequest_responseXML(QScriptContext *context, QScri
request->readyState() != QDeclarativeXMLHttpRequest::Done)
return engine->nullValue();
else
- return Document::load(engine, request->responseBody());
+ return Document::load(engine, request->rawResponseBody());
}
static QScriptValue qmlxmlhttprequest_onreadystatechange(QScriptContext *context, QScriptEngine *engine)
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 76b6a58..8c8dd95 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -1341,24 +1341,26 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t)
\brief The RotationAnimation element allows you to animate rotations.
RotationAnimation is a specialized PropertyAnimation that gives control
- over the direction of rotation.
+ over the direction of rotation. By default, it will rotate
+ via the shortest path; for example, a rotation from 20 to 340 degrees will
+ rotation 40 degrees counterclockwise.
- The RotationAnimation in the following example ensures that we always take
- the shortest rotation path when switching between our states.
+ When used in a transition RotationAnimation will rotate all
+ properties named "rotation" or "angle". You can override this by providing
+ your own properties via \c properties or \c property.
+
+ In the following example we use RotationAnimation to animate the rotation
+ between states via the shortest path.
\qml
states: {
State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
- State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } }
- State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } }
+ State { name: "90"; PropertyChanges { target: myItem; rotation: 90 } }
+ State { name: "-90"; PropertyChanges { target: myItem; rotation: -90 } }
}
transition: Transition {
- RotationAnimation { direction: RotationAnimation.Shortest }
+ RotationAnimation { }
}
\endqml
-
- By default, when used in a transition RotationAnimation will rotate all
- properties named "rotation" or "angle". You can override this by providing
- your own properties via \c properties or \c property.
*/
/*!
@@ -2389,6 +2391,52 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions
}
}
+/*!
+ \qmlclass ParentAnimation QDeclarativeParentAnimation
+ \since 4.7
+ \inherits Animation
+ \brief The ParentAnimation element allows you to animate parent changes.
+
+ ParentAnimation is used in conjunction with NumberAnimation to smoothly
+ animate changing an item's parent. In the following example,
+ ParentAnimation wraps a NumberAnimation which animates from the
+ current position in the old parent to the new position in the new
+ parent.
+
+ \qml
+ ...
+ State {
+ //reparent myItem to newParent. myItem's final location
+ //should be 10,10 in newParent.
+ ParentChange {
+ target: myItem
+ parent: newParent
+ x: 10; y: 10
+ }
+ }
+ ...
+ Transition {
+ //smoothly reparent myItem and move into new position
+ ParentAnimation {
+ target: theItem
+ NumberAnimation { properties: "x,y" }
+ }
+ }
+ \endqml
+
+ ParentAnimation can wrap any number of animations -- those animations will
+ be run in parallel (like those in a ParallelAnimation group).
+
+ In some cases, such as reparenting between items with clipping, it's useful
+ to animate the parent change \i via another item with no clipping.
+
+ When used in a transition, ParentAnimation will by default animate
+ all ParentChanges.
+*/
+/*!
+ \internal
+ \class QDeclarativeParentAnimation
+*/
QDeclarativeParentAnimation::QDeclarativeParentAnimation(QObject *parent)
: QDeclarativeAnimationGroup(*(new QDeclarativeParentAnimationPrivate), parent)
{
@@ -2410,6 +2458,13 @@ QDeclarativeParentAnimation::~QDeclarativeParentAnimation()
{
}
+/*!
+ \qmlproperty item ParentAnimation::target
+ The item to reparent.
+
+ When used in a transition, if no target is specified all
+ ParentChanges will be animated by the ParentAnimation.
+*/
QDeclarativeItem *QDeclarativeParentAnimation::target() const
{
Q_D(const QDeclarativeParentAnimation);
@@ -2422,6 +2477,12 @@ void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target)
d->target = target;
}
+/*!
+ \qmlproperty item ParentAnimation::newParent
+ The new parent to animate to.
+
+ If not set, then the parent defined in the end state of the transition.
+*/
QDeclarativeItem *QDeclarativeParentAnimation::newParent() const
{
Q_D(const QDeclarativeParentAnimation);
@@ -2434,6 +2495,19 @@ void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent)
d->newParent = newParent;
}
+/*!
+ \qmlproperty item ParentAnimation::via
+ The item to reparent via. This provides a way to do an unclipped animation
+ when both the old parent and new parent are clipped
+
+ \qml
+ ParentAnimation {
+ target: myItem
+ via: topLevelItem
+ ...
+ }
+ \endqml
+*/
QDeclarativeItem *QDeclarativeParentAnimation::via() const
{
Q_D(const QDeclarativeParentAnimation);
@@ -2480,12 +2554,13 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
struct QDeclarativeParentActionData : public QAbstractAnimationAction
{
- QDeclarativeParentActionData(): pc(0) {}
- ~QDeclarativeParentActionData() { delete pc; }
+ QDeclarativeParentActionData() {}
+ ~QDeclarativeParentActionData() { qDeleteAll(pc); }
QDeclarativeStateActions actions;
+ //### reverse should probably apply on a per-action basis
bool reverse;
- QDeclarativeParentChange *pc;
+ QList<QDeclarativeParentChange *> pc;
virtual void doAction()
{
for (int ii = 0; ii < actions.count(); ++ii) {
@@ -2500,6 +2575,33 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
QDeclarativeParentActionData *viaData = new QDeclarativeParentActionData;
+
+ bool hasExplicit = false;
+ if (d->target && d->newParent) {
+ data->reverse = false;
+ QDeclarativeAction myAction;
+ QDeclarativeParentChange *pc = new QDeclarativeParentChange;
+ pc->setObject(d->target);
+ pc->setParent(d->newParent);
+ myAction.event = pc;
+ data->pc << pc;
+ data->actions << myAction;
+ hasExplicit = true;
+ if (d->via) {
+ viaData->reverse = false;
+ QDeclarativeAction myVAction;
+ QDeclarativeParentChange *vpc = new QDeclarativeParentChange;
+ vpc->setObject(d->target);
+ vpc->setParent(d->via);
+ myVAction.event = vpc;
+ viaData->pc << vpc;
+ viaData->actions << myVAction;
+ }
+ //### once actions have concept of modified,
+ // loop to match appropriate ParentChanges and mark as modified
+ }
+
+ if (!hasExplicit)
for (int i = 0; i < actions.size(); ++i) {
QDeclarativeAction &action = actions[i];
if (action.event && action.event->typeName() == QLatin1String("ParentChange")
@@ -2508,8 +2610,21 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
QDeclarativeParentChange *pc = static_cast<QDeclarativeParentChange*>(action.event);
QDeclarativeAction myAction = action;
data->reverse = action.reverseEvent;
- action.actionDone = true;
- data->actions << myAction;
+
+ //### this logic differs from PropertyAnimation
+ // (probably a result of modified vs. done)
+ if (d->newParent) {
+ QDeclarativeParentChange *epc = new QDeclarativeParentChange;
+ epc->setObject(static_cast<QDeclarativeParentChange*>(action.event)->object());
+ epc->setParent(d->newParent);
+ myAction.event = epc;
+ data->pc << epc;
+ data->actions << myAction;
+ pc = epc;
+ } else {
+ action.actionDone = true;
+ data->actions << myAction;
+ }
if (d->via) {
viaData->reverse = false;
@@ -2518,7 +2633,7 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
vpc->setObject(pc->object());
vpc->setParent(d->via);
myAction.event = vpc;
- viaData->pc = vpc;
+ viaData->pc << vpc;
viaData->actions << myAction;
QDeclarativeAction dummyAction;
QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction;
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
index 0f23f5c..af48309 100644
--- a/src/declarative/util/qdeclarativeanimation_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -457,7 +457,7 @@ class QDeclarativeParentAnimation : public QDeclarativeAnimationGroup
Q_DECLARE_PRIVATE(QDeclarativeParentAnimation)
Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget)
- //Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent)
+ Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent)
Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia)
public:
diff --git a/src/declarative/util/qdeclarativedatetimeformatter.cpp b/src/declarative/util/qdeclarativedatetimeformatter.cpp
deleted file mode 100644
index 4087091..0000000
--- a/src/declarative/util/qdeclarativedatetimeformatter.cpp
+++ /dev/null
@@ -1,373 +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 "qdeclarativedatetimeformatter_p.h"
-
-#include <QtCore/qlocale.h>
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//TODO: may need optimisation as the QDateTime member may not be needed?
-// be able to set a locale?
-
-class QDeclarativeDateTimeFormatterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeDateTimeFormatter)
-public:
- QDeclarativeDateTimeFormatterPrivate() : locale(QLocale::system()), longStyle(false), componentComplete(true) {}
-
- void updateText();
-
- QDateTime dateTime;
- QDate date;
- QTime time;
- QLocale locale;
- QString dateTimeText;
- QString dateText;
- QString timeText;
- QString dateTimeFormat; //set for convienience?
- QString dateFormat;
- QString timeFormat;
- bool longStyle;
- bool componentComplete;
-};
-
-/*!
- \qmlclass DateTimeFormatter QDeclarativeDateTimeFormatter
- \since 4.7
- \brief The DateTimeFormatter allows you to control the format of a date string.
-
- \code
- DateTimeFormatter { id: formatter; date: System.date }
- Text { text: formatter.dateText }
- \endcode
-
- By default, the text properties (dateText, timeText, and dateTimeText) will return the
- date and time using the current system locale's format.
-*/
-
-/*!
- \internal
- \class QDeclarativeDateTimeFormatter
- \ingroup group_utility
- \brief The QDeclarativeDateTimeFormatter class allows you to format a date string.
-*/
-
-QDeclarativeDateTimeFormatter::QDeclarativeDateTimeFormatter(QObject *parent)
-: QObject(*(new QDeclarativeDateTimeFormatterPrivate), parent)
-{
-}
-
-QDeclarativeDateTimeFormatter::~QDeclarativeDateTimeFormatter()
-{
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateText
- \qmlproperty string DateTimeFormatter::timeText
- \qmlproperty string DateTimeFormatter::dateTimeText
-
- Formatted text representations of the \c date, \c time,
- and \c {date and time}, respectively.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- \code
- // specify source date (assuming today is February 19, 2009)
- DateTimeFormatter { id: formatter; dateTime: Today.date }
-
- // display the full date and time
- Text { text: formatter.dateText }
- \endcode
-
- Would be equivalent to the following for a US English locale:
-
- \code
- // display the date
- Text { text: "2/19/09" }
- \endcode
-*/
-QString QDeclarativeDateTimeFormatter::dateTimeText() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateTimeText;
-}
-
-QString QDeclarativeDateTimeFormatter::dateText() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateText;
-}
-
-QString QDeclarativeDateTimeFormatter::timeText() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->timeText;
-}
-
-/*!
- \qmlproperty date DateTimeFormatter::date
- \qmlproperty time DateTimeFormatter::time
- \qmlproperty datetime DateTimeFormatter::dateTime
-
- The source date and time to be used by the formatter.
-
- \code
- // setting the date and time
- DateTimeFormatter { date: System.date; time: System.time }
- \endcode
-
- For convienience it is possible to set the datetime property to set both the date and the time.
- \code
- // setting the datetime
- DateTimeFormatter { dateTime: System.dateTime }
- \endcode
-
- There can only be one instance of date and time per formatter; if date, time, and dateTime are all
- set the actual date and time used is not guaranteed.
-
- \note If no date is set, dateTimeText will be just the date;
- If no time is set, the dateTimeText will be just the time.
-
-*/
-QDate QDeclarativeDateTimeFormatter::date() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->date;
-}
-
-QTime QDeclarativeDateTimeFormatter::time() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->time;
-}
-
-QDateTime QDeclarativeDateTimeFormatter::dateTime() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateTime;
-}
-
-/*!
- \qmlproperty string DateTimeFormatter::dateFormat
- \qmlproperty string DateTimeFormatter::timeFormat
- \qmlproperty string DateTimeFormatter::dateTimeFormat
-
- Specifies a custom format which the DateTime Formatter can use.
-
- If there is no explictly specified format the DateTimeFormatter
- will use the system locale's default 'short' setting.
-
- The text's format may be modified by setting:
- \list
- \i \c dateFormat
- \i \c timeFormat
- \i \c dateTimeFormat
- \endlist
-
- If only the format for date is defined, the time and dateTime formats will be defined
- as the system locale default and likewise for the others.
-
- Syntax for the format is based on the QDateTime::toString() formatting options.
-
- \code
- // Format the date such that the dateText is: '1997-12-12'
- DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" }
- \endcode
-
- Assigning an empty string to a particular format will reset it.
-*/
-QString QDeclarativeDateTimeFormatter::dateTimeFormat() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateTimeFormat;
-}
-
-QString QDeclarativeDateTimeFormatter::dateFormat() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->dateFormat;
-}
-
-QString QDeclarativeDateTimeFormatter::timeFormat() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->timeFormat;
-}
-
-/*!
- \qmlproperty bool DateTimeFormatter::longStyle
-
- This property causes the formatter to use the system locale's long format rather than short format
- by default.
-
- This setting is off by default.
-*/
-bool QDeclarativeDateTimeFormatter::longStyle() const
-{
- Q_D(const QDeclarativeDateTimeFormatter);
- return d->longStyle;
-}
-
-void QDeclarativeDateTimeFormatter::setDateTime(const QDateTime &dateTime)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- if (d->dateTime == dateTime)
- return;
- d->dateTime = dateTime;
- d->date = d->dateTime.date();
- d->time = d->dateTime.time();
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setTime(const QTime &time)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- if (d->dateTime.time() == time)
- return;
- d->time = time;
- d->dateTime.setTime(time);
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setDate(const QDate &date)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- if (d->dateTime.date() == date)
- return;
- d->date = date;
- bool clearTime = d->dateTime.time().isValid() ? false : true; //because setting date generates default time
- d->dateTime.setDate(date);
- if (clearTime)
- d->dateTime.setTime(QTime());
- d->updateText();
-}
-
-//DateTime formatting may be a combination of date and time?
-void QDeclarativeDateTimeFormatter::setDateTimeFormat(const QString &format)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- //no format checking
- d->dateTimeFormat = format;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setDateFormat(const QString &format)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- //no format checking
- d->dateFormat = format;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setTimeFormat(const QString &format)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- //no format checking
- d->timeFormat = format;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatter::setLongStyle(bool longStyle)
-{
- Q_D(QDeclarativeDateTimeFormatter);
- d->longStyle = longStyle;
- d->updateText();
-}
-
-void QDeclarativeDateTimeFormatterPrivate::updateText()
-{
- Q_Q(QDeclarativeDateTimeFormatter);
- if (!componentComplete)
- return;
-
- QString str;
- QString str1;
- QString str2;
-
- Qt::DateFormat defaultFormat = longStyle ? Qt::SystemLocaleLongDate : Qt::SystemLocaleShortDate;
-
- if (dateFormat.isEmpty())
- str1 = date.toString(defaultFormat);
- else
- str1 = date.toString(dateFormat);
-
- if (timeFormat.isEmpty())
- str2 = time.toString(defaultFormat);
- else
- str2 = time.toString(timeFormat);
-
- if (dateTimeFormat.isEmpty())
- str = dateTime.toString(defaultFormat);
- //else if (!formatTime.isEmpty() && !formatDate.isEmpty())
- // str = str1 + QLatin1Char(' ') + str2;
- else
- str = dateTime.toString(dateTimeFormat);
-
- if (dateTimeText == str && dateText == str1 && timeText == str2)
- return;
-
- dateTimeText = str;
- dateText = str1;
- timeText = str2;
-
- emit q->textChanged();
-}
-
-void QDeclarativeDateTimeFormatter::classBegin()
-{
- Q_D(QDeclarativeDateTimeFormatter);
- d->componentComplete = false;
-}
-
-void QDeclarativeDateTimeFormatter::componentComplete()
-{
- Q_D(QDeclarativeDateTimeFormatter);
- d->componentComplete = true;
- d->updateText();
-}
-
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativedatetimeformatter_p.h b/src/declarative/util/qdeclarativedatetimeformatter_p.h
deleted file mode 100644
index da900be..0000000
--- a/src/declarative/util/qdeclarativedatetimeformatter_p.h
+++ /dev/null
@@ -1,117 +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 QDECLARATIVEDATETIMEFORMATTER_H
-#define QDECLARATIVEDATETIMEFORMATTER_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/qdatetime.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeDateTimeFormatterPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeDateTimeFormatter : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-
- Q_PROPERTY(QString dateText READ dateText NOTIFY textChanged)
- Q_PROPERTY(QString timeText READ timeText NOTIFY textChanged)
- Q_PROPERTY(QString dateTimeText READ dateTimeText NOTIFY textChanged)
- Q_PROPERTY(QDate date READ date WRITE setDate)
- Q_PROPERTY(QTime time READ time WRITE setTime)
- Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime)
- Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat)
- Q_PROPERTY(QString timeFormat READ timeFormat WRITE setTimeFormat)
- Q_PROPERTY(QString dateTimeFormat READ dateTimeFormat WRITE setDateTimeFormat)
- Q_PROPERTY(bool longStyle READ longStyle WRITE setLongStyle)
-public:
- QDeclarativeDateTimeFormatter(QObject *parent=0);
- ~QDeclarativeDateTimeFormatter();
-
- QString dateTimeText() const;
- QString dateText() const;
- QString timeText() const;
-
- QDate date() const;
- void setDate(const QDate &);
-
- QTime time() const;
- void setTime(const QTime &);
-
- QDateTime dateTime() const;
- void setDateTime(const QDateTime &);
-
- QString dateTimeFormat() const;
- void setDateTimeFormat(const QString &);
-
- QString dateFormat() const;
- void setDateFormat(const QString &);
-
- QString timeFormat() const;
- void setTimeFormat(const QString &);
-
- bool longStyle() const;
- void setLongStyle(bool);
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- Q_DISABLE_COPY(QDeclarativeDateTimeFormatter)
- Q_DECLARE_PRIVATE(QDeclarativeDateTimeFormatter)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeDateTimeFormatter)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qdeclarativenumberformatter.cpp b/src/declarative/util/qdeclarativenumberformatter.cpp
deleted file mode 100644
index 5d81958..0000000
--- a/src/declarative/util/qdeclarativenumberformatter.cpp
+++ /dev/null
@@ -1,261 +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 "qdeclarativenumberformatter_p.h"
-
-#include <private/qobject_p.h>
-
-QT_BEGIN_NAMESPACE
-
-//TODO: set locale
-// docs
-// this is a wrapper around qnumberformat (test integration)
-// if number or format haven't been explictly set, text should be an empty string
-
-class QDeclarativeNumberFormatterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDeclarativeNumberFormatter)
-public:
- QDeclarativeNumberFormatterPrivate() : locale(QLocale::system()), number(0), componentComplete(true) {}
-
- void updateText();
-
- QLocale locale;
- QString format;
- QNumberFormat numberFormat;
- QString text;
- qreal number;
- bool componentComplete;
-};
-/*!
- \qmlclass NumberFormatter
- \since 4.7
- \brief The NumberFormatter allows you to control the format of a number string.
-
- The format property documentation has more details on how the format can be manipulated.
-
- In the following example, the text element will display the text "1,234.57".
- \code
- NumberFormatter { id: formatter; number: 1234.5678; format: "##,##0.##" }
- Text { text: formatter.text }
- \endcode
-
- */
-/*!
- \internal
- \class QDeclarativeNumberFormatter
- \ingroup group_utility
- \brief The QDeclarativeNumberFormatter class allows you to format a number to a particular string format/locale specific number format.
-*/
-
-QDeclarativeNumberFormatter::QDeclarativeNumberFormatter(QObject *parent)
-: QObject(*(new QDeclarativeNumberFormatterPrivate), parent)
-{
-}
-
-QDeclarativeNumberFormatter::~QDeclarativeNumberFormatter()
-{
-}
-
-/*!
- \qmlproperty string NumberFormatter::text
-
- The number in the specified format.
-
- If no format is specified the text will be empty.
-*/
-
-QString QDeclarativeNumberFormatter::text() const
-{
- Q_D(const QDeclarativeNumberFormatter);
- return d->text;
-}
-
-/*!
- \qmlproperty real NumberFormatter::number
-
- A single point precision number. (Doubles are not yet supported)
-
-*/
-qreal QDeclarativeNumberFormatter::number() const
-{
- Q_D(const QDeclarativeNumberFormatter);
- return d->number;
-}
-
-/*!
- \qmlproperty string NumberFormatter::format
-
- The particular format the number will adhere to during the conversion to text.
-
- The format syntax follows a style similar to the Unicode Standard (UTS35).
-
- The table below shows the characters, patterns that can be used in the format.
-
- \table
- \header
- \o Character
- \o Meaning
- \row
- \o #
- \o Any digit(s), zero shows as absent (for leading/trailing zeroes).
- \row
- \o 0
- \o Implicit digit. Zero will show in the case that the input number is too small.
- \row
- \o .
- \o Decimal separator. Output decimal seperator will be dependant on system locale.
- \row
- \o ,
- \o Grouping separator. The number of digits (either #, or 0) between the grouping separator and the decimal (or the rightmost digit) will determine the groupingSize).
- \row
- \o other
- \o Any other character will be taken as a string literal and placed directly into the output string.
- \endtable
-
- Invalid formats will not guarantee a meaningful text output.
-
- \note Input numbers that are too long for the given format will be rounded dependent on precison based on the position of the decimal point.
-
- The following table illustrates the output text created by applying some examples of numeric formats to the formatter.
-
- \table
- \header
- \o Format
- \o Number
- \o Output
- \row
- \o ###
- \o 123456
- \o 123456
- \row
- \o 000
- \o 123456
- \o 123456
- \row
- \o ######
- \o 1234
- \o 1234
- \row
- \o 000000
- \o 1234
- \o 001234
- \row
- \o ##,##0.##
- \o 1234.456
- \o 1,234.46 (for US locale)
- \codeline 1 234,46 (for FR locale)
- \row
- \o 000000,000.#
- \o 123456
- \o 000,123,456 (for US locale)
- \codeline 000 123 456 (for FR locale)
- \row
- \o 0.0###
- \o 0.999997
- \o 1.0
- \row
- \o (000) 000 - 000
- \o 12345678
- \o (012) 345 - 678
- \row
- \o #A
- \o 12
- \o 12A
- \endtable
-
-*/
-QString QDeclarativeNumberFormatter::format() const
-{
- Q_D(const QDeclarativeNumberFormatter);
- return d->format;
-}
-
-void QDeclarativeNumberFormatter::setNumber(const qreal &number)
-{
- Q_D(QDeclarativeNumberFormatter);
- if (d->number == number)
- return;
- d->number = number;
- d->updateText();
-}
-
-void QDeclarativeNumberFormatter::setFormat(const QString &format)
-{
- Q_D(QDeclarativeNumberFormatter);
- //no format checking
- if (format.isEmpty())
- d->format = QString::null;
- else
- d->format = format;
- d->updateText();
-}
-
-void QDeclarativeNumberFormatterPrivate::updateText()
-{
- Q_Q(QDeclarativeNumberFormatter);
- if (!componentComplete)
- return;
-
- QNumberFormat tempFormat;
- tempFormat.setFormat(format);
- tempFormat.setNumber(number);
-
- text = tempFormat.text();
-
- emit q->textChanged();
-}
-
-void QDeclarativeNumberFormatter::classBegin()
-{
- Q_D(QDeclarativeNumberFormatter);
- d->componentComplete = false;
-}
-
-void QDeclarativeNumberFormatter::componentComplete()
-{
- Q_D(QDeclarativeNumberFormatter);
- d->componentComplete = true;
- d->updateText();
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qdeclarativenumberformatter_p.h b/src/declarative/util/qdeclarativenumberformatter_p.h
deleted file mode 100644
index 3b8c7e1..0000000
--- a/src/declarative/util/qdeclarativenumberformatter_p.h
+++ /dev/null
@@ -1,93 +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 QDECLARATIVENUMBERFORMATTER_H
-#define QDECLARATIVENUMBERFORMATTER_H
-
-#include "qnumberformat_p.h"
-
-#include <qdeclarative.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class QDeclarativeNumberFormatterPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeNumberFormatter : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-
- Q_PROPERTY(QString text READ text NOTIFY textChanged)
- Q_PROPERTY(QString format READ format WRITE setFormat)
- Q_PROPERTY(qreal number READ number WRITE setNumber)
-public:
- QDeclarativeNumberFormatter(QObject *parent=0);
- ~QDeclarativeNumberFormatter();
-
- QString text() const;
-
- qreal number() const;
- void setNumber(const qreal &);
-
- QString format() const;
- void setFormat(const QString &);
-
- virtual void classBegin();
- virtual void componentComplete();
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- Q_DISABLE_COPY(QDeclarativeNumberFormatter)
- Q_DECLARE_PRIVATE(QDeclarativeNumberFormatter)
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QDeclarativeNumberFormatter)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index cea9ad7..cd06380 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -158,17 +158,17 @@ void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, Q
\qmlclass ParentChange QDeclarativeParentChange
\brief The ParentChange element allows you to reparent an Item in a state change.
- ParentChange reparents an Item while preserving its visual appearance (position, rotation,
- and scale) on screen. You can then specify a transition to move/rotate/scale the Item to
- its final intended appearance.
+ ParentChange reparents an item while preserving its visual appearance (position, size,
+ rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale
+ the item to its final intended appearance.
ParentChange can only preserve visual appearance if no complex transforms are involved.
More specifically, it will not work if the transform property has been set for any
- Items involved in the reparenting (defined as any Items in the common ancestor tree
+ items involved in the reparenting (i.e. items in the common ancestor tree
for the original and new parent).
You can specify at which point in a transition you want a ParentChange to occur by
- using a ParentAction.
+ using a ParentAnimation or ParentAction.
*/
@@ -181,6 +181,16 @@ QDeclarativeParentChange::~QDeclarativeParentChange()
{
}
+/*!
+ \qmlproperty real ParentChange::x
+ \qmlproperty real ParentChange::y
+ \qmlproperty real ParentChange::width
+ \qmlproperty real ParentChange::height
+ \qmlproperty real ParentChange::scale
+ \qmlproperty real ParentChange::rotation
+ These properties hold the new position, size, scale, and rotation
+ for the item in this state.
+*/
qreal QDeclarativeParentChange::x() const
{
Q_D(const QDeclarativeParentChange);
@@ -314,7 +324,7 @@ void QDeclarativeParentChange::setObject(QDeclarativeItem *target)
/*!
\qmlproperty Item ParentChange::parent
- This property holds the parent for the item in this state
+ This property holds the new parent for the item in this state.
*/
QDeclarativeItem *QDeclarativeParentChange::parent() const
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/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 1f85b89..65bfdc1 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -46,13 +46,11 @@
#include "qdeclarativebehavior_p.h"
#include "qdeclarativebind_p.h"
#include "qdeclarativeconnections_p.h"
-#include "qdeclarativedatetimeformatter_p.h"
#include "qdeclarativeeasefollow_p.h"
#include "qdeclarativefontloader_p.h"
#include "qdeclarativelistaccessor_p.h"
#include "qdeclarativelistmodel_p.h"
#include "qdeclarativenullablevalue_p_p.h"
-#include "qdeclarativenumberformatter_p.h"
#include "qdeclarativeopenmetaobject_p.h"
#include "qdeclarativepackage_p.h"
#include "qdeclarativepixmapcache_p.h"
@@ -73,7 +71,6 @@
#ifndef QT_NO_XMLPATTERNS
#include "qdeclarativexmllistmodel_p.h"
#endif
-#include "qnumberformat_p.h"
#include "qperformancelog_p_p.h"
void QDeclarativeUtilModule::defineModule()
@@ -83,12 +80,10 @@ void QDeclarativeUtilModule::defineModule()
QML_REGISTER_TYPE(Qt,4,6,Binding,QDeclarativeBind);
QML_REGISTER_TYPE(Qt,4,6,ColorAnimation,QDeclarativeColorAnimation);
QML_REGISTER_TYPE(Qt,4,6,Connections,QDeclarativeConnections);
- QML_REGISTER_TYPE(Qt,4,6,DateTimeFormatter,QDeclarativeDateTimeFormatter);
QML_REGISTER_TYPE(Qt,4,6,EaseFollow,QDeclarativeEaseFollow);;
QML_REGISTER_TYPE(Qt,4,6,FontLoader,QDeclarativeFontLoader);
QML_REGISTER_TYPE(Qt,4,6,ListElement,QDeclarativeListElement);
QML_REGISTER_TYPE(Qt,4,6,NumberAnimation,QDeclarativeNumberAnimation);
- QML_REGISTER_TYPE(Qt,4,6,NumberFormatter,QDeclarativeNumberFormatter);;
QML_REGISTER_TYPE(Qt,4,6,Package,QDeclarativePackage);
QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QDeclarativeParallelAnimation);
QML_REGISTER_TYPE(Qt,4,6,ParentAction,QDeclarativeParentAction);
@@ -116,7 +111,6 @@ void QDeclarativeUtilModule::defineModule()
QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors);
QML_REGISTER_NOCREATE_TYPE(QDeclarativeAbstractAnimation);
QML_REGISTER_NOCREATE_TYPE(QDeclarativeStateOperation);
- QML_REGISTER_NOCREATE_TYPE(QNumberFormat);
QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QDeclarativeListModel, QDeclarativeListModelParser);
QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QDeclarativePropertyChanges, QDeclarativePropertyChangesParser);
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;
diff --git a/src/declarative/util/qnumberformat.cpp b/src/declarative/util/qnumberformat.cpp
deleted file mode 100644
index 81d0b90..0000000
--- a/src/declarative/util/qnumberformat.cpp
+++ /dev/null
@@ -1,224 +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 "qnumberformat_p.h"
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal),
- _groupingSize(0)
-{
- _locale = QLocale::system();
- _groupingSeparator = _locale.groupSeparator();
- _decimalSeparator = _locale.decimalPoint();
- _currencySymbol = QLatin1Char('$');
-}
-
-QNumberFormat::~QNumberFormat()
-{
-
-}
-
-void QNumberFormat::updateText()
-{
- QTime t;
- t.start();
- static int totalTime;
-
- handleFormat();
-
- totalTime += t.elapsed();
- emit textChanged();
-}
-
-void QNumberFormat::handleFormat()
-{
- // ### is extremely messy
- if (_format.isEmpty()) {
- _text = QString::number(_number, 'f', -1);
- return;
- }
-
- QString inputString;
-
- // ### possible to use the following parsed data in the future
-
- int remainingLength = _format.size();
- int currentIndex = _format.size()-1;
-
- int maxDigits = 0;
- int minDigits = 0;
- int decimalLength = 0;
-
- while (remainingLength > 0) {
- switch(_format.at(currentIndex).unicode()) {
- case ',':
- if (decimalLength && !_groupingSize)
- setGroupingSize(maxDigits - decimalLength);
- else if (!_groupingSize)
- setGroupingSize(maxDigits);
- break;
- case '.':
- if (!decimalLength)
- decimalLength = maxDigits;
- break;
- case '0':
- minDigits++;
- case '#':
- maxDigits++;
- break;
- default:
- break;
- }
- currentIndex--;
- remainingLength--;
- }
-
- // round given the decimal length/precision
- inputString = QString::number(_number, 'f', decimalLength);
-
- QStringList parts = inputString.split(QLatin1Char('.'));
- QStringList formatParts = _format.split(QLatin1Char('.'));
-
- if (formatParts.size() > 2 || parts.size() > 2 )
- return;
-
- QString formatInt = formatParts.at(0);
-
- QString formatDec;
- if (formatParts.size() == 2)
- formatDec = formatParts.at(1);
-
- QString integer = parts.at(0);
-
- QString decimal;
- if (parts.size() == 2)
- decimal = parts.at(1);
-
- QString outputDecimal = formatDecimal(formatDec, decimal);
- QString outputInteger = formatInteger(formatInt, integer);
-
- // insert separators
- if (_groupingSize) {
- unsigned int count = 0;
- for (int i = outputInteger.size()-1; i > 0; i--) {
- if (outputInteger.at(i).digitValue() >= 0) {
- if (count == _groupingSize - 1) {
- count = 0;
- outputInteger.insert(i, _groupingSeparator);
- }
- else
- count++;
- }
- }
- }
- if (!outputDecimal.isEmpty())
- _text = outputInteger + _decimalSeparator + outputDecimal;
- else
- _text = outputInteger;
-}
-
-QString QNumberFormat::formatInteger(const QString &formatInt, const QString &integer)
-{
- if (formatInt.isEmpty() || integer.isEmpty())
- return QString();
-
- QString outputInteger;
- int formatIndex = formatInt.size()-1;
-
- //easier for carry?
- for (int index= integer.size()-1; index >= 0; index--) {
- if (formatIndex < 0) {
- outputInteger.push_front(integer.at(index));
- }
- else {
- switch(formatInt.at(formatIndex).unicode()) {
- case '0':
- if (index > integer.size()-1) {
- outputInteger.push_front(QLatin1Char('0'));
- break;
- }
- case '#':
- outputInteger.push_front(integer.at(index));
- break;
- case ',':
- index++;
- break;
- default:
- outputInteger.push_front(formatInt.at(formatIndex));
- index++;
- break;
- }
- formatIndex--;
- }
- }
- while (formatIndex >= 0) {
- if (formatInt.at(formatIndex).unicode() != '#' && formatInt.at(formatIndex).unicode() != ',')
- outputInteger.push_front(formatInt.at(formatIndex));
- formatIndex--;
- }
- return outputInteger;
-}
-
-QString QNumberFormat::formatDecimal(const QString &formatDec, const QString &decimal)
-{
- QString outputDecimal;
-
- // up to max 6 decimal places
- for (int index=formatDec.size()-1; index >= 0; index--) {
- switch(formatDec.at(index).unicode()) {
- case '0':
- outputDecimal.push_front(decimal.at(index));
- break;
- case '#':
- if (decimal.at(index) != QLatin1Char('0') || outputDecimal.size() > 0)
- outputDecimal.push_front(decimal.at(index));
- break;
- default:
- outputDecimal.push_front(formatDec.at(index));
- break;
- }
- }
- return outputDecimal;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/util/qnumberformat_p.h b/src/declarative/util/qnumberformat_p.h
deleted file mode 100644
index ced4442..0000000
--- a/src/declarative/util/qnumberformat_p.h
+++ /dev/null
@@ -1,174 +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 NUMBERFORMAT_H
-#define NUMBERFORMAT_H
-
-#include <qdeclarative.h>
-
-#include <QtCore/QLocale>
-#include <QtCore/QTime>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-// TODO
-// be able to set Locale, instead of default system for dynamic formatting
-// add currency support
-// add additional syntax, extend to format scientific, percentiles, significant digits etc
-
-
-class QNumberFormat : public QObject
-{
- Q_OBJECT
- Q_ENUMS(NumberType)
-public:
- QNumberFormat(QObject *parent=0);
- ~QNumberFormat();
-
- enum NumberType {
- Percent,
- Scientific,
- Currency,
- Decimal
- };
-
- //external property, only visible
- Q_PROPERTY(QString text READ text NOTIFY textChanged)
-
- //mutatable properties to modify the output (text)
- Q_PROPERTY(qreal number READ number WRITE setNumber)
- Q_PROPERTY(QString format READ format WRITE setFormat)
- Q_PROPERTY(QLocale locale READ locale WRITE setLocale)
-
- //Format specific settings
- Q_PROPERTY(unsigned short groupingSeparator READ groupingSeparator WRITE setGroupingSeparator)
- Q_PROPERTY(unsigned short decimalSeperator READ decimalSeparator WRITE setDecimalSeparator)
- Q_PROPERTY(unsigned int groupingSize READ groupingSize WRITE setGroupingSize)
- Q_PROPERTY(unsigned short currencySymbol READ currencySymbol WRITE setCurrencySymbol)
-
-
- QString text() const { return _text; }
-
- qreal number() const { return _number; }
- void setNumber(qreal n) {
- if (_number == n)
- return;
- _number = n;
- updateText();
- }
-
- QString format() const { return _format; }
- void setFormat(const QString &format) {
- if (format.isEmpty())
- _format = QString::null;
- else if (_format == format)
- return;
-
- _format = format;
- updateText();
- }
-
- QLocale locale() const { return _locale; }
- void setLocale(const QLocale &locale) { _locale = locale; updateText(); }
-
- //Do we deal with unicode standard? or create our own
- // ### since this is the backend for the number conversions, we will use the unicode
- // the front-end will handle the QChar/QString -> short int
-
- unsigned short groupingSeparator() { return _groupingSeparator.unicode(); }
- void setGroupingSeparator(unsigned short unicodeSymbol)
- {
- _groupingSeparator = QChar(unicodeSymbol);
- }
-
- unsigned short decimalSeparator() { return _decimalSeparator.unicode(); }
- void setDecimalSeparator(unsigned short unicodeSymbol)
- {
- _decimalSeparator = QChar(unicodeSymbol);
- }
-
- unsigned short currencySymbol() { return _currencySymbol.unicode(); }
- void setCurrencySymbol(unsigned short unicodeSymbol)
- {
- _currencySymbol = QChar(unicodeSymbol);
- }
-
- unsigned int groupingSize() { return _groupingSize; }
- void setGroupingSize(unsigned int size)
- {
- _groupingSize = size;
- }
-
-Q_SIGNALS:
- void textChanged();
-
-private:
- void updateText();
- void handleFormat();
- QString formatInteger(const QString &formatInt, const QString &integer);
- QString formatDecimal(const QString &formatDec, const QString &decimal);
-
- qreal _number;
- NumberType _type;
- QChar _groupingSeparator;
- QChar _decimalSeparator;
- QChar _currencySymbol;
- unsigned int _groupingSize;
-
- QLocale _locale;
- QString _format;
-
- // only hooked member at the moment
- QString _text;
-
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QNumberFormat)
-
-QT_END_HEADER
-
-#endif
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index 198e9e5..26edecc 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -25,9 +25,6 @@ SOURCES += \
$$PWD/qdeclarativebind.cpp \
$$PWD/qdeclarativepropertymap.cpp \
$$PWD/qdeclarativepixmapcache.cpp \
- $$PWD/qnumberformat.cpp \
- $$PWD/qdeclarativenumberformatter.cpp \
- $$PWD/qdeclarativedatetimeformatter.cpp \
$$PWD/qdeclarativebehavior.cpp \
$$PWD/qdeclarativefontloader.cpp \
$$PWD/qdeclarativestyledtext.cpp
@@ -60,9 +57,6 @@ HEADERS += \
$$PWD/qdeclarativebind_p.h \
$$PWD/qdeclarativepropertymap.h \
$$PWD/qdeclarativepixmapcache_p.h \
- $$PWD/qnumberformat_p.h \
- $$PWD/qdeclarativenumberformatter_p.h \
- $$PWD/qdeclarativedatetimeformatter_p.h \
$$PWD/qdeclarativebehavior_p.h \
$$PWD/qdeclarativefontloader_p.h \
$$PWD/qdeclarativestyledtext_p.h