From e5922ab126f3532483b18720ce893d6be826d50e Mon Sep 17 00:00:00 2001 From: mae Date: Wed, 10 Mar 2010 18:29:44 +0100 Subject: Document - and use - the qmlRegisterXXX template functions This commit removes the obsolete QML_REGISTER_TYPE macros. --- demos/declarative/minehunt/minehunt.cpp | 5 +- doc/src/declarative/declarativeui.qdoc | 4 +- doc/src/declarative/extending.qdoc | 62 +++++----- doc/src/declarative/qtdeclarative.qdoc | 48 ++++++++ examples/declarative/extending/adding/main.cpp | 2 +- examples/declarative/extending/attached/main.cpp | 12 +- examples/declarative/extending/binding/main.cpp | 15 ++- examples/declarative/extending/coercion/main.cpp | 8 +- examples/declarative/extending/default/main.cpp | 8 +- examples/declarative/extending/extended/main.cpp | 2 +- examples/declarative/extending/grouped/main.cpp | 10 +- examples/declarative/extending/properties/main.cpp | 4 +- examples/declarative/extending/signal/main.cpp | 12 +- .../declarative/extending/valuesource/main.cpp | 14 +-- .../graphicsitems/qdeclarativeitemsmodule.cpp | 134 ++++++++++----------- src/declarative/qml/qdeclarative.h | 3 + src/declarative/qml/qdeclarativecustomparser_p.h | 3 +- src/declarative/qml/qdeclarativeengine.cpp | 10 +- src/declarative/util/qdeclarativeutilmodule.cpp | 75 ++++++------ src/imports/webkit/plugin.cpp | 2 +- src/imports/widgets/widgets.cpp | 6 +- tools/qml/qdeclarativefolderlistmodel.cpp | 2 +- tools/qml/qfxtester.cpp | 8 +- tools/qml/qmlruntime.cpp | 2 +- 24 files changed, 254 insertions(+), 197 deletions(-) diff --git a/demos/declarative/minehunt/minehunt.cpp b/demos/declarative/minehunt/minehunt.cpp index 89845ef..2e1b5b3 100644 --- a/demos/declarative/minehunt/minehunt.cpp +++ b/demos/declarative/minehunt/minehunt.cpp @@ -292,9 +292,8 @@ class MinehuntExtensionPlugin : public QDeclarativeExtensionPlugin public: void registerTypes(const char *uri) { - Q_UNUSED(uri); - QML_REGISTER_TYPE(SameGameCore, 0, 1, Tile, Tile); - QML_REGISTER_TYPE(SameGameCore, 0, 1, Game, MinehuntGame); + qmlRegisterType(uri, 0, 1, "Tile"); + qmlRegisterType(uri, 0, 1, "Game"); } void initializeEngine(QDeclarativeEngine *engine, const char *uri) { diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 4b61bd9..ed63367 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -68,7 +68,7 @@ internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo br Qt Declarative builds on \l {QML for Qt programmers}{Qt's existing strengths}. QML can be be used to incrementally extend an existing application or to build -completely new applications. QML is fully \l {Extending QML}{extensible from C++}. +completely new applications. QML is fully \l {Extending QML in C++}{extensible from C++}. \section1 Getting Started: \list @@ -100,7 +100,7 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+ \list \o \l {QML Elements} \o \l {QML Global Object} -\o \l {Extending QML} +\o \l {Extending QML in C++} \o \l {QML Internationalization} \o \l {QtDeclarative Module} \o \l {Debugging QML} diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 5aaa7bd..0ae4f7d 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -41,7 +41,7 @@ /*! \page qml-extending.html -\title Extending QML +\title Extending QML in C++ The QML syntax declaratively describes how to construct an in memory object tree. In Qt, QML is mainly used to describe a visual scene graph, but it is @@ -67,21 +67,23 @@ that derive from QObject. The QML engine has no intrinsic knowledge of any class types. Instead the programmer must define the C++ types, and their corresponding QML name. -Custom C++ types are made available to QML using these two macros: +Custom C++ types are declared QML types using a macro and a template function: \quotation + \code #define QML_DECLARE_TYPE(T) -#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,QDeclarativeName,T) +template +int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) \endcode -Register the C++ type \a T with the QML system, and make it available in QML -under the name \a QDeclarativeName in library URI version VMAJ.VMIN. -\a T and \a QDeclarativeName may be the same. +Calling qmlRegisterType() registers the C++ type \a T with the QML system, and makes it available in QML +under the name \a qmlName in library \a uri version \a versionMajor.versionMinor. +The \a qmlName can be the same as the C++ type name. Generally the QML_DECLARE_TYPE() macro should be included immediately following -the type declaration (usually in its header file), and the QML_REGISTER_TYPE() -macro called by the implementation. +the type declaration (usually in its header file), and the template function qmlRegisterType() +called by the implementation. Type \a T must be a concrete type that inherits QObject and has a default constructor. @@ -147,19 +149,20 @@ property can be assigned. QML also supports assigning Qt interfaces. To assign to a property whose type is a Qt interface pointer, the interface must also be registered with QML. As they cannot be instantiated directly, registering a Qt interface is different -from registering a new QML type. The following macros are used instead: +from registering a new QML type. The following macro and function are used instead: \quotation \code - #define QML_DECLARE_INTERFACE(T) - #define QML_REGISTER_INTERFACE(T) +#define QML_DECLARE_INTERFACE(T) +template +int qmlRegisterInterface(const char *typeName) \endcode -Register the C++ interface \a T with the QML system. +Registers the C++ interface \a T with the QML system as \a typeName. Generally the QML_DECLARE_INTERFACE() macro should be included immediately following the interface declaration (usually in its header file), and the -QML_REGISTER_INTERFACE() macro called by the implementation. +qmlRegisterInterface() template function called by the implementation. Following registration, QML can coerce objects that implement this interface for assignment to appropriately typed properties. @@ -174,7 +177,7 @@ The guest property declaration looks like this: \snippet examples/declarative/extending/properties/birthdayparty.h 2 -\l {Extending QML - Object and List Property Types Example} shows the complete +\l {Extending QML in C++ - Object and List Property Types Example} shows the complete code used to create the \c BirthdayParty type. \section1 Inheritance and Coercion @@ -192,25 +195,26 @@ 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_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 +Both the qmlRegisterType() and qmlRegisterInterface() template functions 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: +registered these macro and function can be used: \quotation \code #define QML_DECLARE_TYPE(T) - #define QML_REGISTER_NOCREATE_TYPE(T) + template + int qmlRegisterType() \endcode -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 +Registers the C++ type \a T with the QML system. The parameterless call to the template +function qmlRegisterType() 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_REGISTER_NOCREATE_TYPE() macro called from the implementation. +qmlRegisterType() template function 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. @@ -220,7 +224,7 @@ QML will automatically coerce C++ types when assigning to either an object property, or to a list property. Only if coercion fails does an assignment error occur. -\l {Extending QML - Inheritance and Coercion Example} shows the complete +\l {Extending QML in C++ - Inheritance and Coercion Example} shows the complete code used to create the \c Boy and \c Girl types. \section1 Default Property @@ -252,7 +256,7 @@ refer to a property declared in the class itself, or a property inherited from a base class. \endquotation -\l {Extending QML - Default Property Example} shows the complete code used to +\l {Extending QML in C++ - Default Property Example} shows the complete code used to specify a default property. \section1 Grouped Properties @@ -277,7 +281,7 @@ property block - in this case the size, color, brand and price properties. Grouped property blocks may declared and accessed be recusively. -\l {Extending QML - Grouped Properties Example} shows the complete code used to +\l {Extending QML in C++ - Grouped Properties Example} shows the complete code used to implement the \c shoe property grouping. \section1 Attached Properties @@ -369,7 +373,7 @@ creating it if it does not already exist. If \a create is false, the attachment object will only be returned if it has previously been created. \endquotation -\l {Extending QML - Attached Properties Example} shows the complete code used to +\l {Extending QML in C++ - Attached Properties Example} shows the complete code used to implement the rsvp attached property. \section1 Memory Management and QVariant types @@ -431,7 +435,7 @@ listed in \l {Adding Types}, as well registered object types are permitted as signal parameter types. Using other types is not an error, but the parameter value will not be accessible from script. -\l {Extending QML - Signal Support Example} shows the complete code used to +\l {Extending QML in C++ - Signal Support Example} shows the complete code used to implement the onPartyStarted signal property. \section1 Property Value Sources @@ -478,7 +482,7 @@ to assign it normally, as though it were a regular QML type. Only if this assignment fails does the engine call the setTarget() method. This allows the type to also be used in contexts other than just as a value source. -\l {Extending QML - Property Value Source Example} shows the complete code used +\l {Extending QML in C++ - Property Value Source Example} shows the complete code used implement the HappyBirthday property value source. \section1 Property Binding @@ -550,7 +554,7 @@ The CONSTANT attribute should only be used for properties whose value is set, and finalized, only in the class constructor. All other properties that want to be used in bindings should have a NOTIFY signal instead. -\l {Extending QML - Binding Example} shows the BirthdayParty example updated to +\l {Extending QML in C++ - Binding Example} shows the BirthdayParty example updated to include NOTIFY signals for use in binding. \section1 Extension Objects @@ -623,7 +627,7 @@ public: \title Extending types from QML Many of the elements available for use in QML are implemented in -\l {Extending QML}{C++}. These types are know as "core types". QML +\l {Extending QML in C++}{C++}. These types are know as "core types". QML allows programmers to build new, fully functional elements without using C++. Existing core types can be extended, and new types defined entirely in the QML language. diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index 41d6338..b43d0ec 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -65,3 +65,51 @@ For more information on the Qt Declarative module, see the \l{declarativeui.html}{Declarative UI} documentation. */ + + +/*! + \macro QML_DECLARE_TYPE(T) + \relates QDeclarativeEngine + + yada yada yada + +*/ + + +/*! + \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) + \relates QDeclarativeEngine + + This template function registers the C++ type \a T with the QML system, and make it available in + QML under the name \a qmlName in the import library \a uri version \a versionMajor.versionMajor. + + Returns the QML type id. + + Example: Register the C++ class \c MinehuntGame as QML type \c Game version 0.1 in the import + library \c MinehuntCore: + + \code + qmlRegisterType("MinehuntCore", 0, 1, "Game"); + \endcode + +*/ + +/*! + \fn int qmlRegisterType() + \relates QDeclarativeEngine + \overload + + This template function registers the C++ type \a T with the QML system. Instances of this type cannot + be created from the QML system. + + Returns the QML type id. +*/ + +/*! \fn int qmlRegisterInterface(const char *typeName) + \relates QDeclarativeEngine + + This template function registers the C++ type \a T as interface with the QML system, under the name + \a typeName. + + Returns the QML type id. + */ diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp index 76e0736..b9e5aa3 100644 --- a/examples/declarative/extending/adding/main.cpp +++ b/examples/declarative/extending/adding/main.cpp @@ -48,7 +48,7 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_TYPE(People, 1,0, Person, Person); + qmlRegisterType("People", 1,0, "Person"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp index 684d8d3..fd2d525 100644 --- a/examples/declarative/extending/attached/main.cpp +++ b/examples/declarative/extending/attached/main.cpp @@ -49,12 +49,12 @@ 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); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp index 873f8c9..ce6c50d 100644 --- a/examples/declarative/extending/binding/main.cpp +++ b/examples/declarative/extending/binding/main.cpp @@ -49,14 +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_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); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthday"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp index 1e2209f..312aff9 100644 --- a/examples/declarative/extending/coercion/main.cpp +++ b/examples/declarative/extending/coercion/main.cpp @@ -49,12 +49,12 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + qmlRegisterType("People", 1,0, "BirthdayParty"); // ![0] - QML_REGISTER_NOCREATE_TYPE(Person); + qmlRegisterType(); // ![0] - QML_REGISTER_TYPE(People, 1,0, Boy, Boy); - QML_REGISTER_TYPE(People, 1,0, Girl, Girl); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp index 7d7f8a1..06282ad 100644 --- a/examples/declarative/extending/default/main.cpp +++ b/examples/declarative/extending/default/main.cpp @@ -49,10 +49,10 @@ 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); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp index 5cbeea3..ca7242d 100644 --- a/examples/declarative/extending/extended/main.cpp +++ b/examples/declarative/extending/extended/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); - QML_REGISTER_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension); + qmlRegisterExtendedType("People", 1,0, "QLineEdit"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp index 15a0bb5..b383a8b 100644 --- a/examples/declarative/extending/grouped/main.cpp +++ b/examples/declarative/extending/grouped/main.cpp @@ -49,11 +49,11 @@ 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); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp index ce69ad2..350f8bd 100644 --- a/examples/declarative/extending/properties/main.cpp +++ b/examples/declarative/extending/properties/main.cpp @@ -49,8 +49,8 @@ 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); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp index afc1a66..1b23a46 100644 --- a/examples/declarative/extending/signal/main.cpp +++ b/examples/declarative/extending/signal/main.cpp @@ -49,12 +49,12 @@ 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); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp index 873f8c9..2574917 100644 --- a/examples/declarative/extending/valuesource/main.cpp +++ b/examples/declarative/extending/valuesource/main.cpp @@ -50,13 +50,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_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); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthday"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp index 25660f8..2d05c7c 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp @@ -82,76 +82,76 @@ void QDeclarativeItemModule::defineModule() { - QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QDeclarativeAnimatedImage); - QML_REGISTER_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect); - QML_REGISTER_TYPE(Qt,4,6,BorderImage,QDeclarativeBorderImage); - QML_REGISTER_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect); - QML_REGISTER_TYPE(Qt,4,6,Column,QDeclarativeColumn); - QML_REGISTER_TYPE(Qt,4,6,Drag,QDeclarativeDrag); - QML_REGISTER_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect); - QML_REGISTER_TYPE(Qt,4,6,Flickable,QDeclarativeFlickable); - QML_REGISTER_TYPE(Qt,4,6,Flipable,QDeclarativeFlipable); - QML_REGISTER_TYPE(Qt,4,6,Flow,QDeclarativeFlow); - QML_REGISTER_TYPE(Qt,4,6,FocusPanel,QDeclarativeFocusPanel); - QML_REGISTER_TYPE(Qt,4,6,FocusScope,QDeclarativeFocusScope); - QML_REGISTER_TYPE(Qt,4,6,Gradient,QDeclarativeGradient); - QML_REGISTER_TYPE(Qt,4,6,GradientStop,QDeclarativeGradientStop); - QML_REGISTER_TYPE(Qt,4,6,GraphicsObjectContainer,QDeclarativeGraphicsObjectContainer); - QML_REGISTER_TYPE(Qt,4,6,Grid,QDeclarativeGrid); - QML_REGISTER_TYPE(Qt,4,6,GridView,QDeclarativeGridView); - QML_REGISTER_TYPE(Qt,4,6,Image,QDeclarativeImage); - QML_REGISTER_TYPE(Qt,4,6,Item,QDeclarativeItem); - QML_REGISTER_TYPE(Qt,4,6,KeyNavigation,QDeclarativeKeyNavigationAttached); - QML_REGISTER_TYPE(Qt,4,6,Keys,QDeclarativeKeysAttached); - QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QDeclarativeLayoutItem); - QML_REGISTER_TYPE(Qt,4,6,ListView,QDeclarativeListView); - QML_REGISTER_TYPE(Qt,4,6,Loader,QDeclarativeLoader); - QML_REGISTER_TYPE(Qt,4,6,MouseArea,QDeclarativeMouseArea); - QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect); - QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QDeclarativeParticleMotion); - QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QDeclarativeParticleMotionGravity); - QML_REGISTER_TYPE(Qt,4,6,ParticleMotionLinear,QDeclarativeParticleMotionLinear); - QML_REGISTER_TYPE(Qt,4,6,ParticleMotionWander,QDeclarativeParticleMotionWander); - QML_REGISTER_TYPE(Qt,4,6,Particles,QDeclarativeParticles); - QML_REGISTER_TYPE(Qt,4,6,Path,QDeclarativePath); - QML_REGISTER_TYPE(Qt,4,6,PathAttribute,QDeclarativePathAttribute); - QML_REGISTER_TYPE(Qt,4,6,PathCubic,QDeclarativePathCubic); - QML_REGISTER_TYPE(Qt,4,6,PathLine,QDeclarativePathLine); - QML_REGISTER_TYPE(Qt,4,6,PathPercent,QDeclarativePathPercent); - QML_REGISTER_TYPE(Qt,4,6,PathQuad,QDeclarativePathQuad); - QML_REGISTER_TYPE(Qt,4,6,PathView,QDeclarativePathView); - QML_REGISTER_TYPE(Qt,4,6,Pen,QDeclarativePen); - QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator); + qmlRegisterType("Qt",4,6,"AnimatedImage"); + qmlRegisterType("Qt",4,6,"Blur"); + qmlRegisterType("Qt",4,6,"BorderImage"); + qmlRegisterType("Qt",4,6,"Colorize"); + qmlRegisterType("Qt",4,6,"Column"); + qmlRegisterType("Qt",4,6,"Drag"); + qmlRegisterType("Qt",4,6,"DropShadow"); + qmlRegisterType("Qt",4,6,"Flickable"); + qmlRegisterType("Qt",4,6,"Flipable"); + qmlRegisterType("Qt",4,6,"Flow"); + qmlRegisterType("Qt",4,6,"FocusPanel"); + qmlRegisterType("Qt",4,6,"FocusScope"); + qmlRegisterType("Qt",4,6,"Gradient"); + qmlRegisterType("Qt",4,6,"GradientStop"); + qmlRegisterType("Qt",4,6,"GraphicsObjectContainer"); + qmlRegisterType("Qt",4,6,"Grid"); + qmlRegisterType("Qt",4,6,"GridView"); + qmlRegisterType("Qt",4,6,"Image"); + qmlRegisterType("Qt",4,6,"Item"); + qmlRegisterType("Qt",4,6,"KeyNavigation"); + qmlRegisterType("Qt",4,6,"Keys"); + qmlRegisterType("Qt",4,6,"LayoutItem"); + qmlRegisterType("Qt",4,6,"ListView"); + qmlRegisterType("Qt",4,6,"Loader"); + qmlRegisterType("Qt",4,6,"MouseArea"); + qmlRegisterType("Qt",4,6,"Opacity"); + qmlRegisterType("Qt",4,6,"ParticleMotion"); + qmlRegisterType("Qt",4,6,"ParticleMotionGravity"); + qmlRegisterType("Qt",4,6,"ParticleMotionLinear"); + qmlRegisterType("Qt",4,6,"ParticleMotionWander"); + qmlRegisterType("Qt",4,6,"Particles"); + qmlRegisterType("Qt",4,6,"Path"); + qmlRegisterType("Qt",4,6,"PathAttribute"); + qmlRegisterType("Qt",4,6,"PathCubic"); + qmlRegisterType("Qt",4,6,"PathLine"); + qmlRegisterType("Qt",4,6,"PathPercent"); + qmlRegisterType("Qt",4,6,"PathQuad"); + qmlRegisterType("Qt",4,6,"PathView"); + qmlRegisterType("Qt",4,6,"Pen"); + qmlRegisterType("Qt",4,6,"QIntValidator"); #if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) - QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator); - QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator); + qmlRegisterType("Qt",4,7,"QDoubleValidator"); + qmlRegisterType("Qt",4,7,"QRegExpValidator"); #endif - QML_REGISTER_TYPE(Qt,4,6,Rectangle,QDeclarativeRectangle); - QML_REGISTER_TYPE(Qt,4,6,Repeater,QDeclarativeRepeater); - QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation); - QML_REGISTER_TYPE(Qt,4,6,Row,QDeclarativeRow); - QML_REGISTER_TYPE(Qt,4,6,Scale,QGraphicsScale); - QML_REGISTER_TYPE(Qt,4,6,Text,QDeclarativeText); - QML_REGISTER_TYPE(Qt,4,6,TextEdit,QDeclarativeTextEdit); - QML_REGISTER_TYPE(Qt,4,6,TextInput,QDeclarativeTextInput); - QML_REGISTER_TYPE(Qt,4,6,ViewSection,QDeclarativeViewSection); - QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QDeclarativeFlickableVisibleArea); - QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QDeclarativeVisualDataModel); - QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QDeclarativeVisualItemModel); + qmlRegisterType("Qt",4,6,"Rectangle"); + qmlRegisterType("Qt",4,6,"Repeater"); + qmlRegisterType("Qt",4,6,"Rotation"); + qmlRegisterType("Qt",4,6,"Row"); + qmlRegisterType("Qt",4,6,"Scale"); + qmlRegisterType("Qt",4,6,"Text"); + qmlRegisterType("Qt",4,6,"TextEdit"); + qmlRegisterType("Qt",4,6,"TextInput"); + qmlRegisterType("Qt",4,6,"ViewSection"); + qmlRegisterType("Qt",4,6,"VisibleArea"); + qmlRegisterType("Qt",4,6,"VisualDataModel"); + qmlRegisterType("Qt",4,6,"VisualItemModel"); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors); - QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeKeyEvent); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeMouseEvent); - QML_REGISTER_NOCREATE_TYPE(QGraphicsObject); - QML_REGISTER_NOCREATE_TYPE(QGraphicsTransform); - QML_REGISTER_NOCREATE_TYPE(QDeclarativePathElement); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeCurve); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeScaleGrid); - QML_REGISTER_NOCREATE_TYPE(QValidator); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeVisualModel); - QML_REGISTER_NOCREATE_TYPE(QAction); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); #ifdef QT_WEBKIT_LIB - QML_REGISTER_NOCREATE_TYPE(QDeclarativeWebSettings); + qmlRegisterType(); #endif } diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h index 77b7484..2a7a9cf 100644 --- a/src/declarative/qml/qdeclarative.h +++ b/src/declarative/qml/qdeclarative.h @@ -275,6 +275,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, return QDeclarativePrivate::registerType(type); } +#if 0 #define QML_REGISTER_INTERFACE(INTERFACE) \ qmlRegisterInterface(#INTERFACE) @@ -287,6 +288,8 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor, #define QML_REGISTER_NOCREATE_TYPE(CLASS) \ qmlRegisterType() +#endif + class QDeclarativeContext; class QDeclarativeEngine; Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *); diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h index 99587a8..39bd43c 100644 --- a/src/declarative/qml/qdeclarativecustomparser_p.h +++ b/src/declarative/qml/qdeclarativecustomparser_p.h @@ -128,9 +128,10 @@ private: QList exceptions; }; +#if 0 #define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE) - +#endif QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 62fe5b5..41c0f5c 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -146,12 +146,12 @@ static bool qt_QmlQtModule_registered = false; void QDeclarativeEnginePrivate::defineModule() { - QML_REGISTER_TYPE(Qt,4,6,Component,QDeclarativeComponent); - QML_REGISTER_TYPE(Qt,4,6,QtObject,QObject); - QML_REGISTER_TYPE(Qt,4,6,WorkerScript,QDeclarativeWorkerScript); - QML_REGISTER_TYPE(Qt,4,6,WorkerListModel,QDeclarativeWorkerListModel); + qmlRegisterType("Qt",4,6,"Component"); + qmlRegisterType("Qt",4,6,"QtObject"); + qmlRegisterType("Qt",4,6,"WorkerScript"); + qmlRegisterType("Qt",4,6,"WorkerListModel"); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeBinding); + qmlRegisterType(); } QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp index 65bfdc1..9c3b0aa 100644 --- a/src/declarative/util/qdeclarativeutilmodule.cpp +++ b/src/declarative/util/qdeclarativeutilmodule.cpp @@ -75,44 +75,47 @@ void QDeclarativeUtilModule::defineModule() { - QML_REGISTER_TYPE(Qt,4,6,AnchorChanges,QDeclarativeAnchorChanges); - QML_REGISTER_TYPE(Qt,4,6,Behavior,QDeclarativeBehavior); - QML_REGISTER_TYPE(Qt,4,6,Binding,QDeclarativeBind); - QML_REGISTER_TYPE(Qt,4,6,ColorAnimation,QDeclarativeColorAnimation); - QML_REGISTER_TYPE(Qt,4,6,Connections,QDeclarativeConnections); - QML_REGISTER_TYPE(Qt,4,6,EaseFollow,QDeclarativeEaseFollow);; - QML_REGISTER_TYPE(Qt,4,6,FontLoader,QDeclarativeFontLoader); - QML_REGISTER_TYPE(Qt,4,6,ListElement,QDeclarativeListElement); - QML_REGISTER_TYPE(Qt,4,6,NumberAnimation,QDeclarativeNumberAnimation); - QML_REGISTER_TYPE(Qt,4,6,Package,QDeclarativePackage); - QML_REGISTER_TYPE(Qt,4,6,ParallelAnimation,QDeclarativeParallelAnimation); - QML_REGISTER_TYPE(Qt,4,6,ParentAction,QDeclarativeParentAction); - QML_REGISTER_TYPE(Qt,4,6,ParentAnimation,QDeclarativeParentAnimation); - QML_REGISTER_TYPE(Qt,4,6,ParentChange,QDeclarativeParentChange); - QML_REGISTER_TYPE(Qt,4,6,PauseAnimation,QDeclarativePauseAnimation); - QML_REGISTER_TYPE(Qt,4,6,PropertyAction,QDeclarativePropertyAction); - QML_REGISTER_TYPE(Qt,4,6,PropertyAnimation,QDeclarativePropertyAnimation); - QML_REGISTER_TYPE(Qt,4,6,RotationAnimation,QDeclarativeRotationAnimation); - QML_REGISTER_TYPE(Qt,4,6,ScriptAction,QDeclarativeScriptAction); - QML_REGISTER_TYPE(Qt,4,6,SequentialAnimation,QDeclarativeSequentialAnimation); - QML_REGISTER_TYPE(Qt,4,6,SpringFollow,QDeclarativeSpringFollow); - QML_REGISTER_TYPE(Qt,4,6,StateChangeScript,QDeclarativeStateChangeScript); - QML_REGISTER_TYPE(Qt,4,6,StateGroup,QDeclarativeStateGroup); - QML_REGISTER_TYPE(Qt,4,6,State,QDeclarativeState); - QML_REGISTER_TYPE(Qt,4,6,SystemPalette,QDeclarativeSystemPalette); - QML_REGISTER_TYPE(Qt,4,6,Timer,QDeclarativeTimer); - QML_REGISTER_TYPE(Qt,4,6,Transition,QDeclarativeTransition); - QML_REGISTER_TYPE(Qt,4,6,Vector3dAnimation,QDeclarativeVector3dAnimation); + qmlRegisterType("Qt",4,6,"AnchorChanges"); + qmlRegisterType("Qt",4,6,"Behavior"); + qmlRegisterType("Qt",4,6,"Binding"); + qmlRegisterType("Qt",4,6,"ColorAnimation"); + qmlRegisterType("Qt",4,6,"Connections"); + qmlRegisterType("Qt",4,6,"EaseFollow"); + qmlRegisterType("Qt",4,6,"FontLoader"); + qmlRegisterType("Qt",4,6,"ListElement"); + qmlRegisterType("Qt",4,6,"NumberAnimation"); + qmlRegisterType("Qt",4,6,"Package"); + qmlRegisterType("Qt",4,6,"ParallelAnimation"); + qmlRegisterType("Qt",4,6,"ParentAction"); + qmlRegisterType("Qt",4,6,"ParentAnimation"); + qmlRegisterType("Qt",4,6,"ParentChange"); + qmlRegisterType("Qt",4,6,"PauseAnimation"); + qmlRegisterType("Qt",4,6,"PropertyAction"); + qmlRegisterType("Qt",4,6,"PropertyAnimation"); + qmlRegisterType("Qt",4,6,"RotationAnimation"); + qmlRegisterType("Qt",4,6,"ScriptAction"); + qmlRegisterType("Qt",4,6,"SequentialAnimation"); + qmlRegisterType("Qt",4,6,"SpringFollow"); + qmlRegisterType("Qt",4,6,"StateChangeScript"); + qmlRegisterType("Qt",4,6,"StateGroup"); + qmlRegisterType("Qt",4,6,"State"); + qmlRegisterType("Qt",4,6,"SystemPalette"); + qmlRegisterType("Qt",4,6,"Timer"); + qmlRegisterType("Qt",4,6,"Transition"); + qmlRegisterType("Qt",4,6,"Vector3dAnimation"); #ifndef QT_NO_XMLPATTERNS - QML_REGISTER_TYPE(Qt,4,6,XmlListModel,QDeclarativeXmlListModel); - QML_REGISTER_TYPE(Qt,4,6,XmlRole,QDeclarativeXmlListModelRole); + qmlRegisterType("Qt",4,6,"XmlListModel"); + qmlRegisterType("Qt",4,6,"XmlRole"); #endif - QML_REGISTER_NOCREATE_TYPE(QDeclarativeAnchors); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeAbstractAnimation); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeStateOperation); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); - QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, ListModel, QDeclarativeListModel, QDeclarativeListModelParser); - QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, PropertyChanges, QDeclarativePropertyChanges, QDeclarativePropertyChangesParser); - QML_REGISTER_CUSTOM_TYPE(Qt, 4,6, Connections, QDeclarativeConnections, QDeclarativeConnectionsParser); + qmlRegisterCustomType("Qt", 4,6, "ListModel", "QDeclarativeListModel", + new QDeclarativeListModelParser); + qmlRegisterCustomType("Qt", 4, 6, "PropertyChanges", "QDeclarativePropertyChanges", + new QDeclarativePropertyChangesParser); + qmlRegisterCustomType("Qt", 4, 6, "Connections", "QDeclarativeConnections", + new QDeclarativeConnectionsParser); } diff --git a/src/imports/webkit/plugin.cpp b/src/imports/webkit/plugin.cpp index 799fe9e..e3d73ec 100644 --- a/src/imports/webkit/plugin.cpp +++ b/src/imports/webkit/plugin.cpp @@ -54,7 +54,7 @@ public: virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("org.webkit")); - QML_REGISTER_NOCREATE_TYPE(QDeclarativeWebSettings); + qmlRegisterType(); qmlRegisterType(uri,1,0,"WebView"); } }; diff --git a/src/imports/widgets/widgets.cpp b/src/imports/widgets/widgets.cpp index ec21cc4..bc18e8a 100644 --- a/src/imports/widgets/widgets.cpp +++ b/src/imports/widgets/widgets.cpp @@ -118,15 +118,15 @@ public: { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.widgets")); - QML_REGISTER_INTERFACE(QGraphicsLayoutItem); - QML_REGISTER_INTERFACE(QGraphicsLayout); + qmlRegisterInterface("QGraphicsLayoutItem"); + qmlRegisterInterface("QGraphicsLayout"); qmlRegisterType(uri,4,6,"QGraphicsLinearLayoutStretchItem"); qmlRegisterType(uri,4,6,"QGraphicsLinearLayout"); qmlRegisterType(uri,4,6,"QGraphicsGridLayout"); qmlRegisterExtendedType(uri,4,6,"QGraphicsView"); qmlRegisterExtendedType(uri,4,6,"QGraphicsScene"); qmlRegisterExtendedType(uri,4,6,"QGraphicsWidget"); - QML_REGISTER_INTERFACE(QGraphicsItem); + qmlRegisterInterface("QGraphicsItem"); } }; diff --git a/tools/qml/qdeclarativefolderlistmodel.cpp b/tools/qml/qdeclarativefolderlistmodel.cpp index 58bf59b..d36033d 100644 --- a/tools/qml/qdeclarativefolderlistmodel.cpp +++ b/tools/qml/qdeclarativefolderlistmodel.cpp @@ -413,7 +413,7 @@ void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) void QDeclarativeFolderListModel::registerTypes() { - QML_REGISTER_TYPE(Qt,4,6,FolderListModel,QDeclarativeFolderListModel); + qmlRegisterType("Qt",4,6,"FolderListModel"); } QT_END_NAMESPACE diff --git a/tools/qml/qfxtester.cpp b/tools/qml/qfxtester.cpp index 638a3c9..28bbf5e 100644 --- a/tools/qml/qfxtester.cpp +++ b/tools/qml/qfxtester.cpp @@ -372,10 +372,10 @@ void QDeclarativeTester::updateCurrentTime(int msec) void QDeclarativeTester::registerTypes() { - QML_REGISTER_TYPE(Qt.VisualTest, 4,6, VisualTest, QDeclarativeVisualTest); - QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Frame, QDeclarativeVisualTestFrame); - QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Mouse, QDeclarativeVisualTestMouse); - QML_REGISTER_TYPE(Qt.VisualTest, 4,6, Key, QDeclarativeVisualTestKey); + qmlRegisterType("Qt.VisualTest", 4,6, "VisualTest"); + qmlRegisterType("Qt.VisualTest", 4,6, "Frame"); + qmlRegisterType("Qt.VisualTest", 4,6, "Mouse"); + qmlRegisterType("Qt.VisualTest", 4,6, "Key"); } QT_END_NAMESPACE diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 7da3f5a..f12ec6f 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -1460,7 +1460,7 @@ void QDeclarativeViewer::setUseNativeFileBrowser(bool use) void QDeclarativeViewer::registerTypes() { - QML_REGISTER_TYPE(QDeclarativeViewer, 1, 0, Screen, Screen); + qmlRegisterType("QDeclarativeViewer", 1, 0, "Screen"); } QT_END_NAMESPACE -- cgit v0.12