From 8727985d81c793d52d5e24ed6815e7237ae879f1 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 24 Feb 2010 09:07:29 +1000 Subject: Remove QML_DEFINE_... macros, now use QML_REGISTER_... macros calls. Task-number: QT-2798 --- demos/declarative/minehunt/main.cpp | 3 +- doc/src/declarative/extending-examples.qdoc | 8 +- doc/src/declarative/extending.qdoc | 31 +- examples/declarative/extending/adding/main.cpp | 2 + examples/declarative/extending/adding/person.cpp | 1 - .../extending/attached/birthdayparty.cpp | 3 - examples/declarative/extending/attached/main.cpp | 7 + examples/declarative/extending/attached/person.cpp | 4 - .../extending/binding/birthdayparty.cpp | 2 - .../extending/binding/happybirthday.cpp | 1 - examples/declarative/extending/binding/main.cpp | 9 + examples/declarative/extending/binding/person.cpp | 4 - .../extending/coercion/birthdayparty.cpp | 1 - examples/declarative/extending/coercion/main.cpp | 7 + examples/declarative/extending/coercion/person.cpp | 6 - .../extending/default/birthdayparty.cpp | 1 - examples/declarative/extending/default/main.cpp | 5 + examples/declarative/extending/default/person.cpp | 3 - .../declarative/extending/extended/lineedit.cpp | 1 - examples/declarative/extending/extended/main.cpp | 3 + .../extending/grouped/birthdayparty.cpp | 1 - examples/declarative/extending/grouped/main.cpp | 6 + examples/declarative/extending/grouped/person.cpp | 4 - .../extending/properties/birthdayparty.cpp | 1 - examples/declarative/extending/properties/main.cpp | 3 + .../declarative/extending/properties/person.cpp | 1 - .../declarative/extending/signal/birthdayparty.cpp | 2 - examples/declarative/extending/signal/main.cpp | 7 + examples/declarative/extending/signal/person.cpp | 4 - .../extending/valuesource/birthdayparty.cpp | 2 - .../extending/valuesource/happybirthday.cpp | 1 - .../declarative/extending/valuesource/main.cpp | 9 + .../declarative/extending/valuesource/person.cpp | 4 - src/declarative/declarative.pro | 1 - .../graphicsitems/qmlgraphicsitemsmodule.cpp | 6 - src/declarative/qml/qml.h | 39 +-- src/declarative/qml/qmlbinding.cpp | 2 - src/declarative/qml/qmlcomponent.cpp | 1 - src/declarative/qml/qmlcustomparser.cpp | 8 +- src/declarative/qml/qmlcustomparser_p.h | 10 +- src/declarative/qml/qmlengine.cpp | 14 +- src/declarative/qml/qmlengine_p.h | 2 + src/declarative/qml/qmlworkerscript.cpp | 4 - src/declarative/util/qmlanimation.cpp | 24 +- src/declarative/util/qmlbehavior.cpp | 2 +- src/declarative/util/qmlbind.cpp | 2 +- src/declarative/util/qmlconnection.cpp | 2 +- src/declarative/util/qmldatetimeformatter.cpp | 2 +- src/declarative/util/qmleasefollow.cpp | 2 +- src/declarative/util/qmlfontloader.cpp | 2 +- src/declarative/util/qmlgraphicsutilmodule.cpp | 118 ++++++++ src/declarative/util/qmlgraphicsutilmodule_p.h | 63 ++++ src/declarative/util/qmllistmodel.cpp | 35 +-- src/declarative/util/qmllistmodel_p.h | 32 +++ src/declarative/util/qmlnumberformatter.cpp | 2 +- src/declarative/util/qmlpackage.cpp | 20 +- src/declarative/util/qmlpackage_p.h | 16 ++ src/declarative/util/qmlpropertychanges.cpp | 11 - src/declarative/util/qmlpropertychanges_p.h | 11 + src/declarative/util/qmlspringfollow.cpp | 2 +- src/declarative/util/qmlstate.cpp | 3 +- src/declarative/util/qmlstategroup.cpp | 2 +- src/declarative/util/qmlstateoperations.cpp | 6 +- src/declarative/util/qmlstyledtext_p.h | 1 + src/declarative/util/qmlsystempalette.cpp | 2 +- src/declarative/util/qmltimer.cpp | 2 +- src/declarative/util/qmltransition.cpp | 2 +- src/declarative/util/qmlxmllistmodel.cpp | 39 +-- src/declarative/util/qmlxmllistmodel_p.h | 33 +++ src/declarative/util/qnumberformat.cpp | 2 - src/declarative/util/util.pri | 2 + src/declarative/widgets/graphicslayouts.cpp | 319 --------------------- src/declarative/widgets/graphicslayouts_p.h | 168 ----------- src/declarative/widgets/graphicswidgets.cpp | 117 -------- src/declarative/widgets/graphicswidgets_p.h | 68 ----- src/declarative/widgets/widgets.pri | 9 - src/plugins/qmlmodules/qmlmodules.pro | 2 + src/plugins/qmlmodules/widgets/graphicslayouts.cpp | 260 +++++++++++++++++ src/plugins/qmlmodules/widgets/graphicslayouts_p.h | 226 +++++++++++++++ src/plugins/qmlmodules/widgets/graphicswidgets.cpp | 40 +++ src/plugins/qmlmodules/widgets/graphicswidgets_p.h | 68 +++++ src/plugins/qmlmodules/widgets/widgets.cpp | 144 ++++++++++ src/plugins/qmlmodules/widgets/widgets.pro | 15 + tests/auto/declarative/layouts/data/layouts.qml | 1 + tests/auto/declarative/qmlecmascript/testtypes.cpp | 15 +- tests/auto/declarative/qmlecmascript/testtypes.h | 2 + .../qmlecmascript/tst_qmlecmascript.cpp | 3 + .../declarative/qmlgraphicswebview/testtypes.cpp | 5 +- .../declarative/qmlgraphicswebview/testtypes.h | 2 + .../qmlgraphicswebview/tst_qmlgraphicswebview.cpp | 6 + tests/auto/declarative/qmllanguage/testtypes.cpp | 21 +- tests/auto/declarative/qmllanguage/testtypes.h | 2 + .../declarative/qmllanguage/tst_qmllanguage.cpp | 16 +- .../qmllistreference/tst_qmllistreference.cpp | 7 +- .../qmlmetaproperty/tst_qmlmetaproperty.cpp | 11 +- .../declarative/qmlmetatype/tst_qmlmetatype.cpp | 14 +- .../declarative/qmlmoduleplugin/plugin/plugin.cpp | 2 +- tests/auto/declarative/qmlstates/tst_qmlstates.cpp | 8 +- tests/auto/declarative/qmlvaluetypes/testtypes.cpp | 9 +- tests/auto/declarative/qmlvaluetypes/testtypes.h | 2 + .../qmlvaluetypes/tst_qmlvaluetypes.cpp | 7 + tests/benchmarks/declarative/binding/testtypes.cpp | 5 +- tests/benchmarks/declarative/binding/testtypes.h | 2 + .../benchmarks/declarative/binding/tst_binding.cpp | 9 +- .../declarative/qmlcomponent/testtypes.cpp | 5 +- .../declarative/qmlcomponent/testtypes.h | 2 + .../declarative/qmlcomponent/tst_qmlcomponent.cpp | 9 +- tests/benchmarks/declarative/qmltime/qmltime.cpp | 3 +- tests/benchmarks/declarative/script/tst_script.cpp | 8 +- tools/qmlviewer/main.cpp | 6 + tools/qmlviewer/qfxtester.cpp | 12 +- tools/qmlviewer/qfxtester.h | 2 + tools/qmlviewer/qmlfolderlistmodel.cpp | 8 +- tools/qmlviewer/qmlfolderlistmodel.h | 2 + tools/qmlviewer/qmlviewer.cpp | 7 +- tools/qmlviewer/qmlviewer.h | 2 + 116 files changed, 1330 insertions(+), 995 deletions(-) create mode 100644 src/declarative/util/qmlgraphicsutilmodule.cpp create mode 100644 src/declarative/util/qmlgraphicsutilmodule_p.h delete mode 100644 src/declarative/widgets/graphicslayouts.cpp delete mode 100644 src/declarative/widgets/graphicslayouts_p.h delete mode 100644 src/declarative/widgets/graphicswidgets.cpp delete mode 100644 src/declarative/widgets/graphicswidgets_p.h delete mode 100644 src/declarative/widgets/widgets.pri create mode 100644 src/plugins/qmlmodules/widgets/graphicslayouts.cpp create mode 100644 src/plugins/qmlmodules/widgets/graphicslayouts_p.h create mode 100644 src/plugins/qmlmodules/widgets/graphicswidgets.cpp create mode 100644 src/plugins/qmlmodules/widgets/graphicswidgets_p.h create mode 100644 src/plugins/qmlmodules/widgets/widgets.cpp create mode 100644 src/plugins/qmlmodules/widgets/widgets.pro diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index 0b862e3..9c225af 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -92,7 +92,6 @@ private: }; QML_DECLARE_TYPE(Tile); -QML_DEFINE_TYPE(0,0,0,Tile,Tile); class MyWidget : public QWidget { @@ -323,6 +322,8 @@ int main(int argc, char ** argv) int width = 370; int height = 480; + QML_REGISTER_TYPE(0,0,0,Tile,Tile); + for (int i = 1; i < argc; ++i) { QString arg = argv[i]; if (arg == "-frameless") { diff --git a/doc/src/declarative/extending-examples.qdoc b/doc/src/declarative/extending-examples.qdoc index b84ae0e..b912a1d 100644 --- a/doc/src/declarative/extending-examples.qdoc +++ b/doc/src/declarative/extending-examples.qdoc @@ -69,7 +69,7 @@ Q_DECLARE_METATYPE() functionality. The Person class implementation is quite basic. The property accessors simply return members of the object instance. -The implementation must also include the QML_DEFINE_TYPE() macro. This macro +The implementation must also be registered using the QML_REGISTER_TYPE() macro. This macro registers the Person class with QML as a type in the People library version 1.0, and defines the mapping between the C++ and QML class names. @@ -160,13 +160,13 @@ previous example. However, as we have repurposed the People class as a common base for Boy and Girl, we want to prevent it from being instantiated from QML directly - an explicit Boy or Girl should be instantiated instead. -\snippet examples/declarative/extending/coercion/person.cpp 0 +\snippet examples/declarative/extending/coercion/main.cpp 0 While we want to disallow instantiating Person from within QML, it still needs to be registered with the QML engine, so that it can be used as a property type and other types can be coerced to it. To register a type, without defining a -named mapping into QML, we use the QML_DEFINE_NOCREATE_TYPE() macro instead of -the QML_DEFINE_TYPE() macro used previously. +named mapping into QML, we call the QML_REGISTER_NOCREATE_TYPE() macro instead of +the QML_REGISTER_TYPE() macro used previously. \section2 Define Boy and Girl diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index d3e6c14..b40980d 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -72,7 +72,7 @@ Custom C++ types are made available to QML using these two macros: \quotation \code #define QML_DECLARE_TYPE(T) -#define QML_DEFINE_TYPE(URI,VMAJ,VMIN,QmlName,T) +#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,QmlName,T) \endcode Register the C++ type \a T with the QML system, and make it available in QML @@ -80,9 +80,8 @@ under the name \a QmlName in library URI version VMAJ.VMIN. \a T and \a QmlName may be the same. Generally the QML_DECLARE_TYPE() macro should be included immediately following -the type declaration (usually in its header file), and the QML_DEFINE_TYPE() -macro in the implementation file. QML_DEFINE_TYPE() must not be present in -a header file. +the type declaration (usually in its header file), and the QML_REGISTER_TYPE() +macro called by the implementation. Type \a T must be a concrete type that inherits QObject and has a default constructor. @@ -153,15 +152,14 @@ from registering a new QML type. The following macros are used instead: \quotation \code #define QML_DECLARE_INTERFACE(T) - #define QML_DEFINE_INTERFACE(T) + #define QML_REGISTER_INTERFACE(T) \endcode Register the C++ interface \a T with the QML system. Generally the QML_DECLARE_INTERFACE() macro should be included immediately following the interface declaration (usually in its header file), and the -QML_DEFINE_INTERFACE() macro in an implementation file. QML_DEFINE_INTERFACE() -must not be present in a header file. +QML_REGISTER_INTERFACE() macro called by the implementation. Following registration, QML can coerce objects that implement this interface for assignment to appropriately typed properties. @@ -194,7 +192,7 @@ type used in the previous section, but the assignment is valid as both the Boy and Girl objects inherit from Person. To assign to a property, the property's type must have been registered with QML. -Both the QML_DEFINE_TYPE() and QML_DEFINE_INTERFACE() macros already shown can +Both the QML_REGISTER_TYPE() and QML_REGISTER_INTERFACE() macros already shown can be used to register a type with QML. Additionally, if a type that acts purely as a base class that cannot be instantiated from QML needs to be registered these macros can be used: @@ -202,18 +200,17 @@ registered these macros can be used: \quotation \code #define QML_DECLARE_TYPE(T) - #define QML_DEFINE_NOCREATE_TYPE(T) + #define QML_REGISTER_NOCREATE_TYPE(T) \endcode -Register the C++ type \a T with the QML system. QML_DEFINE_NOCREATE_TYPE() -differs from QML_DEFINE_TYPE() in that it does not define a mapping between the +Register the C++ type \a T with the QML system. QML_REGISTER_NOCREATE_TYPE() +differs from QML_REGISTER_TYPE() in that it does not define a mapping between the C++ class and a QML element name, so the type is not instantiable from QML, but it is available for type coercion. Generally the QML_DECLARE_TYPE() macro should be included immediately following the type declaration (usually in its header file), and the -QML_DEFINE_NOCREATE_TYPE() macro in the implementation file. -QML_DEFINE_NOCREATE_TYPE() must not be present in a header file. +QML_REGISTER_NOCREATE_TYPE() macro called from the implementation. Type \a T must inherit QObject, but there are no restrictions on whether it is concrete or the signature of its constructor. @@ -597,11 +594,11 @@ the appropriate property on the extension object is used instead. When an extended type is installed, one of the \code - #define QML_DEFINE_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QmlName,T, ExtendedT) - #define QML_DEFINE_EXTENDED_NOCREATE_TYPE(T, ExtendedT) + #define QML_REGISTER_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QmlName,T, ExtendedT) + #define QML_REGISTER_EXTENDED_NOCREATE_TYPE(T, ExtendedT) \endcode -macros should be used instead of the regular \c QML_DEFINE_TYPE or -\c QML_DEFINE_NOCREATE_TYPE. The arguments are identical to the corresponding +macros should be used instead of the regular \c QML_REGISTER_TYPE or +\c QML_REGISTER_NOCREATE_TYPE. The arguments are identical to the corresponding non-extension object macro, except for the ExtendedT parameter which is the type of the extension object. diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp index 74ea35c..0aeeecf 100644 --- a/examples/declarative/extending/adding/main.cpp +++ b/examples/declarative/extending/adding/main.cpp @@ -48,6 +48,8 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_TYPE(People, 1,0, Person, Person); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); Person *person = qobject_cast(component.create()); diff --git a/examples/declarative/extending/adding/person.cpp b/examples/declarative/extending/adding/person.cpp index 9efa2b8..cdf08e0 100644 --- a/examples/declarative/extending/adding/person.cpp +++ b/examples/declarative/extending/adding/person.cpp @@ -66,5 +66,4 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -QML_DEFINE_TYPE(People, 1,0, Person, Person); // ![0] diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp index ffdda57..293628e 100644 --- a/examples/declarative/extending/attached/birthdayparty.cpp +++ b/examples/declarative/extending/attached/birthdayparty.cpp @@ -55,8 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d) m_rsvp = d; } -QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached); - BirthdayParty::BirthdayParty(QObject *parent) : QObject(parent), m_celebrant(0) { @@ -92,4 +90,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) return new BirthdayPartyAttached(object); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp index 27a9287..f4223a2 100644 --- a/examples/declarative/extending/attached/main.cpp +++ b/examples/declarative/extending/attached/main.cpp @@ -49,6 +49,13 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_NOCREATE_TYPE(ShoeDescription); + QML_REGISTER_NOCREATE_TYPE(Person); + QML_REGISTER_TYPE(People, 1,0, Boy, Boy); + QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/attached/person.cpp b/examples/declarative/extending/attached/person.cpp index 909505a..0a9e508 100644 --- a/examples/declarative/extending/attached/person.cpp +++ b/examples/declarative/extending/attached/person.cpp @@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p) { m_price = p; } -QML_DEFINE_NOCREATE_TYPE(ShoeDescription); Person::Person(QObject *parent) : QObject(parent) @@ -106,18 +105,15 @@ ShoeDescription *Person::shoe() return &m_shoe; } -QML_DEFINE_NOCREATE_TYPE(Person); Boy::Boy(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Boy, Boy); Girl::Girl(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Girl, Girl); diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp index 62b9c7b..392c59a 100644 --- a/examples/declarative/extending/binding/birthdayparty.cpp +++ b/examples/declarative/extending/binding/birthdayparty.cpp @@ -58,7 +58,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d) } } -QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached); BirthdayParty::BirthdayParty(QObject *parent) : QObject(parent), m_celebrant(0) @@ -113,4 +112,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) return new BirthdayPartyAttached(object); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/binding/happybirthday.cpp b/examples/declarative/extending/binding/happybirthday.cpp index 38f3c08..704d384 100644 --- a/examples/declarative/extending/binding/happybirthday.cpp +++ b/examples/declarative/extending/binding/happybirthday.cpp @@ -84,4 +84,3 @@ void HappyBirthday::advance() m_target.write(m_lyrics.at(m_line)); } -QML_DEFINE_TYPE(People, 1,0, HappyBirthday, HappyBirthday); diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp index ba38e82..ea0e33a 100644 --- a/examples/declarative/extending/binding/main.cpp +++ b/examples/declarative/extending/binding/main.cpp @@ -43,12 +43,21 @@ #include #include #include "birthdayparty.h" +#include "happybirthday.h" #include "person.h" int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday); + QML_REGISTER_NOCREATE_TYPE(ShoeDescription); + QML_REGISTER_NOCREATE_TYPE(Person); + QML_REGISTER_TYPE(People, 1,0, Boy, Boy); + QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/binding/person.cpp b/examples/declarative/extending/binding/person.cpp index 50fb754..9a2248f 100644 --- a/examples/declarative/extending/binding/person.cpp +++ b/examples/declarative/extending/binding/person.cpp @@ -100,7 +100,6 @@ void ShoeDescription::setPrice(qreal p) m_price = p; emit shoeChanged(); } -QML_DEFINE_NOCREATE_TYPE(ShoeDescription); Person::Person(QObject *parent) : QObject(parent) @@ -126,18 +125,15 @@ ShoeDescription *Person::shoe() return &m_shoe; } -QML_DEFINE_NOCREATE_TYPE(Person); Boy::Boy(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Boy, Boy); Girl::Girl(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Girl, Girl); diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp index 15a4ca9..f0eb599 100644 --- a/examples/declarative/extending/coercion/birthdayparty.cpp +++ b/examples/declarative/extending/coercion/birthdayparty.cpp @@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const return m_guests.at(index); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp index ccbee83..b1a203f 100644 --- a/examples/declarative/extending/coercion/main.cpp +++ b/examples/declarative/extending/coercion/main.cpp @@ -49,6 +49,13 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); +// ![0] + QML_REGISTER_NOCREATE_TYPE(Person); +// ![0] + QML_REGISTER_TYPE(People, 1,0, Boy, Boy); + QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/coercion/person.cpp b/examples/declarative/extending/coercion/person.cpp index 9eef8f7..5b5203a 100644 --- a/examples/declarative/extending/coercion/person.cpp +++ b/examples/declarative/extending/coercion/person.cpp @@ -65,22 +65,16 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -// ![0] -QML_DEFINE_NOCREATE_TYPE(Person); -// ![0] - // ![1] Boy::Boy(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Boy, Boy); Girl::Girl(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Girl, Girl); // ![1] diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp index 15a4ca9..f0eb599 100644 --- a/examples/declarative/extending/default/birthdayparty.cpp +++ b/examples/declarative/extending/default/birthdayparty.cpp @@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const return m_guests.at(index); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp index ccbee83..ea51e00 100644 --- a/examples/declarative/extending/default/main.cpp +++ b/examples/declarative/extending/default/main.cpp @@ -49,6 +49,11 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_NOCREATE_TYPE(Person); + QML_REGISTER_TYPE(People, 1,0, Boy, Boy); + QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/default/person.cpp b/examples/declarative/extending/default/person.cpp index a0b4960..69216d3 100644 --- a/examples/declarative/extending/default/person.cpp +++ b/examples/declarative/extending/default/person.cpp @@ -65,18 +65,15 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -QML_DEFINE_NOCREATE_TYPE(Person); Boy::Boy(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Boy, Boy); Girl::Girl(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Girl, Girl); diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp index ec86aad..0d8eb7f 100644 --- a/examples/declarative/extending/extended/lineedit.cpp +++ b/examples/declarative/extending/extended/lineedit.cpp @@ -103,4 +103,3 @@ void LineEditExtension::setBottomMargin(int m) } QML_DECLARE_TYPE(QLineEdit); -QML_DEFINE_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension); diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp index 9376af7..ad4bf50 100644 --- a/examples/declarative/extending/extended/main.cpp +++ b/examples/declarative/extending/extended/main.cpp @@ -43,11 +43,14 @@ #include #include #include +#include "lineedit.h" int main(int argc, char ** argv) { QApplication app(argc, argv); + QML_REGISTER_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); QLineEdit *edit = qobject_cast(component.create()); diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp index 15a4ca9..f0eb599 100644 --- a/examples/declarative/extending/grouped/birthdayparty.cpp +++ b/examples/declarative/extending/grouped/birthdayparty.cpp @@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const return m_guests.at(index); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp index 79aaab5..a8dafd9 100644 --- a/examples/declarative/extending/grouped/main.cpp +++ b/examples/declarative/extending/grouped/main.cpp @@ -49,6 +49,12 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_NOCREATE_TYPE(ShoeDescription); + QML_REGISTER_NOCREATE_TYPE(Person); + QML_REGISTER_TYPE(People, 1,0, Boy, Boy); + QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/grouped/person.cpp b/examples/declarative/extending/grouped/person.cpp index 909505a..0a9e508 100644 --- a/examples/declarative/extending/grouped/person.cpp +++ b/examples/declarative/extending/grouped/person.cpp @@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p) { m_price = p; } -QML_DEFINE_NOCREATE_TYPE(ShoeDescription); Person::Person(QObject *parent) : QObject(parent) @@ -106,18 +105,15 @@ ShoeDescription *Person::shoe() return &m_shoe; } -QML_DEFINE_NOCREATE_TYPE(Person); Boy::Boy(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Boy, Boy); Girl::Girl(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Girl, Girl); diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp index 23e6e58..2fbdad9 100644 --- a/examples/declarative/extending/properties/birthdayparty.cpp +++ b/examples/declarative/extending/properties/birthdayparty.cpp @@ -72,4 +72,3 @@ Person *BirthdayParty::guest(int index) const } // ![0] -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp index 97d7905..2211b89 100644 --- a/examples/declarative/extending/properties/main.cpp +++ b/examples/declarative/extending/properties/main.cpp @@ -49,6 +49,9 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_TYPE(People, 1,0, Person, Person); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/properties/person.cpp b/examples/declarative/extending/properties/person.cpp index d1b8bf4..92c54f5 100644 --- a/examples/declarative/extending/properties/person.cpp +++ b/examples/declarative/extending/properties/person.cpp @@ -65,4 +65,3 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -QML_DEFINE_TYPE(People, 1,0, Person, Person); diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp index d8686f0..d57e075 100644 --- a/examples/declarative/extending/signal/birthdayparty.cpp +++ b/examples/declarative/extending/signal/birthdayparty.cpp @@ -55,7 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d) m_rsvp = d; } -QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached); BirthdayParty::BirthdayParty(QObject *parent) : QObject(parent), m_celebrant(0) @@ -98,4 +97,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) return new BirthdayPartyAttached(object); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp index eb3bb4b..9d8e253 100644 --- a/examples/declarative/extending/signal/main.cpp +++ b/examples/declarative/extending/signal/main.cpp @@ -49,6 +49,13 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_NOCREATE_TYPE(ShoeDescription); + QML_REGISTER_NOCREATE_TYPE(Person); + QML_REGISTER_TYPE(People, 1,0, Boy, Boy); + QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/signal/person.cpp b/examples/declarative/extending/signal/person.cpp index 909505a..0a9e508 100644 --- a/examples/declarative/extending/signal/person.cpp +++ b/examples/declarative/extending/signal/person.cpp @@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p) { m_price = p; } -QML_DEFINE_NOCREATE_TYPE(ShoeDescription); Person::Person(QObject *parent) : QObject(parent) @@ -106,18 +105,15 @@ ShoeDescription *Person::shoe() return &m_shoe; } -QML_DEFINE_NOCREATE_TYPE(Person); Boy::Boy(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Boy, Boy); Girl::Girl(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Girl, Girl); diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp index a5b3fab..5b3fec1 100644 --- a/examples/declarative/extending/valuesource/birthdayparty.cpp +++ b/examples/declarative/extending/valuesource/birthdayparty.cpp @@ -55,7 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d) m_rsvp = d; } -QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached); BirthdayParty::BirthdayParty(QObject *parent) : QObject(parent), m_celebrant(0) @@ -108,4 +107,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) return new BirthdayPartyAttached(object); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/valuesource/happybirthday.cpp b/examples/declarative/extending/valuesource/happybirthday.cpp index fbbc9e9..306ec98 100644 --- a/examples/declarative/extending/valuesource/happybirthday.cpp +++ b/examples/declarative/extending/valuesource/happybirthday.cpp @@ -79,4 +79,3 @@ void HappyBirthday::advance() m_target.write(m_lyrics.at(m_line)); } -QML_DEFINE_TYPE(People, 1,0, HappyBirthday, HappyBirthday); diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp index ba38e82..ea0e33a 100644 --- a/examples/declarative/extending/valuesource/main.cpp +++ b/examples/declarative/extending/valuesource/main.cpp @@ -43,12 +43,21 @@ #include #include #include "birthdayparty.h" +#include "happybirthday.h" #include "person.h" int main(int argc, char ** argv) { QCoreApplication app(argc, argv); + QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday); + QML_REGISTER_NOCREATE_TYPE(ShoeDescription); + QML_REGISTER_NOCREATE_TYPE(Person); + QML_REGISTER_TYPE(People, 1,0, Boy, Boy); + QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + QmlEngine engine; QmlComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast(component.create()); diff --git a/examples/declarative/extending/valuesource/person.cpp b/examples/declarative/extending/valuesource/person.cpp index 909505a..0a9e508 100644 --- a/examples/declarative/extending/valuesource/person.cpp +++ b/examples/declarative/extending/valuesource/person.cpp @@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p) { m_price = p; } -QML_DEFINE_NOCREATE_TYPE(ShoeDescription); Person::Person(QObject *parent) : QObject(parent) @@ -106,18 +105,15 @@ ShoeDescription *Person::shoe() return &m_shoe; } -QML_DEFINE_NOCREATE_TYPE(Person); Boy::Boy(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Boy, Boy); Girl::Girl(QObject * parent) : Person(parent) { } -QML_DEFINE_TYPE(People, 1,0, Girl, Girl); diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index 86a0370..05eb566 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -24,7 +24,6 @@ include(3rdparty/3rdparty.pri) include(util/util.pri) include(graphicsitems/graphicsitems.pri) include(qml/qml.pri) -include(widgets/widgets.pri) include(debugger/debugger.pri) symbian:TARGET.UID3=0x2001E623 diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp index 9263f49..121026e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp @@ -80,12 +80,6 @@ #endif #include "qmlgraphicsanchors_p.h" -#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \ - qmlRegisterType(#URI, VMAJ, VMIN, #TYPE, #CLASS) - -#define QML_REGISTER_NOCREATE_TYPE(CLASS) \ - qmlRegisterType(#CLASS) - void QmlGraphicsItemModule::defineModule() { QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage); diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index 7972305..34873a2 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -88,40 +88,17 @@ QT_END_NAMESPACE QT_BEGIN_NAMESPACE -#if defined(Q_OS_SYMBIAN) -#define QML_DEFINE_INTERFACE(INTERFACE) \ - static int defineInterface##INTERFACE = qmlRegisterInterface(#INTERFACE); +#define QML_REGISTER_INTERFACE(INTERFACE) \ + qmlRegisterInterface(#INTERFACE) -#define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \ - static int registerExtended##TYPE = qmlRegisterExtendedType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE); +#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \ + qmlRegisterExtendedType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE) -#define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE) \ - static int defineType##TYPE = qmlRegisterType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE); +#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \ + qmlRegisterType(#URI, VMAJ, VMIN, #TYPE, #CLASS) -#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \ - static int registerExtendedNoCreate##TYPE = qmlRegisterExtendedType(#TYPE); - -#define QML_DEFINE_NOCREATE_TYPE(TYPE) \ - static int registerNoCreate##TYPE = qmlRegisterType(#TYPE); - -#else - -#define QML_DEFINE_INTERFACE(INTERFACE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterInterface(#INTERFACE)); - -#define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterExtendedType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)); - -#define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)); - -#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterExtendedType(#TYPE)); - -#define QML_DEFINE_NOCREATE_TYPE(TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterType(#TYPE)); - -#endif +#define QML_REGISTER_NOCREATE_TYPE(CLASS) \ + qmlRegisterType(#CLASS) class QmlContext; class QmlEngine; diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index feadd0f..4fea0f0 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_NOCREATE_TYPE(QmlBinding); - QmlBindingData::QmlBindingData() : updating(false), enabled(false) { diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 87ecb8a..470e96f 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -121,7 +121,6 @@ Item { } \endqml */ -QML_DEFINE_TYPE(Qt,4,6,Component,QmlComponent); /*! \enum QmlComponent::Status diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp index d781110..8e52b72 100644 --- a/src/declarative/qml/qmlcustomparser.cpp +++ b/src/declarative/qml/qmlcustomparser.cpp @@ -58,11 +58,11 @@ using namespace QmlParser; By subclassing QmlCustomParser, you can add a parser for building a particular type. - The subclass must implement compile() and setCustomData(), and define - itself in the meta type system with the macro: + The subclass must implement compile() and setCustomData(), and register + itself in the meta type system by calling the macro: \code - QML_DEFINE_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass) + QML_REGISTER_CUSTOM_TYPE(Module, MajorVersion, MinorVersion, Name, TypeClass, ParserClass) \endcode */ @@ -88,7 +88,7 @@ using namespace QmlParser; by \a data, which is a block of data previously returned by a call to compile(). - The \a object will be an instance of the TypeClass specified by QML_DEFINE_CUSTOM_TYPE. + The \a object will be an instance of the TypeClass specified by QML_REGISTER_CUSTOM_TYPE. */ QmlCustomParserNode diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 7aebb0d..e198712 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -128,13 +128,9 @@ private: QList exceptions; }; -#if defined(Q_OS_SYMBIAN) -# define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ - static int defineCustomType##NAME = qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE); -#else -# define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)); -#endif +#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ + qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE) + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 97d8250..9127954 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -99,6 +99,7 @@ #include #include +#include #ifdef Q_OS_WIN // for %APPDATA% #include @@ -113,7 +114,6 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE) -QML_DEFINE_TYPE(Qt,4,6,QtObject,QObject) /*! \qmlclass QtObject QObject \brief The QtObject element is the most basic element in QML @@ -142,6 +142,16 @@ struct StaticQtMetaObject : public QObject static bool qt_QmlQtModule_registered = false; +void QmlEnginePrivate::defineModule() +{ + QML_REGISTER_TYPE(Qt,4,6,Component,QmlComponent); + QML_REGISTER_TYPE(Qt,4,6,QtObject,QObject); + QML_REGISTER_TYPE(Qt,4,6,WorkerScript,QmlWorkerScript); + QML_REGISTER_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel); + + QML_REGISTER_NOCREATE_TYPE(QmlBinding); +} + QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) : captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), @@ -153,6 +163,8 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) if (!qt_QmlQtModule_registered) { qt_QmlQtModule_registered = true; QmlGraphicsItemModule::defineModule(); + QmlGraphicsUtilModule::defineModule(); + QmlEnginePrivate::defineModule(); } globalClass = new QmlGlobalScriptClass(&scriptEngine); fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml")); diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 3fe7991..2ea8ac7 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -321,6 +321,8 @@ public: static QmlEnginePrivate *get(QScriptEngine *e) { return static_cast(e)->p; } static QmlEngine *get(QmlEnginePrivate *p) { return p->q_func(); } QmlContext *getContext(QScriptContext *); + + static void defineModule(); }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp index a2e8c7a..ce534d0 100644 --- a/src/declarative/qml/qmlworkerscript.cpp +++ b/src/declarative/qml/qmlworkerscript.cpp @@ -633,8 +633,6 @@ bool QmlWorkerScript::event(QEvent *event) } } -QML_DEFINE_TYPE(Qt, 4, 6, WorkerScript, QmlWorkerScript); - void QmlWorkerListModelAgent::Data::clearChange() { changes.clear(); @@ -1038,8 +1036,6 @@ QVariant QmlWorkerListModel::data(int index, int role) const QT_END_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel) - #include "qmlworkerscript.moc" diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index c044f97..918bd51 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -139,8 +139,6 @@ static QEasingCurve stringToCurve(const QString &curve, QObject *obj) return easingCurve; } -QML_DEFINE_NOCREATE_TYPE(QmlAbstractAnimation) - /*! \qmlclass Animation QmlAbstractAnimation \brief The Animation element is the base of all QML animations. @@ -609,7 +607,7 @@ void QmlAbstractAnimation::timelineComplete() \class QmlPauseAnimation */ -QML_DEFINE_TYPE(Qt,4,6,PauseAnimation,QmlPauseAnimation) + QmlPauseAnimation::QmlPauseAnimation(QObject *parent) : QmlAbstractAnimation(*(new QmlPauseAnimationPrivate), parent) { @@ -721,7 +719,7 @@ void QmlColorAnimation::setTo(const QColor &t) QmlPropertyAnimation::setTo(t); } -QML_DEFINE_TYPE(Qt,4,6,ColorAnimation,QmlColorAnimation) + /*! \qmlclass ScriptAction QmlScriptAction @@ -827,7 +825,7 @@ QAbstractAnimation *QmlScriptAction::qtAnimation() return d->rsa; } -QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction) + /*! \qmlclass PropertyAction QmlPropertyAction @@ -1075,7 +1073,7 @@ void QmlPropertyAction::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction) + /*! \qmlclass ParentAction QmlParentAction @@ -1278,7 +1276,7 @@ void QmlParentAction::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction) + /*! \qmlclass NumberAnimation QmlNumberAnimation @@ -1341,7 +1339,7 @@ void QmlNumberAnimation::setTo(qreal t) QmlPropertyAnimation::setTo(t); } -QML_DEFINE_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation) + /*! \qmlclass Vector3dAnimation QmlVector3dAnimation @@ -1399,7 +1397,7 @@ void QmlVector3dAnimation::setTo(QVector3D t) QmlPropertyAnimation::setTo(t); } -QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation) + /*! \qmlclass RotationAnimation QmlRotationAnimation @@ -1570,7 +1568,7 @@ void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection emit directionChanged(); } -QML_DEFINE_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation) + QmlAnimationGroup::QmlAnimationGroup(QObject *parent) : QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent) @@ -1667,7 +1665,7 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,SequentialAnimation,QmlSequentialAnimation) + /*! \qmlclass ParallelAnimation QmlParallelAnimation @@ -1723,7 +1721,7 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,ParallelAnimation,QmlParallelAnimation) + //convert a variant from string type to another animatable type void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) @@ -2429,6 +2427,6 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, } } -QML_DEFINE_TYPE(Qt,4,6,PropertyAnimation,QmlPropertyAnimation) + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp index d65d8cd..6c67e00 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qmlbehavior.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Behavior,QmlBehavior) + class QmlBehaviorPrivate : public QObjectPrivate { diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index fc1562b..3924bff 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -68,7 +68,7 @@ public: QmlNullableValue value; }; -QML_DEFINE_TYPE(Qt,4,6,Binding,QmlBind) + /*! \qmlclass Binding QmlBind \brief The Binding element allows arbitrary property bindings to be created. diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp index 3d04aaf..90290b9 100644 --- a/src/declarative/util/qmlconnection.cpp +++ b/src/declarative/util/qmlconnection.cpp @@ -282,6 +282,6 @@ void QmlConnection::setSignal(const QString& sig) connectIfValid(); } -QML_DEFINE_TYPE(Qt,4,6,Connection,QmlConnection) + QT_END_NAMESPACE diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp index c44ca5e..112da1e 100644 --- a/src/declarative/util/qmldatetimeformatter.cpp +++ b/src/declarative/util/qmldatetimeformatter.cpp @@ -367,6 +367,6 @@ void QmlDateTimeFormatter::componentComplete() d->updateText(); } -QML_DEFINE_TYPE(Qt,4,6,DateTimeFormatter,QmlDateTimeFormatter) + QT_END_NAMESPACE diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp index deb474a..6694678 100644 --- a/src/declarative/util/qmleasefollow.cpp +++ b/src/declarative/util/qmleasefollow.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,EaseFollow,QmlEaseFollow); + class QmlEaseFollowPrivate : public QObjectPrivate { diff --git a/src/declarative/util/qmlfontloader.cpp b/src/declarative/util/qmlfontloader.cpp index 4599b99..558c125 100644 --- a/src/declarative/util/qmlfontloader.cpp +++ b/src/declarative/util/qmlfontloader.cpp @@ -70,7 +70,7 @@ public: QmlFontLoader::Status status; }; -QML_DEFINE_TYPE(Qt,4,6,FontLoader,QmlFontLoader) + /*! \qmlclass FontLoader QmlFontLoader diff --git a/src/declarative/util/qmlgraphicsutilmodule.cpp b/src/declarative/util/qmlgraphicsutilmodule.cpp new file mode 100644 index 0000000..13323be --- /dev/null +++ b/src/declarative/util/qmlgraphicsutilmodule.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 "qmlgraphicsutilmodule_p.h" +#include "qfxperf_p_p.h" +#include "qmlanimation_p.h" +#include "qmlanimation_p_p.h" +#include "qmlbehavior_p.h" +#include "qmlbind_p.h" +#include "qmlconnection_p.h" +#include "qmldatetimeformatter_p.h" +#include "qmleasefollow_p.h" +#include "qmlfontloader_p.h" +#include "qmllistaccessor_p.h" +#include "qmllistmodel_p.h" +#include "qmlnullablevalue_p_p.h" +#include "qmlnumberformatter_p.h" +#include "qmlopenmetaobject_p.h" +#include "qmlpackage_p.h" +#include "qmlpixmapcache_p.h" +#include "qmlpropertychanges_p.h" +#include "qmlpropertymap.h" +#include "qmlspringfollow_p.h" +#include "qmlstategroup_p.h" +#include "qmlstateoperations_p.h" +#include "qmlstate_p.h" +#include "qmlstate_p_p.h" +#include "qmlstyledtext_p.h" +#include "qmlsystempalette_p.h" +#include "qmltimeline_p_p.h" +#include "qmltimer_p.h" +#include "qmltransitionmanager_p_p.h" +#include "qmltransition_p.h" +#include "qmlview.h" +#include "qmlxmllistmodel_p.h" +#include "qnumberformat_p.h" +#include "qperformancelog_p_p.h" + +void QmlGraphicsUtilModule::defineModule() +{ + QML_REGISTER_TYPE(Qt,4,6,AnchorChanges,QmlAnchorChanges); + QML_REGISTER_TYPE(Qt,4,6,Behavior,QmlBehavior); + QML_REGISTER_TYPE(Qt,4,6,Binding,QmlBind); + QML_REGISTER_TYPE(Qt,4,6,ColorAnimation,QmlColorAnimation); + QML_REGISTER_TYPE(Qt,4,6,Connection,QmlConnection); + QML_REGISTER_TYPE(Qt,4,6,DateTimeFormatter,QmlDateTimeFormatter); + QML_REGISTER_TYPE(Qt,4,6,EaseFollow,QmlEaseFollow);; + QML_REGISTER_TYPE(Qt,4,6,FontLoader,QmlFontLoader); + QML_REGISTER_TYPE(Qt,4,6,ListElement,QmlListElement); + QML_REGISTER_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation); + QML_REGISTER_TYPE(Qt,4,6,NumberFormatter,QmlNumberFormatter);; + QML_REGISTER_TYPE(Qt,4,6,Package,QmlPackage); + QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QmlParallelAnimation); + QML_REGISTER_TYPE(Qt,4,6,ParentAction,QmlParentAction); + QML_REGISTER_TYPE(Qt,4,6,ParentChange,QmlParentChange); + QML_REGISTER_TYPE(Qt,4,6,PauseAnimation,QmlPauseAnimation); + QML_REGISTER_TYPE(Qt,4,6,PropertyAction,QmlPropertyAction); + QML_REGISTER_TYPE(Qt,4,6,PropertyAnimation,QmlPropertyAnimation); + QML_REGISTER_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation); + QML_REGISTER_TYPE(Qt,4,6,ScriptAction,QmlScriptAction); + QML_REGISTER_TYPE(Qt,4,6,SequentialAnimation,QmlSequentialAnimation); + QML_REGISTER_TYPE(Qt,4,6,SpringFollow,QmlSpringFollow); + QML_REGISTER_TYPE(Qt,4,6,StateChangeScript,QmlStateChangeScript); + QML_REGISTER_TYPE(Qt,4,6,StateGroup,QmlStateGroup); + QML_REGISTER_TYPE(Qt,4,6,State,QmlState); + QML_REGISTER_TYPE(Qt,4,6,SystemPalette,QmlSystemPalette); + QML_REGISTER_TYPE(Qt,4,6,Timer,QmlTimer); + QML_REGISTER_TYPE(Qt,4,6,Transition,QmlTransition); + QML_REGISTER_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation); + QML_REGISTER_TYPE(Qt,4,6,XmlListModel,QmlXmlListModel); + QML_REGISTER_TYPE(Qt,4,6,XmlRole,QmlXmlListModelRole); + + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsAnchors); + QML_REGISTER_NOCREATE_TYPE(QmlAbstractAnimation); + QML_REGISTER_NOCREATE_TYPE(QmlStateOperation); + QML_REGISTER_NOCREATE_TYPE(QNumberFormat); + + QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QmlListModel, QmlListModelParser); + QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QmlPropertyChanges, QmlPropertyChangesParser); +} diff --git a/src/declarative/util/qmlgraphicsutilmodule_p.h b/src/declarative/util/qmlgraphicsutilmodule_p.h new file mode 100644 index 0000000..68a16a9 --- /dev/null +++ b/src/declarative/util/qmlgraphicsutilmodule_p.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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 QMLGRAPHICSUTILMODULE_H +#define QMLGRAPHICSUTILMODULE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlGraphicsUtilModule +{ +public: + static void defineModule(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMLGRAPHICSUTILMODULE_H diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 8fda3ae..c5e797e 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -61,18 +61,10 @@ QT_BEGIN_NAMESPACE #define DATA_ROLE_ID 1 #define DATA_ROLE_NAME "data" -struct ListInstruction +QmlListModelParser::ListInstruction *QmlListModelParser::ListModelData::instructions() const { - enum { Push, Pop, Value, Set } type; - int dataIdx; -}; - -struct ListModelData -{ - int dataOffset; - int instrCount; - ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); } -}; + return (QmlListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData)); +} static void dump(ModelNode *node, int ind); @@ -737,17 +729,6 @@ void QmlListModel::setProperty(int index, const QString& property, const QVarian emit itemsChanged(index,1,roles); } -class QmlListModelParser : public QmlCustomParser -{ -public: - QByteArray compile(const QList &); - bool compileProperty(const QmlCustomParserProperty &prop, QList &instr, QByteArray &data); - void setCustomData(QObject *, const QByteArray &); - -private: - bool definesEmptyList(const QString &); -}; - bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList &instr, QByteArray &data) { QList values = prop.assignedValues(); @@ -953,20 +934,12 @@ bool QmlListModelParser::definesEmptyList(const QString &s) return false; } -QML_DEFINE_CUSTOM_TYPE(Qt, 4,6, ListModel, QmlListModel, QmlListModelParser) - /*! \qmlclass ListElement \brief The ListElement element defines a data item in a ListModel. \sa ListModel */ -// ### FIXME -class QmlListElement : public QObject -{ -Q_OBJECT -}; -QML_DEFINE_TYPE(Qt,4,6,ListElement,QmlListElement) static void dump(ModelNode *node, int ind) { @@ -1007,6 +980,4 @@ ModelNode::~ModelNode() QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlListElement) - #include diff --git a/src/declarative/util/qmllistmodel_p.h b/src/declarative/util/qmllistmodel_p.h index 4cf6746..e6ddb0e 100644 --- a/src/declarative/util/qmllistmodel_p.h +++ b/src/declarative/util/qmllistmodel_p.h @@ -43,6 +43,7 @@ #define QMLLISTMODEL_H #include +#include #include #include @@ -98,9 +99,40 @@ private: ModelNode *_root; }; +// ### FIXME +class QmlListElement : public QObject +{ +Q_OBJECT +}; + +class QmlListModelParser : public QmlCustomParser +{ +public: + QByteArray compile(const QList &); + void setCustomData(QObject *, const QByteArray &); + +private: + struct ListInstruction + { + enum { Push, Pop, Value, Set } type; + int dataIdx; + }; + struct ListModelData + { + int dataOffset; + int instrCount; + ListInstruction *instructions() const; + }; + bool compileProperty(const QmlCustomParserProperty &prop, QList &instr, QByteArray &data); + + bool definesEmptyList(const QString &); +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlListModel) +QML_DECLARE_TYPE(QmlListElement) QT_END_HEADER diff --git a/src/declarative/util/qmlnumberformatter.cpp b/src/declarative/util/qmlnumberformatter.cpp index f78abdf..b301191 100644 --- a/src/declarative/util/qmlnumberformatter.cpp +++ b/src/declarative/util/qmlnumberformatter.cpp @@ -255,6 +255,6 @@ void QmlNumberFormatter::componentComplete() d->componentComplete = true; d->updateText(); } -QML_DEFINE_TYPE(Qt,4,6,NumberFormatter,QmlNumberFormatter); + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp index 82f776f..c9b9cbb 100644 --- a/src/declarative/util/qmlpackage.cpp +++ b/src/declarative/util/qmlpackage.cpp @@ -80,22 +80,6 @@ public: } }; -class QmlPackageAttached : public QObject -{ -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -public: - QmlPackageAttached(QObject *parent); - virtual ~QmlPackageAttached(); - - QString name() const; - void setName(const QString &n); - - static QHash attached; -private: - QString _name; -}; - QHash QmlPackageAttached::attached; QmlPackageAttached::QmlPackageAttached(QObject *parent) @@ -178,8 +162,6 @@ QmlPackageAttached *QmlPackage::qmlAttachedProperties(QObject *o) return new QmlPackageAttached(o); } -QML_DEFINE_TYPE(Qt,4,6,Package,QmlPackage) -QT_END_NAMESPACE -#include +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlpackage_p.h b/src/declarative/util/qmlpackage_p.h index 29b6bbe..63d878a 100644 --- a/src/declarative/util/qmlpackage_p.h +++ b/src/declarative/util/qmlpackage_p.h @@ -78,6 +78,22 @@ public: static QmlPackageAttached *qmlAttachedProperties(QObject *); }; +class QmlPackageAttached : public QObject +{ +Q_OBJECT +Q_PROPERTY(QString name READ name WRITE setName) +public: + QmlPackageAttached(QObject *parent); + virtual ~QmlPackageAttached(); + + QString name() const; + void setName(const QString &n); + + static QHash attached; +private: + QString _name; +}; + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlPackage) diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index 068cb4d..76c2441 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -184,15 +184,6 @@ public: QmlMetaProperty property(const QByteArray &); }; -class QmlPropertyChangesParser : public QmlCustomParser -{ -public: - void compileList(QList > &list, const QByteArray &pre, const QmlCustomParserProperty &prop); - - virtual QByteArray compile(const QList &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - void QmlPropertyChangesParser::compileList(QList > &list, const QByteArray &pre, @@ -463,6 +454,4 @@ void QmlPropertyChanges::setIsExplicit(bool e) d->isExplicit = e; } -QML_DEFINE_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QmlPropertyChanges, QmlPropertyChangesParser) - QT_END_NAMESPACE diff --git a/src/declarative/util/qmlpropertychanges_p.h b/src/declarative/util/qmlpropertychanges_p.h index 19dcf9d..62e977a 100644 --- a/src/declarative/util/qmlpropertychanges_p.h +++ b/src/declarative/util/qmlpropertychanges_p.h @@ -43,6 +43,7 @@ #define QMLPROPERTYCHANGES_H #include "qmlstateoperations_p.h" +#include QT_BEGIN_HEADER @@ -75,6 +76,16 @@ public: virtual ActionList actions(); }; +class QmlPropertyChangesParser : public QmlCustomParser +{ +public: + void compileList(QList > &list, const QByteArray &pre, const QmlCustomParserProperty &prop); + + virtual QByteArray compile(const QList &); + virtual void setCustomData(QObject *, const QByteArray &); +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlPropertyChanges) diff --git a/src/declarative/util/qmlspringfollow.cpp b/src/declarative/util/qmlspringfollow.cpp index 6d4ecf2..1eafd9e 100644 --- a/src/declarative/util/qmlspringfollow.cpp +++ b/src/declarative/util/qmlspringfollow.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,SpringFollow,QmlSpringFollow) + class QmlSpringFollowPrivate : public QObjectPrivate { diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index 4462b1f..52cd360 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -154,7 +154,7 @@ QmlStateOperation::QmlStateOperation(QObjectPrivate &dd, QObject *parent) \sa {states-transitions}{States and Transitions} */ -QML_DEFINE_TYPE(Qt,4,6,State,QmlState) + QmlState::QmlState(QObject *parent) : QObject(*(new QmlStatePrivate), parent) { @@ -473,7 +473,6 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever d->transitionManager.transition(applyList, trans); } -QML_DEFINE_NOCREATE_TYPE(QmlStateOperation) QmlStateOperation::ActionList QmlStateOperation::actions() { return ActionList(); diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 4ad77c8..3694255 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -437,4 +437,4 @@ void QmlStateGroup::removeState(QmlState *state) QT_END_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup) + diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index bd1f5f0..9170d65 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -162,7 +162,7 @@ void QmlParentChangePrivate::doChange(QmlGraphicsItem *targetParent, QmlGraphics using a ParentAction. */ -QML_DEFINE_TYPE(Qt,4,6,ParentChange,QmlParentChange) + QmlParentChange::QmlParentChange(QObject *parent) : QmlStateOperation(*(new QmlParentChangePrivate), parent) { @@ -322,7 +322,7 @@ public: Alternatively you can use a ScriptAction to specify at which point in the transition you want the StateChangeScript to be run. */ -QML_DEFINE_TYPE(Qt,4,6,StateChangeScript,QmlStateChangeScript) + QmlStateChangeScript::QmlStateChangeScript(QObject *parent) : QmlStateOperation(*(new QmlStateChangeScriptPrivate), parent) { @@ -409,7 +409,7 @@ QString QmlStateChangeScript::typeName() const For more information on anchors see \l {anchor-layout}{Anchor Layouts}. */ -QML_DEFINE_TYPE(Qt,4,6,AnchorChanges,QmlAnchorChanges) + class QmlAnchorChangesPrivate : public QObjectPrivate { diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qmlstyledtext_p.h index 4698279..2c29832 100644 --- a/src/declarative/util/qmlstyledtext_p.h +++ b/src/declarative/util/qmlstyledtext_p.h @@ -50,6 +50,7 @@ class QPainter; class QPointF; class QString; class QmlStyledTextPrivate; +class QTextLayout; class Q_DECLARATIVE_EXPORT QmlStyledText { diff --git a/src/declarative/util/qmlsystempalette.cpp b/src/declarative/util/qmlsystempalette.cpp index cc4fb3e..9bc62bd 100644 --- a/src/declarative/util/qmlsystempalette.cpp +++ b/src/declarative/util/qmlsystempalette.cpp @@ -54,7 +54,7 @@ public: QPalette::ColorGroup group; }; -QML_DEFINE_TYPE(Qt,4,6,SystemPalette,QmlSystemPalette) + /*! \qmlclass SystemPalette QmlSystemPalette diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index d3a1a7c..5f926fe 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Timer,QmlTimer) + class QmlTimerPrivate : public QObjectPrivate { diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index e90fc20..1a9ad05 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -124,7 +124,7 @@ void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, Q } -QML_DEFINE_TYPE(Qt,4,6,Transition,QmlTransition) + QmlTransition::QmlTransition(QObject *parent) : QObject(*(new QmlTransitionPrivate), parent) { diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp index e631cd9..4c153e2 100644 --- a/src/declarative/util/qmlxmllistmodel.cpp +++ b/src/declarative/util/qmlxmllistmodel.cpp @@ -60,8 +60,8 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,XmlRole,QmlXmlListModelRole) -QML_DEFINE_TYPE(Qt,4,6,XmlListModel,QmlXmlListModel) + + /*! \qmlclass XmlRole QmlXmlListModelRole @@ -94,41 +94,6 @@ QML_DEFINE_TYPE(Qt,4,6,XmlListModel,QmlXmlListModel) \endqml */ -class Q_DECLARATIVE_EXPORT QmlXmlListModelRole : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QString query READ query WRITE setQuery) - -public: - QmlXmlListModelRole() {} - ~QmlXmlListModelRole() {} - - QString name() const { return m_name; } - void setName(const QString &name) { m_name = name; } - - QString query() const { return m_query; } - void setQuery(const QString &query) - { - if (query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << tr("An XmlRole query must not start with '/'"); - return; - } - m_query = query; - } - - bool isValid() { - return !m_name.isEmpty() && !m_query.isEmpty(); - } - -private: - QString m_name; - QString m_query; -}; -QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlXmlListModelRole) -QT_BEGIN_NAMESPACE - class QmlXmlQuery : public QThread { diff --git a/src/declarative/util/qmlxmllistmodel_p.h b/src/declarative/util/qmlxmllistmodel_p.h index a6627e2..969afd1 100644 --- a/src/declarative/util/qmlxmllistmodel_p.h +++ b/src/declarative/util/qmlxmllistmodel_p.h @@ -127,9 +127,42 @@ private: Q_DISABLE_COPY(QmlXmlListModel) }; +class Q_DECLARATIVE_EXPORT QmlXmlListModelRole : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QString query READ query WRITE setQuery) + +public: + QmlXmlListModelRole() {} + ~QmlXmlListModelRole() {} + + QString name() const { return m_name; } + void setName(const QString &name) { m_name = name; } + + QString query() const { return m_query; } + void setQuery(const QString &query) + { + if (query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << tr("An XmlRole query must not start with '/'"); + return; + } + m_query = query; + } + + bool isValid() { + return !m_name.isEmpty() && !m_query.isEmpty(); + } + +private: + QString m_name; + QString m_query; +}; + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlXmlListModel) +QML_DECLARE_TYPE(QmlXmlListModelRole) QT_END_HEADER diff --git a/src/declarative/util/qnumberformat.cpp b/src/declarative/util/qnumberformat.cpp index 42c12fe..2e83874 100644 --- a/src/declarative/util/qnumberformat.cpp +++ b/src/declarative/util/qnumberformat.cpp @@ -43,8 +43,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_NOCREATE_TYPE(QNumberFormat) - QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal), _groupingSize(0) { diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index b6a5c90..90a8a27 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -1,6 +1,7 @@ INCLUDEPATH += $$PWD SOURCES += \ + $$PWD/qmlgraphicsutilmodule.cpp\ $$PWD/qmlview.cpp \ $$PWD/qfxperf.cpp \ $$PWD/qperformancelog.cpp \ @@ -32,6 +33,7 @@ SOURCES += \ $$PWD/qmlstyledtext.cpp HEADERS += \ + $$PWD/qmlgraphicsutilmodule_p.h\ $$PWD/qmlview.h \ $$PWD/qfxperf_p_p.h \ $$PWD/qperformancelog_p_p.h \ diff --git a/src/declarative/widgets/graphicslayouts.cpp b/src/declarative/widgets/graphicslayouts.cpp deleted file mode 100644 index 62e941a..0000000 --- a/src/declarative/widgets/graphicslayouts.cpp +++ /dev/null @@ -1,319 +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 "graphicslayouts_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QML_DEFINE_INTERFACE(QGraphicsLayoutItem) -QML_DEFINE_INTERFACE(QGraphicsLayout) - -QML_DEFINE_TYPE(Qt,4,6,QGraphicsLinearLayoutStretchItem,QGraphicsLinearLayoutStretchItemObject) -QML_DEFINE_TYPE(Qt,4,6,QGraphicsLinearLayout,QGraphicsLinearLayoutObject) -QML_DEFINE_TYPE(Qt,4,6,QGraphicsGridLayout,QGraphicsGridLayoutObject) - -class LinearLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) -public: - LinearLayoutAttached(QObject *parent) - : QObject(parent), _stretch(1), _alignment(Qt::AlignCenter) - { - } - - int stretchFactor() const { return _stretch; } - void setStretchFactor(int f) - { - if (_stretch == f) - return; - - _stretch = f; - emit stretchChanged(reinterpret_cast(parent()), _stretch); - } - - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a) - { - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast(parent()), _alignment); - } - -Q_SIGNALS: - void stretchChanged(QGraphicsLayoutItem*,int); - void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - -private: - int _stretch; - Qt::Alignment _alignment; -}; - - -QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) - : QObject(parent) -{ -} - -QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - Q_UNUSED(which); - Q_UNUSED(constraint); - return QSizeF(); -} - - -QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject() -{ -} - -void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) -{ - insertItem(index, item); - - //connect attached properties - if (LinearLayoutAttached *obj = attachedProperties.value(item)) { - setStretchFactor(item, obj->stretchFactor()); - setAlignment(item, obj->alignment()); - QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - //### need to disconnect when widget is removed? - } -} - -//### is there a better way to do this? -void QGraphicsLinearLayoutObject::clearChildren() -{ - for (int i = 0; i < count(); ++i) - removeAt(i); -} - -void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) -{ - QGraphicsLinearLayout::setStretchFactor(item, stretch); -} - -void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ - QGraphicsLinearLayout::setAlignment(item, alignment); -} - -QHash QGraphicsLinearLayoutObject::attachedProperties; -LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) -{ - // ### This is not allowed - you must attach to any object - if (!qobject_cast(obj)) - return 0; - LinearLayoutAttached *rv = new LinearLayoutAttached(obj); - attachedProperties.insert(qobject_cast(obj), rv); - return rv; -} - -////////////////////////////////////////////////////////////////////////////////////////////////////// -// QGraphicsGridLayout-related classes -////////////////////////////////////////////////////////////////////////////////////////////////////// -class GridLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int row READ row WRITE setRow) - Q_PROPERTY(int column READ column WRITE setColumn) - Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) - Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) -public: - GridLayoutAttached(QObject *parent) - : QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1) - { - } - - int row() const { return _row; } - void setRow(int r) - { - if (_row == r) - return; - - _row = r; - //emit rowChanged(reinterpret_cast(parent()), _row); - } - - int column() const { return _column; } - void setColumn(int c) - { - if (_column == c) - return; - - _column = c; - //emit columnChanged(reinterpret_cast(parent()), _column); - } - - int rowSpan() const { return _rowspan; } - void setRowSpan(int rs) - { - if (_rowspan == rs) - return; - - _rowspan = rs; - //emit rowSpanChanged(reinterpret_cast(parent()), _rowSpan); - } - - int columnSpan() const { return _colspan; } - void setColumnSpan(int cs) - { - if (_colspan == cs) - return; - - _colspan = cs; - //emit columnSpanChanged(reinterpret_cast(parent()), _columnSpan); - } - - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a) - { - if (_alignment == a) - return; - - _alignment = a; - //emit alignmentChanged(reinterpret_cast(parent()), _alignment); - } - -Q_SIGNALS: - //void rowChanged(QGraphicsLayoutItem*,int); - //void columnSpanChanged(QGraphicsLayoutItem*,int); - //void rowSpanChanged(QGraphicsLayoutItem*,int); - //void columnChanged(QGraphicsLayoutItem*,int); - //void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); - -private: - int _row; - int _column; - int _rowspan; - int _colspan; - Qt::Alignment _alignment; -}; - - -QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject() -{ -} - -void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) -{ - //use attached properties - if (QObject *obj = attachedProperties.value(qobject_cast(wid))) { - int row = static_cast(obj)->row(); - int column = static_cast(obj)->column(); - int rowSpan = static_cast(obj)->rowSpan(); - int columnSpan = static_cast(obj)->columnSpan(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - addItem(wid, row, column, rowSpan, columnSpan); - } -} - -void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) -{ - //use attached properties - if (GridLayoutAttached *obj = attachedProperties.value(item)) { - int row = obj->row(); - int column = obj->column(); - int rowSpan = obj->rowSpan(); - int columnSpan = obj->columnSpan(); - Qt::Alignment alignment = obj->alignment(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - addItem(item, row, column, rowSpan, columnSpan); - if (alignment != -1) - setAlignment(item,alignment); - } -} - -//### is there a better way to do this? -void QGraphicsGridLayoutObject::clearChildren() -{ - for (int i = 0; i < count(); ++i) - removeAt(i); -} - -qreal QGraphicsGridLayoutObject::spacing() const -{ - if (verticalSpacing() == horizontalSpacing()) - return verticalSpacing(); - return -1; //### -} - -QHash QGraphicsGridLayoutObject::attachedProperties; -GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) -{ - // ### This is not allowed - you must attach to any object - if (!qobject_cast(obj)) - return 0; - GridLayoutAttached *rv = new GridLayoutAttached(obj); - attachedProperties.insert(qobject_cast(obj), rv); - return rv; -} - -QT_END_NAMESPACE - -#include diff --git a/src/declarative/widgets/graphicslayouts_p.h b/src/declarative/widgets/graphicslayouts_p.h deleted file mode 100644 index 3076af1..0000000 --- a/src/declarative/widgets/graphicslayouts_p.h +++ /dev/null @@ -1,168 +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 GRAPHICSLAYOUTS_H -#define GRAPHICSLAYOUTS_H - -#include "graphicswidgets_p.h" - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayoutItem) -public: - QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0); - - virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; -}; - -class LinearLayoutAttached; -class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QmlListProperty children READ children) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsLinearLayoutObject(QObject * = 0); - ~QGraphicsLinearLayoutObject(); - - QmlListProperty children() { return QmlListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - static LinearLayoutAttached *qmlAttachedProperties(QObject *); - -private Q_SLOTS: - void updateStretch(QGraphicsLayoutItem*,int); - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class LinearLayoutAttached; - void clearChildren(); - void insertLayoutItem(int, QGraphicsLayoutItem *); - static QHash attachedProperties; - - static void children_append(QmlListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->insertLayoutItem(-1, item); - } - - static void children_clear(QmlListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QmlListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QmlListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } -}; - -class GridLayoutAttached; -class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QmlListProperty children READ children) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) - Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsGridLayoutObject(QObject * = 0); - ~QGraphicsGridLayoutObject(); - - QmlListProperty children() { return QmlListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - qreal spacing() const; - - static GridLayoutAttached *qmlAttachedProperties(QObject *); - -private: - friend class GraphicsLayoutAttached; - void addWidget(QGraphicsWidget *); - void clearChildren(); - void addLayoutItem(QGraphicsLayoutItem *); - static QHash attachedProperties; - - static void children_append(QmlListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->addLayoutItem(item); - } - - static void children_clear(QmlListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QmlListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QmlListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } -}; - -QT_END_NAMESPACE - -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) -QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) -QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QGraphicsGridLayoutObject) -QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // GRAPHICSLAYOUTS_H diff --git a/src/declarative/widgets/graphicswidgets.cpp b/src/declarative/widgets/graphicswidgets.cpp deleted file mode 100644 index bb4dc74..0000000 --- a/src/declarative/widgets/graphicswidgets.cpp +++ /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$ -** -****************************************************************************/ - -#include "graphicswidgets_p.h" - -QT_BEGIN_NAMESPACE - -class QGraphicsViewDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QGraphicsScene *scene READ scene WRITE setScene) - Q_CLASSINFO("DefaultProperty", "scene") -public: - QGraphicsViewDeclarativeUI(QObject *other) : QObject(other) {} - - QGraphicsScene *scene() const { return static_cast(parent())->scene(); } - void setScene(QGraphicsScene *scene) - { - static_cast(parent())->setScene(scene); - } -}; - -class QGraphicsSceneDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QmlListProperty children READ children) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other) {} - - QmlListProperty children() { return QmlListProperty(this->parent(), 0, children_append); } - -private: - static void children_append(QmlListProperty *prop, QObject *o) { - if (QGraphicsObject *go = qobject_cast(o)) - static_cast(prop->object)->addItem(go); - } -}; - -class QGraphicsWidgetDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QmlListProperty children READ children) - Q_PROPERTY(QGraphicsLayout *layout READ layout WRITE setLayout) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other) {} - - QmlListProperty children() { return QmlListProperty(this, 0, children_append); } - - QGraphicsLayout *layout() const { return static_cast(parent())->layout(); } - void setLayout(QGraphicsLayout *lo) - { - static_cast(parent())->setLayout(lo); - } - -private: - void setItemParent(QGraphicsItem *wid) - { - wid->setParentItem(static_cast(parent())); - } - - static void children_append(QmlListProperty *prop, QGraphicsItem *i) { - static_cast(prop->object)->setItemParent(i); - } -}; - -QML_DEFINE_EXTENDED_TYPE(Qt,4,6,QGraphicsView,QGraphicsView,QGraphicsViewDeclarativeUI) -QML_DEFINE_EXTENDED_TYPE(Qt,4,6,QGraphicsScene,QGraphicsScene,QGraphicsSceneDeclarativeUI) -QML_DEFINE_EXTENDED_TYPE(Qt,4,6,QGraphicsWidget,QGraphicsWidget,QGraphicsWidgetDeclarativeUI) - -QML_DEFINE_INTERFACE(QGraphicsItem) - -QT_END_NAMESPACE - -#include diff --git a/src/declarative/widgets/graphicswidgets_p.h b/src/declarative/widgets/graphicswidgets_p.h deleted file mode 100644 index 6255d2b..0000000 --- a/src/declarative/widgets/graphicswidgets_p.h +++ /dev/null @@ -1,68 +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 GRAPHICSWIDGETS_H -#define GRAPHICSWIDGETS_H - -#include - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QGraphicsView) -QML_DECLARE_TYPE_HASMETATYPE(QGraphicsScene) -QML_DECLARE_TYPE(QGraphicsWidget) -QML_DECLARE_TYPE(QGraphicsObject) -QML_DECLARE_INTERFACE_HASMETATYPE(QGraphicsItem) - -QT_END_HEADER - -#endif // GRAPHICSWIDGETS_H diff --git a/src/declarative/widgets/widgets.pri b/src/declarative/widgets/widgets.pri deleted file mode 100644 index 4cae3ff..0000000 --- a/src/declarative/widgets/widgets.pri +++ /dev/null @@ -1,9 +0,0 @@ -INCLUDEPATH += $$PWD - -SOURCES += \ - $$PWD/graphicswidgets.cpp \ - $$PWD/graphicslayouts.cpp - -HEADERS += \ - $$PWD/graphicswidgets_p.h \ - $$PWD/graphicslayouts_p.h diff --git a/src/plugins/qmlmodules/qmlmodules.pro b/src/plugins/qmlmodules/qmlmodules.pro index b1dc0ef..0a6f444 100644 --- a/src/plugins/qmlmodules/qmlmodules.pro +++ b/src/plugins/qmlmodules/qmlmodules.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs +SUBDIRS += widgets + contains(QT_CONFIG, multimedia): SUBDIRS += multimedia diff --git a/src/plugins/qmlmodules/widgets/graphicslayouts.cpp b/src/plugins/qmlmodules/widgets/graphicslayouts.cpp new file mode 100644 index 0000000..fc15ad2 --- /dev/null +++ b/src/plugins/qmlmodules/widgets/graphicslayouts.cpp @@ -0,0 +1,260 @@ +/**************************************************************************** +** +** 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 "graphicslayouts_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +LinearLayoutAttached::LinearLayoutAttached(QObject *parent) +: QObject(parent), _stretch(1), _alignment(Qt::AlignCenter) +{ +} + +void LinearLayoutAttached::setStretchFactor(int f) +{ + if (_stretch == f) + return; + + _stretch = f; + emit stretchChanged(reinterpret_cast(parent()), _stretch); +} + +void LinearLayoutAttached::setAlignment(Qt::Alignment a) +{ + if (_alignment == a) + return; + + _alignment = a; + emit alignmentChanged(reinterpret_cast(parent()), _alignment); +} + +QGraphicsLinearLayoutStretchItemObject::QGraphicsLinearLayoutStretchItemObject(QObject *parent) + : QObject(parent) +{ +} + +QSizeF QGraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const +{ +Q_UNUSED(which); +Q_UNUSED(constraint); +return QSizeF(); +} + + +QGraphicsLinearLayoutObject::QGraphicsLinearLayoutObject(QObject *parent) +: QObject(parent) +{ +} + +QGraphicsLinearLayoutObject::~QGraphicsLinearLayoutObject() +{ +} + +void QGraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) +{ +insertItem(index, item); + +//connect attached properties +if (LinearLayoutAttached *obj = attachedProperties.value(item)) { + setStretchFactor(item, obj->stretchFactor()); + setAlignment(item, obj->alignment()); + QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), + this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); + QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), + this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); + //### need to disconnect when widget is removed? +} +} + +//### is there a better way to do this? +void QGraphicsLinearLayoutObject::clearChildren() +{ +for (int i = 0; i < count(); ++i) + removeAt(i); +} + +void QGraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) +{ +QGraphicsLinearLayout::setStretchFactor(item, stretch); +} + +void QGraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) +{ +QGraphicsLinearLayout::setAlignment(item, alignment); +} + +QHash QGraphicsLinearLayoutObject::attachedProperties; +LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) +{ +// ### This is not allowed - you must attach to any object +if (!qobject_cast(obj)) + return 0; +LinearLayoutAttached *rv = new LinearLayoutAttached(obj); +attachedProperties.insert(qobject_cast(obj), rv); +return rv; +} + +////////////////////////////////////////////////////////////////////////////////////////////////////// +// QGraphicsGridLayout-related classes +////////////////////////////////////////////////////////////////////////////////////////////////////// +GridLayoutAttached::GridLayoutAttached(QObject *parent) +: QObject(parent), _row(-1), _column(-1), _rowspan(1), _colspan(1), _alignment(-1) +{ +} + +void GridLayoutAttached::setRow(int r) +{ + if (_row == r) + return; + + _row = r; + //emit rowChanged(reinterpret_cast(parent()), _row); +} + +void GridLayoutAttached::setColumn(int c) +{ + if (_column == c) + return; + + _column = c; + //emit columnChanged(reinterpret_cast(parent()), _column); +} + +void GridLayoutAttached::setRowSpan(int rs) +{ + if (_rowspan == rs) + return; + + _rowspan = rs; + //emit rowSpanChanged(reinterpret_cast(parent()), _rowSpan); +} + +void GridLayoutAttached::setColumnSpan(int cs) +{ + if (_colspan == cs) + return; + + _colspan = cs; + //emit columnSpanChanged(reinterpret_cast(parent()), _columnSpan); +} + +void GridLayoutAttached::setAlignment(Qt::Alignment a) +{ + if (_alignment == a) + return; + + _alignment = a; + //emit alignmentChanged(reinterpret_cast(parent()), _alignment); +} + +QGraphicsGridLayoutObject::QGraphicsGridLayoutObject(QObject *parent) +: QObject(parent) +{ +} + +QGraphicsGridLayoutObject::~QGraphicsGridLayoutObject() +{ +} + +void QGraphicsGridLayoutObject::addWidget(QGraphicsWidget *wid) +{ +//use attached properties +if (QObject *obj = attachedProperties.value(qobject_cast(wid))) { + int row = static_cast(obj)->row(); + int column = static_cast(obj)->column(); + int rowSpan = static_cast(obj)->rowSpan(); + int columnSpan = static_cast(obj)->columnSpan(); + if (row == -1 || column == -1) { + qWarning() << "Must set row and column for an item in a grid layout"; + return; + } + addItem(wid, row, column, rowSpan, columnSpan); +} +} + +void QGraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) +{ +//use attached properties +if (GridLayoutAttached *obj = attachedProperties.value(item)) { + int row = obj->row(); + int column = obj->column(); + int rowSpan = obj->rowSpan(); + int columnSpan = obj->columnSpan(); + Qt::Alignment alignment = obj->alignment(); + if (row == -1 || column == -1) { + qWarning() << "Must set row and column for an item in a grid layout"; + return; + } + addItem(item, row, column, rowSpan, columnSpan); + if (alignment != -1) + setAlignment(item,alignment); +} +} + +//### is there a better way to do this? +void QGraphicsGridLayoutObject::clearChildren() +{ +for (int i = 0; i < count(); ++i) + removeAt(i); +} + +qreal QGraphicsGridLayoutObject::spacing() const +{ +if (verticalSpacing() == horizontalSpacing()) + return verticalSpacing(); +return -1; //### +} + +QHash QGraphicsGridLayoutObject::attachedProperties; +GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) +{ +// ### This is not allowed - you must attach to any object +if (!qobject_cast(obj)) + return 0; +GridLayoutAttached *rv = new GridLayoutAttached(obj); +attachedProperties.insert(qobject_cast(obj), rv); +return rv; +} + +QT_END_NAMESPACE diff --git a/src/plugins/qmlmodules/widgets/graphicslayouts_p.h b/src/plugins/qmlmodules/widgets/graphicslayouts_p.h new file mode 100644 index 0000000..5394ffa --- /dev/null +++ b/src/plugins/qmlmodules/widgets/graphicslayouts_p.h @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** 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 GRAPHICSLAYOUTS_H +#define GRAPHICSLAYOUTS_H + +#include "graphicswidgets_p.h" + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayoutItem) +public: + QGraphicsLinearLayoutStretchItemObject(QObject *parent = 0); + + virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; +}; + +class LinearLayoutAttached; +class QGraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) + + Q_PROPERTY(QmlListProperty children READ children) + Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsLinearLayoutObject(QObject * = 0); + ~QGraphicsLinearLayoutObject(); + + QmlListProperty children() { return QmlListProperty(this, 0, children_append, children_count, children_at, children_clear); } + + static LinearLayoutAttached *qmlAttachedProperties(QObject *); + +private Q_SLOTS: + void updateStretch(QGraphicsLayoutItem*,int); + void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); + +private: + friend class LinearLayoutAttached; + void clearChildren(); + void insertLayoutItem(int, QGraphicsLayoutItem *); + static QHash attachedProperties; + + static void children_append(QmlListProperty *prop, QGraphicsLayoutItem *item) { + static_cast(prop->object)->insertLayoutItem(-1, item); + } + + static void children_clear(QmlListProperty *prop) { + static_cast(prop->object)->clearChildren(); + } + + static int children_count(QmlListProperty *prop) { + return static_cast(prop->object)->count(); + } + + static QGraphicsLayoutItem *children_at(QmlListProperty *prop, int index) { + return static_cast(prop->object)->itemAt(index); + } +}; + +class GridLayoutAttached; +class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout +{ + Q_OBJECT + Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) + + Q_PROPERTY(QmlListProperty children READ children) + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) + Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) + Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsGridLayoutObject(QObject * = 0); + ~QGraphicsGridLayoutObject(); + + QmlListProperty children() { return QmlListProperty(this, 0, children_append, children_count, children_at, children_clear); } + + qreal spacing() const; + + static GridLayoutAttached *qmlAttachedProperties(QObject *); + +private: + friend class GraphicsLayoutAttached; + void addWidget(QGraphicsWidget *); + void clearChildren(); + void addLayoutItem(QGraphicsLayoutItem *); + static QHash attachedProperties; + + static void children_append(QmlListProperty *prop, QGraphicsLayoutItem *item) { + static_cast(prop->object)->addLayoutItem(item); + } + + static void children_clear(QmlListProperty *prop) { + static_cast(prop->object)->clearChildren(); + } + + static int children_count(QmlListProperty *prop) { + return static_cast(prop->object)->count(); + } + + static QGraphicsLayoutItem *children_at(QmlListProperty *prop, int index) { + return static_cast(prop->object)->itemAt(index); + } +}; + +class LinearLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) +public: + LinearLayoutAttached(QObject *parent); + + int stretchFactor() const { return _stretch; } + void setStretchFactor(int f); + Qt::Alignment alignment() const { return _alignment; } + void setAlignment(Qt::Alignment a); + +Q_SIGNALS: + void stretchChanged(QGraphicsLayoutItem*,int); + void alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment); + +private: + int _stretch; + Qt::Alignment _alignment; +}; + +class GridLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int row READ row WRITE setRow) + Q_PROPERTY(int column READ column WRITE setColumn) + Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) + Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) +public: + GridLayoutAttached(QObject *parent); + + int row() const { return _row; } + void setRow(int r); + + int column() const { return _column; } + void setColumn(int c); + + int rowSpan() const { return _rowspan; } + void setRowSpan(int rs); + + int columnSpan() const { return _colspan; } + void setColumnSpan(int cs); + + Qt::Alignment alignment() const { return _alignment; } + void setAlignment(Qt::Alignment a); + +private: + int _row; + int _column; + int _rowspan; + int _colspan; + Qt::Alignment _alignment; +}; + +QT_END_NAMESPACE + +QML_DECLARE_INTERFACE(QGraphicsLayoutItem) +QML_DECLARE_INTERFACE(QGraphicsLayout) +QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) +QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) +QML_DECLARE_TYPEINFO(QGraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QGraphicsGridLayoutObject) +QML_DECLARE_TYPEINFO(QGraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) + +QT_END_HEADER + +#endif // GRAPHICSLAYOUTS_H diff --git a/src/plugins/qmlmodules/widgets/graphicswidgets.cpp b/src/plugins/qmlmodules/widgets/graphicswidgets.cpp new file mode 100644 index 0000000..062e516 --- /dev/null +++ b/src/plugins/qmlmodules/widgets/graphicswidgets.cpp @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ diff --git a/src/plugins/qmlmodules/widgets/graphicswidgets_p.h b/src/plugins/qmlmodules/widgets/graphicswidgets_p.h new file mode 100644 index 0000000..6255d2b --- /dev/null +++ b/src/plugins/qmlmodules/widgets/graphicswidgets_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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 GRAPHICSWIDGETS_H +#define GRAPHICSWIDGETS_H + +#include + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QGraphicsView) +QML_DECLARE_TYPE_HASMETATYPE(QGraphicsScene) +QML_DECLARE_TYPE(QGraphicsWidget) +QML_DECLARE_TYPE(QGraphicsObject) +QML_DECLARE_INTERFACE_HASMETATYPE(QGraphicsItem) + +QT_END_HEADER + +#endif // GRAPHICSWIDGETS_H diff --git a/src/plugins/qmlmodules/widgets/widgets.cpp b/src/plugins/qmlmodules/widgets/widgets.cpp new file mode 100644 index 0000000..a5cf389 --- /dev/null +++ b/src/plugins/qmlmodules/widgets/widgets.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins 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 +#include + +#include "graphicslayouts_p.h" +#include "graphicswidgets_p.h" + +QT_BEGIN_NAMESPACE + +class QGraphicsViewDeclarativeUI : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QGraphicsScene *scene READ scene WRITE setScene) + Q_CLASSINFO("DefaultProperty", "scene") +public: + QGraphicsViewDeclarativeUI(QObject *other) : QObject(other) {} + + QGraphicsScene *scene() const { return static_cast(parent())->scene(); } + void setScene(QGraphicsScene *scene) + { + static_cast(parent())->setScene(scene); + } +}; + +class QGraphicsSceneDeclarativeUI : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QmlListProperty children READ children) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other) {} + + QmlListProperty children() { return QmlListProperty(this->parent(), 0, children_append); } + +private: + static void children_append(QmlListProperty *prop, QObject *o) { + if (QGraphicsObject *go = qobject_cast(o)) + static_cast(prop->object)->addItem(go); + } +}; + +class QGraphicsWidgetDeclarativeUI : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QmlListProperty children READ children) + Q_PROPERTY(QGraphicsLayout *layout READ layout WRITE setLayout) + Q_CLASSINFO("DefaultProperty", "children") +public: + QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other) {} + + QmlListProperty children() { return QmlListProperty(this, 0, children_append); } + + QGraphicsLayout *layout() const { return static_cast(parent())->layout(); } + void setLayout(QGraphicsLayout *lo) + { + static_cast(parent())->setLayout(lo); + } + +private: + void setItemParent(QGraphicsItem *wid) + { + wid->setParentItem(static_cast(parent())); + } + + static void children_append(QmlListProperty *prop, QGraphicsItem *i) { + static_cast(prop->object)->setItemParent(i); + } +}; + +class QWidgetsQmlModule : public QmlModulePlugin +{ + Q_OBJECT +public: + QStringList keys() const + { + return QStringList() << QLatin1String("Qt.widgets"); + } + + void defineModule(const QString& uri) + { + Q_UNUSED(uri) + Q_ASSERT(uri == QLatin1String("Qt.widgets")); + + QML_REGISTER_INTERFACE(QGraphicsLayoutItem); + QML_REGISTER_INTERFACE(QGraphicsLayout); + QML_REGISTER_TYPE(Qt,4,6,QGraphicsLinearLayoutStretchItem,QGraphicsLinearLayoutStretchItemObject); + QML_REGISTER_TYPE(Qt,4,6,QGraphicsLinearLayout,QGraphicsLinearLayoutObject); + QML_REGISTER_TYPE(Qt,4,6,QGraphicsGridLayout,QGraphicsGridLayoutObject); + QML_REGISTER_EXTENDED_TYPE(Qt,4,6,QGraphicsView,QGraphicsView,QGraphicsViewDeclarativeUI); + QML_REGISTER_EXTENDED_TYPE(Qt,4,6,QGraphicsScene,QGraphicsScene,QGraphicsSceneDeclarativeUI); + QML_REGISTER_EXTENDED_TYPE(Qt,4,6,QGraphicsWidget,QGraphicsWidget,QGraphicsWidgetDeclarativeUI); + QML_REGISTER_INTERFACE(QGraphicsItem); + } +}; + +QT_END_NAMESPACE + +#include "widgets.moc" + +Q_EXPORT_PLUGIN2(qtwidgetsqmlmodule, QT_PREPEND_NAMESPACE(QWidgetsQmlModule)); + diff --git a/src/plugins/qmlmodules/widgets/widgets.pro b/src/plugins/qmlmodules/widgets/widgets.pro new file mode 100644 index 0000000..5cc8dcc --- /dev/null +++ b/src/plugins/qmlmodules/widgets/widgets.pro @@ -0,0 +1,15 @@ +TARGET = widgets +include(../../qpluginbase.pri) + +QT += declarative + +SOURCES += \ + graphicslayouts.cpp \ + widgets.cpp + +HEADERS += \ + graphicswidgets_p.h \ + graphicslayouts_p.h + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/qmlmodules +target.path = $$[QT_INSTALL_PLUGINS]/plugins/qmlmodules diff --git a/tests/auto/declarative/layouts/data/layouts.qml b/tests/auto/declarative/layouts/data/layouts.qml index 00d785d..1792500 100644 --- a/tests/auto/declarative/layouts/data/layouts.qml +++ b/tests/auto/declarative/layouts/data/layouts.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import Qt.widgets 4.6 Item { id: resizable diff --git a/tests/auto/declarative/qmlecmascript/testtypes.cpp b/tests/auto/declarative/qmlecmascript/testtypes.cpp index 3c6b256..6a04704 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.cpp +++ b/tests/auto/declarative/qmlecmascript/testtypes.cpp @@ -72,11 +72,14 @@ private: int m_value; }; -QML_DEFINE_TYPE(Qt.test, 1,0, MyQmlObject,MyQmlObject); -QML_DEFINE_TYPE(Qt.test, 1,0, MyDeferredObject,MyDeferredObject); -QML_DEFINE_TYPE(Qt.test, 1,0, MyQmlContainer,MyQmlContainer); -QML_DEFINE_EXTENDED_TYPE(Qt.test, 1,0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject); -QML_DEFINE_EXTENDED_TYPE(Qt.test, 1,0, MyExtendedObject,MyExtendedObject,ExtensionObject); -QML_DEFINE_TYPE(Qt.test, 1,0, MyTypeObject, MyTypeObject); +void registerTypes() +{ + QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlObject,MyQmlObject); + QML_REGISTER_TYPE(Qt.test, 1,0, MyDeferredObject,MyDeferredObject); + QML_REGISTER_TYPE(Qt.test, 1,0, MyQmlContainer,MyQmlContainer); + QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyBaseExtendedObject,MyBaseExtendedObject,BaseExtensionObject); + QML_REGISTER_EXTENDED_TYPE(Qt.test, 1,0, MyExtendedObject,MyExtendedObject,ExtensionObject); + QML_REGISTER_TYPE(Qt.test, 1,0, MyTypeObject, MyTypeObject); +} #include "testtypes.moc" diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h index 0af72cb..e1fb1b7 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.h +++ b/tests/auto/declarative/qmlecmascript/testtypes.h @@ -588,5 +588,7 @@ private: QVariantList m_actuals; }; +void registerTypes(); + #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index b30ad1c..88f06ad 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -76,6 +76,7 @@ public: tst_qmlecmascript() {} private slots: + void initTestCase(); void assignBasicTypes(); void idShortcutInvalidates(); void boolPropertiesEvaluateAsBool(); @@ -129,6 +130,8 @@ private: QmlEngine engine; }; +void tst_qmlecmascript::initTestCase() { registerTypes(); } + void tst_qmlecmascript::assignBasicTypes() { { diff --git a/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp b/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp index 00c1b67..676d19a 100644 --- a/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/testtypes.cpp @@ -46,4 +46,7 @@ void MyWebView::drawContents(QPainter *p, const QRect &r) QmlGraphicsWebView::drawContents(p,r); } -QML_DEFINE_TYPE(Test,1,0,MyWebView,MyWebView); +void registerTypes() +{ + QML_REGISTER_TYPE(Test,1,0,MyWebView,MyWebView); +} diff --git a/tests/auto/declarative/qmlgraphicswebview/testtypes.h b/tests/auto/declarative/qmlgraphicswebview/testtypes.h index 0b3176d..fa9a301 100644 --- a/tests/auto/declarative/qmlgraphicswebview/testtypes.h +++ b/tests/auto/declarative/qmlgraphicswebview/testtypes.h @@ -61,4 +61,6 @@ private: QML_DECLARE_TYPE(MyWebView); +void registerTypes(); + #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index f3c39f8..6672f5b 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -59,6 +59,7 @@ public: tst_qmlgraphicswebview() {} private slots: + void initTestCase(); void basicProperties(); void settings(); void historyNav(); @@ -81,6 +82,11 @@ private: } }; +void tst_qmlgraphicswebview::initTestCase() +{ + registerTypes(); +} + static QString strippedHtml(QString html) { html.replace(QRegExp("\\s+"),""); diff --git a/tests/auto/declarative/qmllanguage/testtypes.cpp b/tests/auto/declarative/qmllanguage/testtypes.cpp index a295054..9ffe28a 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.cpp +++ b/tests/auto/declarative/qmllanguage/testtypes.cpp @@ -40,15 +40,18 @@ ****************************************************************************/ #include "testtypes.h" -QML_DEFINE_INTERFACE(MyInterface); -QML_DEFINE_TYPE(Test,1,0,MyQmlObject,MyQmlObject); -QML_DEFINE_TYPE(Test,1,0,MyTypeObject,MyTypeObject); -QML_DEFINE_TYPE(Test,1,0,MyContainer,MyContainer); -QML_DEFINE_TYPE(Test,1,0,MyPropertyValueSource,MyPropertyValueSource); -QML_DEFINE_TYPE(Test,1,0,MyDotPropertyObject,MyDotPropertyObject); -QML_DEFINE_TYPE(Test,1,0,MyNamespacedType,MyNamespace::MyNamespacedType); -QML_DEFINE_TYPE(Test,1,0,MySecondNamespacedType,MyNamespace::MySecondNamespacedType); -QML_DEFINE_NOCREATE_TYPE(MyGroupedObject); +void registerTypes() +{ + QML_REGISTER_INTERFACE(MyInterface); + QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject); + QML_REGISTER_TYPE(Test,1,0,MyTypeObject,MyTypeObject); + QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer); + QML_REGISTER_TYPE(Test,1,0,MyPropertyValueSource,MyPropertyValueSource); + QML_REGISTER_TYPE(Test,1,0,MyDotPropertyObject,MyDotPropertyObject); + QML_REGISTER_TYPE(Test,1,0,MyNamespacedType,MyNamespace::MyNamespacedType); + QML_REGISTER_TYPE(Test,1,0,MySecondNamespacedType,MyNamespace::MySecondNamespacedType); + QML_REGISTER_NOCREATE_TYPE(MyGroupedObject); +} QVariant myCustomVariantTypeConverter(const QString &data) { diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h index 27b45e4..9fd0973 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.h +++ b/tests/auto/declarative/qmllanguage/testtypes.h @@ -542,4 +542,6 @@ namespace MyNamespace { QML_DECLARE_TYPE(MyNamespace::MyNamespacedType); QML_DECLARE_TYPE(MyNamespace::MySecondNamespacedType); +void registerTypes(); + #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 4090e1d..5f9cb1b 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -182,6 +182,15 @@ inline QUrl TEST_FILE(const char *filename) void tst_qmllanguage::initTestCase() { + registerTypes(); + + QML_REGISTER_TYPE(com.nokia.Test, 0, 0, TestTP, TestType) + QML_REGISTER_TYPE(com.nokia.Test, 1, 0, Test, TestType) + QML_REGISTER_TYPE(com.nokia.Test, 1, 5, Test, TestType) + QML_REGISTER_TYPE(com.nokia.Test, 1, 8, Test, TestType2) + QML_REGISTER_TYPE(com.nokia.Test, 1, 9, OldTest, TestType) + QML_REGISTER_TYPE(com.nokia.Test, 1, 12, Test, TestType2) + // Create locale-specific file // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters @@ -1058,13 +1067,6 @@ void tst_qmllanguage::testType(const QString& qml, const QString& type) QML_DECLARE_TYPE(TestType) QML_DECLARE_TYPE(TestType2) -QML_DEFINE_TYPE(com.nokia.Test, 0, 0, TestTP, TestType) -QML_DEFINE_TYPE(com.nokia.Test, 1, 0, Test, TestType) -QML_DEFINE_TYPE(com.nokia.Test, 1, 5, Test, TestType) -QML_DEFINE_TYPE(com.nokia.Test, 1, 8, Test, TestType2) -QML_DEFINE_TYPE(com.nokia.Test, 1, 9, OldTest, TestType) -QML_DEFINE_TYPE(com.nokia.Test, 1, 12, Test, TestType2) - // Import tests (QT-558) void tst_qmllanguage::importsBuiltin_data() diff --git a/tests/auto/declarative/qmllistreference/tst_qmllistreference.cpp b/tests/auto/declarative/qmllistreference/tst_qmllistreference.cpp index 6122f1e..db9f218 100644 --- a/tests/auto/declarative/qmllistreference/tst_qmllistreference.cpp +++ b/tests/auto/declarative/qmllistreference/tst_qmllistreference.cpp @@ -67,6 +67,7 @@ public: tst_qmllistreference() {} private slots: + void initTestCase(); void qmllistreference(); void qmllistreference_invalid(); void isValid(); @@ -101,7 +102,11 @@ public: QmlListProperty property; }; QML_DECLARE_TYPE(TestType); -QML_DEFINE_NOCREATE_TYPE(TestType); + +void tst_qmllistreference::initTestCase() +{ + QML_REGISTER_NOCREATE_TYPE(TestType); +} void tst_qmllistreference::qmllistreference() { diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index c289641..4be0800 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -54,7 +54,6 @@ public: }; QML_DECLARE_TYPE(MyQmlObject); -QML_DEFINE_TYPE(Test,1,0,MyQmlObject,MyQmlObject); class MyAttached : public QObject { @@ -88,7 +87,6 @@ private: }; QML_DECLARE_TYPE(MyContainer); -QML_DEFINE_TYPE(Test,1,0,MyContainer,MyContainer); QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES) class tst_qmlmetaproperty : public QObject @@ -98,6 +96,7 @@ public: tst_qmlmetaproperty() {} private slots: + void initTestCase(); // Constructors void qmlmetaproperty(); @@ -126,6 +125,13 @@ private: QmlEngine engine; }; +void tst_qmlmetaproperty::initTestCase() +{ + QML_REGISTER_TYPE(Test,1,0,MyQmlObject,MyQmlObject); + QML_REGISTER_TYPE(Test,1,0,PropertyObject,PropertyObject); + QML_REGISTER_TYPE(Test,1,0,MyContainer,MyContainer); +} + void tst_qmlmetaproperty::qmlmetaproperty() { QmlMetaProperty prop; @@ -209,7 +215,6 @@ private: }; QML_DECLARE_TYPE(PropertyObject); -QML_DEFINE_TYPE(Test,1,0,PropertyObject,PropertyObject); void tst_qmlmetaproperty::qmlmetaproperty_object() { diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp index 750ccf8..027b607 100644 --- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp +++ b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp @@ -60,6 +60,8 @@ public: tst_qmlmetatype() {} private slots: + void initTestCase(); + void copy(); void qmlParserStatusCast(); @@ -81,7 +83,6 @@ public: int foo() { return 0; } }; QML_DECLARE_TYPE(TestType); -QML_DEFINE_TYPE(Test, 1, 0, TestType, TestType); class ParserStatusTestType : public QObject, public QmlParserStatus { @@ -89,7 +90,6 @@ class ParserStatusTestType : public QObject, public QmlParserStatus Q_CLASSINFO("DefaultProperty", "foo"); // Missing default property }; QML_DECLARE_TYPE(ParserStatusTestType); -QML_DEFINE_TYPE(Test, 1, 0, ParserStatusTestType, ParserStatusTestType); class ValueSourceTestType : public QObject, public QmlPropertyValueSource { @@ -99,7 +99,6 @@ public: virtual void setTarget(const QmlMetaProperty &) {} }; QML_DECLARE_TYPE(ValueSourceTestType); -QML_DEFINE_TYPE(Test, 1, 0, ValueSourceTestType, ValueSourceTestType); class ValueInterceptorTestType : public QObject, public QmlPropertyValueInterceptor { @@ -110,7 +109,6 @@ public: virtual void write(const QVariant &) {} }; QML_DECLARE_TYPE(ValueInterceptorTestType); -QML_DEFINE_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType); #define COPY_TEST(cpptype, metatype, value, defaultvalue) \ @@ -131,6 +129,14 @@ QML_DEFINE_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType); QVERIFY(v == (value)); \ } +void tst_qmlmetatype::initTestCase() +{ + QML_REGISTER_TYPE(Test, 1, 0, TestType, TestType); + QML_REGISTER_TYPE(Test, 1, 0, ParserStatusTestType, ParserStatusTestType); + QML_REGISTER_TYPE(Test, 1, 0, ValueSourceTestType, ValueSourceTestType); + QML_REGISTER_TYPE(Test, 1, 0, ValueInterceptorTestType, ValueInterceptorTestType); +} + void tst_qmlmetatype::copy() { QVERIFY(QmlMetaType::copy(QMetaType::Void, 0, 0)); diff --git a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp index ddd1e5e..6354d31 100644 --- a/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp +++ b/tests/auto/declarative/qmlmoduleplugin/plugin/plugin.cpp @@ -61,7 +61,6 @@ private: }; QML_DECLARE_TYPE(MyPluginType); -QML_DEFINE_TYPE(com.nokia.AutoTestQmlPluginType,1,0,MyPluginType,MyPluginType); class MyPlugin : public QmlModulePlugin @@ -81,6 +80,7 @@ public: void defineModule(const QString& uri) { Q_ASSERT(uri == "com.nokia.AutoTestQmlPluginType"); + QML_REGISTER_TYPE(com.nokia.AutoTestQmlPluginType,1,0,MyPluginType,MyPluginType); } }; diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp index b910c85..c372a15 100644 --- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp +++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp @@ -56,6 +56,8 @@ private: static QByteArray fullDataPath(const QString &path); private slots: + void initTestCase(); + void basicChanges(); void basicExtension(); void basicBinding(); @@ -344,7 +346,11 @@ Q_SIGNALS: }; QML_DECLARE_TYPE(MyRect) -QML_DEFINE_TYPE(Qt.test, 1, 0, MyRectangle,MyRect); + +void tst_qmlstates::initTestCase() +{ + QML_REGISTER_TYPE(Qt.test, 1, 0, MyRectangle,MyRect); +} void tst_qmlstates::signalOverride() { diff --git a/tests/auto/declarative/qmlvaluetypes/testtypes.cpp b/tests/auto/declarative/qmlvaluetypes/testtypes.cpp index c51b777..aa8bd6e 100644 --- a/tests/auto/declarative/qmlvaluetypes/testtypes.cpp +++ b/tests/auto/declarative/qmlvaluetypes/testtypes.cpp @@ -40,6 +40,9 @@ ****************************************************************************/ #include "testtypes.h" -QML_DEFINE_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject); -QML_DEFINE_TYPE(Test, 1, 0, MyConstantValueSource, MyConstantValueSource); -QML_DEFINE_TYPE(Test, 1, 0, MyOffsetValueInterceptor, MyOffsetValueInterceptor); +void registerTypes() +{ + QML_REGISTER_TYPE(Test, 1, 0, MyTypeObject, MyTypeObject); + QML_REGISTER_TYPE(Test, 1, 0, MyConstantValueSource, MyConstantValueSource); + QML_REGISTER_TYPE(Test, 1, 0, MyOffsetValueInterceptor, MyOffsetValueInterceptor); +} diff --git a/tests/auto/declarative/qmlvaluetypes/testtypes.h b/tests/auto/declarative/qmlvaluetypes/testtypes.h index b57fbff..5f9dde1 100644 --- a/tests/auto/declarative/qmlvaluetypes/testtypes.h +++ b/tests/auto/declarative/qmlvaluetypes/testtypes.h @@ -149,4 +149,6 @@ private: }; QML_DECLARE_TYPE(MyOffsetValueInterceptor); +void registerTypes(); + #endif // TESTTYPES_H diff --git a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp index f99d3ce..26cf9b0 100644 --- a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp +++ b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp @@ -53,6 +53,8 @@ public: tst_qmlvaluetypes() {} private slots: + void initTestCase(); + void point(); void pointf(); void size(); @@ -79,6 +81,11 @@ private: QmlEngine engine; }; +void tst_qmlvaluetypes::initTestCase() +{ + registerTypes(); +} + inline QUrl TEST_FILE(const QString &filename) { return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); diff --git a/tests/benchmarks/declarative/binding/testtypes.cpp b/tests/benchmarks/declarative/binding/testtypes.cpp index 3a9f59b..043c8ab 100644 --- a/tests/benchmarks/declarative/binding/testtypes.cpp +++ b/tests/benchmarks/declarative/binding/testtypes.cpp @@ -40,4 +40,7 @@ ****************************************************************************/ #include "testtypes.h" -QML_DEFINE_TYPE(Test, 1, 0, MyQmlObject, MyQmlObject); +void registerTypes() +{ + QML_REGISTER_TYPE(Test, 1, 0, MyQmlObject, MyQmlObject); +} diff --git a/tests/benchmarks/declarative/binding/testtypes.h b/tests/benchmarks/declarative/binding/testtypes.h index d4e0a1a..a4f16d0 100644 --- a/tests/benchmarks/declarative/binding/testtypes.h +++ b/tests/benchmarks/declarative/binding/testtypes.h @@ -78,4 +78,6 @@ private: }; QML_DECLARE_TYPE(MyQmlObject); +void registerTypes(); + #endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/binding/tst_binding.cpp b/tests/benchmarks/declarative/binding/tst_binding.cpp index 74a3407..8fae924 100644 --- a/tests/benchmarks/declarative/binding/tst_binding.cpp +++ b/tests/benchmarks/declarative/binding/tst_binding.cpp @@ -57,8 +57,8 @@ public: virtual ~tst_binding(); public slots: - void init(); - void cleanup(); + void initTestCase(); + void cleanupTestCase(); private slots: void objectproperty_data(); @@ -78,11 +78,12 @@ tst_binding::~tst_binding() { } -void tst_binding::init() +void tst_binding::initTestCase() { + registerTypes(); } -void tst_binding::cleanup() +void tst_binding::cleanupTestCase() { } diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp index f0bc1f9..acdc395 100644 --- a/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp +++ b/tests/benchmarks/declarative/qmlcomponent/testtypes.cpp @@ -40,4 +40,7 @@ ****************************************************************************/ #include "testtypes.h" -QML_DEFINE_TYPE(Qt.test, 4, 6, MyQmlObject, MyQmlObject); +void registerTypes() +{ + QML_REGISTER_TYPE(Qt.test, 4, 6, MyQmlObject, MyQmlObject); +} diff --git a/tests/benchmarks/declarative/qmlcomponent/testtypes.h b/tests/benchmarks/declarative/qmlcomponent/testtypes.h index d4e0a1a..a4f16d0 100644 --- a/tests/benchmarks/declarative/qmlcomponent/testtypes.h +++ b/tests/benchmarks/declarative/qmlcomponent/testtypes.h @@ -78,4 +78,6 @@ private: }; QML_DECLARE_TYPE(MyQmlObject); +void registerTypes(); + #endif // TESTTYPES_H diff --git a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp index 647edbf..afd1cdf 100644 --- a/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp +++ b/tests/benchmarks/declarative/qmlcomponent/tst_qmlcomponent.cpp @@ -58,8 +58,8 @@ public: virtual ~tst_qmlcomponent(); public slots: - void init(); - void cleanup(); + void initTestCase(); + void cleanupTestCase(); private slots: void creation_data(); @@ -77,11 +77,12 @@ tst_qmlcomponent::~tst_qmlcomponent() { } -void tst_qmlcomponent::init() +void tst_qmlcomponent::initTestCase() { + registerTypes(); } -void tst_qmlcomponent::cleanup() +void tst_qmlcomponent::cleanupTestCase() { } diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp index 2cc5d0d..cbac422 100644 --- a/tests/benchmarks/declarative/qmltime/qmltime.cpp +++ b/tests/benchmarks/declarative/qmltime/qmltime.cpp @@ -76,7 +76,6 @@ private: QGraphicsRectItem m_item; }; QML_DECLARE_TYPE(Timer); -QML_DEFINE_TYPE(QmlTime, 1, 0, Timer, Timer); Timer *Timer::m_timer = 0; @@ -157,6 +156,8 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); + QML_REGISTER_TYPE(QmlTime, 1, 0, Timer, Timer); + uint iterations = 1024; QString filename; bool willParent = false; diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index dd21997..a90a98b 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -55,6 +55,8 @@ public: tst_script() {} private slots: + void initTestCase(); + void property_js(); void property_getter(); void property_getter_js(); @@ -88,6 +90,11 @@ private slots: private: }; +void tst_script::initTestCase() +{ + QML_REGISTER_TYPE(Qt.test, 1, 0, TestObject, TestObject); +} + inline QUrl TEST_FILE(const QString &filename) { return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); @@ -123,7 +130,6 @@ private: int m_x; }; QML_DECLARE_TYPE(TestObject); -QML_DEFINE_TYPE(Qt.test, 1, 0, TestObject, TestObject); TestObject::TestObject(QObject *parent) : QObject(parent), m_x(0) diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 57c445f..0f51da2 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -46,6 +46,8 @@ #include #include #include +#include "qfxtester.h" +#include "qmlfolderlistmodel.h" QT_USE_NAMESPACE @@ -150,6 +152,10 @@ int main(int argc, char ** argv) app.setOrganizationName("Nokia"); app.setOrganizationDomain("nokia.com"); + QmlViewer::registerTypes(); + QmlGraphicsTester::registerTypes(); + QmlFolderListModel::registerTypes(); + bool frameless = false; bool resizeview = false; QString fileName; diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp index c3c0124..b2e4054 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -52,10 +52,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt.VisualTest, 4,6, VisualTest, QmlGraphicsVisualTest); -QML_DEFINE_TYPE(Qt.VisualTest, 4,6, Frame, QmlGraphicsVisualTestFrame); -QML_DEFINE_TYPE(Qt.VisualTest, 4,6, Mouse, QmlGraphicsVisualTestMouse); -QML_DEFINE_TYPE(Qt.VisualTest, 4,6, Key, QmlGraphicsVisualTestKey); QmlGraphicsTester::QmlGraphicsTester(const QString &script, QmlViewer::ScriptOptions opts, QmlView *parent) @@ -375,4 +371,12 @@ void QmlGraphicsTester::updateCurrentTime(int msec) complete(); } +void QmlGraphicsTester::registerTypes() +{ + QML_REGISTER_TYPE(Qt.VisualTest, 4,6, VisualTest, QmlGraphicsVisualTest); + QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Frame, QmlGraphicsVisualTestFrame); + QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Mouse, QmlGraphicsVisualTestMouse); + QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Key, QmlGraphicsVisualTestKey); +} + QT_END_NAMESPACE diff --git a/tools/qmlviewer/qfxtester.h b/tools/qmlviewer/qfxtester.h index 4b8ff9f..bae807b 100644 --- a/tools/qmlviewer/qfxtester.h +++ b/tools/qmlviewer/qfxtester.h @@ -206,6 +206,8 @@ public: QmlGraphicsTester(const QString &script, QmlViewer::ScriptOptions options, QmlView *parent); ~QmlGraphicsTester(); + static void registerTypes(); + virtual int duration() const; void run(); diff --git a/tools/qmlviewer/qmlfolderlistmodel.cpp b/tools/qmlviewer/qmlfolderlistmodel.cpp index 698df54..aec7756 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.cpp +++ b/tools/qmlviewer/qmlfolderlistmodel.cpp @@ -401,7 +401,7 @@ bool QmlFolderListModel::showOnlyReadable() const return d->model.filter() & QDir::Readable; } -void QmlFolderListModel::setShowOnlyReadable(bool on) +void QmlFolderListModel::setShowOnlyReadable(bool on) { if (!(d->model.filter() & QDir::Readable) == !on) return; @@ -411,8 +411,10 @@ void QmlFolderListModel::setShowOnlyReadable(bool on) d->model.setFilter(d->model.filter() & ~QDir::Readable); } - -QML_DEFINE_TYPE(Qt,4,6,FolderListModel,QmlFolderListModel) +void QmlFolderListModel::registerTypes() +{ + QML_REGISTER_TYPE(Qt,4,6,FolderListModel,QmlFolderListModel); +} QT_END_NAMESPACE diff --git a/tools/qmlviewer/qmlfolderlistmodel.h b/tools/qmlviewer/qmlfolderlistmodel.h index c180e97..1a1c299 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.h +++ b/tools/qmlviewer/qmlfolderlistmodel.h @@ -69,6 +69,8 @@ public: QmlFolderListModel(QObject *parent = 0); ~QmlFolderListModel(); + static void registerTypes(); + virtual QHash data(int index, const QList &roles = (QList())) const; virtual QVariant data(int index, int role) const; virtual int count() const; diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 626e4c4..4fe7d7d 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -139,8 +139,6 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(Screen) -QML_DEFINE_TYPE(QmlViewer, 1, 0, Screen, Screen) - QT_BEGIN_NAMESPACE class SizedMenuBar : public QMenuBar @@ -1460,6 +1458,11 @@ void QmlViewer::setUseNativeFileBrowser(bool use) useQmlFileBrowser = !use; } +void QmlViewer::registerTypes() +{ + QML_REGISTER_TYPE(QmlViewer, 1, 0, Screen, Screen); +} + QT_END_NAMESPACE #include "qmlviewer.moc" diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index c7f87ed..ac7b9a0 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -72,6 +72,8 @@ public: QmlViewer(QWidget *parent=0, Qt::WindowFlags flags=0); ~QmlViewer(); + static void registerTypes(); + enum ScriptOption { Play = 0x00000001, Record = 0x00000002, -- cgit v0.12