summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-03-05 03:31:45 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-03-05 03:31:45 (GMT)
commitad1621773b7096732d226ea4c13c6f9cf41fe141 (patch)
treedceb6d027154b77c7b01e0aec1a605e9720b20d0
parent8fa8dcd33f5395060a84f6b7062c927aa675cde6 (diff)
parentae6f59d8dffc1a0569640e374dde01ed84f9c542 (diff)
downloadQt-ad1621773b7096732d226ea4c13c6f9cf41fe141.zip
Qt-ad1621773b7096732d226ea4c13c6f9cf41fe141.tar.gz
Qt-ad1621773b7096732d226ea4c13c6f9cf41fe141.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
-rw-r--r--examples/declarative/dynamic/dynamic.qml42
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml44
-rw-r--r--examples/declarative/tabwidget/tab.pngbin0 -> 507 bytes
-rw-r--r--examples/declarative/tabwidget/tabs.qml49
-rw-r--r--examples/declarative/velocity/Day.qml2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp1
-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
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp37
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml6
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml7
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml10
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp70
26 files changed, 340 insertions, 78 deletions
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
index 2831b0c..6af3e81 100644
--- a/examples/declarative/dynamic/dynamic.qml
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -17,15 +17,17 @@ Item {
}
// stars (when there's no sun)
- Particles { id: stars
- x: 0; y: 0; width: parent.width; height: parent.height/2
+ Particles {
+ id: stars
+ x: 0; y: 0; width: parent.width; height: parent.height / 2
source: "images/star.png"; angleDeviation: 360; velocity: 0
velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800
opacity: 1
}
// ground, which has a z such that the sun can set behind it
- Rectangle { id: ground
+ Rectangle {
+ id: ground
z: 2
anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.right; bottom: parent.bottom }
gradient: Gradient {
@@ -35,7 +37,8 @@ Item {
}
//Day state, for when you place a sun
- states: State { name: "Day"; when: window.activeSuns > 0
+ states: State {
+ name: "Day"; when: window.activeSuns > 0
PropertyChanges { target: stopA; color: "DeepSkyBlue"}
PropertyChanges { target: stopB; color: "SkyBlue"}
PropertyChanges { target: stars; opacity: 0 }
@@ -56,56 +59,57 @@ Item {
width: 480
anchors { right: parent.right; top:parent.top; bottom: parent.bottom }
Rectangle { //Not a child of any positioner
- color: "white"; border.color: "black";
+ color: "white"; border.color: "black";
width: toolRow.width + 4
height: toolRow.height + 4
x: toolboxPositioner.x + toolRow.x - 2
y: toolboxPositioner.y + toolRow.y - 2
}
- Column{
+ Column {
id: toolboxPositioner
anchors.centerIn: parent
spacing: 8
- Text{ text: "Drag an item into the scene." }
- Row{ id: toolRow
- spacing: 8;
- PaletteItem{
+ Text { text: "Drag an item into the scene." }
+ Row {
+ id: toolRow
+ spacing: 8;
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "Sun.qml";
image: "../images/sun.png"
}
- PaletteItem{
+ PaletteItem {
file: "GenericItem.qml"
image: "../images/moon.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/tree_s.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/rabbit_brown.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/rabbit_bw.png"
}
}
- Text{ text: "Active Suns: " + activeSuns }
+ Text { text: "Active Suns: " + activeSuns }
Rectangle { width: 440; height: 1; color: "black" }
- Text{ text: "Arbitrary QML: " }
+ Text { text: "Arbitrary QML: " }
TextEdit {
id: qmlText
width: 460
height: 220
readOnly: false
focusOnPress: true
- font.pixelSize: 16
-
- text: "import Qt 4.6\nImage { id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n opacity: NumberAnimation{ \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}"
+ font.pixelSize: 14
+
+ text: "import Qt 4.6\nImage {\n id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n NumberAnimation on opacity { \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}"
}
Button {
text: "Create"
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
index f0dfee8..f0f7164 100644
--- a/examples/declarative/tabwidget/TabWidget.qml
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -1,42 +1,50 @@
import Qt 4.6
Item {
- id: page
+ id: tabWidget
property int current: 0
default property alias content: stack.children
+
onCurrentChanged: setOpacities()
Component.onCompleted: setOpacities()
+
function setOpacities()
{
- for (var i=0; i<stack.children.length; ++i) {
- stack.children[i].opacity = i==current ? 1 : 0
+ for (var i = 0; i < stack.children.length; ++i) {
+ stack.children[i].opacity = i == current ? 1 : 0
}
}
+
Row {
id: header
Repeater {
delegate:
+ Rectangle {
+ width: tabWidget.width / stack.children.length; height: 36
Rectangle {
- width: page.width / stack.children.length
- height: 15
- color: page.current == index ? "grey" : "lightGrey"
- Text {
- anchors.fill: parent
- text: stack.children[index].title
- elide: Text.ElideRight
- }
- MouseArea {
- anchors.fill: parent
- onClicked: page.current = index
- }
+ color: "#acb2c2"; width: parent.width; height: 1
+ anchors { bottom: parent.bottom; bottomMargin: 1 }
+ }
+ BorderImage {
+ source: "tab.png"; visible: tabWidget.current == index; border.left: 7; border.right: 7
+ anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
}
+ Text {
+ horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
+ anchors.fill: parent; text: stack.children[index].title
+ elide: Text.ElideRight; font.bold: tabWidget.current == index
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: tabWidget.current = index
+ }
+ }
model: stack.children.length
}
}
+
Item {
id: stack
- anchors.top: header.bottom
- anchors.bottom: page.bottom
- width: page.width
+ anchors.top: header.bottom; anchors.bottom: tabWidget.bottom; width: tabWidget.width
}
}
diff --git a/examples/declarative/tabwidget/tab.png b/examples/declarative/tabwidget/tab.png
new file mode 100644
index 0000000..ad80216
--- /dev/null
+++ b/examples/declarative/tabwidget/tab.png
Binary files differ
diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml
index 54ed7df..1d11b03 100644
--- a/examples/declarative/tabwidget/tabs.qml
+++ b/examples/declarative/tabwidget/tabs.qml
@@ -2,28 +2,47 @@ import Qt 4.6
TabWidget {
id: tabs
- width: 200
- height: 200
- current: 2
+ width: 640; height: 480
+
Rectangle {
property string title: "Red"
- color: "red"
- anchors.fill: parent
- Text { anchors.centerIn: parent; text: "<div align=center>Roses are red"; font.pixelSize: 24
- wrap: true; width: parent.width-20 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#ff7f7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Roses are red"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
}
+
Rectangle {
property string title: "Green"
- color: "green"
- anchors.fill: parent
- Text { anchors.centerIn: parent; text: "<div align=center>Flower stems are green"; font.pixelSize: 24;
- wrap: true; width: parent.width-20 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7fff7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Flower stems are green"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
}
+
Rectangle {
property string title: "Blue"
- color: "blue"
- anchors.fill: parent
- Text { anchors.centerIn: parent; text: "<div align=center>Violets are blue"; color: "white"; font.pixelSize: 24
- wrap: true; width: parent.width-20 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7f7fff"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Violets are blue"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
}
}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index 8a7364e..f4c24a5 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -52,7 +52,7 @@ Rectangle {
id: mouse
onClicked: { myText.focus = true }
anchors.fill: parent
- drag.target: stickyPage; drag.axis: "XandYAxis"; drag.minimumY: 0; drag.maximumY: 500
+ drag.target: stickyPage; drag.axis: MouseArea.XandYAxis; drag.minimumY: 0; drag.maximumY: 500
drag.minimumX: 0; drag.maximumX: 400
}
}
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/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;
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
new file mode 100644
index 0000000..d4e0cc0
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
@@ -0,0 +1 @@
+3:1:Element is not creatable.
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
new file mode 100644
index 0000000..a723269
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
@@ -0,0 +1,4 @@
+import Qt 4.6
+
+Font {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 3ce15cb..da0bf1a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -326,6 +326,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidRoot") << "invalidRoot.qml" << "invalidRoot.errors.txt" << false;
QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
+ QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
}
diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
index b120d5d..1dfec50 100644
--- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
+++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp
@@ -38,6 +38,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include <QtTest/QSignalSpy>
#include <qtest.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
@@ -161,6 +162,18 @@ void tst_qdeclarativetimer::repeat()
QVERIFY(helper.count == oldCount);
QVERIFY(timer->isRunning() == false);
+ QSignalSpy spy(timer, SIGNAL(repeatChanged()));
+
+ timer->setRepeating(false);
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(true);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
@@ -184,6 +197,18 @@ void tst_qdeclarativetimer::triggeredOnStart()
QCOMPARE(helper.count, 2);
QVERIFY(timer->isRunning() == false);
+ QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
+
+ timer->setTriggeredOnStart(false);
+ QVERIFY(!timer->triggeredOnStart());
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(true);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
@@ -250,6 +275,18 @@ void tst_qdeclarativetimer::changeDuration()
QCOMPARE(helper.count, 3);
QVERIFY(timer->isRunning());
+ QSignalSpy spy(timer, SIGNAL(intervalChanged()));
+
+ timer->setInterval(200);
+ QCOMPARE(timer->interval(), 200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(300);
+ QCOMPARE(spy.count(),2);
+
delete timer;
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
index 0eadd50..cb01a80 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
@@ -1,6 +1,6 @@
import Test 1.0
MyTypeObject {
- font.capitalization: "MixedCase"
+ font.capitalization: "AllUppercase"
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
index 81f1c92..93f1ed5 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
@@ -1,6 +1,6 @@
import Test 1.0
MyTypeObject {
- font.capitalization: if (1) "MixedCase"
+ font.capitalization: if (1) "AllUppercase"
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
new file mode 100644
index 0000000..3be5099
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
@@ -0,0 +1,6 @@
+import Test 1.0
+import Qt 4.6
+
+MyTypeObject {
+ font.capitalization: Font.AllUppercase
+}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
new file mode 100644
index 0000000..6b494e4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
@@ -0,0 +1,7 @@
+import Test 1.0
+import Qt 4.6 as MyQt
+
+MyTypeObject {
+ font.capitalization: MyQt.Font.AllUppercase
+}
+
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index 8732215..51f9a07 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -597,7 +597,7 @@ void tst_qdeclarativevaluetypes::enums()
QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
delete object;
}
@@ -605,7 +605,23 @@ void tst_qdeclarativevaluetypes::enums()
QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::MixedCase);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QDeclarativeComponent component(&engine, TEST_FILE("enums.4.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
delete object;
}
}
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
new file mode 100644
index 0000000..737ec81
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
@@ -0,0 +1,10 @@
+import Qt 4.6
+
+XmlListModel {
+ source: "model.xml"
+ query: "/Pets/Pet"
+ XmlRole { objectName: "role"; name: "name"; query: "name/string()" }
+ XmlRole { name: "type"; query: "type/string()" }
+ XmlRole { name: "age"; query: "age/number()" }
+ XmlRole { name: "size"; query: "size/string()" }
+}
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 68029bc..6199234 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -74,6 +74,7 @@ private slots:
void useKeys_data();
void noKeysValueChanges();
void keysChanged();
+ void propertyChanges();
private:
QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
@@ -440,6 +441,8 @@ void tst_qdeclarativexmllistmodel::noKeysValueChanges()
model->setXml(xml);
QTRY_COMPARE(model->count(), 2);
+ model->setXml("");
+
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
@@ -476,6 +479,8 @@ void tst_qdeclarativexmllistmodel::keysChanged()
model->setXml(xml);
QTRY_COMPARE(model->count(), 2);
+ model->setXml("");
+
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
@@ -496,6 +501,71 @@ void tst_qdeclarativexmllistmodel::keysChanged()
QCOMPARE(spyCount.count(), 0);
}
+void tst_qdeclarativexmllistmodel::propertyChanges()
+{
+ QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml"));
+ QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QDeclarativeXmlListModelRole *role = model->findChild<QDeclarativeXmlListModelRole*>("role");
+ QVERIFY(role);
+
+ QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
+ QSignalSpy querySpy(role, SIGNAL(queryChanged()));
+ QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
+
+ role->setName("size");
+ role->setQuery("size/string()");
+ role->setIsKey(true);
+
+ QCOMPARE(role->name(), QString("size"));
+ QCOMPARE(role->query(), QString("size/string()"));
+ QVERIFY(role->isKey());
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ role->setName("size");
+ role->setQuery("size/string()");
+ role->setIsKey(true);
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
+ QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
+ QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
+ QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
+
+ model->setSource(QUrl(""));
+ model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setQuery("/Pets");
+ model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(model->source(), QUrl(""));
+ QCOMPARE(model->xml(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
+ QCOMPARE(model->query(), QString("/Pets"));
+ QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+
+ model->setSource(QUrl(""));
+ model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setQuery("/Pets");
+ model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+}
+
QTEST_MAIN(tst_qdeclarativexmllistmodel)
#include "tst_qdeclarativexmllistmodel.moc"