diff options
Diffstat (limited to 'src/declarative')
42 files changed, 285 insertions, 815 deletions
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<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS) - -#define QML_REGISTER_NOCREATE_TYPE(CLASS) \ - qmlRegisterType<CLASS>(#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>(#INTERFACE); +#define QML_REGISTER_INTERFACE(INTERFACE) \ + qmlRegisterInterface<INTERFACE>(#INTERFACE) -#define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \ - static int registerExtended##TYPE = qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE); +#define QML_REGISTER_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \ + qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE) -#define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE) \ - static int defineType##TYPE = qmlRegisterType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE); +#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \ + qmlRegisterType<CLASS>(#URI, VMAJ, VMIN, #TYPE, #CLASS) -#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \ - static int registerExtendedNoCreate##TYPE = qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE); - -#define QML_DEFINE_NOCREATE_TYPE(TYPE) \ - static int registerNoCreate##TYPE = qmlRegisterType<TYPE>(#TYPE); - -#else - -#define QML_DEFINE_INTERFACE(INTERFACE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<INTERFACE *,0,0>::instance(qmlRegisterInterface<INTERFACE>(#INTERFACE)); - -#define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN)>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)); - -#define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,(VERSION_MAJ), (VERSION_MIN)>::instance(qmlRegisterType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE)); - -#define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,0,0>::instance(qmlRegisterExtendedType<TYPE,EXTENSION>(#TYPE)); - -#define QML_DEFINE_NOCREATE_TYPE(TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define<TYPE *,0,0>::instance(qmlRegisterType<TYPE>(#TYPE)); - -#endif +#define QML_REGISTER_NOCREATE_TYPE(CLASS) \ + qmlRegisterType<CLASS>(#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<QmlError> exceptions; }; -#if defined(Q_OS_SYMBIAN) -# define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ - static int defineCustomType##NAME = qmlRegisterCustomType<TYPE>(#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<TYPE *,(VERSION_MAJ), (VERSION_MIN)>::instance(qmlRegisterCustomType<TYPE>(#URI, VERSION_MAJ, VERSION_MIN, #NAME, #TYPE, new CUSTOMTYPE)); -#endif +#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \ + qmlRegisterCustomType<TYPE>(#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 <private/qscriptdeclarativeclass_p.h> #include <private/qmlgraphicsitemsmodule_p.h> +#include <private/qmlgraphicsutilmodule_p.h> #ifdef Q_OS_WIN // for %APPDATA% #include <qt_windows.h> @@ -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<QmlScriptEngine*>(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<QVariant> 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/widgets/graphicswidgets_p.h b/src/declarative/util/qmlgraphicsutilmodule_p.h index 6255d2b..68a16a9 100644 --- a/src/declarative/widgets/graphicswidgets_p.h +++ b/src/declarative/util/qmlgraphicsutilmodule_p.h @@ -39,30 +39,25 @@ ** ****************************************************************************/ -#ifndef GRAPHICSWIDGETS_H -#define GRAPHICSWIDGETS_H +#ifndef QMLGRAPHICSUTILMODULE_H +#define QMLGRAPHICSUTILMODULE_H #include <qml.h> -#include <QtGui/QGraphicsScene> -#include <QtGui/QGraphicsView> -#include <QtGui/QGraphicsWidget> -#include <QtGui/QGraphicsItem> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -QT_END_NAMESPACE +class QmlGraphicsUtilModule +{ +public: + static void defineModule(); +}; -QML_DECLARE_TYPE(QGraphicsView) -QML_DECLARE_TYPE_HASMETATYPE(QGraphicsScene) -QML_DECLARE_TYPE(QGraphicsWidget) -QML_DECLARE_TYPE(QGraphicsObject) -QML_DECLARE_INTERFACE_HASMETATYPE(QGraphicsItem) +QT_END_NAMESPACE QT_END_HEADER -#endif // GRAPHICSWIDGETS_H +#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<QmlCustomParserProperty> &); - bool compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data); - void setCustomData(QObject *, const QByteArray &); - -private: - bool definesEmptyList(const QString &); -}; - bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data) { QList<QVariant> 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 <qmllistmodel.moc> 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 <qml.h> +#include <private/qmlcustomparser_p.h> #include <QtCore/QObject> #include <QtCore/QStringList> @@ -98,9 +99,40 @@ private: ModelNode *_root; }; +// ### FIXME +class QmlListElement : public QObject +{ +Q_OBJECT +}; + +class QmlListModelParser : public QmlCustomParser +{ +public: + QByteArray compile(const QList<QmlCustomParserProperty> &); + 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<ListInstruction> &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<QObject *, QmlPackageAttached *> attached; -private: - QString _name; -}; - QHash<QObject *, QmlPackageAttached *> 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 <qmlpackage.moc> +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<QObject *, QmlPackageAttached *> 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<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QmlCustomParserProperty &prop); - - virtual QByteArray compile(const QList<QmlCustomParserProperty> &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - void QmlPropertyChangesParser::compileList(QList<QPair<QByteArray, QVariant> > &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 <private/qmlcustomparser_p.h> QT_BEGIN_HEADER @@ -75,6 +76,16 @@ public: virtual ActionList actions(); }; +class QmlPropertyChangesParser : public QmlCustomParser +{ +public: + void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QmlCustomParserProperty &prop); + + virtual QByteArray compile(const QList<QmlCustomParserProperty> &); + 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 <QtGui/qgraphicswidget.h> -#include <QtCore/qdebug.h> - -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<QGraphicsLayoutItem*>(parent()), _stretch); - } - - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a) - { - if (_alignment == a) - return; - - _alignment = a; - emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(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<QGraphicsLayoutItem*, LinearLayoutAttached*> QGraphicsLinearLayoutObject::attachedProperties; -LinearLayoutAttached *QGraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) -{ - // ### This is not allowed - you must attach to any object - if (!qobject_cast<QGraphicsLayoutItem*>(obj)) - return 0; - LinearLayoutAttached *rv = new LinearLayoutAttached(obj); - attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(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<QGraphicsLayoutItem*>(parent()), _row); - } - - int column() const { return _column; } - void setColumn(int c) - { - if (_column == c) - return; - - _column = c; - //emit columnChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _column); - } - - int rowSpan() const { return _rowspan; } - void setRowSpan(int rs) - { - if (_rowspan == rs) - return; - - _rowspan = rs; - //emit rowSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _rowSpan); - } - - int columnSpan() const { return _colspan; } - void setColumnSpan(int cs) - { - if (_colspan == cs) - return; - - _colspan = cs; - //emit columnSpanChanged(reinterpret_cast<QGraphicsLayoutItem*>(parent()), _columnSpan); - } - - Qt::Alignment alignment() const { return _alignment; } - void setAlignment(Qt::Alignment a) - { - if (_alignment == a) - return; - - _alignment = a; - //emit alignmentChanged(reinterpret_cast<QGraphicsLayoutItem*>(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<QGraphicsLayoutItem*>(wid))) { - int row = static_cast<GridLayoutAttached *>(obj)->row(); - int column = static_cast<GridLayoutAttached *>(obj)->column(); - int rowSpan = static_cast<GridLayoutAttached *>(obj)->rowSpan(); - int columnSpan = static_cast<GridLayoutAttached *>(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<QGraphicsLayoutItem*, GridLayoutAttached*> QGraphicsGridLayoutObject::attachedProperties; -GridLayoutAttached *QGraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) -{ - // ### This is not allowed - you must attach to any object - if (!qobject_cast<QGraphicsLayoutItem*>(obj)) - return 0; - GridLayoutAttached *rv = new GridLayoutAttached(obj); - attachedProperties.insert(qobject_cast<QGraphicsLayoutItem*>(obj), rv); - return rv; -} - -QT_END_NAMESPACE - -#include <graphicslayouts.moc> 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 <QtGui/QGraphicsLinearLayout> -#include <QtGui/QGraphicsGridLayout> - -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<QGraphicsLayoutItem> 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<QGraphicsLayoutItem> children() { return QmlListProperty<QGraphicsLayoutItem>(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<QGraphicsLayoutItem*, LinearLayoutAttached*> attachedProperties; - - static void children_append(QmlListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) { - static_cast<QGraphicsLinearLayoutObject*>(prop->object)->insertLayoutItem(-1, item); - } - - static void children_clear(QmlListProperty<QGraphicsLayoutItem> *prop) { - static_cast<QGraphicsLinearLayoutObject*>(prop->object)->clearChildren(); - } - - static int children_count(QmlListProperty<QGraphicsLayoutItem> *prop) { - return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QmlListProperty<QGraphicsLayoutItem> *prop, int index) { - return static_cast<QGraphicsLinearLayoutObject*>(prop->object)->itemAt(index); - } -}; - -class GridLayoutAttached; -class QGraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QmlListProperty<QGraphicsLayoutItem> 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<QGraphicsLayoutItem> children() { return QmlListProperty<QGraphicsLayoutItem>(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<QGraphicsLayoutItem*, GridLayoutAttached*> attachedProperties; - - static void children_append(QmlListProperty<QGraphicsLayoutItem> *prop, QGraphicsLayoutItem *item) { - static_cast<QGraphicsGridLayoutObject*>(prop->object)->addLayoutItem(item); - } - - static void children_clear(QmlListProperty<QGraphicsLayoutItem> *prop) { - static_cast<QGraphicsGridLayoutObject*>(prop->object)->clearChildren(); - } - - static int children_count(QmlListProperty<QGraphicsLayoutItem> *prop) { - return static_cast<QGraphicsGridLayoutObject*>(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QmlListProperty<QGraphicsLayoutItem> *prop, int index) { - return static_cast<QGraphicsGridLayoutObject*>(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<QGraphicsView *>(parent())->scene(); } - void setScene(QGraphicsScene *scene) - { - static_cast<QGraphicsView *>(parent())->setScene(scene); - } -}; - -class QGraphicsSceneDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QmlListProperty<QObject> children READ children) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsSceneDeclarativeUI(QObject *other) : QObject(other) {} - - QmlListProperty<QObject> children() { return QmlListProperty<QObject>(this->parent(), 0, children_append); } - -private: - static void children_append(QmlListProperty<QObject> *prop, QObject *o) { - if (QGraphicsObject *go = qobject_cast<QGraphicsObject *>(o)) - static_cast<QGraphicsScene *>(prop->object)->addItem(go); - } -}; - -class QGraphicsWidgetDeclarativeUI : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QmlListProperty<QGraphicsItem> children READ children) - Q_PROPERTY(QGraphicsLayout *layout READ layout WRITE setLayout) - Q_CLASSINFO("DefaultProperty", "children") -public: - QGraphicsWidgetDeclarativeUI(QObject *other) : QObject(other) {} - - QmlListProperty<QGraphicsItem> children() { return QmlListProperty<QGraphicsItem>(this, 0, children_append); } - - QGraphicsLayout *layout() const { return static_cast<QGraphicsWidget *>(parent())->layout(); } - void setLayout(QGraphicsLayout *lo) - { - static_cast<QGraphicsWidget *>(parent())->setLayout(lo); - } - -private: - void setItemParent(QGraphicsItem *wid) - { - wid->setParentItem(static_cast<QGraphicsWidget *>(parent())); - } - - static void children_append(QmlListProperty<QGraphicsItem> *prop, QGraphicsItem *i) { - static_cast<QGraphicsWidgetDeclarativeUI*>(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 <graphicswidgets.moc> 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 |