diff --git a/doc/src/declarative/whatsnew.qdoc b/doc/src/declarative/whatsnew.qdoc index e20efa7392..0bf0fe6f59 100644 --- a/doc/src/declarative/whatsnew.qdoc +++ b/doc/src/declarative/whatsnew.qdoc @@ -43,6 +43,19 @@ set binding when its \e when clause becomes false. QDeclarativeExpression can now be directly (and more efficiently) constructed from a QDeclarativeScriptString. +\section2 QtQuick 1 is now a separate library and module + +Writing C++ applications using QtQuick 1 specific API, i.e. QDeclarativeView or QDeclarativeItem +requires adding the "qtquick1" module to the .pro file, e.g. QT += declarative qtquick1 + +QDeclarativeView and QDeclarativeItem headers are now in the QtQuick 1 module, i.e. +#include +#include + +"import QtQuick 1.0" loads the module dynamically. To deploy QtQuick 1 applications +the library (lib/libQtQuick1*) and plugin (imports/QtQuick/) must be installed. + + \section1 Qt 4.7.4 includes QtQuick 1.1 QtQuick 1.1 is a minor feature update. \e {import QtQuick 1.1} to use the new diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro index eaa48cd901..5a915034dc 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += declarative qtquick1 DESTDIR = ImageProviderCore TARGET = qmlimageproviderplugin diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro index 74d8db321d..ba0498eaf8 100644 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = networkaccessmanagerfactory DEPENDPATH += . INCLUDEPATH += . -QT += declarative network +QT += declarative network qtquick1 # Input SOURCES += main.cpp diff --git a/examples/declarative/cppextensions/qgraphicslayouts/layoutitem/layoutitem.pro b/examples/declarative/cppextensions/qgraphicslayouts/layoutitem/layoutitem.pro index 77c6b2a287..32e81fe557 100644 --- a/examples/declarative/cppextensions/qgraphicslayouts/layoutitem/layoutitem.pro +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutitem/layoutitem.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . -QT += declarative +QT += declarative qtquick1 SOURCES += main.cpp RESOURCES += layoutitem.qrc diff --git a/examples/declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.pro b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.pro index ae6373d49b..2d9e7bc04e 100644 --- a/examples/declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.pro +++ b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = qgraphicsgridlayout -QT += declarative +QT += declarative qtquick1 SOURCES += \ gridlayout.cpp \ diff --git a/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.pro b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.pro index 79eb6ff8b4..c2e9b57fd1 100644 --- a/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.pro +++ b/examples/declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = qgraphicslinearlayout -QT += declarative +QT += declarative qtquick1 SOURCES += \ linearlayout.cpp \ diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp index 9e7ab5f120..93b9a5280b 100644 --- a/examples/declarative/minehunt/main.cpp +++ b/examples/declarative/minehunt/main.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include -#include +#include #include #include diff --git a/examples/declarative/minehunt/minehunt.pro b/examples/declarative/minehunt/minehunt.pro index 67e25dcfad..fe464fb498 100644 --- a/examples/declarative/minehunt/minehunt.pro +++ b/examples/declarative/minehunt/minehunt.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = minehunt -QT += declarative +QT += declarative qtquick1 # Input HEADERS += minehunt.h diff --git a/examples/declarative/modelviews/objectlistmodel/main.cpp b/examples/declarative/modelviews/objectlistmodel/main.cpp index 812d8addf1..345b5eec87 100644 --- a/examples/declarative/modelviews/objectlistmodel/main.cpp +++ b/examples/declarative/modelviews/objectlistmodel/main.cpp @@ -43,8 +43,8 @@ #include #include #include -#include -#include +#include +#include #include "dataobject.h" @@ -64,7 +64,8 @@ int main(int argc, char ** argv) dataList.append(new DataObject("Item 3", "blue")); dataList.append(new DataObject("Item 4", "yellow")); - QDeclarativeView view; + QSGView view; + view.setResizeMode(QSGView::SizeRootObjectToView); QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); //![0] diff --git a/examples/declarative/modelviews/objectlistmodel/view.qml b/examples/declarative/modelviews/objectlistmodel/view.qml index 264289f3bf..6dab6d95f0 100644 --- a/examples/declarative/modelviews/objectlistmodel/view.qml +++ b/examples/declarative/modelviews/objectlistmodel/view.qml @@ -38,12 +38,11 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 //![0] ListView { width: 100; height: 100 - anchors.fill: parent model: myModel delegate: Rectangle { diff --git a/examples/declarative/modelviews/stringlistmodel/main.cpp b/examples/declarative/modelviews/stringlistmodel/main.cpp index b3452baf5b..c69963b89a 100644 --- a/examples/declarative/modelviews/stringlistmodel/main.cpp +++ b/examples/declarative/modelviews/stringlistmodel/main.cpp @@ -43,8 +43,8 @@ #include #include #include -#include -#include +#include +#include /* @@ -63,7 +63,7 @@ int main(int argc, char ** argv) dataList.append("Item 3"); dataList.append("Item 4"); - QDeclarativeView view; + QSGView view; QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); //![0] diff --git a/examples/declarative/modelviews/stringlistmodel/view.qml b/examples/declarative/modelviews/stringlistmodel/view.qml index 9c65d80514..d4dfb3e97b 100644 --- a/examples/declarative/modelviews/stringlistmodel/view.qml +++ b/examples/declarative/modelviews/stringlistmodel/view.qml @@ -38,12 +38,11 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 //![0] ListView { width: 100; height: 100 - anchors.fill: parent model: myModel delegate: Rectangle { diff --git a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro index 0f0416718c..77cc4cdfca 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += declarative qtquick1 HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro index 0f0416718c..77cc4cdfca 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += declarative qtquick1 HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro index 0f0416718c..77cc4cdfca 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += declarative qtquick1 HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro index c3f5402aea..9942ccd0a9 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += declarative qtquick1 HEADERS += piechart.h \ pieslice.h diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro index c3f5402aea..9942ccd0a9 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -1,4 +1,4 @@ -QT += declarative +QT += declarative qtquick1 HEADERS += piechart.h \ pieslice.h diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro index aa1fb0129b..e5963ee3e5 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative +QT += declarative qtquick1 DESTDIR = lib OBJECTS_DIR = tmp diff --git a/modules/qt_qtquick1.pri b/modules/qt_qtquick1.pri new file mode 100644 index 0000000000..173c3da684 --- /dev/null +++ b/modules/qt_qtquick1.pri @@ -0,0 +1,17 @@ +QT.qtquick1.VERSION = 5.0.0 +QT.qtquick1.MAJOR_VERSION = 5 +QT.qtquick1.MINOR_VERSION = 0 +QT.qtquick1.PATCH_VERSION = 0 + +QT.qtquick1.name = QtQuick1 +QT.qtquick1.bins = $$QT_MODULE_BIN_BASE +QT.qtquick1.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtQuick1 +QT.qtquick1.private_includes = $$QT_MODULE_INCLUDE_BASE/QtQuick1/$$QT.qtquick1.VERSION +QT.qtquick1.sources = $$QT_MODULE_BASE/src/qtquick1 +QT.qtquick1.libs = $$QT_MODULE_LIB_BASE +QT.qtquick1.plugins = $$QT_MODULE_PLUGIN_BASE +QT.qtquick1.imports = $$QT_MODULE_IMPORT_BASE +QT.qtquick1.depends = declarative +QT.qtquick1.DEFINES = QT_DECLARATIVE_LIB + +QT_CONFIG += qtquick1 diff --git a/src/declarative/debugger/qdeclarativedebugtrace_p.h b/src/declarative/debugger/qdeclarativedebugtrace_p.h index 6681d28846..f2710cde93 100644 --- a/src/declarative/debugger/qdeclarativedebugtrace_p.h +++ b/src/declarative/debugger/qdeclarativedebugtrace_p.h @@ -63,7 +63,7 @@ struct QDeclarativeDebugData }; class QUrl; -class Q_AUTOTEST_EXPORT QDeclarativeDebugTrace : public QDeclarativeDebugService +class Q_DECLARATIVE_EXPORT QDeclarativeDebugTrace : public QDeclarativeDebugService { public: enum Message { diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index 5cb1d9570c..a43dbdac51 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -28,7 +28,6 @@ HEADERS += qtdeclarativeversion.h #modules include(util/util.pri) -include(graphicsitems/graphicsitems.pri) include(qml/qml.pri) include(debugger/debugger.pri) include(scenegraph/scenegraph.pri) diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp deleted file mode 100644 index 57a91c4b57..0000000000 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/**************************************************************************** -** -** 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$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativeitemsmodule_p.h" - -#include -#include -#include - -#include "private/qdeclarativeevents_p_p.h" -#include "private/qdeclarativescalegrid_p_p.h" -#include "private/qdeclarativeanimatedimage_p.h" -#include "private/qdeclarativeborderimage_p.h" -#include "private/qdeclarativepositioners_p.h" -#include "private/qdeclarativemousearea_p.h" -#include "private/qdeclarativeflickable_p.h" -#include "private/qdeclarativeflickable_p_p.h" -#include "private/qdeclarativeflipable_p.h" -#include "private/qdeclarativefocuspanel_p.h" -#include "private/qdeclarativefocusscope_p.h" -#include "private/qdeclarativegridview_p.h" -#include "private/qdeclarativeimage_p.h" -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativelayoutitem_p.h" -#include "private/qdeclarativelistview_p.h" -#include "private/qdeclarativeloader_p.h" -#include "private/qdeclarativemousearea_p.h" -#include "private/qdeclarativepath_p.h" -#include "private/qdeclarativepathview_p.h" -#include "private/qdeclarativerectangle_p.h" -#include "private/qdeclarativerepeater_p.h" -#include "private/qdeclarativetranslate_p.h" -#include "private/qdeclarativetext_p.h" -#include "private/qdeclarativetextedit_p.h" -#include "private/qdeclarativetextinput_p.h" -#include "private/qdeclarativevisualitemmodel_p.h" -#include "private/qdeclarativegraphicswidget_p.h" -#ifdef QT_WEBKIT_LIB -#include "private/qdeclarativewebview_p.h" -#include "private/qdeclarativewebview_p_p.h" -#endif -#include "private/qdeclarativeanchors_p.h" -#include "private/qdeclarativepincharea_p.h" - -static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent) -{ - QGraphicsObject* gobj = qobject_cast(obj); - if (!gobj) - return QDeclarativePrivate::IncompatibleObject; - - QGraphicsObject* gparent = qobject_cast(parent); - if (!gparent) - return QDeclarativePrivate::IncompatibleParent; - - gobj->setParentItem(gparent); - return QDeclarativePrivate::Parented; -} - -void QDeclarativeItemModule::defineModule() -{ - QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qgraphicsobject_autoParent }; - QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent); -#ifdef QT_NO_MOVIE - qmlRegisterTypeNotAvailable("QtQuick",1,0,"AnimatedImage", - qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie")); -#else - qmlRegisterType("QtQuick",1,0,"AnimatedImage"); -#endif - qmlRegisterType("QtQuick",1,0,"BorderImage"); - qmlRegisterType("QtQuick",1,0,"Column"); - qmlRegisterType("QtQuick",1,0,"Drag"); - qmlRegisterType("QtQuick",1,0,"Flickable"); - qmlRegisterType("QtQuick",1,0,"Flipable"); - qmlRegisterType("QtQuick",1,0,"Flow"); - qmlRegisterType("QtQuick",1,0,"FocusPanel"); - qmlRegisterType("QtQuick",1,0,"FocusScope"); - qmlRegisterType("QtQuick",1,0,"Gradient"); - qmlRegisterType("QtQuick",1,0,"GradientStop"); - qmlRegisterType("QtQuick",1,0,"Grid"); - qmlRegisterType("QtQuick",1,0,"GridView"); - qmlRegisterType("QtQuick",1,0,"Image"); - qmlRegisterType("QtQuick",1,0,"Item"); - qmlRegisterType("QtQuick",1,0,"LayoutItem"); - qmlRegisterType("QtQuick",1,0,"ListView"); - qmlRegisterType("QtQuick",1,0,"Loader"); - qmlRegisterType("QtQuick",1,0,"MouseArea"); - qmlRegisterType("QtQuick",1,0,"Path"); - qmlRegisterType("QtQuick",1,0,"PathAttribute"); - qmlRegisterType("QtQuick",1,0,"PathCubic"); - qmlRegisterType("QtQuick",1,0,"PathLine"); - qmlRegisterType("QtQuick",1,0,"PathPercent"); - qmlRegisterType("QtQuick",1,0,"PathQuad"); - qmlRegisterType("QtQuick",1,0,"PathView"); -#ifndef QT_NO_VALIDATOR - qmlRegisterType("QtQuick",1,0,"IntValidator"); - qmlRegisterType("QtQuick",1,0,"DoubleValidator"); - qmlRegisterType("QtQuick",1,0,"RegExpValidator"); -#endif - qmlRegisterType("QtQuick",1,0,"Rectangle"); - qmlRegisterType("QtQuick",1,0,"Repeater"); - qmlRegisterType("QtQuick",1,0,"Rotation"); - qmlRegisterType("QtQuick",1,0,"Row"); - qmlRegisterType("QtQuick",1,0,"Translate"); - qmlRegisterType("QtQuick",1,0,"Scale"); - qmlRegisterType("QtQuick",1,0,"Text"); - qmlRegisterType("QtQuick",1,0,"TextEdit"); -#ifndef QT_NO_LINEEDIT - qmlRegisterType("QtQuick",1,0,"TextInput"); -#endif - qmlRegisterType("QtQuick",1,0,"ViewSection"); - qmlRegisterType("QtQuick",1,0,"VisualDataModel"); - qmlRegisterType("QtQuick",1,0,"VisualItemModel"); - - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("QtQuick",1,0,"QGraphicsWidget"); - qmlRegisterExtendedType("QtQuick",1,0,"QGraphicsWidget"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); -#ifndef QT_NO_VALIDATOR - qmlRegisterType(); -#endif - qmlRegisterType(); -#ifndef QT_NO_ACTION - qmlRegisterType(); -#endif - qmlRegisterType(); - qmlRegisterType(); -#ifndef QT_NO_GRAPHICSEFFECT - qmlRegisterType(); -#endif - - qmlRegisterUncreatableType("QtQuick",1,0,"KeyNavigation",QDeclarativeKeyNavigationAttached::tr("KeyNavigation is only available via attached properties")); - qmlRegisterUncreatableType("QtQuick",1,0,"Keys",QDeclarativeKeysAttached::tr("Keys is only available via attached properties")); - - // QtQuick 1.1 items - qmlRegisterType("QtQuick",1,1,"PinchArea"); - qmlRegisterType("QtQuick",1,1,"Pinch"); - qmlRegisterType(); - qmlRegisterType("QtQuick",1,1,"Item"); - qmlRegisterType("QtQuick",1,1,"MouseArea"); - qmlRegisterType("QtQuick",1,1,"Flickable"); - qmlRegisterType("QtQuick",1,1,"ListView"); - qmlRegisterType("QtQuick",1,1,"GridView"); - qmlRegisterType("QtQuick",1,1,"Row"); - qmlRegisterType("QtQuick",1,1,"Grid"); - qmlRegisterType("QtQuick",1,1,"Flow"); - qmlRegisterType("QtQuick",1,1,"Repeater"); - qmlRegisterType("QtQuick",1,1,"Text"); - qmlRegisterType("QtQuick",1,1,"TextEdit"); -#ifndef QT_NO_LINEEDIT - qmlRegisterType("QtQuick",1,1,"TextInput"); -#endif - qmlRegisterRevision("QtQuick",1,1); - qmlRegisterRevision("QtQuick",1,0); - qmlRegisterRevision("QtQuick",1,1); - qmlRegisterRevision("QtQuick",1,0); - qmlRegisterRevision("QtQuick",1,1); - qmlRegisterUncreatableType("QtQuick",1,1,"LayoutMirroring", QDeclarativeLayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties")); - -#ifndef QT_NO_IMPORT_QT47_QML -#ifdef QT_NO_MOVIE - qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage", - qApp->translate("QDeclarativeAnimatedImage","Qt was built without support for QMovie")); -#else - qmlRegisterType("Qt",4,7,"AnimatedImage"); -#endif - qmlRegisterType("Qt",4,7,"BorderImage"); - qmlRegisterType("Qt",4,7,"Column"); - qmlRegisterType("Qt",4,7,"Drag"); - qmlRegisterType("Qt",4,7,"Flickable"); - qmlRegisterType("Qt",4,7,"Flipable"); - qmlRegisterType("Qt",4,7,"Flow"); - qmlRegisterType("Qt",4,7,"FocusPanel"); - qmlRegisterType("Qt",4,7,"FocusScope"); - qmlRegisterType("Qt",4,7,"Gradient"); - qmlRegisterType("Qt",4,7,"GradientStop"); - qmlRegisterType("Qt",4,7,"Grid"); - qmlRegisterType("Qt",4,7,"GridView"); - qmlRegisterType("Qt",4,7,"Image"); - qmlRegisterType("Qt",4,7,"Item"); - qmlRegisterType("Qt",4,7,"LayoutItem"); - qmlRegisterType("Qt",4,7,"ListView"); - qmlRegisterType("Qt",4,7,"Loader"); - qmlRegisterType("Qt",4,7,"MouseArea"); - qmlRegisterType("Qt",4,7,"Path"); - qmlRegisterType("Qt",4,7,"PathAttribute"); - qmlRegisterType("Qt",4,7,"PathCubic"); - qmlRegisterType("Qt",4,7,"PathLine"); - qmlRegisterType("Qt",4,7,"PathPercent"); - qmlRegisterType("Qt",4,7,"PathQuad"); - qmlRegisterType("Qt",4,7,"PathView"); -#ifndef QT_NO_VALIDATOR - qmlRegisterType("Qt",4,7,"IntValidator"); - qmlRegisterType("Qt",4,7,"DoubleValidator"); - qmlRegisterType("Qt",4,7,"RegExpValidator"); -#endif - qmlRegisterType("Qt",4,7,"Rectangle"); - qmlRegisterType("Qt",4,7,"Repeater"); - qmlRegisterType("Qt",4,7,"Rotation"); - qmlRegisterType("Qt",4,7,"Row"); - qmlRegisterType("Qt",4,7,"Translate"); - qmlRegisterType("Qt",4,7,"Scale"); - qmlRegisterType("Qt",4,7,"Text"); - qmlRegisterType("Qt",4,7,"TextEdit"); -#ifndef QT_NO_LINEEDIT - qmlRegisterType("Qt",4,7,"TextInput"); -#endif - qmlRegisterType("Qt",4,7,"ViewSection"); - qmlRegisterType("Qt",4,7,"VisualDataModel"); - qmlRegisterType("Qt",4,7,"VisualItemModel"); - - qmlRegisterType("Qt",4,7,"QGraphicsWidget"); - qmlRegisterExtendedType("Qt",4,7,"QGraphicsWidget"); - - qmlRegisterUncreatableType("Qt",4,7,"KeyNavigation",QDeclarativeKeyNavigationAttached::tr("KeyNavigation is only available via attached properties")); - qmlRegisterUncreatableType("Qt",4,7,"Keys",QDeclarativeKeysAttached::tr("Keys is only available via attached properties")); -#endif -} diff --git a/src/declarative/items/qsgitem.cpp b/src/declarative/items/qsgitem.cpp index 2b6f5573aa..b4fbacb90b 100644 --- a/src/declarative/items/qsgitem.cpp +++ b/src/declarative/items/qsgitem.cpp @@ -48,9 +48,7 @@ #include "qsgevents_p_p.h" -#include #include -#include #include #include #include @@ -1311,7 +1309,7 @@ void QSGItemPrivate::data_append(QDeclarativeListProperty *prop, QObjec // This test is measurably (albeit only slightly) faster than qobject_cast<>() const QMetaObject *mo = o->metaObject(); while (mo && mo != &QSGItem::staticMetaObject) { - if (mo == &QDeclarativeItem::staticMetaObject) + if (mo == &QGraphicsObject::staticMetaObject) qWarning("Cannot add a QtQuick 1.0 item (%s) into a QtQuick 2.0 scene!", o->metaObject()->className()); mo = mo->d.superdata; } diff --git a/src/declarative/items/qsgitem.h b/src/declarative/items/qsgitem.h index e7d9d0aa0a..12e93603c7 100644 --- a/src/declarative/items/qsgitem.h +++ b/src/declarative/items/qsgitem.h @@ -82,6 +82,7 @@ protected Q_SLOTS: Q_DECLARE_PRIVATE(QSGTransform); }; +class QDeclarativeV8Function; class QDeclarativeState; class QSGAnchorLine; class QDeclarativeTransition; diff --git a/src/declarative/items/qsgtext_p_p.h b/src/declarative/items/qsgtext_p_p.h index 0d4a9d2d18..050e3984ab 100644 --- a/src/declarative/items/qsgtext_p_p.h +++ b/src/declarative/items/qsgtext_p_p.h @@ -60,8 +60,6 @@ #include #include -#include - QT_BEGIN_NAMESPACE class QTextLayout; diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h index da9fc76f4a..9c434ea557 100644 --- a/src/declarative/qml/qdeclarative.h +++ b/src/declarative/qml/qdeclarative.h @@ -410,6 +410,9 @@ QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true) return qmlAttachedPropertiesObject(&idx, obj, &T::staticMetaObject, create); } +// For the use of QtQuick1 module +Q_DECLARATIVE_EXPORT void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor); + /*! This function may be used to register a module API provider \a callback in a particular \a uri with a version specified in \a versionMajor and \a versionMinor. diff --git a/src/declarative/qml/qdeclarativeboundsignal_p.h b/src/declarative/qml/qdeclarativeboundsignal_p.h index bc1cd3ba49..42852131f5 100644 --- a/src/declarative/qml/qdeclarativeboundsignal_p.h +++ b/src/declarative/qml/qdeclarativeboundsignal_p.h @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE -class QDeclarativeAbstractBoundSignal : public QObject +class Q_DECLARATIVE_EXPORT QDeclarativeAbstractBoundSignal : public QObject { Q_OBJECT public: @@ -70,7 +70,7 @@ class QDeclarativeAbstractBoundSignal : public QObject }; class QDeclarativeBoundSignalParameters; -class QDeclarativeBoundSignal : public QDeclarativeAbstractBoundSignal +class Q_DECLARATIVE_EXPORT QDeclarativeBoundSignal : public QDeclarativeAbstractBoundSignal { public: QDeclarativeBoundSignal(QObject *scope, const QMetaMethod &signal, QObject *parent); diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 7571704f19..d0fd3ae4f4 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1356,7 +1356,7 @@ bool QDeclarativeCompiler::buildSubObject(QDeclarativeParser::Object *obj, const int QDeclarativeCompiler::componentTypeRef() { - QDeclarativeType *t = QDeclarativeMetaType::qmlType("QtQuick/Component",1,0); + QDeclarativeType *t = QDeclarativeMetaType::qmlType("QtQuick/Component",2,0); for (int ii = output->types.count() - 1; ii >= 0; --ii) { if (output->types.at(ii).type == t) return ii; diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h index 59d886c366..bb9c2ada02 100644 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ b/src/declarative/qml/qdeclarativecontext_p.h @@ -110,7 +110,7 @@ class QDeclarativeContextPrivate : public QObjectPrivate class QDeclarativeComponentAttached; class QDeclarativeGuardedContextData; -class Q_AUTOTEST_EXPORT QDeclarativeContextData +class Q_DECLARATIVE_EXPORT QDeclarativeContextData { public: QDeclarativeContextData(); diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index 65f49268e9..b7b68b20cf 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -72,7 +72,7 @@ class QDeclarativeDataExtended; // default state for elemental object allocations. This is crucial in the // workings of the QDeclarativeInstruction::CreateSimpleObject instruction. // Don't change anything here without first considering that case! -class Q_AUTOTEST_EXPORT QDeclarativeData : public QAbstractDeclarativeData +class Q_DECLARATIVE_EXPORT QDeclarativeData : public QAbstractDeclarativeData { public: QDeclarativeData() diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ab85b2d273..2117f063fc 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -96,7 +96,6 @@ #include -#include #include #include #include @@ -114,6 +113,13 @@ Q_DECLARE_METATYPE(QDeclarativeProperty) QT_BEGIN_NAMESPACE +void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor) +{ + QDeclarativeEnginePrivate::registerBaseTypes(uri, versionMajor, versionMinor); + QDeclarativeValueTypeFactory::registerBaseTypes(uri, versionMajor, versionMinor); + QDeclarativeUtilModule::registerBaseTypes(uri, versionMajor, versionMinor); +} + /*! \qmlclass QtObject QObject \ingroup qml-utility-elements @@ -178,18 +184,16 @@ struct StaticQtMetaObject : public QObject static bool qt_QmlQtModule_registered = false; bool QDeclarativeEnginePrivate::qml_debugging_enabled = false; -void QDeclarativeEnginePrivate::defineModule() +void QDeclarativeEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int versionMinor) { - qmlRegisterType("QtQuick",1,0,"Component"); - qmlRegisterType("QtQuick",1,0,"QtObject"); - qmlRegisterType("QtQuick",1,0,"WorkerScript"); - -#ifndef QT_NO_IMPORT_QT47_QML - qmlRegisterType("Qt",4,7,"Component"); - qmlRegisterType("Qt",4,7,"QtObject"); - qmlRegisterType("Qt",4,7,"WorkerScript"); -#endif + qmlRegisterType(uri,versionMajor,versionMinor,"Component"); + qmlRegisterType(uri,versionMajor,versionMinor,"QtObject"); + qmlRegisterType(uri,versionMajor,versionMinor,"WorkerScript"); +} +void QDeclarativeEnginePrivate::defineModule() +{ + registerBaseTypes("QtQuick", 2, 0); qmlRegisterType(); } @@ -352,7 +356,6 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) { if (!qt_QmlQtModule_registered) { qt_QmlQtModule_registered = true; - QDeclarativeItemModule::defineModule(); QDeclarativeUtilModule::defineModule(); QDeclarativeEnginePrivate::defineModule(); QSGItemsModule::defineModule(); diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index ba22ba95c0..538e8a05a0 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -101,7 +101,7 @@ class QDir; class QSGTexture; class QSGContext; -class Q_AUTOTEST_EXPORT QDeclarativeEnginePrivate : public QObjectPrivate +class Q_DECLARATIVE_EXPORT QDeclarativeEnginePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QDeclarativeEngine) public: @@ -264,6 +264,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeEnginePrivate : public QObjectPrivate static QString urlToLocalFileOrQrc(const QUrl& url); + static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor); static void defineModule(); static bool qml_debugging_enabled; diff --git a/src/declarative/qml/qdeclarativefastproperties.cpp b/src/declarative/qml/qdeclarativefastproperties.cpp index 5c447eef41..93703e2bdc 100644 --- a/src/declarative/qml/qdeclarativefastproperties.cpp +++ b/src/declarative/qml/qdeclarativefastproperties.cpp @@ -41,7 +41,8 @@ #include "private/qdeclarativefastproperties_p.h" -#include +#include +#include QT_BEGIN_NAMESPACE @@ -51,6 +52,13 @@ QT_BEGIN_NAMESPACE // primarily read from bindings is a candidate for inclusion as a fast // property. +Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties) + +QDeclarativeFastProperties *QDeclarativeFastProperties::instance() +{ + return fastProperties(); +} + static void QObject_objectName(QObject *object, void *output, QDeclarativeNotifierEndpoint *endpoint) { if (endpoint) @@ -60,8 +68,6 @@ static void QObject_objectName(QObject *object, void *output, QDeclarativeNotifi QDeclarativeFastProperties::QDeclarativeFastProperties() { - add(&QDeclarativeItem::staticMetaObject, QDeclarativeItem::staticMetaObject.indexOfProperty("parent"), - QDeclarativeItemPrivate::parentProperty); add(&QObject::staticMetaObject, QObject::staticMetaObject.indexOfProperty("objectName"), QObject_objectName); } @@ -75,6 +81,7 @@ int QDeclarativeFastProperties::accessorIndexForProperty(const QMetaObject *meta while (metaObject->propertyOffset() > propertyIndex) metaObject = metaObject->superClass(); + QReadLocker lock(&m_lock); QHash, int>::Iterator iter = m_index.find(qMakePair(metaObject, propertyIndex)); if (iter != m_index.end()) @@ -93,6 +100,7 @@ void QDeclarativeFastProperties::add(const QMetaObject *metaObject, int property metaObject = metaObject->superClass(); QPair data = qMakePair(metaObject, propertyIndex); + QWriteLocker lock(&m_lock); int accessorIndex = m_accessors.count(); m_accessors.append(accessor); m_index.insert(data, accessorIndex); diff --git a/src/declarative/qml/qdeclarativefastproperties_p.h b/src/declarative/qml/qdeclarativefastproperties_p.h index ed4975f2f8..1e09131222 100644 --- a/src/declarative/qml/qdeclarativefastproperties_p.h +++ b/src/declarative/qml/qdeclarativefastproperties_p.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -51,21 +52,23 @@ QT_BEGIN_NAMESPACE class QObject; class QDeclarativeNotifierEndpoint; -class QDeclarativeFastProperties +class Q_DECLARATIVE_EXPORT QDeclarativeFastProperties { public: typedef void (*Accessor)(QObject *object, void *output, QDeclarativeNotifierEndpoint *endpoint); - QDeclarativeFastProperties(); - Accessor accessor(int index) const { return m_accessors.at(index); } + Accessor accessor(int index) const { QReadLocker lock(&m_lock); return m_accessors.at(index); } int accessorIndexForProperty(const QMetaObject *, int); -private: void add(const QMetaObject *, int, Accessor); + static QDeclarativeFastProperties *instance(); + +private: QHash, int> m_index; QVector m_accessors; + mutable QReadWriteLock m_lock; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 16b2fa2886..b2fa071f91 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -195,7 +195,7 @@ cacheForNamespace(QDeclarativeEngine *engine, const QDeclarativeImportedNamespac foreach (QDeclarativeType *type, types) { if (type->qmlTypeName().startsWith(base) && type->qmlTypeName().lastIndexOf('/') == (base.length() - 1) && - type->availableInVersion(major,minor)) + (major < 0 || type->availableInVersion(major,minor))) { QString name = QString::fromUtf8(type->qmlTypeName().mid(base.length())); @@ -295,17 +295,19 @@ bool QDeclarativeImportedNamespace::find_helper(int i, const QByteArray& type, i int vmaj = majversions.at(i); int vmin = minversions.at(i); - QByteArray qt = uris.at(i).toUtf8(); - qt += '/'; - qt += type; - - QDeclarativeType *t = QDeclarativeMetaType::qmlType(qt,vmaj,vmin); - if (t) { - if (vmajor) *vmajor = vmaj; - if (vminor) *vminor = vmin; - if (type_return) - *type_return = t; - return true; + if (vmaj >= 0 && vmin >= 0) { + QByteArray qt = uris.at(i).toUtf8(); + qt += '/'; + qt += type; + + QDeclarativeType *t = QDeclarativeMetaType::qmlType(qt,vmaj,vmin); + if (t) { + if (vmajor) *vmajor = vmaj; + if (vminor) *vminor = vmin; + if (type_return) + *type_return = t; + return true; + } } QUrl url = QUrl(urls.at(i) + QLatin1Char('/') + QString::fromUtf8(type) + QLatin1String(".qml")); @@ -319,7 +321,7 @@ bool QDeclarativeImportedNamespace::find_helper(int i, const QByteArray& type, i typeWasDeclaredInQmldir = true; // importing version -1 means import ALL versions - if ((vmaj == -1) || (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion))) { + if ((vmaj == -1) || (c.majorVersion == vmaj && vmin >= c.minorVersion)) { QUrl candidate = url.resolved(QUrl(c.fileName)); if (c.internal && base) { if (base->resolved(QUrl(c.fileName)) != candidate) @@ -501,53 +503,53 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp if (!s) set.insert(prefix,(s=new QDeclarativeImportedNamespace)); } - QString url = uri; bool versionFound = false; if (importType == QDeclarativeScriptParser::Import::Library) { + + Q_ASSERT(vmaj >= 0 && vmin >= 0); // Versions are always specified for libraries + url.replace(QLatin1Char('.'), QLatin1Char('/')); bool found = false; QString dir; // step 1: search for extension with fully encoded version number - if (vmaj >= 0 && vmin >= 0) { - foreach (const QString &p, database->fileImportPath) { - dir = p+QLatin1Char('/')+url; + foreach (const QString &p, database->fileImportPath) { + dir = p+QLatin1Char('/')+url; - QFileInfo fi(dir+QString(QLatin1String(".%1.%2")).arg(vmaj).arg(vmin)+QLatin1String("/qmldir")); - const QString absoluteFilePath = fi.absoluteFilePath(); + QFileInfo fi(dir+QString(QLatin1String(".%1.%2")).arg(vmaj).arg(vmin)+QLatin1String("/qmldir")); + const QString absoluteFilePath = fi.absoluteFilePath(); - if (fi.isFile()) { - found = true; + if (fi.isFile()) { + found = true; - url = QUrl::fromLocalFile(fi.absolutePath()).toString(); - uri = resolvedUri(dir, database); - if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errors)) - return false; - break; - } + url = QUrl::fromLocalFile(fi.absolutePath()).toString(); + uri = resolvedUri(dir, database); + if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errors)) + return false; + break; } } + // step 2: search for extension with encoded version major - if (vmaj >= 0 && vmin >= 0) { - foreach (const QString &p, database->fileImportPath) { - dir = p+QLatin1Char('/')+url; + foreach (const QString &p, database->fileImportPath) { + dir = p+QLatin1Char('/')+url; - QFileInfo fi(dir+QString(QLatin1String(".%1")).arg(vmaj)+QLatin1String("/qmldir")); - const QString absoluteFilePath = fi.absoluteFilePath(); + QFileInfo fi(dir+QString(QLatin1String(".%1")).arg(vmaj)+QLatin1String("/qmldir")); + const QString absoluteFilePath = fi.absoluteFilePath(); - if (fi.isFile()) { - found = true; + if (fi.isFile()) { + found = true; - url = QUrl::fromLocalFile(fi.absolutePath()).toString(); - uri = resolvedUri(dir, database); - if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errors)) - return false; - break; - } + url = QUrl::fromLocalFile(fi.absolutePath()).toString(); + uri = resolvedUri(dir, database); + if (!importExtension(absoluteFilePath, uri, database, &qmldircomponents, errors)) + return false; + break; } } + if (!found) { // step 3: search for extension without version number @@ -569,12 +571,13 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp } } - if (QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin)) + if (QDeclarativeMetaType::isModule(uri.toUtf8(), vmaj, vmin)) { versionFound = true; + } if (!versionFound && qmldircomponents.isEmpty()) { if (errors) { - bool anyversion = QDeclarativeMetaType::isModule(uri.toUtf8(), -1, -1); + bool anyversion = QDeclarativeMetaType::isAnyModule(uri.toUtf8()); QDeclarativeError error; // we don't set the url or line or column as these will be set by the loader. if (anyversion) error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin)); @@ -636,23 +639,15 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp if (!versionFound && vmaj > -1 && vmin > -1 && !qmldircomponents.isEmpty()) { QList::ConstIterator it = qmldircomponents.begin(); - int lowest_maj = INT_MAX; int lowest_min = INT_MAX; - int highest_maj = INT_MIN; int highest_min = INT_MIN; for (; it != qmldircomponents.end(); ++it) { - if (it->majorVersion > highest_maj || (it->majorVersion == highest_maj && it->minorVersion > highest_min)) { - highest_maj = it->majorVersion; - highest_min = it->minorVersion; - } - if (it->majorVersion < lowest_maj || (it->majorVersion == lowest_maj && it->minorVersion < lowest_min)) { - lowest_maj = it->majorVersion; - lowest_min = it->minorVersion; + if (it->majorVersion == vmaj) { + lowest_min = qMin(lowest_min, it->minorVersion); + highest_min = qMax(highest_min, it->minorVersion); } } - if (lowest_maj > vmaj || (lowest_maj == vmaj && lowest_min > vmin) - || highest_maj < vmaj || (highest_maj == vmaj && highest_min < vmin)) - { + if (lowest_min > vmin || highest_min < vmin) { if (errors) { QDeclarativeError error; // we don't set the url or line or column information, as these will be set by the loader. error.setDescription(QDeclarativeImportDatabase::tr("module \"%1\" version %2.%3 is not installed").arg(uri_arg).arg(vmaj).arg(vmin)); diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index aab5f63f08..4884d1cc4a 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -110,13 +110,13 @@ struct QDeclarativeMetaTypeData struct ModuleInfo { ModuleInfo(int major, int minor) - : vmajor_min(major), vminor_min(minor), vmajor_max(major), vminor_max(minor) {} - ModuleInfo(int major_min, int minor_min, int major_max, int minor_max) - : vmajor_min(major_min), vminor_min(minor_min), vmajor_max(major_max), vminor_max(minor_max) {} - int vmajor_min, vminor_min; - int vmajor_max, vminor_max; + : vmajor(major), vminor_min(minor), vminor_max(minor) {} + ModuleInfo(int major, int minor_min, int minor_max) + : vmajor(major), vminor_min(minor_min), vminor_max(minor_max) {} + int vmajor; + int vminor_min, vminor_max; }; - typedef QHash ModuleInfoHash; + typedef QHash, ModuleInfo> ModuleInfoHash; ModuleInfoHash modules; QBitArray objects; @@ -268,12 +268,12 @@ int QDeclarativeType::minorVersion() const bool QDeclarativeType::availableInVersion(int vmajor, int vminor) const { - return vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min); + return vmajor == d->m_version_maj && vminor >= d->m_version_min; } bool QDeclarativeType::availableInVersion(const QByteArray &module, int vmajor, int vminor) const { - return module == d->m_module && (vmajor > d->m_version_maj || (vmajor == d->m_version_maj && vminor >= d->m_version_min)); + return module == d->m_module && vmajor == d->m_version_maj && vminor >= d->m_version_min; } // returns the nearest _registered_ super class @@ -662,16 +662,19 @@ int registerType(const QDeclarativePrivate::RegisterType &type) if (type.uri) { QByteArray mod(type.uri); - QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(mod); + QPair key(mod,type.versionMajor); + QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(key); if (it == data->modules.end()) { // New module - data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor,type.versionMinor)); - } else if ((*it).vmajor_max < type.versionMajor || ((*it).vmajor_max == type.versionMajor && (*it).vminor_max < type.versionMinor)) { - // Newer module - data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo((*it).vmajor_min, (*it).vminor_min, type.versionMajor, type.versionMinor)); - } else if ((*it).vmajor_min > type.versionMajor || ((*it).vmajor_min == type.versionMajor && (*it).vminor_min > type.versionMinor)) { - // Older module - data->modules.insert(mod, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor, type.versionMinor, (*it).vmajor_min, (*it).vminor_min)); + data->modules.insert(key, QDeclarativeMetaTypeData::ModuleInfo(type.versionMajor,type.versionMinor)); + } else { + if ((*it).vminor_max < type.versionMinor) { + // Newer module + data->modules.insert(key, QDeclarativeMetaTypeData::ModuleInfo((*it).vmajor, (*it).vminor_min, type.versionMinor)); + } else if ((*it).vminor_min > type.versionMinor) { + // Older module + data->modules.insert(key, QDeclarativeMetaTypeData::ModuleInfo((*it).vmajor, type.versionMinor, (*it).vminor_min)); + } } } @@ -724,34 +727,41 @@ int QDeclarativePrivate::qmlregister(RegistrationType type, void *data) return -1; } +bool QDeclarativeMetaType::isAnyModule(const QByteArray &module) +{ + QDeclarativeMetaTypeData *data = metaTypeData(); + + QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.begin(); + while (it != data->modules.end()) { + if (it.key().first == module) + return true; + ++it; + } + + return false; +} + /* Returns true if any type or API has been registered for the given \a module with at least versionMajor.versionMinor, or if types have been registered for \a module with at most versionMajor.versionMinor. So if only 4.7 and 4.9 have been registered, 4.7,4.8, and 4.9 are valid, but not 4.6 nor 4.10. - - Passing -1 for both \a versionMajor \a versionMinor will return true if any version is installed. */ bool QDeclarativeMetaType::isModule(const QByteArray &module, int versionMajor, int versionMinor) { QDeclarativeMetaTypeData *data = metaTypeData(); // first, check Types - QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(module); - if (it != data->modules.end() - && ((versionMajor<0 && versionMinor<0) || - (((*it).vmajor_max > versionMajor || - ((*it).vmajor_max == versionMajor && (*it).vminor_max >= versionMinor)) - && ((*it).vmajor_min < versionMajor || - ((*it).vmajor_min == versionMajor && (*it).vminor_min <= versionMinor))))) { - return true; + QDeclarativeMetaTypeData::ModuleInfoHash::Iterator it = data->modules.find(QPair(module,versionMajor)); + if (it != data->modules.end()) { + if (((*it).vminor_max >= versionMinor && (*it).vminor_min <= versionMinor)) + return true; } // then, check ModuleApis foreach (const QDeclarativeMetaType::ModuleApi &mApi, data->moduleApis.value(module).moduleApis) { - if ((versionMajor<0 && versionMinor<0) - || (mApi.major == versionMajor && mApi.minor == versionMinor)) { + if (mApi.major == versionMajor && mApi.minor == versionMinor) { return true; } } diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h index ba2d445826..cfc4f077f8 100644 --- a/src/declarative/qml/qdeclarativemetatype_p.h +++ b/src/declarative/qml/qdeclarativemetatype_p.h @@ -104,6 +104,7 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeMetaType static void registerCustomStringConverter(int, StringConverter); static StringConverter customStringConverter(int); + static bool isAnyModule(const QByteArray &module); static bool isModule(const QByteArray &module, int versionMajor, int versionMinor); static QList parentFunctions(); diff --git a/src/declarative/qml/qdeclarativenotifier_p.h b/src/declarative/qml/qdeclarativenotifier_p.h index 5f70f7d138..0781886ea2 100644 --- a/src/declarative/qml/qdeclarativenotifier_p.h +++ b/src/declarative/qml/qdeclarativenotifier_p.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeNotifierEndpoint; -class QDeclarativeNotifier +class Q_DECLARATIVE_EXPORT QDeclarativeNotifier { public: inline QDeclarativeNotifier(); diff --git a/src/declarative/util/qdeclarativenullablevalue_p_p.h b/src/declarative/qml/qdeclarativenullablevalue_p_p.h similarity index 100% rename from src/declarative/util/qdeclarativenullablevalue_p_p.h rename to src/declarative/qml/qdeclarativenullablevalue_p_p.h diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h index 1787e6ad14..621463dad9 100644 --- a/src/declarative/qml/qdeclarativepropertycache_p.h +++ b/src/declarative/qml/qdeclarativepropertycache_p.h @@ -68,7 +68,7 @@ class QMetaProperty; class QV8Engine; class QV8QObjectWrapper; -class Q_AUTOTEST_EXPORT QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup +class Q_DECLARATIVE_EXPORT QDeclarativePropertyCache : public QDeclarativeRefCount, public QDeclarativeCleanup { public: QDeclarativePropertyCache(QDeclarativeEngine *); diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index 8505caefac..7f77388516 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -97,14 +97,15 @@ bool QDeclarativeValueTypeFactory::isValueType(int idx) return false; } +void QDeclarativeValueTypeFactory::registerBaseTypes(const char *uri, int versionMajor, int versionMinor) +{ + qmlRegisterValueTypeEnums(uri, versionMajor, versionMinor, "Easing"); + qmlRegisterValueTypeEnums(uri, versionMajor, versionMinor, "Font"); +} + void QDeclarativeValueTypeFactory::registerValueTypes() { - qmlRegisterValueTypeEnums("QtQuick",1,0,"Easing"); - qmlRegisterValueTypeEnums("QtQuick",1,0,"Font"); -#ifndef QT_NO_IMPORT_QT47_QML - qmlRegisterValueTypeEnums("Qt",4,7,"Easing"); - qmlRegisterValueTypeEnums("Qt",4,7,"Font"); -#endif + registerBaseTypes("QtQuick", 2, 0); } QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t) diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index 73fa6ca54e..5d103a46de 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -89,6 +89,7 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeValueTypeFactory static bool isValueType(int); static QDeclarativeValueType *valueType(int); + static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor); static void registerValueTypes(); QDeclarativeValueType *operator[](int idx) const { diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 7325cd8340..3e63a9c88f 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -112,6 +112,8 @@ HEADERS += \ $$PWD/qdeclarativeextensioninterface.h \ $$PWD/qdeclarativeimport_p.h \ $$PWD/qdeclarativeextensionplugin.h \ + $$PWD/qperformancetimer_p.h \ + $$PWD/qdeclarativenullablevalue_p_p.h \ $$PWD/qintrusivelist_p.h \ $$PWD/qdeclarativescriptstring_p.h diff --git a/src/declarative/qml/rewriter/textwriter_p.h b/src/declarative/qml/rewriter/textwriter_p.h index 719297f701..1f94591c30 100644 --- a/src/declarative/qml/rewriter/textwriter_p.h +++ b/src/declarative/qml/rewriter/textwriter_p.h @@ -42,7 +42,7 @@ #ifndef TEXTWRITER_H #define TEXTWRITER_H -#include +#include #include #include diff --git a/src/declarative/qml/v4/qdeclarativev4bindings.cpp b/src/declarative/qml/v4/qdeclarativev4bindings.cpp index c81f59b0bc..9209e93e4f 100644 --- a/src/declarative/qml/v4/qdeclarativev4bindings.cpp +++ b/src/declarative/qml/v4/qdeclarativev4bindings.cpp @@ -44,10 +44,10 @@ #include "private/qdeclarativev4bindings_p.h" #include "private/qdeclarativev4program_p.h" #include "private/qdeclarativev4compiler_p.h" +#include "private/qdeclarativev4compiler_p_p.h" #include #include -#include // For AnchorLine #include // For AnchorLine #include @@ -534,10 +534,10 @@ static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4) } int type = qtscript.userType(); - - if (type == qMetaTypeId()) { - QDeclarativeAnchorLine la = qvariant_cast(qtscript); - QDeclarativeAnchorLine ra = qvariant_cast(v4); + + if (type == qMetaTypeId()) { + QDeclarative1AnchorLine la = qvariant_cast(qtscript); + QDeclarative1AnchorLine ra = qvariant_cast(v4); return la == ra; } else if (type == qMetaTypeId()) { @@ -623,8 +623,8 @@ static void testBindingResult(const QString &binding, int line, int column, v4value = result.getqreal(); break; default: - if (resultType == qMetaTypeId()) { - v4value = qVariantFromValue(*(QDeclarativeAnchorLine *)result.typeDataPtr()); + if (resultType == qMetaTypeId()) { + v4value = qVariantFromValue(*(QDeclarative1AnchorLine *)result.typeDataPtr()); } else if (resultType == qMetaTypeId()) { v4value = qVariantFromValue(*(QSGAnchorLine *)result.typeDataPtr()); } else { @@ -852,7 +852,7 @@ void QDeclarativeV4BindingsPrivate::run(int instrIndex, quint32 &executedBlocks, reg.init((Register::Type)instr->fetchAndSubscribe.valueType); if (instr->fetchAndSubscribe.valueType >= FirstCleanupType) MARK_REGISTER(instr->fetchAndSubscribe.reg); - QDeclarativeV4Compiler::fastPropertyAccessor()->accessor(instr->fetchAndSubscribe.function)(object, reg.typeDataPtr(), sub); + QDeclarativeFastProperties::instance()->accessor(instr->fetchAndSubscribe.function)(object, reg.typeDataPtr(), sub); } } QML_V4_END_INSTR(FetchAndSubscribe, fetchAndSubscribe) diff --git a/src/declarative/qml/v4/qdeclarativev4compiler.cpp b/src/declarative/qml/v4/qdeclarativev4compiler.cpp index 672bf2e57d..371edda6c9 100644 --- a/src/declarative/qml/v4/qdeclarativev4compiler.cpp +++ b/src/declarative/qml/v4/qdeclarativev4compiler.cpp @@ -48,7 +48,6 @@ #include #include #include -#include // For AnchorLine #include // For AnchorLine QT_BEGIN_NAMESPACE @@ -59,8 +58,6 @@ DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL) DEFINE_BOOL_CONFIG_OPTION(qmlVerboseCompiler, QML_VERBOSE_COMPILER) DEFINE_BOOL_CONFIG_OPTION(qmlBindingsTestEnv, QML_BINDINGS_TEST) -Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties) - static bool qmlBindingsTest = false; using namespace QDeclarativeJS; @@ -312,7 +309,7 @@ void QDeclarativeV4CompilerPrivate::visitName(IR::Name *e) _subscribeName << e->id; QMetaProperty prop = e->meta->property(e->index); - int fastFetchIndex = fastProperties()->accessorIndexForProperty(e->meta, e->index); + int fastFetchIndex = QDeclarativeFastProperties::instance()->accessorIndexForProperty(e->meta, e->index); const int propTy = prop.userType(); QDeclarativeRegisterType regType; @@ -332,7 +329,7 @@ void QDeclarativeV4CompilerPrivate::visitName(IR::Name *e) break; default: - if (propTy == qMetaTypeId()) { + if (propTy == qMetaTypeId()) { regType = PODValueType; } else if (propTy == qMetaTypeId()) { regType = PODValueType; @@ -925,7 +922,7 @@ void QDeclarativeV4CompilerPrivate::visitRet(IR::Ret *s) test.storetest.regType = QMetaType::QUrl; break; case IR::AnchorLineType: - test.storetest.regType = qMetaTypeId(); + test.storetest.regType = qMetaTypeId(); break; case IR::SGAnchorLineType: test.storetest.regType = qMetaTypeId(); @@ -978,11 +975,6 @@ void QDeclarativeV4Compiler::dump(const QByteArray &programData) } } -QDeclarativeFastProperties *QDeclarativeV4Compiler::fastPropertyAccessor() -{ - return fastProperties(); -} - /*! Clear the state associated with attempting to compile a specific binding. This does not clear the global "committed binding" states. diff --git a/src/declarative/qml/v4/qdeclarativev4compiler_p.h b/src/declarative/qml/v4/qdeclarativev4compiler_p.h index 3b89d0d376..cc93f4dbf2 100644 --- a/src/declarative/qml/v4/qdeclarativev4compiler_p.h +++ b/src/declarative/qml/v4/qdeclarativev4compiler_p.h @@ -60,7 +60,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QDeclarativeFastProperties; class QDeclarativeTypeNameCache; class QDeclarativeV4CompilerPrivate; class Q_AUTOTEST_EXPORT QDeclarativeV4Compiler @@ -90,7 +89,6 @@ class Q_AUTOTEST_EXPORT QDeclarativeV4Compiler QByteArray program() const; static void dump(const QByteArray &); - static QDeclarativeFastProperties *fastPropertyAccessor(); static void enableBindingsTest(bool); private: QDeclarativeV4CompilerPrivate *d; diff --git a/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h b/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h index 2776630fb8..1d9414dce6 100644 --- a/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h +++ b/src/declarative/qml/v4/qdeclarativev4compiler_p_p.h @@ -63,6 +63,36 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +// NOTE: This is a copy of QDeclarative1AnchorLine: src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h +class QGraphicsObject; +class QDeclarative1AnchorLine +{ +public: + QDeclarative1AnchorLine() : item(0), anchorLine(Invalid) {} + + enum AnchorLine { + Invalid = 0x0, + Left = 0x01, + Right = 0x02, + Top = 0x04, + Bottom = 0x08, + HCenter = 0x10, + VCenter = 0x20, + Baseline = 0x40, + Horizontal_Mask = Left | Right | HCenter, + Vertical_Mask = Top | Bottom | VCenter | Baseline + }; + + QGraphicsObject *item; + AnchorLine anchorLine; +}; + +inline bool operator==(const QDeclarative1AnchorLine& a, const QDeclarative1AnchorLine& b) +{ + return a.item == b.item && a.anchorLine == b.anchorLine; +} + + class QDeclarativeV4CompilerPrivate: protected QDeclarativeJS::IR::ExprVisitor, protected QDeclarativeJS::IR::StmtVisitor { @@ -178,6 +208,8 @@ class QDeclarativeV4CompilerPrivate: protected QDeclarativeJS::IR::ExprVisitor, QT_END_NAMESPACE +Q_DECLARE_METATYPE(QDeclarative1AnchorLine) + QT_END_HEADER #endif // QDECLARATIVEV4COMPILER_P_P_H diff --git a/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp b/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp index 795406f006..34a59caf1a 100644 --- a/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp +++ b/src/declarative/qml/v4/qdeclarativev4irbuilder.cpp @@ -40,8 +40,8 @@ ****************************************************************************/ #include "qdeclarativev4irbuilder_p.h" +#include "qdeclarativev4compiler_p_p.h" -#include // For AnchorLine #include // For AnchorLine #include @@ -70,7 +70,7 @@ static IR::Type irTypeFromVariantType(int t, QDeclarativeEnginePrivate *engine, return IR::UrlType; default: - if (t == qMetaTypeId()) + if (t == qMetaTypeId()) return IR::AnchorLineType; else if (t == qMetaTypeId()) return IR::SGAnchorLineType; diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h index ef8f16013d..6c05fe4faf 100644 --- a/src/declarative/qml/v8/qv8engine_p.h +++ b/src/declarative/qml/v8/qv8engine_p.h @@ -206,7 +206,7 @@ class QDeclarativeEngine; class QDeclarativeValueType; class QNetworkAccessManager; class QDeclarativeContextData; -class Q_AUTOTEST_EXPORT QV8Engine +class Q_DECLARATIVE_EXPORT QV8Engine { public: QV8Engine(); diff --git a/src/declarative/qml/v8/qv8qobjectwrapper_p.h b/src/declarative/qml/v8/qv8qobjectwrapper_p.h index bc4eb443dc..dd787cc476 100644 --- a/src/declarative/qml/v8/qv8qobjectwrapper_p.h +++ b/src/declarative/qml/v8/qv8qobjectwrapper_p.h @@ -71,7 +71,7 @@ class QV8ObjectResource; class QV8QObjectInstance; class QV8QObjectConnectionList; class QDeclarativePropertyCache; -class Q_AUTOTEST_EXPORT QV8QObjectWrapper +class Q_DECLARATIVE_EXPORT QV8QObjectWrapper { public: QV8QObjectWrapper(); diff --git a/src/declarative/qml/v8/qv8stringwrapper_p.h b/src/declarative/qml/v8/qv8stringwrapper_p.h index 8dde5c8c44..36c9e24c06 100644 --- a/src/declarative/qml/v8/qv8stringwrapper_p.h +++ b/src/declarative/qml/v8/qv8stringwrapper_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QV8StringWrapper +class Q_DECLARATIVE_EXPORT QV8StringWrapper { public: QV8StringWrapper(); diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index ce21bcd30e..213ebe564a 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2431,519 +2431,6 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions } } -/*! - \qmlclass ParentAnimation QDeclarativeParentAnimation - \ingroup qml-animation-transition - \since 4.7 - \inherits Animation - \brief The ParentAnimation element animates changes in parent values. - - ParentAnimation is used to animate a parent change for an \l Item. - - For example, the following ParentChange changes \c blueRect to become - a child of \c redRect when it is clicked. The inclusion of the - ParentAnimation, which defines a NumberAnimation to be applied during - the transition, ensures the item animates smoothly as it moves to - its new parent: - - \snippet doc/src/snippets/declarative/parentanimation.qml 0 - - A ParentAnimation can contain any number of animations. These animations will - be run in parallel; to run them sequentially, define them within a - SequentialAnimation. - - In some cases, such as when reparenting between items with clipping enabled, it is useful - to animate the parent change via another item that does not have clipping - enabled. Such an item can be set using the \l via property. - - For convenience, when a ParentAnimation is used in a \l Transition, it will - animate any ParentChange that has occurred during the state change. - This can be overridden by setting a specific target item using the - \l target property. - - Like any other animation element, a ParentAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QDeclarativeParentAnimation::QDeclarativeParentAnimation(QObject *parent) - : QDeclarativeAnimationGroup(*(new QDeclarativeParentAnimationPrivate), parent) -{ - Q_D(QDeclarativeParentAnimation); - d->topLevelGroup = new QSequentialAnimationGroup; - QDeclarative_setParent_noEvent(d->topLevelGroup, this); - - d->startAction = new QActionAnimation; - QDeclarative_setParent_noEvent(d->startAction, d->topLevelGroup); - d->topLevelGroup->addAnimation(d->startAction); - - d->ag = new QParallelAnimationGroup; - QDeclarative_setParent_noEvent(d->ag, d->topLevelGroup); - d->topLevelGroup->addAnimation(d->ag); - - d->endAction = new QActionAnimation; - QDeclarative_setParent_noEvent(d->endAction, d->topLevelGroup); - d->topLevelGroup->addAnimation(d->endAction); -} - -QDeclarativeParentAnimation::~QDeclarativeParentAnimation() -{ -} - -/*! - \qmlproperty Item ParentAnimation::target - The item to reparent. - - When used in a transition, if no target is specified, all - ParentChange occurrences are animated by the ParentAnimation. -*/ -QDeclarativeItem *QDeclarativeParentAnimation::target() const -{ - Q_D(const QDeclarativeParentAnimation); - return d->target; -} - -void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target) -{ - Q_D(QDeclarativeParentAnimation); - if (target == d->target) - return; - - d->target = target; - emit targetChanged(); -} - -/*! - \qmlproperty Item ParentAnimation::newParent - The new parent to animate to. - - If the ParentAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. -*/ -QDeclarativeItem *QDeclarativeParentAnimation::newParent() const -{ - Q_D(const QDeclarativeParentAnimation); - return d->newParent; -} - -void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent) -{ - Q_D(QDeclarativeParentAnimation); - if (newParent == d->newParent) - return; - - d->newParent = newParent; - emit newParentChanged(); -} - -/*! - \qmlproperty Item ParentAnimation::via - The item to reparent via. This provides a way to do an unclipped animation - when both the old parent and new parent are clipped. - - \qml - ParentAnimation { - target: myItem - via: topLevelItem - // ... - } - \endqml -*/ -QDeclarativeItem *QDeclarativeParentAnimation::via() const -{ - Q_D(const QDeclarativeParentAnimation); - return d->via; -} - -void QDeclarativeParentAnimation::setVia(QDeclarativeItem *via) -{ - Q_D(QDeclarativeParentAnimation); - if (via == d->via) - return; - - d->via = via; - emit viaChanged(); -} - -//### mirrors same-named function in QDeclarativeItem -QPointF QDeclarativeParentAnimationPrivate::computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const -{ - switch(origin) { - default: - case QDeclarativeItem::TopLeft: - return QPointF(0, 0); - case QDeclarativeItem::Top: - return QPointF(width / 2., 0); - case QDeclarativeItem::TopRight: - return QPointF(width, 0); - case QDeclarativeItem::Left: - return QPointF(0, height / 2.); - case QDeclarativeItem::Center: - return QPointF(width / 2., height / 2.); - case QDeclarativeItem::Right: - return QPointF(width, height / 2.); - case QDeclarativeItem::BottomLeft: - return QPointF(0, height); - case QDeclarativeItem::Bottom: - return QPointF(width / 2., height); - case QDeclarativeItem::BottomRight: - return QPointF(width, height); - } -} - -void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarativeParentAnimation); - - struct QDeclarativeParentAnimationData : public QAbstractAnimationAction - { - QDeclarativeParentAnimationData() {} - ~QDeclarativeParentAnimationData() { qDeleteAll(pc); } - - QDeclarativeStateActions actions; - //### reverse should probably apply on a per-action basis - bool reverse; - QList pc; - virtual void doAction() - { - for (int ii = 0; ii < actions.count(); ++ii) { - const QDeclarativeAction &action = actions.at(ii); - if (reverse) - action.event->reverse(); - else - action.event->execute(); - } - } - }; - - QDeclarativeParentAnimationData *data = new QDeclarativeParentAnimationData; - QDeclarativeParentAnimationData *viaData = new QDeclarativeParentAnimationData; - - bool hasExplicit = false; - if (d->target && d->newParent) { - data->reverse = false; - QDeclarativeAction myAction; - QDeclarativeParentChange *pc = new QDeclarativeParentChange; - pc->setObject(d->target); - pc->setParent(d->newParent); - myAction.event = pc; - data->pc << pc; - data->actions << myAction; - hasExplicit = true; - if (d->via) { - viaData->reverse = false; - QDeclarativeAction myVAction; - QDeclarativeParentChange *vpc = new QDeclarativeParentChange; - vpc->setObject(d->target); - vpc->setParent(d->via); - myVAction.event = vpc; - viaData->pc << vpc; - viaData->actions << myVAction; - } - //### once actions have concept of modified, - // loop to match appropriate ParentChanges and mark as modified - } - - if (!hasExplicit) - for (int i = 0; i < actions.size(); ++i) { - QDeclarativeAction &action = actions[i]; - if (action.event && action.event->typeName() == QLatin1String("ParentChange") - && (!d->target || static_cast(action.event)->object() == d->target)) { - - QDeclarativeParentChange *pc = static_cast(action.event); - QDeclarativeAction myAction = action; - data->reverse = action.reverseEvent; - - //### this logic differs from PropertyAnimation - // (probably a result of modified vs. done) - if (d->newParent) { - QDeclarativeParentChange *epc = new QDeclarativeParentChange; - epc->setObject(static_cast(action.event)->object()); - epc->setParent(d->newParent); - myAction.event = epc; - data->pc << epc; - data->actions << myAction; - pc = epc; - } else { - action.actionDone = true; - data->actions << myAction; - } - - if (d->via) { - viaData->reverse = false; - QDeclarativeAction myAction; - QDeclarativeParentChange *vpc = new QDeclarativeParentChange; - vpc->setObject(pc->object()); - vpc->setParent(d->via); - myAction.event = vpc; - viaData->pc << vpc; - viaData->actions << myAction; - QDeclarativeAction dummyAction; - QDeclarativeAction &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarativeItem *target = pc->object(); - QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); - - //### this mirrors the logic in QDeclarativeParentChange. - bool ok; - const QTransform &transform = targetParent->itemTransform(d->via, &ok); - if (transform.type() >= QTransform::TxShear || !ok) { - qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under complex transform"); - ok = false; - } - - qreal scale = 1; - qreal rotation = 0; - bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0); - if (ok && !isRotate) { - if (transform.m11() == transform.m22()) - scale = transform.m11(); - else { - qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - } else if (ok && isRotate) { - if (transform.m11() == transform.m22()) - scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); - else { - qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - - if (scale != 0) - rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; - else { - qmlInfo(this) << QDeclarativeParentAnimation::tr("Unable to preserve appearance under scale of 0"); - ok = false; - } - } - - const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal())); - qreal x = point.x(); - qreal y = point.y(); - if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { - qreal w = target->width(); - qreal h = target->height(); - if (pc->widthIsSet() && i < actions.size() - 1) - w = actions[++i].toValue.toReal(); - if (pc->heightIsSet() && i < actions.size() - 1) - h = actions[++i].toValue.toReal(); - const QPointF &transformOrigin - = d->computeTransformOrigin(target->transformOrigin(), w,h); - qreal tempxt = transformOrigin.x(); - qreal tempyt = transformOrigin.y(); - QTransform t; - t.translate(-tempxt, -tempyt); - t.rotate(rotation); - t.scale(scale, scale); - t.translate(tempxt, tempyt); - const QPointF &offset = t.map(QPointF(0,0)); - x += offset.x(); - y += offset.y(); - } - - if (ok) { - //qDebug() << x << y << rotation << scale; - xAction.toValue = x; - yAction.toValue = y; - sAction.toValue = sAction.toValue.toReal() * scale; - rAction.toValue = rAction.toValue.toReal() + rotation; - } - } - } - } - - if (data->actions.count()) { - if (direction == QDeclarativeAbstractAnimation::Forward) { - d->startAction->setAnimAction(d->via ? viaData : data, QActionAnimation::DeleteWhenStopped); - d->endAction->setAnimAction(d->via ? data : 0, QActionAnimation::DeleteWhenStopped); - } else { - d->endAction->setAnimAction(d->via ? viaData : data, QActionAnimation::DeleteWhenStopped); - d->startAction->setAnimAction(d->via ? data : 0, QActionAnimation::DeleteWhenStopped); - } - if (!d->via) - delete viaData; - } else { - delete data; - delete viaData; - } - - //take care of any child animations - bool valid = d->defaultProperty.isValid(); - for (int ii = 0; ii < d->animations.count(); ++ii) { - if (valid) - d->animations.at(ii)->setDefaultTarget(d->defaultProperty); - d->animations.at(ii)->transition(actions, modified, direction); - } - -} - -QAbstractAnimation *QDeclarativeParentAnimation::qtAnimation() -{ - Q_D(QDeclarativeParentAnimation); - return d->topLevelGroup; -} - -/*! - \qmlclass AnchorAnimation QDeclarativeAnchorAnimation - \ingroup qml-animation-transition - \since 4.7 - \inherits Animation - \brief The AnchorAnimation element animates changes in anchor values. - - AnchorAnimation is used to animate an anchor change. - - In the following snippet we animate the addition of a right anchor to a \l Rectangle: - - \snippet doc/src/snippets/declarative/anchoranimation.qml 0 - - For convenience, when an AnchorAnimation is used in a \l Transition, it will - animate any AnchorChanges that have occurred during the state change. - This can be overridden by setting a specific target item using the - \l target property. - - Like any other animation element, an AnchorAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa {QML Animation and Transitions}, AnchorChanges -*/ - -QDeclarativeAnchorAnimation::QDeclarativeAnchorAnimation(QObject *parent) -: QDeclarativeAbstractAnimation(*(new QDeclarativeAnchorAnimationPrivate), parent) -{ - Q_D(QDeclarativeAnchorAnimation); - d->va = new QDeclarativeBulkValueAnimator; - QDeclarative_setParent_noEvent(d->va, this); -} - -QDeclarativeAnchorAnimation::~QDeclarativeAnchorAnimation() -{ -} - -QAbstractAnimation *QDeclarativeAnchorAnimation::qtAnimation() -{ - Q_D(QDeclarativeAnchorAnimation); - return d->va; -} - -/*! - \qmlproperty list AnchorAnimation::targets - The items to reanchor. - - If no targets are specified all AnchorChanges will be - animated by the AnchorAnimation. -*/ -QDeclarativeListProperty QDeclarativeAnchorAnimation::targets() -{ - Q_D(QDeclarativeAnchorAnimation); - return QDeclarativeListProperty(this, d->targets); -} - -/*! - \qmlproperty int AnchorAnimation::duration - This property holds the duration of the animation, in milliseconds. - - The default value is 250. -*/ -int QDeclarativeAnchorAnimation::duration() const -{ - Q_D(const QDeclarativeAnchorAnimation); - return d->va->duration(); -} - -void QDeclarativeAnchorAnimation::setDuration(int duration) -{ - if (duration < 0) { - qmlInfo(this) << tr("Cannot set a duration of < 0"); - return; - } - - Q_D(QDeclarativeAnchorAnimation); - if (d->va->duration() == duration) - return; - d->va->setDuration(duration); - emit durationChanged(duration); -} - -/*! - \qmlproperty enumeration AnchorAnimation::easing.type - \qmlproperty real AnchorAnimation::easing.amplitude - \qmlproperty real AnchorAnimation::easing.overshoot - \qmlproperty real AnchorAnimation::easing.period - \brief the easing curve used for the animation. - - To specify an easing curve you need to specify at least the type. For some curves you can also specify - amplitude, period and/or overshoot. The default easing curve is - Linear. - - \qml - AnchorAnimation { easing.type: Easing.InOutQuad } - \endqml - - See the \l{PropertyAnimation::easing.type} documentation for information - about the different types of easing curves. -*/ - -QEasingCurve QDeclarativeAnchorAnimation::easing() const -{ - Q_D(const QDeclarativeAnchorAnimation); - return d->va->easingCurve(); -} - -void QDeclarativeAnchorAnimation::setEasing(const QEasingCurve &e) -{ - Q_D(QDeclarativeAnchorAnimation); - if (d->va->easingCurve() == e) - return; - - d->va->setEasingCurve(e); - emit easingChanged(e); -} - -void QDeclarativeAnchorAnimation::transition(QDeclarativeStateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_UNUSED(modified); - Q_D(QDeclarativeAnchorAnimation); - QDeclarativeAnimationPropertyUpdater *data = new QDeclarativeAnimationPropertyUpdater; - data->interpolatorType = QMetaType::QReal; - data->interpolator = d->interpolator; - - data->reverse = direction == Backward ? true : false; - data->fromSourced = false; - data->fromDefined = false; - - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarativeAction &action = actions[ii]; - if (action.event && action.event->typeName() == QLatin1String("AnchorChanges") - && (d->targets.isEmpty() || d->targets.contains(static_cast(action.event)->object()))) { - data->actions << static_cast(action.event)->additionalActions(); - } - } - - if (data->actions.count()) { - if (!d->rangeIsSet) { - d->va->setStartValue(qreal(0)); - d->va->setEndValue(qreal(1)); - d->rangeIsSet = true; - } - d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); - d->va->setFromSourcedValue(&data->fromSourced); - } else { - delete data; - } -} QDeclarativeScriptActionPrivate::QDeclarativeScriptActionPrivate() : QDeclarativeAbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {} diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index 09350ce61e..30f05ececa 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -235,7 +235,6 @@ class QDeclarativePropertyAction : public QDeclarativeAbstractAnimation virtual QAbstractAnimation *qtAnimation(); }; -class QDeclarativeItem; class QDeclarativePropertyAnimationPrivate; class Q_AUTOTEST_EXPORT QDeclarativePropertyAnimation : public QDeclarativeAbstractAnimation { @@ -440,72 +439,6 @@ class QDeclarativeParallelAnimation : public QDeclarativeAnimationGroup virtual QAbstractAnimation *qtAnimation(); }; -class QDeclarativeParentAnimationPrivate; -class QDeclarativeParentAnimation : public QDeclarativeAnimationGroup -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeParentAnimation) - - Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged) - Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia NOTIFY viaChanged) - -public: - QDeclarativeParentAnimation(QObject *parent=0); - virtual ~QDeclarativeParentAnimation(); - - QDeclarativeItem *target() const; - void setTarget(QDeclarativeItem *); - - QDeclarativeItem *newParent() const; - void setNewParent(QDeclarativeItem *); - - QDeclarativeItem *via() const; - void setVia(QDeclarativeItem *); - -Q_SIGNALS: - void targetChanged(); - void newParentChanged(); - void viaChanged(); - -protected: - virtual void transition(QDeclarativeStateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; - -class QDeclarativeAnchorAnimationPrivate; -class QDeclarativeAnchorAnimation : public QDeclarativeAbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeAnchorAnimation) - Q_PROPERTY(QDeclarativeListProperty targets READ targets) - Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) - -public: - QDeclarativeAnchorAnimation(QObject *parent=0); - virtual ~QDeclarativeAnchorAnimation(); - - QDeclarativeListProperty targets(); - - int duration() const; - void setDuration(int); - - QEasingCurve easing() const; - void setEasing(const QEasingCurve &); - -Q_SIGNALS: - void durationChanged(int); - void easingChanged(const QEasingCurve&); - -protected: - virtual void transition(QDeclarativeStateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; QT_END_NAMESPACE @@ -520,8 +453,6 @@ QML_DECLARE_TYPE(QDeclarativeSequentialAnimation) QML_DECLARE_TYPE(QDeclarativeParallelAnimation) QML_DECLARE_TYPE(QDeclarativeVector3dAnimation) QML_DECLARE_TYPE(QDeclarativeRotationAnimation) -QML_DECLARE_TYPE(QDeclarativeParentAnimation) -QML_DECLARE_TYPE(QDeclarativeAnchorAnimation) QT_END_HEADER diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h index 8e00b4b65a..b46475b5bd 100644 --- a/src/declarative/util/qdeclarativeanimation_p_p.h +++ b/src/declarative/util/qdeclarativeanimation_p_p.h @@ -59,7 +59,6 @@ #include "private/qdeclarativetimeline_p_p.h" #include -#include #include #include @@ -344,38 +343,6 @@ class QDeclarativeRotationAnimationPrivate : public QDeclarativePropertyAnimatio QDeclarativeRotationAnimation::RotationDirection direction; }; -class QDeclarativeParentAnimationPrivate : public QDeclarativeAnimationGroupPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeParentAnimation) -public: - QDeclarativeParentAnimationPrivate() - : QDeclarativeAnimationGroupPrivate(), target(0), newParent(0), - via(0), topLevelGroup(0), startAction(0), endAction(0) {} - - QDeclarativeItem *target; - QDeclarativeItem *newParent; - QDeclarativeItem *via; - - QSequentialAnimationGroup *topLevelGroup; - QActionAnimation *startAction; - QActionAnimation *endAction; - - QPointF computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const; -}; - -class QDeclarativeAnchorAnimationPrivate : public QDeclarativeAbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeAnchorAnimation) -public: - QDeclarativeAnchorAnimationPrivate() : rangeIsSet(false), va(0), - interpolator(QVariantAnimationPrivate::getInterpolator(QMetaType::QReal)) {} - - bool rangeIsSet; - QDeclarativeBulkValueAnimator *va; - QVariantAnimation::Interpolator interpolator; - QList targets; -}; - class Q_AUTOTEST_EXPORT QDeclarativeAnimationPropertyUpdater : public QDeclarativeBulkValueUpdater { public: diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/util/qdeclarativepath.cpp similarity index 100% rename from src/declarative/graphicsitems/qdeclarativepath.cpp rename to src/declarative/util/qdeclarativepath.cpp diff --git a/src/declarative/graphicsitems/qdeclarativepath_p.h b/src/declarative/util/qdeclarativepath_p.h similarity index 99% rename from src/declarative/graphicsitems/qdeclarativepath_p.h rename to src/declarative/util/qdeclarativepath_p.h index db4d690cc7..c8420eb996 100644 --- a/src/declarative/graphicsitems/qdeclarativepath_p.h +++ b/src/declarative/util/qdeclarativepath_p.h @@ -42,8 +42,6 @@ #ifndef QDECLARATIVEPATH_H #define QDECLARATIVEPATH_H -#include "qdeclarativeitem.h" - #include #include diff --git a/src/declarative/graphicsitems/qdeclarativepath_p_p.h b/src/declarative/util/qdeclarativepath_p_p.h similarity index 99% rename from src/declarative/graphicsitems/qdeclarativepath_p_p.h rename to src/declarative/util/qdeclarativepath_p_p.h index 2a1d072a39..4e407eca35 100644 --- a/src/declarative/graphicsitems/qdeclarativepath_p_p.h +++ b/src/declarative/util/qdeclarativepath_p_p.h @@ -57,6 +57,7 @@ #include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index c260684eef..0ced8ebd61 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -45,8 +45,6 @@ #include #include #include -#include -#include #include #include #include "private/qdeclarativecontext_p.h" @@ -62,532 +60,6 @@ QT_BEGIN_NAMESPACE -class QDeclarativeParentChangePrivate : public QDeclarativeStateOperationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeParentChange) -public: - QDeclarativeParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0), - rewindParent(0), rewindStackBefore(0) {} - - QDeclarativeItem *target; - QDeclarativeGuard parent; - QDeclarativeGuard origParent; - QDeclarativeGuard origStackBefore; - QDeclarativeItem *rewindParent; - QDeclarativeItem *rewindStackBefore; - - QDeclarativeNullableValue xString; - QDeclarativeNullableValue yString; - QDeclarativeNullableValue widthString; - QDeclarativeNullableValue heightString; - QDeclarativeNullableValue scaleString; - QDeclarativeNullableValue rotationString; - - QDeclarativeNullableValue x; - QDeclarativeNullableValue y; - QDeclarativeNullableValue width; - QDeclarativeNullableValue height; - QDeclarativeNullableValue scale; - QDeclarativeNullableValue rotation; - - void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0); -}; - -void QDeclarativeParentChangePrivate::doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore) -{ - if (targetParent && target && target->parentItem()) { - Q_Q(QDeclarativeParentChange); - bool ok; - const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok); - if (transform.type() >= QTransform::TxShear || !ok) { - qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under complex transform"); - ok = false; - } - - qreal scale = 1; - qreal rotation = 0; - bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0); - if (ok && !isRotate) { - if (transform.m11() == transform.m22()) - scale = transform.m11(); - else { - qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - } else if (ok && isRotate) { - if (transform.m11() == transform.m22()) - scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); - else { - qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - - if (scale != 0) - rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; - else { - qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under scale of 0"); - ok = false; - } - } - - const QPointF &point = transform.map(QPointF(target->x(),target->y())); - qreal x = point.x(); - qreal y = point.y(); - - // setParentItem will update the transformOriginPoint if needed - target->setParentItem(targetParent); - - if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { - qreal tempxt = target->transformOriginPoint().x(); - qreal tempyt = target->transformOriginPoint().y(); - QTransform t; - t.translate(-tempxt, -tempyt); - t.rotate(rotation); - t.scale(scale, scale); - t.translate(tempxt, tempyt); - const QPointF &offset = t.map(QPointF(0,0)); - x += offset.x(); - y += offset.y(); - } - - if (ok) { - //qDebug() << x << y << rotation << scale; - target->setX(x); - target->setY(y); - target->setRotation(target->rotation() + rotation); - target->setScale(target->scale() * scale); - } - } else if (target) { - target->setParentItem(targetParent); - } - - //restore the original stack position. - //### if stackBefore has also been reparented this won't work - if (stackBefore) - target->stackBefore(stackBefore); -} - -/*! - \preliminary - \qmlclass ParentChange QDeclarativeParentChange - \ingroup qml-state-elements - \brief The ParentChange element allows you to reparent an Item in a state change. - - ParentChange reparents an item while preserving its visual appearance (position, size, - rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale - the item to its final intended appearance. - - ParentChange can only preserve visual appearance if no complex transforms are involved. - More specifically, it will not work if the transform property has been set for any - items involved in the reparenting (i.e. items in the common ancestor tree - for the original and new parent). - - The example below displays a large red rectangle and a small blue rectangle, side by side. - When the \c blueRect is clicked, it changes to the "reparented" state: its parent is changed to \c redRect and it is - positioned at (10, 10) within the red rectangle, as specified in the ParentChange. - - \snippet doc/src/snippets/declarative/parentchange.qml 0 - - \image parentchange.png - - You can specify at which point in a transition you want a ParentChange to occur by - using a ParentAnimation. -*/ - - -QDeclarativeParentChange::QDeclarativeParentChange(QObject *parent) - : QDeclarativeStateOperation(*(new QDeclarativeParentChangePrivate), parent) -{ -} - -QDeclarativeParentChange::~QDeclarativeParentChange() -{ -} - -/*! - \qmlproperty real ParentChange::x - \qmlproperty real ParentChange::y - \qmlproperty real ParentChange::width - \qmlproperty real ParentChange::height - \qmlproperty real ParentChange::scale - \qmlproperty real ParentChange::rotation - These properties hold the new position, size, scale, and rotation - for the item in this state. -*/ -QDeclarativeScriptString QDeclarativeParentChange::x() const -{ - Q_D(const QDeclarativeParentChange); - return d->xString.value; -} - -void tryReal(QDeclarativeNullableValue &value, const QString &string) -{ - bool ok = false; - qreal realValue = string.toFloat(&ok); - if (ok) - value = realValue; - else - value.invalidate(); -} - -void QDeclarativeParentChange::setX(QDeclarativeScriptString x) -{ - Q_D(QDeclarativeParentChange); - d->xString = x; - tryReal(d->x, x.script()); -} - -bool QDeclarativeParentChange::xIsSet() const -{ - Q_D(const QDeclarativeParentChange); - return d->xString.isValid(); -} - -QDeclarativeScriptString QDeclarativeParentChange::y() const -{ - Q_D(const QDeclarativeParentChange); - return d->yString.value; -} - -void QDeclarativeParentChange::setY(QDeclarativeScriptString y) -{ - Q_D(QDeclarativeParentChange); - d->yString = y; - tryReal(d->y, y.script()); -} - -bool QDeclarativeParentChange::yIsSet() const -{ - Q_D(const QDeclarativeParentChange); - return d->yString.isValid(); -} - -QDeclarativeScriptString QDeclarativeParentChange::width() const -{ - Q_D(const QDeclarativeParentChange); - return d->widthString.value; -} - -void QDeclarativeParentChange::setWidth(QDeclarativeScriptString width) -{ - Q_D(QDeclarativeParentChange); - d->widthString = width; - tryReal(d->width, width.script()); -} - -bool QDeclarativeParentChange::widthIsSet() const -{ - Q_D(const QDeclarativeParentChange); - return d->widthString.isValid(); -} - -QDeclarativeScriptString QDeclarativeParentChange::height() const -{ - Q_D(const QDeclarativeParentChange); - return d->heightString.value; -} - -void QDeclarativeParentChange::setHeight(QDeclarativeScriptString height) -{ - Q_D(QDeclarativeParentChange); - d->heightString = height; - tryReal(d->height, height.script()); -} - -bool QDeclarativeParentChange::heightIsSet() const -{ - Q_D(const QDeclarativeParentChange); - return d->heightString.isValid(); -} - -QDeclarativeScriptString QDeclarativeParentChange::scale() const -{ - Q_D(const QDeclarativeParentChange); - return d->scaleString.value; -} - -void QDeclarativeParentChange::setScale(QDeclarativeScriptString scale) -{ - Q_D(QDeclarativeParentChange); - d->scaleString = scale; - tryReal(d->scale, scale.script()); -} - -bool QDeclarativeParentChange::scaleIsSet() const -{ - Q_D(const QDeclarativeParentChange); - return d->scaleString.isValid(); -} - -QDeclarativeScriptString QDeclarativeParentChange::rotation() const -{ - Q_D(const QDeclarativeParentChange); - return d->rotationString.value; -} - -void QDeclarativeParentChange::setRotation(QDeclarativeScriptString rotation) -{ - Q_D(QDeclarativeParentChange); - d->rotationString = rotation; - tryReal(d->rotation, rotation.script()); -} - -bool QDeclarativeParentChange::rotationIsSet() const -{ - Q_D(const QDeclarativeParentChange); - return d->rotationString.isValid(); -} - -QDeclarativeItem *QDeclarativeParentChange::originalParent() const -{ - Q_D(const QDeclarativeParentChange); - return d->origParent; -} - -/*! - \qmlproperty Item ParentChange::target - This property holds the item to be reparented -*/ - -QDeclarativeItem *QDeclarativeParentChange::object() const -{ - Q_D(const QDeclarativeParentChange); - return d->target; -} - -void QDeclarativeParentChange::setObject(QDeclarativeItem *target) -{ - Q_D(QDeclarativeParentChange); - d->target = target; -} - -/*! - \qmlproperty Item ParentChange::parent - This property holds the new parent for the item in this state. -*/ - -QDeclarativeItem *QDeclarativeParentChange::parent() const -{ - Q_D(const QDeclarativeParentChange); - return d->parent; -} - -void QDeclarativeParentChange::setParent(QDeclarativeItem *parent) -{ - Q_D(QDeclarativeParentChange); - d->parent = parent; -} - -QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions() -{ - Q_D(QDeclarativeParentChange); - if (!d->target || !d->parent) - return ActionList(); - - ActionList actions; - - QDeclarativeAction a; - a.event = this; - actions << a; - - QDeclarativeContext *ctxt = qmlContext(this); - - if (d->xString.isValid()) { - if (d->x.isValid()) { - QDeclarativeAction xa(d->target, QLatin1String("x"), ctxt, d->x.value); - actions << xa; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->xString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x"), ctxt)); - QDeclarativeAction xa; - xa.property = newBinding->property(); - xa.toBinding = newBinding; - xa.fromValue = xa.property.read(); - xa.deletableToBinding = true; - actions << xa; - } - } - - if (d->yString.isValid()) { - if (d->y.isValid()) { - QDeclarativeAction ya(d->target, QLatin1String("y"), ctxt, d->y.value); - actions << ya; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->yString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y"), ctxt)); - QDeclarativeAction ya; - ya.property = newBinding->property(); - ya.toBinding = newBinding; - ya.fromValue = ya.property.read(); - ya.deletableToBinding = true; - actions << ya; - } - } - - if (d->scaleString.isValid()) { - if (d->scale.isValid()) { - QDeclarativeAction sa(d->target, QLatin1String("scale"), ctxt, d->scale.value); - actions << sa; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->scaleString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale"), ctxt)); - QDeclarativeAction sa; - sa.property = newBinding->property(); - sa.toBinding = newBinding; - sa.fromValue = sa.property.read(); - sa.deletableToBinding = true; - actions << sa; - } - } - - if (d->rotationString.isValid()) { - if (d->rotation.isValid()) { - QDeclarativeAction ra(d->target, QLatin1String("rotation"), ctxt, d->rotation.value); - actions << ra; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->rotationString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation"), ctxt)); - QDeclarativeAction ra; - ra.property = newBinding->property(); - ra.toBinding = newBinding; - ra.fromValue = ra.property.read(); - ra.deletableToBinding = true; - actions << ra; - } - } - - if (d->widthString.isValid()) { - if (d->width.isValid()) { - QDeclarativeAction wa(d->target, QLatin1String("width"), ctxt, d->width.value); - actions << wa; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->widthString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width"), ctxt)); - QDeclarativeAction wa; - wa.property = newBinding->property(); - wa.toBinding = newBinding; - wa.fromValue = wa.property.read(); - wa.deletableToBinding = true; - actions << wa; - } - } - - if (d->heightString.isValid()) { - if (d->height.isValid()) { - QDeclarativeAction ha(d->target, QLatin1String("height"), ctxt, d->height.value); - actions << ha; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->heightString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height"), ctxt)); - QDeclarativeAction ha; - ha.property = newBinding->property(); - ha.toBinding = newBinding; - ha.fromValue = ha.property.read(); - ha.deletableToBinding = true; - actions << ha; - } - } - - return actions; -} - -class AccessibleFxItem : public QDeclarativeItem -{ - Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) -public: - int siblingIndex() { - Q_D(QDeclarativeItem); - return d->siblingIndex; - } -}; - -void QDeclarativeParentChange::saveOriginals() -{ - Q_D(QDeclarativeParentChange); - saveCurrentValues(); - d->origParent = d->rewindParent; - d->origStackBefore = d->rewindStackBefore; -} - -/*void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) -{ - Q_D(QDeclarativeParentChange); - QDeclarativeParentChange *pc = static_cast(other); - - d->origParent = pc->d_func()->rewindParent; - d->origStackBefore = pc->d_func()->rewindStackBefore; - - saveCurrentValues(); -}*/ - -void QDeclarativeParentChange::execute(Reason) -{ - Q_D(QDeclarativeParentChange); - d->doChange(d->parent); -} - -bool QDeclarativeParentChange::isReversable() -{ - return true; -} - -void QDeclarativeParentChange::reverse(Reason) -{ - Q_D(QDeclarativeParentChange); - d->doChange(d->origParent, d->origStackBefore); -} - -QString QDeclarativeParentChange::typeName() const -{ - return QLatin1String("ParentChange"); -} - -bool QDeclarativeParentChange::override(QDeclarativeActionEvent*other) -{ - Q_D(QDeclarativeParentChange); - if (other->typeName() != QLatin1String("ParentChange")) - return false; - if (QDeclarativeParentChange *otherPC = static_cast(other)) - return (d->target == otherPC->object()); - return false; -} - -void QDeclarativeParentChange::saveCurrentValues() -{ - Q_D(QDeclarativeParentChange); - if (!d->target) { - d->rewindParent = 0; - d->rewindStackBefore = 0; - return; - } - - d->rewindParent = d->target->parentItem(); - d->rewindStackBefore = 0; - - if (!d->rewindParent) - return; - - //try to determine the item's original stack position so we can restore it - int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1; - QList children = d->rewindParent->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if (!child) - continue; - if (((AccessibleFxItem*)child)->siblingIndex() == siblingIndex) { - d->rewindStackBefore = child; - break; - } - } -} - -void QDeclarativeParentChange::rewind() -{ - Q_D(QDeclarativeParentChange); - d->doChange(d->rewindParent, d->rewindStackBefore); -} - class QDeclarativeStateChangeScriptPrivate : public QDeclarativeStateOperationPrivate { public: @@ -684,903 +156,7 @@ QString QDeclarativeStateChangeScript::typeName() const return QLatin1String("StateChangeScript"); } -/*! - \qmlclass AnchorChanges QDeclarativeAnchorChanges - \ingroup qml-state-elements - \brief The AnchorChanges element allows you to change the anchors of an item in a state. - - The AnchorChanges element is used to modify the anchors of an item in a \l State. - - AnchorChanges cannot be used to modify the margins on an item. For this, use - PropertyChanges intead. - - In the following example we change the top and bottom anchors of an item - using AnchorChanges, and the top and bottom anchor margins using - PropertyChanges: - - \snippet doc/src/snippets/declarative/anchorchanges.qml 0 - - \image anchorchanges.png - - AnchorChanges can be animated using AnchorAnimation. - \qml - //animate our anchor changes - Transition { - AnchorAnimation {} - } - \endqml - - Margin animations can be animated using NumberAnimation. - - For more information on anchors see \l {anchor-layout}{Anchor Layouts}. -*/ - -class QDeclarativeAnchorSetPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeAnchorSet) -public: - QDeclarativeAnchorSetPrivate() - : usedAnchors(0), resetAnchors(0), fill(0), - centerIn(0)/*, leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), - margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)*/ - { - } - - QDeclarativeAnchors::Anchors usedAnchors; - QDeclarativeAnchors::Anchors resetAnchors; - - QDeclarativeItem *fill; - QDeclarativeItem *centerIn; - - QDeclarativeScriptString leftScript; - QDeclarativeScriptString rightScript; - QDeclarativeScriptString topScript; - QDeclarativeScriptString bottomScript; - QDeclarativeScriptString hCenterScript; - QDeclarativeScriptString vCenterScript; - QDeclarativeScriptString baselineScript; - - /*qreal leftMargin; - qreal rightMargin; - qreal topMargin; - qreal bottomMargin; - qreal margins; - qreal vCenterOffset; - qreal hCenterOffset; - qreal baselineOffset;*/ -}; - -QDeclarativeAnchorSet::QDeclarativeAnchorSet(QObject *parent) - : QObject(*new QDeclarativeAnchorSetPrivate, parent) -{ -} - -QDeclarativeAnchorSet::~QDeclarativeAnchorSet() -{ -} - -QDeclarativeScriptString QDeclarativeAnchorSet::top() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->topScript; -} - -void QDeclarativeAnchorSet::setTop(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors |= QDeclarativeAnchors::TopAnchor; - d->topScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetTop(); -} - -void QDeclarativeAnchorSet::resetTop() -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors &= ~QDeclarativeAnchors::TopAnchor; - d->topScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarativeAnchors::TopAnchor; -} - -QDeclarativeScriptString QDeclarativeAnchorSet::bottom() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->bottomScript; -} - -void QDeclarativeAnchorSet::setBottom(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors |= QDeclarativeAnchors::BottomAnchor; - d->bottomScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetBottom(); -} - -void QDeclarativeAnchorSet::resetBottom() -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors &= ~QDeclarativeAnchors::BottomAnchor; - d->bottomScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarativeAnchors::BottomAnchor; -} - -QDeclarativeScriptString QDeclarativeAnchorSet::verticalCenter() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->vCenterScript; -} - -void QDeclarativeAnchorSet::setVerticalCenter(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors |= QDeclarativeAnchors::VCenterAnchor; - d->vCenterScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetVerticalCenter(); -} - -void QDeclarativeAnchorSet::resetVerticalCenter() -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors &= ~QDeclarativeAnchors::VCenterAnchor; - d->vCenterScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarativeAnchors::VCenterAnchor; -} - -QDeclarativeScriptString QDeclarativeAnchorSet::baseline() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->baselineScript; -} - -void QDeclarativeAnchorSet::setBaseline(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors |= QDeclarativeAnchors::BaselineAnchor; - d->baselineScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetBaseline(); -} - -void QDeclarativeAnchorSet::resetBaseline() -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors &= ~QDeclarativeAnchors::BaselineAnchor; - d->baselineScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarativeAnchors::BaselineAnchor; -} - -QDeclarativeScriptString QDeclarativeAnchorSet::left() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->leftScript; -} - -void QDeclarativeAnchorSet::setLeft(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors |= QDeclarativeAnchors::LeftAnchor; - d->leftScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetLeft(); -} - -void QDeclarativeAnchorSet::resetLeft() -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors &= ~QDeclarativeAnchors::LeftAnchor; - d->leftScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarativeAnchors::LeftAnchor; -} - -QDeclarativeScriptString QDeclarativeAnchorSet::right() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->rightScript; -} - -void QDeclarativeAnchorSet::setRight(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors |= QDeclarativeAnchors::RightAnchor; - d->rightScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetRight(); -} - -void QDeclarativeAnchorSet::resetRight() -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors &= ~QDeclarativeAnchors::RightAnchor; - d->rightScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarativeAnchors::RightAnchor; -} - -QDeclarativeScriptString QDeclarativeAnchorSet::horizontalCenter() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->hCenterScript; -} - -void QDeclarativeAnchorSet::setHorizontalCenter(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors |= QDeclarativeAnchors::HCenterAnchor; - d->hCenterScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetHorizontalCenter(); -} - -void QDeclarativeAnchorSet::resetHorizontalCenter() -{ - Q_D(QDeclarativeAnchorSet); - d->usedAnchors &= ~QDeclarativeAnchors::HCenterAnchor; - d->hCenterScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarativeAnchors::HCenterAnchor; -} - -QDeclarativeItem *QDeclarativeAnchorSet::fill() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->fill; -} - -void QDeclarativeAnchorSet::setFill(QDeclarativeItem *f) -{ - Q_D(QDeclarativeAnchorSet); - d->fill = f; -} - -void QDeclarativeAnchorSet::resetFill() -{ - setFill(0); -} - -QDeclarativeItem *QDeclarativeAnchorSet::centerIn() const -{ - Q_D(const QDeclarativeAnchorSet); - return d->centerIn; -} - -void QDeclarativeAnchorSet::setCenterIn(QDeclarativeItem* c) -{ - Q_D(QDeclarativeAnchorSet); - d->centerIn = c; -} - -void QDeclarativeAnchorSet::resetCenterIn() -{ - setCenterIn(0); -} - - -class QDeclarativeAnchorChangesPrivate : public QDeclarativeStateOperationPrivate -{ -public: - QDeclarativeAnchorChangesPrivate() - : target(0), anchorSet(new QDeclarativeAnchorSet), - leftBinding(0), rightBinding(0), hCenterBinding(0), - topBinding(0), bottomBinding(0), vCenterBinding(0), baselineBinding(0), - origLeftBinding(0), origRightBinding(0), origHCenterBinding(0), - origTopBinding(0), origBottomBinding(0), origVCenterBinding(0), - origBaselineBinding(0) - { - - } - ~QDeclarativeAnchorChangesPrivate() { delete anchorSet; } - - QDeclarativeItem *target; - QDeclarativeAnchorSet *anchorSet; - - QDeclarativeBinding *leftBinding; - QDeclarativeBinding *rightBinding; - QDeclarativeBinding *hCenterBinding; - QDeclarativeBinding *topBinding; - QDeclarativeBinding *bottomBinding; - QDeclarativeBinding *vCenterBinding; - QDeclarativeBinding *baselineBinding; - - QDeclarativeAbstractBinding *origLeftBinding; - QDeclarativeAbstractBinding *origRightBinding; - QDeclarativeAbstractBinding *origHCenterBinding; - QDeclarativeAbstractBinding *origTopBinding; - QDeclarativeAbstractBinding *origBottomBinding; - QDeclarativeAbstractBinding *origVCenterBinding; - QDeclarativeAbstractBinding *origBaselineBinding; - - QDeclarativeAnchorLine rewindLeft; - QDeclarativeAnchorLine rewindRight; - QDeclarativeAnchorLine rewindHCenter; - QDeclarativeAnchorLine rewindTop; - QDeclarativeAnchorLine rewindBottom; - QDeclarativeAnchorLine rewindVCenter; - QDeclarativeAnchorLine rewindBaseline; - - qreal fromX; - qreal fromY; - qreal fromWidth; - qreal fromHeight; - - qreal toX; - qreal toY; - qreal toWidth; - qreal toHeight; - - qreal rewindX; - qreal rewindY; - qreal rewindWidth; - qreal rewindHeight; - - bool applyOrigLeft; - bool applyOrigRight; - bool applyOrigHCenter; - bool applyOrigTop; - bool applyOrigBottom; - bool applyOrigVCenter; - bool applyOrigBaseline; - - QDeclarativeNullableValue origWidth; - QDeclarativeNullableValue origHeight; - qreal origX; - qreal origY; - - QList oldBindings; - - QDeclarativeProperty leftProp; - QDeclarativeProperty rightProp; - QDeclarativeProperty hCenterProp; - QDeclarativeProperty topProp; - QDeclarativeProperty bottomProp; - QDeclarativeProperty vCenterProp; - QDeclarativeProperty baselineProp; -}; - -/*! - \qmlproperty Item AnchorChanges::target - This property holds the \l Item for which the anchor changes will be applied. -*/ - -QDeclarativeAnchorChanges::QDeclarativeAnchorChanges(QObject *parent) - : QDeclarativeStateOperation(*(new QDeclarativeAnchorChangesPrivate), parent) -{ -} - -QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges() -{ -} - -QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions() -{ - Q_D(QDeclarativeAnchorChanges); - d->leftBinding = d->rightBinding = d->hCenterBinding = d->topBinding - = d->bottomBinding = d->vCenterBinding = d->baselineBinding = 0; - - d->leftProp = QDeclarativeProperty(d->target, QLatin1String("anchors.left")); - d->rightProp = QDeclarativeProperty(d->target, QLatin1String("anchors.right")); - d->hCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.horizontalCenter")); - d->topProp = QDeclarativeProperty(d->target, QLatin1String("anchors.top")); - d->bottomProp = QDeclarativeProperty(d->target, QLatin1String("anchors.bottom")); - d->vCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.verticalCenter")); - d->baselineProp = QDeclarativeProperty(d->target, QLatin1String("anchors.baseline")); - - QDeclarativeContext *ctxt = qmlContext(this); - - if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::LeftAnchor) { - d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, ctxt); - d->leftBinding->setTarget(d->leftProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::RightAnchor) { - d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, ctxt); - d->rightBinding->setTarget(d->rightProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::HCenterAnchor) { - d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, ctxt); - d->hCenterBinding->setTarget(d->hCenterProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::TopAnchor) { - d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, ctxt); - d->topBinding->setTarget(d->topProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::BottomAnchor) { - d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, ctxt); - d->bottomBinding->setTarget(d->bottomProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::VCenterAnchor) { - d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, ctxt); - d->vCenterBinding->setTarget(d->vCenterProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::BaselineAnchor) { - d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, ctxt); - d->baselineBinding->setTarget(d->baselineProp); - } - - QDeclarativeAction a; - a.event = this; - return ActionList() << a; -} - -QDeclarativeAnchorSet *QDeclarativeAnchorChanges::anchors() -{ - Q_D(QDeclarativeAnchorChanges); - return d->anchorSet; -} - -QDeclarativeItem *QDeclarativeAnchorChanges::object() const -{ - Q_D(const QDeclarativeAnchorChanges); - return d->target; -} - -void QDeclarativeAnchorChanges::setObject(QDeclarativeItem *target) -{ - Q_D(QDeclarativeAnchorChanges); - d->target = target; -} - -/*! - \qmlproperty AnchorLine AnchorChanges::anchors.left - \qmlproperty AnchorLine AnchorChanges::anchors.right - \qmlproperty AnchorLine AnchorChanges::anchors.horizontalCenter - \qmlproperty AnchorLine AnchorChanges::anchors.top - \qmlproperty AnchorLine AnchorChanges::anchors.bottom - \qmlproperty AnchorLine AnchorChanges::anchors.verticalCenter - \qmlproperty AnchorLine AnchorChanges::anchors.baseline - - These properties change the respective anchors of the item. - - To reset an anchor you can assign \c undefined: - \qml - AnchorChanges { - target: myItem - anchors.left: undefined //remove myItem's left anchor - anchors.right: otherItem.right - } - \endqml -*/ - -void QDeclarativeAnchorChanges::execute(Reason reason) -{ - Q_D(QDeclarativeAnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - //incorporate any needed "reverts" - if (d->applyOrigLeft) { - if (!d->origLeftBinding) - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); - } - if (d->applyOrigRight) { - if (!d->origRightBinding) - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); - } - if (d->applyOrigHCenter) { - if (!d->origHCenterBinding) - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); - } - if (d->applyOrigTop) { - if (!d->origTopBinding) - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); - } - if (d->applyOrigBottom) { - if (!d->origBottomBinding) - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); - } - if (d->applyOrigVCenter) { - if (!d->origVCenterBinding) - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); - } - if (d->applyOrigBaseline) { - if (!d->origBaselineBinding) - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); - } - - //destroy old bindings - if (reason == ActualChange) { - for (int i = 0; i < d->oldBindings.size(); ++i) { - QDeclarativeAbstractBinding *binding = d->oldBindings.at(i); - if (binding) - binding->destroy(); - } - d->oldBindings.clear(); - } - - //reset any anchors that have been specified as "undefined" - if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::LeftAnchor) { - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::RightAnchor) { - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::HCenterAnchor) { - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::TopAnchor) { - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BottomAnchor) { - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::VCenterAnchor) { - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BaselineAnchor) { - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); - } - - //set any anchors that have been specified - if (d->leftBinding) - QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), d->leftBinding); - if (d->rightBinding) - QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), d->rightBinding); - if (d->hCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), d->hCenterBinding); - if (d->topBinding) - QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), d->topBinding); - if (d->bottomBinding) - QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), d->bottomBinding); - if (d->vCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), d->vCenterBinding); - if (d->baselineBinding) - QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), d->baselineBinding); -} - -bool QDeclarativeAnchorChanges::isReversable() -{ - return true; -} - -void QDeclarativeAnchorChanges::reverse(Reason reason) -{ - Q_D(QDeclarativeAnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - //reset any anchors set by the state - if (d->leftBinding) { - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0); - if (reason == ActualChange) { - d->leftBinding->destroy(); d->leftBinding = 0; - } - } - if (d->rightBinding) { - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0); - if (reason == ActualChange) { - d->rightBinding->destroy(); d->rightBinding = 0; - } - } - if (d->hCenterBinding) { - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0); - if (reason == ActualChange) { - d->hCenterBinding->destroy(); d->hCenterBinding = 0; - } - } - if (d->topBinding) { - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0); - if (reason == ActualChange) { - d->topBinding->destroy(); d->topBinding = 0; - } - } - if (d->bottomBinding) { - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0); - if (reason == ActualChange) { - d->bottomBinding->destroy(); d->bottomBinding = 0; - } - } - if (d->vCenterBinding) { - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0); - if (reason == ActualChange) { - d->vCenterBinding->destroy(); d->vCenterBinding = 0; - } - } - if (d->baselineBinding) { - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0); - if (reason == ActualChange) { - d->baselineBinding->destroy(); d->baselineBinding = 0; - } - } - - //restore previous anchors - if (d->origLeftBinding) - QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); - if (d->origRightBinding) - QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); - if (d->origHCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); - if (d->origTopBinding) - QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); - if (d->origBottomBinding) - QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); - if (d->origVCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); - if (d->origBaselineBinding) - QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); - - //restore any absolute geometry changed by the state's anchors - QDeclarativeAnchors::Anchors stateVAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::Vertical_Mask; - QDeclarativeAnchors::Anchors origVAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarativeAnchors::Vertical_Mask; - QDeclarativeAnchors::Anchors stateHAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::Horizontal_Mask; - QDeclarativeAnchors::Anchors origHAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarativeAnchors::Horizontal_Mask; - - bool stateSetWidth = (stateHAnchors && - stateHAnchors != QDeclarativeAnchors::LeftAnchor && - stateHAnchors != QDeclarativeAnchors::RightAnchor && - stateHAnchors != QDeclarativeAnchors::HCenterAnchor); - bool origSetWidth = (origHAnchors && - origHAnchors != QDeclarativeAnchors::LeftAnchor && - origHAnchors != QDeclarativeAnchors::RightAnchor && - origHAnchors != QDeclarativeAnchors::HCenterAnchor); - if (d->origWidth.isValid() && stateSetWidth && !origSetWidth) - d->target->setWidth(d->origWidth.value); - - bool stateSetHeight = (stateVAnchors && - stateVAnchors != QDeclarativeAnchors::TopAnchor && - stateVAnchors != QDeclarativeAnchors::BottomAnchor && - stateVAnchors != QDeclarativeAnchors::VCenterAnchor && - stateVAnchors != QDeclarativeAnchors::BaselineAnchor); - bool origSetHeight = (origVAnchors && - origVAnchors != QDeclarativeAnchors::TopAnchor && - origVAnchors != QDeclarativeAnchors::BottomAnchor && - origVAnchors != QDeclarativeAnchors::VCenterAnchor && - origVAnchors != QDeclarativeAnchors::BaselineAnchor); - if (d->origHeight.isValid() && stateSetHeight && !origSetHeight) - d->target->setHeight(d->origHeight.value); - - if (stateHAnchors && !origHAnchors) - d->target->setX(d->origX); - - if (stateVAnchors && !origVAnchors) - d->target->setY(d->origY); -} - -QString QDeclarativeAnchorChanges::typeName() const -{ - return QLatin1String("AnchorChanges"); -} - -QList QDeclarativeAnchorChanges::additionalActions() -{ - Q_D(QDeclarativeAnchorChanges); - QList extra; - - QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors; - bool hChange = combined & QDeclarativeAnchors::Horizontal_Mask; - bool vChange = combined & QDeclarativeAnchors::Vertical_Mask; - - if (d->target) { - QDeclarativeContext *ctxt = qmlContext(this); - QDeclarativeAction a; - if (hChange && d->fromX != d->toX) { - a.property = QDeclarativeProperty(d->target, QLatin1String("x"), ctxt); - a.toValue = d->toX; - extra << a; - } - if (vChange && d->fromY != d->toY) { - a.property = QDeclarativeProperty(d->target, QLatin1String("y"), ctxt); - a.toValue = d->toY; - extra << a; - } - if (hChange && d->fromWidth != d->toWidth) { - a.property = QDeclarativeProperty(d->target, QLatin1String("width"), ctxt); - a.toValue = d->toWidth; - extra << a; - } - if (vChange && d->fromHeight != d->toHeight) { - a.property = QDeclarativeProperty(d->target, QLatin1String("height"), ctxt); - a.toValue = d->toHeight; - extra << a; - } - } - - return extra; -} - -bool QDeclarativeAnchorChanges::changesBindings() -{ - return true; -} - -void QDeclarativeAnchorChanges::saveOriginals() -{ - Q_D(QDeclarativeAnchorChanges); - if (!d->target) - return; - - d->origLeftBinding = QDeclarativePropertyPrivate::binding(d->leftProp); - d->origRightBinding = QDeclarativePropertyPrivate::binding(d->rightProp); - d->origHCenterBinding = QDeclarativePropertyPrivate::binding(d->hCenterProp); - d->origTopBinding = QDeclarativePropertyPrivate::binding(d->topProp); - d->origBottomBinding = QDeclarativePropertyPrivate::binding(d->bottomProp); - d->origVCenterBinding = QDeclarativePropertyPrivate::binding(d->vCenterProp); - d->origBaselineBinding = QDeclarativePropertyPrivate::binding(d->baselineProp); - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - if (targetPrivate->widthValid) - d->origWidth = d->target->width(); - if (targetPrivate->heightValid) - d->origHeight = d->target->height(); - d->origX = d->target->x(); - d->origY = d->target->y(); - - d->applyOrigLeft = d->applyOrigRight = d->applyOrigHCenter = d->applyOrigTop - = d->applyOrigBottom = d->applyOrigVCenter = d->applyOrigBaseline = false; - - saveCurrentValues(); -} - -void QDeclarativeAnchorChanges::copyOriginals(QDeclarativeActionEvent *other) -{ - Q_D(QDeclarativeAnchorChanges); - QDeclarativeAnchorChanges *ac = static_cast(other); - QDeclarativeAnchorChangesPrivate *acp = ac->d_func(); - - QDeclarativeAnchors::Anchors combined = acp->anchorSet->d_func()->usedAnchors | - acp->anchorSet->d_func()->resetAnchors; - - //probably also need to revert some things - d->applyOrigLeft = (combined & QDeclarativeAnchors::LeftAnchor); - d->applyOrigRight = (combined & QDeclarativeAnchors::RightAnchor); - d->applyOrigHCenter = (combined & QDeclarativeAnchors::HCenterAnchor); - d->applyOrigTop = (combined & QDeclarativeAnchors::TopAnchor); - d->applyOrigBottom = (combined & QDeclarativeAnchors::BottomAnchor); - d->applyOrigVCenter = (combined & QDeclarativeAnchors::VCenterAnchor); - d->applyOrigBaseline = (combined & QDeclarativeAnchors::BaselineAnchor); - - d->origLeftBinding = acp->origLeftBinding; - d->origRightBinding = acp->origRightBinding; - d->origHCenterBinding = acp->origHCenterBinding; - d->origTopBinding = acp->origTopBinding; - d->origBottomBinding = acp->origBottomBinding; - d->origVCenterBinding = acp->origVCenterBinding; - d->origBaselineBinding = acp->origBaselineBinding; - - d->origWidth = acp->origWidth; - d->origHeight = acp->origHeight; - d->origX = acp->origX; - d->origY = acp->origY; - - d->oldBindings.clear(); - d->oldBindings << acp->leftBinding << acp->rightBinding << acp->hCenterBinding - << acp->topBinding << acp->bottomBinding << acp->baselineBinding; - - saveCurrentValues(); -} - -void QDeclarativeAnchorChanges::clearBindings() -{ - Q_D(QDeclarativeAnchorChanges); - if (!d->target) - return; - - //### should this (saving "from" values) be moved to saveCurrentValues()? - d->fromX = d->target->x(); - d->fromY = d->target->y(); - d->fromWidth = d->target->width(); - d->fromHeight = d->target->height(); - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - //reset any anchors with corresponding reverts - //reset any anchors that have been specified as "undefined" - //reset any anchors that we'll be setting in the state - QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->resetAnchors | - d->anchorSet->d_func()->usedAnchors; - if (d->applyOrigLeft || (combined & QDeclarativeAnchors::LeftAnchor)) { - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); - } - if (d->applyOrigRight || (combined & QDeclarativeAnchors::RightAnchor)) { - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); - } - if (d->applyOrigHCenter || (combined & QDeclarativeAnchors::HCenterAnchor)) { - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); - } - if (d->applyOrigTop || (combined & QDeclarativeAnchors::TopAnchor)) { - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topProp, 0); - } - if (d->applyOrigBottom || (combined & QDeclarativeAnchors::BottomAnchor)) { - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); - } - if (d->applyOrigVCenter || (combined & QDeclarativeAnchors::VCenterAnchor)) { - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); - } - if (d->applyOrigBaseline || (combined & QDeclarativeAnchors::BaselineAnchor)) { - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); - } -} - -bool QDeclarativeAnchorChanges::override(QDeclarativeActionEvent*other) -{ - if (other->typeName() != QLatin1String("AnchorChanges")) - return false; - if (static_cast(this) == other) - return true; - if (static_cast(other)->object() == object()) - return true; - return false; -} - -void QDeclarativeAnchorChanges::rewind() -{ - Q_D(QDeclarativeAnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - - //restore previous values (but not previous bindings, i.e. anchors) - d->target->setX(d->rewindX); - d->target->setY(d->rewindY); - if (targetPrivate->widthValid) { - d->target->setWidth(d->rewindWidth); - } - if (targetPrivate->heightValid) { - d->target->setHeight(d->rewindHeight); - } -} - -void QDeclarativeAnchorChanges::saveCurrentValues() -{ - Q_D(QDeclarativeAnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - d->rewindLeft = targetPrivate->anchors()->left(); - d->rewindRight = targetPrivate->anchors()->right(); - d->rewindHCenter = targetPrivate->anchors()->horizontalCenter(); - d->rewindTop = targetPrivate->anchors()->top(); - d->rewindBottom = targetPrivate->anchors()->bottom(); - d->rewindVCenter = targetPrivate->anchors()->verticalCenter(); - d->rewindBaseline = targetPrivate->anchors()->baseline(); - - d->rewindX = d->target->x(); - d->rewindY = d->target->y(); - d->rewindWidth = d->target->width(); - d->rewindHeight = d->target->height(); -} - -void QDeclarativeAnchorChanges::saveTargetValues() -{ - Q_D(QDeclarativeAnchorChanges); - if (!d->target) - return; - - d->toX = d->target->x(); - d->toY = d->target->y(); - d->toWidth = d->target->width(); - d->toHeight = d->target->height(); -} -#include #include QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h index 6a6dda6526..9d30bf7578 100644 --- a/src/declarative/util/qdeclarativestateoperations_p.h +++ b/src/declarative/util/qdeclarativestateoperations_p.h @@ -43,9 +43,6 @@ #define QDECLARATIVESTATEOPERATIONS_H #include "private/qdeclarativestate_p.h" - -#include -#include #include QT_BEGIN_HEADER @@ -54,68 +51,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeParentChangePrivate; -class Q_AUTOTEST_EXPORT QDeclarativeParentChange : public QDeclarativeStateOperation, public QDeclarativeActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeParentChange) - - Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) - Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) - Q_PROPERTY(QDeclarativeScriptString x READ x WRITE setX) - Q_PROPERTY(QDeclarativeScriptString y READ y WRITE setY) - Q_PROPERTY(QDeclarativeScriptString width READ width WRITE setWidth) - Q_PROPERTY(QDeclarativeScriptString height READ height WRITE setHeight) - Q_PROPERTY(QDeclarativeScriptString scale READ scale WRITE setScale) - Q_PROPERTY(QDeclarativeScriptString rotation READ rotation WRITE setRotation) -public: - QDeclarativeParentChange(QObject *parent=0); - ~QDeclarativeParentChange(); - - QDeclarativeItem *object() const; - void setObject(QDeclarativeItem *); - - QDeclarativeItem *parent() const; - void setParent(QDeclarativeItem *); - - QDeclarativeItem *originalParent() const; - - QDeclarativeScriptString x() const; - void setX(QDeclarativeScriptString x); - bool xIsSet() const; - - QDeclarativeScriptString y() const; - void setY(QDeclarativeScriptString y); - bool yIsSet() const; - - QDeclarativeScriptString width() const; - void setWidth(QDeclarativeScriptString width); - bool widthIsSet() const; - - QDeclarativeScriptString height() const; - void setHeight(QDeclarativeScriptString height); - bool heightIsSet() const; - - QDeclarativeScriptString scale() const; - void setScale(QDeclarativeScriptString scale); - bool scaleIsSet() const; - - QDeclarativeScriptString rotation() const; - void setRotation(QDeclarativeScriptString rotation); - bool rotationIsSet() const; - - virtual ActionList actions(); - - virtual void saveOriginals(); - //virtual void copyOriginals(QDeclarativeActionEvent*); - virtual void execute(Reason reason = ActualChange); - virtual bool isReversable(); - virtual void reverse(Reason reason = ActualChange); - virtual QString typeName() const; - virtual bool override(QDeclarativeActionEvent*other); - virtual void rewind(); - virtual void saveCurrentValues(); -}; class QDeclarativeStateChangeScriptPrivate; class Q_AUTOTEST_EXPORT QDeclarativeStateChangeScript : public QDeclarativeStateOperation, public QDeclarativeActionEvent @@ -143,156 +78,10 @@ class Q_AUTOTEST_EXPORT QDeclarativeStateChangeScript : public QDeclarativeState virtual void execute(Reason reason = ActualChange); }; -class QDeclarativeAnchorChanges; -class QDeclarativeAnchorSetPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeAnchorSet : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeScriptString left READ left WRITE setLeft RESET resetLeft) - Q_PROPERTY(QDeclarativeScriptString right READ right WRITE setRight RESET resetRight) - Q_PROPERTY(QDeclarativeScriptString horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter) - Q_PROPERTY(QDeclarativeScriptString top READ top WRITE setTop RESET resetTop) - Q_PROPERTY(QDeclarativeScriptString bottom READ bottom WRITE setBottom RESET resetBottom) - Q_PROPERTY(QDeclarativeScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) - Q_PROPERTY(QDeclarativeScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline) - //Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill) - //Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn) - - /*Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) - Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) - Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) - Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) - Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) - Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) - Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) - Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())*/ - -public: - QDeclarativeAnchorSet(QObject *parent=0); - virtual ~QDeclarativeAnchorSet(); - - QDeclarativeScriptString left() const; - void setLeft(const QDeclarativeScriptString &edge); - void resetLeft(); - - QDeclarativeScriptString right() const; - void setRight(const QDeclarativeScriptString &edge); - void resetRight(); - - QDeclarativeScriptString horizontalCenter() const; - void setHorizontalCenter(const QDeclarativeScriptString &edge); - void resetHorizontalCenter(); - - QDeclarativeScriptString top() const; - void setTop(const QDeclarativeScriptString &edge); - void resetTop(); - - QDeclarativeScriptString bottom() const; - void setBottom(const QDeclarativeScriptString &edge); - void resetBottom(); - - QDeclarativeScriptString verticalCenter() const; - void setVerticalCenter(const QDeclarativeScriptString &edge); - void resetVerticalCenter(); - - QDeclarativeScriptString baseline() const; - void setBaseline(const QDeclarativeScriptString &edge); - void resetBaseline(); - - QDeclarativeItem *fill() const; - void setFill(QDeclarativeItem *); - void resetFill(); - - QDeclarativeItem *centerIn() const; - void setCenterIn(QDeclarativeItem *); - void resetCenterIn(); - - /*qreal leftMargin() const; - void setLeftMargin(qreal); - - qreal rightMargin() const; - void setRightMargin(qreal); - - qreal horizontalCenterOffset() const; - void setHorizontalCenterOffset(qreal); - - qreal topMargin() const; - void setTopMargin(qreal); - - qreal bottomMargin() const; - void setBottomMargin(qreal); - - qreal margins() const; - void setMargins(qreal); - - qreal verticalCenterOffset() const; - void setVerticalCenterOffset(qreal); - - qreal baselineOffset() const; - void setBaselineOffset(qreal);*/ - - QDeclarativeAnchors::Anchors usedAnchors() const; - -/*Q_SIGNALS: - void leftMarginChanged(); - void rightMarginChanged(); - void topMarginChanged(); - void bottomMarginChanged(); - void marginsChanged(); - void verticalCenterOffsetChanged(); - void horizontalCenterOffsetChanged(); - void baselineOffsetChanged();*/ - -private: - friend class QDeclarativeAnchorChanges; - Q_DISABLE_COPY(QDeclarativeAnchorSet) - Q_DECLARE_PRIVATE(QDeclarativeAnchorSet) -}; - -class QDeclarativeAnchorChangesPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeAnchorChanges : public QDeclarativeStateOperation, public QDeclarativeActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeAnchorChanges) - - Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) - Q_PROPERTY(QDeclarativeAnchorSet *anchors READ anchors CONSTANT) - -public: - QDeclarativeAnchorChanges(QObject *parent=0); - ~QDeclarativeAnchorChanges(); - - virtual ActionList actions(); - - QDeclarativeAnchorSet *anchors(); - - QDeclarativeItem *object() const; - void setObject(QDeclarativeItem *); - - virtual void execute(Reason reason = ActualChange); - virtual bool isReversable(); - virtual void reverse(Reason reason = ActualChange); - virtual QString typeName() const; - virtual bool override(QDeclarativeActionEvent*other); - virtual bool changesBindings(); - virtual void saveOriginals(); - virtual bool needsCopy() { return true; } - virtual void copyOriginals(QDeclarativeActionEvent*); - virtual void clearBindings(); - virtual void rewind(); - virtual void saveCurrentValues(); - - QList additionalActions(); - virtual void saveTargetValues(); -}; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeParentChange) QML_DECLARE_TYPE(QDeclarativeStateChangeScript) -QML_DECLARE_TYPE(QDeclarativeAnchorSet) -QML_DECLARE_TYPE(QDeclarativeAnchorChanges) QT_END_HEADER diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp index 4bea2e651a..9f3c9b05bf 100644 --- a/src/declarative/util/qdeclarativeutilmodule.cpp +++ b/src/declarative/util/qdeclarativeutilmodule.cpp @@ -17,7 +17,7 @@ ** ** 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. +** version 1.2, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU General @@ -67,108 +67,60 @@ #include "private/qdeclarativetransitionmanager_p_p.h" #include "private/qdeclarativetransition_p.h" #include "private/qdeclarativeapplication_p.h" -#include "qdeclarativeview.h" #include "qdeclarativeinfo.h" #include "private/qdeclarativetypenotavailable_p.h" #ifndef QT_NO_XMLPATTERNS #include "private/qdeclarativexmllistmodel_p.h" #endif -void QDeclarativeUtilModule::defineModule() +void QDeclarativeUtilModule::registerBaseTypes(const char *uri, int versionMajor, int versionMinor) { - qmlRegisterUncreatableType("QtQuick",1,1,"Application", QDeclarativeApplication::tr("Application is an abstract class")); - - qmlRegisterType("QtQuick",1,0,"AnchorAnimation"); - qmlRegisterType("QtQuick",1,0,"AnchorChanges"); - qmlRegisterType("QtQuick",1,0,"Behavior"); - qmlRegisterType("QtQuick",1,0,"Binding"); - qmlRegisterType("QtQuick",1,0,"ColorAnimation"); - qmlRegisterType("QtQuick",1,0,"Connections"); - qmlRegisterType("QtQuick",1,0,"SmoothedAnimation"); - qmlRegisterType("QtQuick",1,0,"FontLoader"); - qmlRegisterType("QtQuick",1,0,"ListElement"); - qmlRegisterType("QtQuick",1,0,"NumberAnimation"); - qmlRegisterType("QtQuick",1,0,"Package"); - qmlRegisterType("QtQuick",1,0,"ParallelAnimation"); - qmlRegisterType("QtQuick",1,0,"ParentAnimation"); - qmlRegisterType("QtQuick",1,0,"ParentChange"); - qmlRegisterType("QtQuick",1,0,"PauseAnimation"); - qmlRegisterType("QtQuick",1,0,"PropertyAction"); - qmlRegisterType("QtQuick",1,0,"PropertyAnimation"); - qmlRegisterType("QtQuick",1,0,"RotationAnimation"); - qmlRegisterType("QtQuick",1,0,"ScriptAction"); - qmlRegisterType("QtQuick",1,0,"SequentialAnimation"); - qmlRegisterType("QtQuick",1,0,"SpringAnimation"); - qmlRegisterType("QtQuick",1,0,"StateChangeScript"); - qmlRegisterType("QtQuick",1,0,"StateGroup"); - qmlRegisterType("QtQuick",1,0,"State"); - qmlRegisterType("QtQuick",1,0,"SystemPalette"); - qmlRegisterType("QtQuick",1,0,"Timer"); - qmlRegisterType("QtQuick",1,0,"Transition"); - qmlRegisterType("QtQuick",1,0,"Vector3dAnimation"); -#ifdef QT_NO_XMLPATTERNS - qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlListModel", - qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns")); - qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlRole", - qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns")); -#else - qmlRegisterType("QtQuick",1,0,"XmlListModel"); - qmlRegisterType("QtQuick",1,0,"XmlRole"); -#endif - - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); + qmlRegisterType(uri, versionMajor, versionMinor,"ListElement"); + qmlRegisterCustomType(uri, versionMajor, versionMinor,"ListModel", new QDeclarativeListModelParser); +} - qmlRegisterUncreatableType("QtQuick",1,0,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class")); +void QDeclarativeUtilModule::defineModule() +{ + qmlRegisterUncreatableType("QtQuick",2,0,"Application", QDeclarativeApplication::tr("Application is an abstract class")); - qmlRegisterCustomType("QtQuick",1,0,"ListModel", new QDeclarativeListModelParser); - qmlRegisterCustomType("QtQuick",1,0,"PropertyChanges", new QDeclarativePropertyChangesParser); - qmlRegisterCustomType("QtQuick",1,0,"Connections", new QDeclarativeConnectionsParser); + qmlRegisterUncreatableType("QtQuick",2,0,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class")); -#ifndef QT_NO_IMPORT_QT47_QML - qmlRegisterType("Qt",4,7,"AnchorAnimation"); - qmlRegisterType("Qt",4,7,"AnchorChanges"); - qmlRegisterType("Qt",4,7,"Behavior"); - qmlRegisterType("Qt",4,7,"Binding"); - qmlRegisterType("Qt",4,7,"ColorAnimation"); - qmlRegisterType("Qt",4,7,"Connections"); - qmlRegisterType("Qt",4,7,"SmoothedAnimation"); - qmlRegisterType("Qt",4,7,"FontLoader"); - qmlRegisterType("Qt",4,7,"ListElement"); - qmlRegisterType("Qt",4,7,"NumberAnimation"); - qmlRegisterType("Qt",4,7,"Package"); - qmlRegisterType("Qt",4,7,"ParallelAnimation"); - qmlRegisterType("Qt",4,7,"ParentAnimation"); - qmlRegisterType("Qt",4,7,"ParentChange"); - qmlRegisterType("Qt",4,7,"PauseAnimation"); - qmlRegisterType("Qt",4,7,"PropertyAction"); - qmlRegisterType("Qt",4,7,"PropertyAnimation"); - qmlRegisterType("Qt",4,7,"RotationAnimation"); - qmlRegisterType("Qt",4,7,"ScriptAction"); - qmlRegisterType("Qt",4,7,"SequentialAnimation"); - qmlRegisterType("Qt",4,7,"SpringAnimation"); - qmlRegisterType("Qt",4,7,"StateChangeScript"); - qmlRegisterType("Qt",4,7,"StateGroup"); - qmlRegisterType("Qt",4,7,"State"); - qmlRegisterType("Qt",4,7,"SystemPalette"); - qmlRegisterType("Qt",4,7,"Timer"); - qmlRegisterType("Qt",4,7,"Transition"); - qmlRegisterType("Qt",4,7,"Vector3dAnimation"); + qmlRegisterType("QtQuick",2,0,"Behavior"); + qmlRegisterType("QtQuick",2,0,"Binding"); + qmlRegisterType("QtQuick",2,0,"ColorAnimation"); + qmlRegisterType("QtQuick",2,0,"Connections"); + qmlRegisterType("QtQuick",2,0,"SmoothedAnimation"); + qmlRegisterType("QtQuick",2,0,"FontLoader"); + qmlRegisterType("QtQuick",2,0,"NumberAnimation"); + qmlRegisterType("QtQuick",2,0,"Package"); + qmlRegisterType("QtQuick",2,0,"ParallelAnimation"); + qmlRegisterType("QtQuick",2,0,"PauseAnimation"); + qmlRegisterType("QtQuick",2,0,"PropertyAction"); + qmlRegisterType("QtQuick",2,0,"PropertyAnimation"); + qmlRegisterType("QtQuick",2,0,"RotationAnimation"); + qmlRegisterType("QtQuick",2,0,"ScriptAction"); + qmlRegisterType("QtQuick",2,0,"SequentialAnimation"); + qmlRegisterType("QtQuick",2,0,"SpringAnimation"); + qmlRegisterType("QtQuick",2,0,"StateChangeScript"); + qmlRegisterType("QtQuick",2,0,"StateGroup"); + qmlRegisterType("QtQuick",2,0,"State"); + qmlRegisterType("QtQuick",2,0,"SystemPalette"); + qmlRegisterType("QtQuick",2,0,"Timer"); + qmlRegisterType("QtQuick",2,0,"Transition"); + qmlRegisterType("QtQuick",2,0,"Vector3dAnimation"); #ifdef QT_NO_XMLPATTERNS - qmlRegisterTypeNotAvailable("Qt",4,7,"XmlListModel", + qmlRegisterTypeNotAvailable("QtQuick",2,0,"XmlListModel", qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns")); - qmlRegisterTypeNotAvailable("Qt",4,7,"XmlRole", + qmlRegisterTypeNotAvailable("QtQuick",2,0,"XmlRole", qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns")); #else - qmlRegisterType("Qt",4,7,"XmlListModel"); - qmlRegisterType("Qt",4,7,"XmlRole"); + qmlRegisterType("QtQuick",2,0,"XmlListModel"); + qmlRegisterType("QtQuick",2,0,"XmlRole"); #endif - qmlRegisterUncreatableType("Qt",4,7,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class")); + qmlRegisterType(); - qmlRegisterCustomType("Qt", 4,7, "ListModel", new QDeclarativeListModelParser); - qmlRegisterCustomType("Qt", 4, 7, "PropertyChanges", new QDeclarativePropertyChangesParser); - qmlRegisterCustomType("Qt", 4, 7, "Connections", new QDeclarativeConnectionsParser); -#endif + qmlRegisterCustomType("QtQuick",2,0,"PropertyChanges", new QDeclarativePropertyChangesParser); + qmlRegisterCustomType("QtQuick",2,0,"Connections", new QDeclarativeConnectionsParser); + registerBaseTypes("QtQuick",2,0); } diff --git a/src/declarative/util/qdeclarativeutilmodule_p.h b/src/declarative/util/qdeclarativeutilmodule_p.h index 7304f6fd77..42a1e02097 100644 --- a/src/declarative/util/qdeclarativeutilmodule_p.h +++ b/src/declarative/util/qdeclarativeutilmodule_p.h @@ -53,6 +53,7 @@ QT_MODULE(Declarative) class QDeclarativeUtilModule { public: + static void registerBaseTypes(const char *uri, int versionMajor, int versionMinor); static void defineModule(); }; diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 4bd1f1bb1b..965acf80c6 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -3,7 +3,6 @@ INCLUDEPATH += $$PWD SOURCES += \ $$PWD/qdeclarativeapplication.cpp \ $$PWD/qdeclarativeutilmodule.cpp\ - $$PWD/qdeclarativeview.cpp \ $$PWD/qdeclarativeconnections.cpp \ $$PWD/qdeclarativepackage.cpp \ $$PWD/qdeclarativeanimation.cpp \ @@ -28,13 +27,13 @@ SOURCES += \ $$PWD/qdeclarativefontloader.cpp \ $$PWD/qdeclarativestyledtext.cpp \ $$PWD/qdeclarativelistmodelworkeragent.cpp \ + $$PWD/qdeclarativepath.cpp \ $$PWD/qdeclarativechangeset.cpp \ $$PWD/qlistmodelinterface.cpp HEADERS += \ $$PWD/qdeclarativeapplication_p.h \ $$PWD/qdeclarativeutilmodule_p.h\ - $$PWD/qdeclarativeview.h \ $$PWD/qdeclarativeconnections_p.h \ $$PWD/qdeclarativepackage_p.h \ $$PWD/qdeclarativeanimation_p.h \ @@ -54,7 +53,6 @@ HEADERS += \ $$PWD/qdeclarativelistmodel_p_p.h\ $$PWD/qdeclarativelistaccessor_p.h \ $$PWD/qdeclarativeopenmetaobject_p.h \ - $$PWD/qdeclarativenullablevalue_p_p.h \ $$PWD/qdeclarativetimeline_p_p.h \ $$PWD/qdeclarativetimer_p.h \ $$PWD/qdeclarativebind_p.h \ @@ -64,6 +62,8 @@ HEADERS += \ $$PWD/qdeclarativefontloader_p.h \ $$PWD/qdeclarativestyledtext_p.h \ $$PWD/qdeclarativelistmodelworkeragent_p.h \ + $$PWD/qdeclarativepath_p.h \ + $$PWD/qdeclarativepath_p_p.h \ $$PWD/qdeclarativechangeset_p.h \ $$PWD/qlistmodelinterface_p.h diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro index 7ecd4b8afa..5c009dde51 100644 --- a/src/imports/gestures/gestures.pro +++ b/src/imports/gestures/gestures.pro @@ -2,7 +2,7 @@ TARGET = qmlgesturesplugin TARGETPATH = Qt/labs/gestures include(../qimportbase.pri) -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1 qtquick1-private SOURCES += qdeclarativegesturearea.cpp plugin.cpp HEADERS += qdeclarativegesturearea_p.h diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp index 8523ec7f30..c0d88a3318 100644 --- a/src/imports/gestures/qdeclarativegesturearea.cpp +++ b/src/imports/gestures/qdeclarativegesturearea.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include diff --git a/src/imports/imports.pro b/src/imports/imports.pro index e81c4bf5cf..c60e72db08 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += folderlistmodel particles gestures inputcontext etcprovider +SUBDIRS += qtquick1 qt47 folderlistmodel particles gestures inputcontext etcprovider contains(QT_CONFIG, qmltest): SUBDIRS += testlib diff --git a/src/imports/particles/V1/qdeclarativeparticles.cpp b/src/imports/particles/V1/qdeclarativeparticles.cpp index 62b2d49805..f307109ee8 100644 --- a/src/imports/particles/V1/qdeclarativeparticles.cpp +++ b/src/imports/particles/V1/qdeclarativeparticles.cpp @@ -42,9 +42,9 @@ #include "qdeclarativeparticles_p.h" #include -#include +#include -#include +#include #include #include @@ -446,7 +446,7 @@ class QDeclarativeParticlesPrivate : public QDeclarativeItemPrivate void updateOpacity(QDeclarativeParticle &p, int age); QUrl url; - QDeclarativePixmap image; + QDeclarative1Pixmap image; int count; int emissionRate; qreal emissionVariance; diff --git a/src/imports/particles/V1/qdeclarativeparticles_p.h b/src/imports/particles/V1/qdeclarativeparticles_p.h index f66531cbce..d0e6c0857b 100644 --- a/src/imports/particles/V1/qdeclarativeparticles_p.h +++ b/src/imports/particles/V1/qdeclarativeparticles_p.h @@ -42,7 +42,7 @@ #ifndef QDECLARATIVEPARTICLES_H #define QDECLARATIVEPARTICLES_H -#include +#include QT_BEGIN_HEADER diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro index 56f663f328..c73d068e2c 100644 --- a/src/imports/particles/particles.pro +++ b/src/imports/particles/particles.pro @@ -9,7 +9,7 @@ SOURCES += \ particles.cpp \ V1/qdeclarativeparticles.cpp -QT += declarative opengl core gui declarative-private core-private gui-private +QT += declarative opengl core gui declarative-private core-private gui-private qtquick1 qtquick1-private OTHER_FILES += \ qmldir diff --git a/src/imports/qt47/plugin.cpp b/src/imports/qt47/plugin.cpp new file mode 100644 index 0000000000..dd086638de --- /dev/null +++ b/src/imports/qt47/plugin.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +//![class decl] +class Qt47Plugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + virtual void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt")); + QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::Qt47); + } +}; +//![class decl] + +QT_END_NAMESPACE + +#include "plugin.moc" + +//![plugin export decl] +Q_EXPORT_PLUGIN2(qt47plugin, QT_PREPEND_NAMESPACE(Qt47Plugin)); +//![plugin export decl] + diff --git a/src/imports/qt47/qmldir b/src/imports/qt47/qmldir new file mode 100644 index 0000000000..cf3a7273d5 --- /dev/null +++ b/src/imports/qt47/qmldir @@ -0,0 +1 @@ +plugin qt47plugin diff --git a/src/imports/qt47/qt47.pro b/src/imports/qt47/qt47.pro new file mode 100644 index 0000000000..34a608a7d7 --- /dev/null +++ b/src/imports/qt47/qt47.pro @@ -0,0 +1,30 @@ +TARGET = qt47plugin +TARGETPATH = Qt +include(../qimportbase.pri) + +SOURCES += \ + plugin.cpp + +QT += declarative qtquick1 opengl qtquick1-private + + +OTHER_FILES += \ + qmldir + +DESTDIR = $$QT.declarative.imports/$$TARGETPATH +target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +qmldir.files += $$PWD/qmldir +qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +symbian:{ +# TARGET.UID3 = + + isEmpty(DESTDIR):importFiles.files = qtquick1plugin$${QT_LIBINFIX}.dll qmldir + else:importFiles.files = $$DESTDIR/qtquick1plugin$${QT_LIBINFIX}.dll qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + +INSTALLS += target qmldir diff --git a/src/imports/qtquick1/plugin.cpp b/src/imports/qtquick1/plugin.cpp new file mode 100644 index 0000000000..522f2ec796 --- /dev/null +++ b/src/imports/qtquick1/plugin.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +//![class decl] +class QtQuick1Plugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + virtual void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); + QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::QtQuick1); + } +}; +//![class decl] + +QT_END_NAMESPACE + +#include "plugin.moc" + +//![plugin export decl] +Q_EXPORT_PLUGIN2(qtquick1plugin, QT_PREPEND_NAMESPACE(QtQuick1Plugin)); +//![plugin export decl] + diff --git a/src/imports/qtquick1/qmldir b/src/imports/qtquick1/qmldir new file mode 100644 index 0000000000..f68e439f53 --- /dev/null +++ b/src/imports/qtquick1/qmldir @@ -0,0 +1 @@ +plugin qtquick1plugin diff --git a/src/imports/qtquick1/qtquick1.pro b/src/imports/qtquick1/qtquick1.pro new file mode 100644 index 0000000000..1c7e324212 --- /dev/null +++ b/src/imports/qtquick1/qtquick1.pro @@ -0,0 +1,30 @@ +TARGET = qtquick1plugin +TARGETPATH = QtQuick +include(../qimportbase.pri) + +SOURCES += \ + plugin.cpp + +QT += declarative qtquick1 opengl qtquick1-private + + +OTHER_FILES += \ + qmldir + +DESTDIR = $$QT.declarative.imports/$$TARGETPATH +target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +qmldir.files += $$PWD/qmldir +qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +symbian:{ +# TARGET.UID3 = + + isEmpty(DESTDIR):importFiles.files = qtquick1plugin$${QT_LIBINFIX}.dll qmldir + else:importFiles.files = $$DESTDIR/qtquick1plugin$${QT_LIBINFIX}.dll qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + +INSTALLS += target qmldir diff --git a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp index 6085d8131a..9b52de1c53 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/editor/liveselectiontool.cpp @@ -52,7 +52,7 @@ #include #include -#include +#include #include #include diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp index 3351df9d0b..bef218ca6b 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.cpp @@ -48,7 +48,10 @@ #include "editor/livelayeritem.h" #include "editor/boundingrecthighlighter.h" -#include +#include +#include +#include +#include #include #include #include diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h index c77cd2c522..1a1b167622 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector.h @@ -48,7 +48,7 @@ #include "abstractviewinspector.h" #include -#include +#include namespace QmlJSDebugger { diff --git a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h index bfa857cf41..a51f155404 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h +++ b/src/plugins/qmltooling/qmldbg_inspector/qdeclarativeviewinspector_p.h @@ -44,6 +44,8 @@ #include "qdeclarativeviewinspector.h" +#include +#include #include #include diff --git a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro index 427a1779e3..7f4d54e53a 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro +++ b/src/plugins/qmltooling/qmldbg_inspector/qmldbg_inspector.pro @@ -1,7 +1,7 @@ load(qt_module) TARGET = qmldbg_inspector -QT += declarative-private core-private gui-private opengl-private +QT += declarative-private core-private gui-private opengl-private qtquick1 load(qt_plugin) diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index 1c2bfd0ab0..6e79be0b09 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -7,7 +7,7 @@ CONFIG += module CONFIG += dll warn_on MODULE_PRI += ../../modules/qt_qmltest.pri -QT += testlib-private declarative script testlib +QT += testlib-private declarative script testlib qtquick1 DEFINES += QT_BUILD_QUICK_TEST_LIB QT_NO_URL_CAST_FROM_STRING diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 4dfad1867b..a2c494513b 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -45,7 +45,7 @@ #include "qtestoptions_p.h" #include #include -#include +#include #include #include #if defined(QML_VERSION) && QML_VERSION >= 0x020000 diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index 68d7dc744b..1be6a6f6e6 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -42,8 +42,8 @@ #include "quicktestevent_p.h" #include #include -#include -#include +#include +#include #if defined(QML_VERSION) && QML_VERSION >= 0x020000 #include #include diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/qtquick1/graphicsitems/graphicsitems.pri similarity index 100% rename from src/declarative/graphicsitems/graphicsitems.pri rename to src/qtquick1/graphicsitems/graphicsitems.pri diff --git a/src/declarative/graphicsitems/qdeclarativeanchors.cpp b/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp similarity index 66% rename from src/declarative/graphicsitems/qdeclarativeanchors.cpp rename to src/qtquick1/graphicsitems/qdeclarativeanchors.cpp index c15384e632..2f074a4f04 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp @@ -39,17 +39,19 @@ ** ****************************************************************************/ -#include "private/qdeclarativeanchors_p_p.h" +#include "QtQuick1/private/qdeclarativeanchors_p_p.h" -#include "qdeclarativeitem.h" -#include "private/qdeclarativeitem_p.h" +#include "QtQuick1/qdeclarativeitem.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" -#include +#include #include QT_BEGIN_NAMESPACE + + //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? //TODO: support non-parent, non-sibling (need to find lowest common ancestor) @@ -79,30 +81,30 @@ static qreal vcenter(QGraphicsItem *i) //### const item? //local position -static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine) +static qreal position(QGraphicsObject *item, QDeclarative1AnchorLine::AnchorLine anchorLine) { qreal ret = 0.0; QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item); switch(anchorLine) { - case QDeclarativeAnchorLine::Left: + case QDeclarative1AnchorLine::Left: ret = item->x(); break; - case QDeclarativeAnchorLine::Right: + case QDeclarative1AnchorLine::Right: ret = item->x() + d->width(); break; - case QDeclarativeAnchorLine::Top: + case QDeclarative1AnchorLine::Top: ret = item->y(); break; - case QDeclarativeAnchorLine::Bottom: + case QDeclarative1AnchorLine::Bottom: ret = item->y() + d->height(); break; - case QDeclarativeAnchorLine::HCenter: + case QDeclarative1AnchorLine::HCenter: ret = item->x() + hcenter(item); break; - case QDeclarativeAnchorLine::VCenter: + case QDeclarative1AnchorLine::VCenter: ret = item->y() + vcenter(item); break; - case QDeclarativeAnchorLine::Baseline: + case QDeclarative1AnchorLine::Baseline: if (d->isDeclarativeItem) ret = item->y() + static_cast(item)->baselineOffset(); break; @@ -114,30 +116,30 @@ static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine } //position when origin is 0,0 -static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine) +static qreal adjustedPosition(QGraphicsObject *item, QDeclarative1AnchorLine::AnchorLine anchorLine) { qreal ret = 0.0; QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item); switch(anchorLine) { - case QDeclarativeAnchorLine::Left: + case QDeclarative1AnchorLine::Left: ret = 0.0; break; - case QDeclarativeAnchorLine::Right: + case QDeclarative1AnchorLine::Right: ret = d->width(); break; - case QDeclarativeAnchorLine::Top: + case QDeclarative1AnchorLine::Top: ret = 0.0; break; - case QDeclarativeAnchorLine::Bottom: + case QDeclarative1AnchorLine::Bottom: ret = d->height(); break; - case QDeclarativeAnchorLine::HCenter: + case QDeclarative1AnchorLine::HCenter: ret = hcenter(item); break; - case QDeclarativeAnchorLine::VCenter: + case QDeclarative1AnchorLine::VCenter: ret = vcenter(item); break; - case QDeclarativeAnchorLine::Baseline: + case QDeclarative1AnchorLine::Baseline: if (d->isDeclarativeItem) ret = static_cast(item)->baselineOffset(); break; @@ -148,20 +150,20 @@ static qreal adjustedPosition(QGraphicsObject *item, QDeclarativeAnchorLine::Anc return ret; } -QDeclarativeAnchors::QDeclarativeAnchors(QObject *parent) - : QObject(*new QDeclarativeAnchorsPrivate(0), parent) +QDeclarative1Anchors::QDeclarative1Anchors(QObject *parent) + : QObject(*new QDeclarative1AnchorsPrivate(0), parent) { - qFatal("QDeclarativeAnchors::QDeclarativeAnchors(QObject*) called"); + qFatal("QDeclarative1Anchors::QDeclarative1Anchors(QObject*) called"); } -QDeclarativeAnchors::QDeclarativeAnchors(QGraphicsObject *item, QObject *parent) - : QObject(*new QDeclarativeAnchorsPrivate(item), parent) +QDeclarative1Anchors::QDeclarative1Anchors(QGraphicsObject *item, QObject *parent) + : QObject(*new QDeclarative1AnchorsPrivate(item), parent) { } -QDeclarativeAnchors::~QDeclarativeAnchors() +QDeclarative1Anchors::~QDeclarative1Anchors() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->remDepend(d->fill); d->remDepend(d->centerIn); d->remDepend(d->left.item); @@ -173,9 +175,9 @@ QDeclarativeAnchors::~QDeclarativeAnchors() d->remDepend(d->baseline.item); } -void QDeclarativeAnchorsPrivate::fillChanged() +void QDeclarative1AnchorsPrivate::fillChanged() { - Q_Q(QDeclarativeAnchors); + Q_Q(QDeclarative1Anchors); if (!fill || !isItemComplete()) return; @@ -195,14 +197,14 @@ void QDeclarativeAnchorsPrivate::fillChanged() --updatingFill; } else { // ### Make this certain :) - qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on fill."); + qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on fill."); } } -void QDeclarativeAnchorsPrivate::centerInChanged() +void QDeclarative1AnchorsPrivate::centerInChanged() { - Q_Q(QDeclarativeAnchors); + Q_Q(QDeclarative1Anchors); if (!centerIn || fill || !isItemComplete()) return; @@ -224,11 +226,11 @@ void QDeclarativeAnchorsPrivate::centerInChanged() --updatingCenterIn; } else { // ### Make this certain :) - qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on centerIn."); + qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on centerIn."); } } -void QDeclarativeAnchorsPrivate::clearItem(QGraphicsObject *item) +void QDeclarative1AnchorsPrivate::clearItem(QGraphicsObject *item) { if (!item) return; @@ -238,35 +240,35 @@ void QDeclarativeAnchorsPrivate::clearItem(QGraphicsObject *item) centerIn = 0; if (left.item == item) { left.item = 0; - usedAnchors &= ~QDeclarativeAnchors::LeftAnchor; + usedAnchors &= ~QDeclarative1Anchors::LeftAnchor; } if (right.item == item) { right.item = 0; - usedAnchors &= ~QDeclarativeAnchors::RightAnchor; + usedAnchors &= ~QDeclarative1Anchors::RightAnchor; } if (top.item == item) { top.item = 0; - usedAnchors &= ~QDeclarativeAnchors::TopAnchor; + usedAnchors &= ~QDeclarative1Anchors::TopAnchor; } if (bottom.item == item) { bottom.item = 0; - usedAnchors &= ~QDeclarativeAnchors::BottomAnchor; + usedAnchors &= ~QDeclarative1Anchors::BottomAnchor; } if (vCenter.item == item) { vCenter.item = 0; - usedAnchors &= ~QDeclarativeAnchors::VCenterAnchor; + usedAnchors &= ~QDeclarative1Anchors::VCenterAnchor; } if (hCenter.item == item) { hCenter.item = 0; - usedAnchors &= ~QDeclarativeAnchors::HCenterAnchor; + usedAnchors &= ~QDeclarative1Anchors::HCenterAnchor; } if (baseline.item == item) { baseline.item = 0; - usedAnchors &= ~QDeclarativeAnchors::BaselineAnchor; + usedAnchors &= ~QDeclarative1Anchors::BaselineAnchor; } } -void QDeclarativeAnchorsPrivate::addDepend(QGraphicsObject *item) +void QDeclarative1AnchorsPrivate::addDepend(QGraphicsObject *item) { if (!item) return; @@ -276,14 +278,14 @@ void QDeclarativeAnchorsPrivate::addDepend(QGraphicsObject *item) static_cast(QGraphicsItemPrivate::get(item)); p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); } else if(itemPrivate->isWidget) { - Q_Q(QDeclarativeAnchors); + Q_Q(QDeclarative1Anchors); QGraphicsWidget *widget = static_cast(item); QObject::connect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); QObject::connect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); } } -void QDeclarativeAnchorsPrivate::remDepend(QGraphicsObject *item) +void QDeclarative1AnchorsPrivate::remDepend(QGraphicsObject *item) { if (!item) return; @@ -293,73 +295,73 @@ void QDeclarativeAnchorsPrivate::remDepend(QGraphicsObject *item) static_cast(itemPrivate); p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); } else if(itemPrivate->isWidget) { - Q_Q(QDeclarativeAnchors); + Q_Q(QDeclarative1Anchors); QGraphicsWidget *widget = static_cast(item); QObject::disconnect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); QObject::disconnect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); } } -bool QDeclarativeAnchorsPrivate::isItemComplete() const +bool QDeclarative1AnchorsPrivate::isItemComplete() const { return componentComplete; } -void QDeclarativeAnchors::classBegin() +void QDeclarative1Anchors::classBegin() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->componentComplete = false; } -void QDeclarativeAnchors::componentComplete() +void QDeclarative1Anchors::componentComplete() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->componentComplete = true; } -bool QDeclarativeAnchors::mirrored() +bool QDeclarative1Anchors::mirrored() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(d->item); return itemPrivate->isDeclarativeItem ? static_cast(itemPrivate)->effectiveLayoutMirror : false; } -void QDeclarativeAnchorsPrivate::setItemHeight(qreal v) +void QDeclarative1AnchorsPrivate::setItemHeight(qreal v) { updatingMe = true; QGraphicsItemPrivate::get(item)->setHeight(v); updatingMe = false; } -void QDeclarativeAnchorsPrivate::setItemWidth(qreal v) +void QDeclarative1AnchorsPrivate::setItemWidth(qreal v) { updatingMe = true; QGraphicsItemPrivate::get(item)->setWidth(v); updatingMe = false; } -void QDeclarativeAnchorsPrivate::setItemX(qreal v) +void QDeclarative1AnchorsPrivate::setItemX(qreal v) { updatingMe = true; item->setX(v); updatingMe = false; } -void QDeclarativeAnchorsPrivate::setItemY(qreal v) +void QDeclarative1AnchorsPrivate::setItemY(qreal v) { updatingMe = true; item->setY(v); updatingMe = false; } -void QDeclarativeAnchorsPrivate::setItemPos(const QPointF &v) +void QDeclarative1AnchorsPrivate::setItemPos(const QPointF &v) { updatingMe = true; item->setPos(v); updatingMe = false; } -void QDeclarativeAnchorsPrivate::setItemSize(const QSizeF &v) +void QDeclarative1AnchorsPrivate::setItemSize(const QSizeF &v) { updatingMe = true; if(QGraphicsItemPrivate::get(item)->isWidget) @@ -369,7 +371,7 @@ void QDeclarativeAnchorsPrivate::setItemSize(const QSizeF &v) updatingMe = false; } -void QDeclarativeAnchorsPrivate::updateMe() +void QDeclarative1AnchorsPrivate::updateMe() { if (updatingMe) { updatingMe = false; @@ -382,7 +384,7 @@ void QDeclarativeAnchorsPrivate::updateMe() updateVerticalAnchors(); } -void QDeclarativeAnchorsPrivate::updateOnComplete() +void QDeclarative1AnchorsPrivate::updateOnComplete() { fillChanged(); centerInChanged(); @@ -390,12 +392,12 @@ void QDeclarativeAnchorsPrivate::updateOnComplete() updateVerticalAnchors(); } -void QDeclarativeAnchorsPrivate::_q_widgetDestroyed(QObject *obj) +void QDeclarative1AnchorsPrivate::_q_widgetDestroyed(QObject *obj) { clearItem(qobject_cast(obj)); } -void QDeclarativeAnchorsPrivate::_q_widgetGeometryChanged() +void QDeclarative1AnchorsPrivate::_q_widgetGeometryChanged() { fillChanged(); centerInChanged(); @@ -403,7 +405,7 @@ void QDeclarativeAnchorsPrivate::_q_widgetGeometryChanged() updateVerticalAnchors(); } -void QDeclarativeAnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const QRectF &newG, const QRectF &oldG) +void QDeclarative1AnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const QRectF &newG, const QRectF &oldG) { fillChanged(); centerInChanged(); @@ -413,15 +415,15 @@ void QDeclarativeAnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const Q updateVerticalAnchors(); } -QGraphicsObject *QDeclarativeAnchors::fill() const +QGraphicsObject *QDeclarative1Anchors::fill() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->fill; } -void QDeclarativeAnchors::setFill(QGraphicsObject *f) +void QDeclarative1Anchors::setFill(QGraphicsObject *f) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->fill == f) return; @@ -442,20 +444,20 @@ void QDeclarativeAnchors::setFill(QGraphicsObject *f) d->fillChanged(); } -void QDeclarativeAnchors::resetFill() +void QDeclarative1Anchors::resetFill() { setFill(0); } -QGraphicsObject *QDeclarativeAnchors::centerIn() const +QGraphicsObject *QDeclarative1Anchors::centerIn() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->centerIn; } -void QDeclarativeAnchors::setCenterIn(QGraphicsObject* c) +void QDeclarative1Anchors::setCenterIn(QGraphicsObject* c) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->centerIn == c) return; @@ -477,16 +479,16 @@ void QDeclarativeAnchors::setCenterIn(QGraphicsObject* c) d->centerInChanged(); } -void QDeclarativeAnchors::resetCenterIn() +void QDeclarative1Anchors::resetCenterIn() { setCenterIn(0); } -bool QDeclarativeAnchorsPrivate::calcStretch(const QDeclarativeAnchorLine &edge1, - const QDeclarativeAnchorLine &edge2, +bool QDeclarative1AnchorsPrivate::calcStretch(const QDeclarative1AnchorLine &edge1, + const QDeclarative1AnchorLine &edge2, qreal offset1, qreal offset2, - QDeclarativeAnchorLine::AnchorLine line, + QDeclarative1AnchorLine::AnchorLine line, qreal &stretch) { bool edge1IsParent = (edge1.item == item->parentItem()); @@ -511,7 +513,7 @@ bool QDeclarativeAnchorsPrivate::calcStretch(const QDeclarativeAnchorLine &edge1 return invalid; } -void QDeclarativeAnchorsPrivate::updateVerticalAnchors() +void QDeclarative1AnchorsPrivate::updateVerticalAnchors() { if (fill || centerIn || !isItemComplete()) return; @@ -519,14 +521,14 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors() if (updatingVerticalAnchor < 2) { ++updatingVerticalAnchor; QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item); - if (usedAnchors & QDeclarativeAnchors::TopAnchor) { + if (usedAnchors & QDeclarative1Anchors::TopAnchor) { //Handle stretching bool invalid = true; qreal height = 0.0; - if (usedAnchors & QDeclarativeAnchors::BottomAnchor) { - invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QDeclarativeAnchorLine::Top, height); - } else if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) { - invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QDeclarativeAnchorLine::Top, height); + if (usedAnchors & QDeclarative1Anchors::BottomAnchor) { + invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QDeclarative1AnchorLine::Top, height); + } else if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { + invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QDeclarative1AnchorLine::Top, height); height *= 2; } if (!invalid) @@ -538,12 +540,12 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors() } else if (top.item->parentItem() == item->parentItem()) { setItemY(position(top.item, top.anchorLine) + topMargin); } - } else if (usedAnchors & QDeclarativeAnchors::BottomAnchor) { + } else if (usedAnchors & QDeclarative1Anchors::BottomAnchor) { //Handle stretching (top + bottom case is handled above) - if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) { + if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { qreal height = 0.0; bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin, - QDeclarativeAnchorLine::Top, height); + QDeclarative1AnchorLine::Top, height); if (!invalid) setItemHeight(height*2); } @@ -554,7 +556,7 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors() } else if (bottom.item->parentItem() == item->parentItem()) { setItemY(position(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin); } - } else if (usedAnchors & QDeclarativeAnchors::VCenterAnchor) { + } else if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { //(stetching handled above) //Handle vCenter @@ -564,7 +566,7 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors() } else if (vCenter.item->parentItem() == item->parentItem()) { setItemY(position(vCenter.item, vCenter.anchorLine) - vcenter(item) + vCenterOffset); } - } else if (usedAnchors & QDeclarativeAnchors::BaselineAnchor) { + } else if (usedAnchors & QDeclarative1Anchors::BaselineAnchor) { //Handle baseline if (baseline.item == item->parentItem()) { if (itemPrivate->isDeclarativeItem) @@ -579,34 +581,34 @@ void QDeclarativeAnchorsPrivate::updateVerticalAnchors() --updatingVerticalAnchor; } else { // ### Make this certain :) - qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on vertical anchor."); + qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on vertical anchor."); } } -inline QDeclarativeAnchorLine::AnchorLine reverseAnchorLine(QDeclarativeAnchorLine::AnchorLine anchorLine) { - if (anchorLine == QDeclarativeAnchorLine::Left) { - return QDeclarativeAnchorLine::Right; - } else if (anchorLine == QDeclarativeAnchorLine::Right) { - return QDeclarativeAnchorLine::Left; +inline QDeclarative1AnchorLine::AnchorLine reverseAnchorLine(QDeclarative1AnchorLine::AnchorLine anchorLine) { + if (anchorLine == QDeclarative1AnchorLine::Left) { + return QDeclarative1AnchorLine::Right; + } else if (anchorLine == QDeclarative1AnchorLine::Right) { + return QDeclarative1AnchorLine::Left; } else { return anchorLine; } } -void QDeclarativeAnchorsPrivate::updateHorizontalAnchors() +void QDeclarative1AnchorsPrivate::updateHorizontalAnchors() { - Q_Q(QDeclarativeAnchors); + Q_Q(QDeclarative1Anchors); if (fill || centerIn || !isItemComplete()) return; if (updatingHorizontalAnchor < 3) { ++updatingHorizontalAnchor; qreal effectiveRightMargin, effectiveLeftMargin, effectiveHorizontalCenterOffset; - QDeclarativeAnchorLine effectiveLeft, effectiveRight, effectiveHorizontalCenter; - QDeclarativeAnchors::Anchor effectiveLeftAnchor, effectiveRightAnchor; + QDeclarative1AnchorLine effectiveLeft, effectiveRight, effectiveHorizontalCenter; + QDeclarative1Anchors::Anchor effectiveLeftAnchor, effectiveRightAnchor; if (q->mirrored()) { - effectiveLeftAnchor = QDeclarativeAnchors::RightAnchor; - effectiveRightAnchor = QDeclarativeAnchors::LeftAnchor; + effectiveLeftAnchor = QDeclarative1Anchors::RightAnchor; + effectiveRightAnchor = QDeclarative1Anchors::LeftAnchor; effectiveLeft.item = right.item; effectiveLeft.anchorLine = reverseAnchorLine(right.anchorLine); effectiveRight.item = left.item; @@ -617,8 +619,8 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors() effectiveRightMargin = leftMargin; effectiveHorizontalCenterOffset = -hCenterOffset; } else { - effectiveLeftAnchor = QDeclarativeAnchors::LeftAnchor; - effectiveRightAnchor = QDeclarativeAnchors::RightAnchor; + effectiveLeftAnchor = QDeclarative1Anchors::LeftAnchor; + effectiveRightAnchor = QDeclarative1Anchors::RightAnchor; effectiveLeft = left; effectiveRight = right; effectiveHorizontalCenter = hCenter; @@ -633,9 +635,9 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors() bool invalid = true; qreal width = 0.0; if (usedAnchors & effectiveRightAnchor) { - invalid = calcStretch(effectiveLeft, effectiveRight, effectiveLeftMargin, -effectiveRightMargin, QDeclarativeAnchorLine::Left, width); - } else if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) { - invalid = calcStretch(effectiveLeft, effectiveHorizontalCenter, effectiveLeftMargin, effectiveHorizontalCenterOffset, QDeclarativeAnchorLine::Left, width); + invalid = calcStretch(effectiveLeft, effectiveRight, effectiveLeftMargin, -effectiveRightMargin, QDeclarative1AnchorLine::Left, width); + } else if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { + invalid = calcStretch(effectiveLeft, effectiveHorizontalCenter, effectiveLeftMargin, effectiveHorizontalCenterOffset, QDeclarative1AnchorLine::Left, width); width *= 2; } if (!invalid) @@ -649,10 +651,10 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors() } } else if (usedAnchors & effectiveRightAnchor) { //Handle stretching (left + right case is handled in updateLeftAnchor) - if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) { + if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { qreal width = 0.0; bool invalid = calcStretch(effectiveHorizontalCenter, effectiveRight, effectiveHorizontalCenterOffset, -effectiveRightMargin, - QDeclarativeAnchorLine::Left, width); + QDeclarative1AnchorLine::Left, width); if (!invalid) setItemWidth(width*2); } @@ -663,7 +665,7 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors() } else if (effectiveRight.item->parentItem() == item->parentItem()) { setItemX(position(effectiveRight.item, effectiveRight.anchorLine) - itemPrivate->width() - effectiveRightMargin); } - } else if (usedAnchors & QDeclarativeAnchors::HCenterAnchor) { + } else if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { //Handle hCenter if (effectiveHorizontalCenter.item == item->parentItem()) { setItemX(adjustedPosition(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset); @@ -674,19 +676,19 @@ void QDeclarativeAnchorsPrivate::updateHorizontalAnchors() --updatingHorizontalAnchor; } else { // ### Make this certain :) - qmlInfo(item) << QDeclarativeAnchors::tr("Possible anchor loop detected on horizontal anchor."); + qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on horizontal anchor."); } } -QDeclarativeAnchorLine QDeclarativeAnchors::top() const +QDeclarative1AnchorLine QDeclarative1Anchors::top() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->top; } -void QDeclarativeAnchors::setTop(const QDeclarativeAnchorLine &edge) +void QDeclarative1Anchors::setTop(const QDeclarative1AnchorLine &edge) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (!d->checkVAnchorValid(edge) || d->top == edge) return; @@ -704,25 +706,25 @@ void QDeclarativeAnchors::setTop(const QDeclarativeAnchorLine &edge) d->updateVerticalAnchors(); } -void QDeclarativeAnchors::resetTop() +void QDeclarative1Anchors::resetTop() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->usedAnchors &= ~TopAnchor; d->remDepend(d->top.item); - d->top = QDeclarativeAnchorLine(); + d->top = QDeclarative1AnchorLine(); emit topChanged(); d->updateVerticalAnchors(); } -QDeclarativeAnchorLine QDeclarativeAnchors::bottom() const +QDeclarative1AnchorLine QDeclarative1Anchors::bottom() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->bottom; } -void QDeclarativeAnchors::setBottom(const QDeclarativeAnchorLine &edge) +void QDeclarative1Anchors::setBottom(const QDeclarative1AnchorLine &edge) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (!d->checkVAnchorValid(edge) || d->bottom == edge) return; @@ -740,25 +742,25 @@ void QDeclarativeAnchors::setBottom(const QDeclarativeAnchorLine &edge) d->updateVerticalAnchors(); } -void QDeclarativeAnchors::resetBottom() +void QDeclarative1Anchors::resetBottom() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->usedAnchors &= ~BottomAnchor; d->remDepend(d->bottom.item); - d->bottom = QDeclarativeAnchorLine(); + d->bottom = QDeclarative1AnchorLine(); emit bottomChanged(); d->updateVerticalAnchors(); } -QDeclarativeAnchorLine QDeclarativeAnchors::verticalCenter() const +QDeclarative1AnchorLine QDeclarative1Anchors::verticalCenter() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->vCenter; } -void QDeclarativeAnchors::setVerticalCenter(const QDeclarativeAnchorLine &edge) +void QDeclarative1Anchors::setVerticalCenter(const QDeclarative1AnchorLine &edge) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (!d->checkVAnchorValid(edge) || d->vCenter == edge) return; @@ -776,25 +778,25 @@ void QDeclarativeAnchors::setVerticalCenter(const QDeclarativeAnchorLine &edge) d->updateVerticalAnchors(); } -void QDeclarativeAnchors::resetVerticalCenter() +void QDeclarative1Anchors::resetVerticalCenter() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->usedAnchors &= ~VCenterAnchor; d->remDepend(d->vCenter.item); - d->vCenter = QDeclarativeAnchorLine(); + d->vCenter = QDeclarative1AnchorLine(); emit verticalCenterChanged(); d->updateVerticalAnchors(); } -QDeclarativeAnchorLine QDeclarativeAnchors::baseline() const +QDeclarative1AnchorLine QDeclarative1Anchors::baseline() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->baseline; } -void QDeclarativeAnchors::setBaseline(const QDeclarativeAnchorLine &edge) +void QDeclarative1Anchors::setBaseline(const QDeclarative1AnchorLine &edge) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (!d->checkVAnchorValid(edge) || d->baseline == edge) return; @@ -812,25 +814,25 @@ void QDeclarativeAnchors::setBaseline(const QDeclarativeAnchorLine &edge) d->updateVerticalAnchors(); } -void QDeclarativeAnchors::resetBaseline() +void QDeclarative1Anchors::resetBaseline() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->usedAnchors &= ~BaselineAnchor; d->remDepend(d->baseline.item); - d->baseline = QDeclarativeAnchorLine(); + d->baseline = QDeclarative1AnchorLine(); emit baselineChanged(); d->updateVerticalAnchors(); } -QDeclarativeAnchorLine QDeclarativeAnchors::left() const +QDeclarative1AnchorLine QDeclarative1Anchors::left() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->left; } -void QDeclarativeAnchors::setLeft(const QDeclarativeAnchorLine &edge) +void QDeclarative1Anchors::setLeft(const QDeclarative1AnchorLine &edge) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (!d->checkHAnchorValid(edge) || d->left == edge) return; @@ -848,25 +850,25 @@ void QDeclarativeAnchors::setLeft(const QDeclarativeAnchorLine &edge) d->updateHorizontalAnchors(); } -void QDeclarativeAnchors::resetLeft() +void QDeclarative1Anchors::resetLeft() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->usedAnchors &= ~LeftAnchor; d->remDepend(d->left.item); - d->left = QDeclarativeAnchorLine(); + d->left = QDeclarative1AnchorLine(); emit leftChanged(); d->updateHorizontalAnchors(); } -QDeclarativeAnchorLine QDeclarativeAnchors::right() const +QDeclarative1AnchorLine QDeclarative1Anchors::right() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->right; } -void QDeclarativeAnchors::setRight(const QDeclarativeAnchorLine &edge) +void QDeclarative1Anchors::setRight(const QDeclarative1AnchorLine &edge) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (!d->checkHAnchorValid(edge) || d->right == edge) return; @@ -884,25 +886,25 @@ void QDeclarativeAnchors::setRight(const QDeclarativeAnchorLine &edge) d->updateHorizontalAnchors(); } -void QDeclarativeAnchors::resetRight() +void QDeclarative1Anchors::resetRight() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->usedAnchors &= ~RightAnchor; d->remDepend(d->right.item); - d->right = QDeclarativeAnchorLine(); + d->right = QDeclarative1AnchorLine(); emit rightChanged(); d->updateHorizontalAnchors(); } -QDeclarativeAnchorLine QDeclarativeAnchors::horizontalCenter() const +QDeclarative1AnchorLine QDeclarative1Anchors::horizontalCenter() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->hCenter; } -void QDeclarativeAnchors::setHorizontalCenter(const QDeclarativeAnchorLine &edge) +void QDeclarative1Anchors::setHorizontalCenter(const QDeclarative1AnchorLine &edge) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (!d->checkHAnchorValid(edge) || d->hCenter == edge) return; @@ -920,25 +922,25 @@ void QDeclarativeAnchors::setHorizontalCenter(const QDeclarativeAnchorLine &edge d->updateHorizontalAnchors(); } -void QDeclarativeAnchors::resetHorizontalCenter() +void QDeclarative1Anchors::resetHorizontalCenter() { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); d->usedAnchors &= ~HCenterAnchor; d->remDepend(d->hCenter.item); - d->hCenter = QDeclarativeAnchorLine(); + d->hCenter = QDeclarative1AnchorLine(); emit horizontalCenterChanged(); d->updateHorizontalAnchors(); } -qreal QDeclarativeAnchors::leftMargin() const +qreal QDeclarative1Anchors::leftMargin() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->leftMargin; } -void QDeclarativeAnchors::setLeftMargin(qreal offset) +void QDeclarative1Anchors::setLeftMargin(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->leftMargin == offset) return; d->leftMargin = offset; @@ -949,15 +951,15 @@ void QDeclarativeAnchors::setLeftMargin(qreal offset) emit leftMarginChanged(); } -qreal QDeclarativeAnchors::rightMargin() const +qreal QDeclarative1Anchors::rightMargin() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->rightMargin; } -void QDeclarativeAnchors::setRightMargin(qreal offset) +void QDeclarative1Anchors::setRightMargin(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->rightMargin == offset) return; d->rightMargin = offset; @@ -968,15 +970,15 @@ void QDeclarativeAnchors::setRightMargin(qreal offset) emit rightMarginChanged(); } -qreal QDeclarativeAnchors::margins() const +qreal QDeclarative1Anchors::margins() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->margins; } -void QDeclarativeAnchors::setMargins(qreal offset) +void QDeclarative1Anchors::setMargins(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->margins == offset) return; //###Is it significantly faster to set them directly so we can call fillChanged only once? @@ -993,15 +995,15 @@ void QDeclarativeAnchors::setMargins(qreal offset) } -qreal QDeclarativeAnchors::horizontalCenterOffset() const +qreal QDeclarative1Anchors::horizontalCenterOffset() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->hCenterOffset; } -void QDeclarativeAnchors::setHorizontalCenterOffset(qreal offset) +void QDeclarative1Anchors::setHorizontalCenterOffset(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->hCenterOffset == offset) return; d->hCenterOffset = offset; @@ -1012,15 +1014,15 @@ void QDeclarativeAnchors::setHorizontalCenterOffset(qreal offset) emit horizontalCenterOffsetChanged(); } -qreal QDeclarativeAnchors::topMargin() const +qreal QDeclarative1Anchors::topMargin() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->topMargin; } -void QDeclarativeAnchors::setTopMargin(qreal offset) +void QDeclarative1Anchors::setTopMargin(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->topMargin == offset) return; d->topMargin = offset; @@ -1031,15 +1033,15 @@ void QDeclarativeAnchors::setTopMargin(qreal offset) emit topMarginChanged(); } -qreal QDeclarativeAnchors::bottomMargin() const +qreal QDeclarative1Anchors::bottomMargin() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->bottomMargin; } -void QDeclarativeAnchors::setBottomMargin(qreal offset) +void QDeclarative1Anchors::setBottomMargin(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->bottomMargin == offset) return; d->bottomMargin = offset; @@ -1050,15 +1052,15 @@ void QDeclarativeAnchors::setBottomMargin(qreal offset) emit bottomMarginChanged(); } -qreal QDeclarativeAnchors::verticalCenterOffset() const +qreal QDeclarative1Anchors::verticalCenterOffset() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->vCenterOffset; } -void QDeclarativeAnchors::setVerticalCenterOffset(qreal offset) +void QDeclarative1Anchors::setVerticalCenterOffset(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->vCenterOffset == offset) return; d->vCenterOffset = offset; @@ -1069,15 +1071,15 @@ void QDeclarativeAnchors::setVerticalCenterOffset(qreal offset) emit verticalCenterOffsetChanged(); } -qreal QDeclarativeAnchors::baselineOffset() const +qreal QDeclarative1Anchors::baselineOffset() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->baselineOffset; } -void QDeclarativeAnchors::setBaselineOffset(qreal offset) +void QDeclarative1Anchors::setBaselineOffset(qreal offset) { - Q_D(QDeclarativeAnchors); + Q_D(QDeclarative1Anchors); if (d->baselineOffset == offset) return; d->baselineOffset = offset; @@ -1085,80 +1087,82 @@ void QDeclarativeAnchors::setBaselineOffset(qreal offset) emit baselineOffsetChanged(); } -QDeclarativeAnchors::Anchors QDeclarativeAnchors::usedAnchors() const +QDeclarative1Anchors::Anchors QDeclarative1Anchors::usedAnchors() const { - Q_D(const QDeclarativeAnchors); + Q_D(const QDeclarative1Anchors); return d->usedAnchors; } -bool QDeclarativeAnchorsPrivate::checkHValid() const +bool QDeclarative1AnchorsPrivate::checkHValid() const { - if (usedAnchors & QDeclarativeAnchors::LeftAnchor && - usedAnchors & QDeclarativeAnchors::RightAnchor && - usedAnchors & QDeclarativeAnchors::HCenterAnchor) { - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify left, right, and hcenter anchors."); + if (usedAnchors & QDeclarative1Anchors::LeftAnchor && + usedAnchors & QDeclarative1Anchors::RightAnchor && + usedAnchors & QDeclarative1Anchors::HCenterAnchor) { + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot specify left, right, and hcenter anchors."); return false; } return true; } -bool QDeclarativeAnchorsPrivate::checkHAnchorValid(QDeclarativeAnchorLine anchor) const +bool QDeclarative1AnchorsPrivate::checkHAnchorValid(QDeclarative1AnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to a null item."); + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to a null item."); return false; - } else if (anchor.anchorLine & QDeclarativeAnchorLine::Vertical_Mask) { - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor a horizontal edge to a vertical edge."); + } else if (anchor.anchorLine & QDeclarative1AnchorLine::Vertical_Mask) { + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor a horizontal edge to a vertical edge."); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item) { - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor item to self."); + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor item to self."); return false; } return true; } -bool QDeclarativeAnchorsPrivate::checkVValid() const +bool QDeclarative1AnchorsPrivate::checkVValid() const { - if (usedAnchors & QDeclarativeAnchors::TopAnchor && - usedAnchors & QDeclarativeAnchors::BottomAnchor && - usedAnchors & QDeclarativeAnchors::VCenterAnchor) { - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot specify top, bottom, and vcenter anchors."); + if (usedAnchors & QDeclarative1Anchors::TopAnchor && + usedAnchors & QDeclarative1Anchors::BottomAnchor && + usedAnchors & QDeclarative1Anchors::VCenterAnchor) { + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot specify top, bottom, and vcenter anchors."); return false; - } else if (usedAnchors & QDeclarativeAnchors::BaselineAnchor && - (usedAnchors & QDeclarativeAnchors::TopAnchor || - usedAnchors & QDeclarativeAnchors::BottomAnchor || - usedAnchors & QDeclarativeAnchors::VCenterAnchor)) { - qmlInfo(item) << QDeclarativeAnchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."); + } else if (usedAnchors & QDeclarative1Anchors::BaselineAnchor && + (usedAnchors & QDeclarative1Anchors::TopAnchor || + usedAnchors & QDeclarative1Anchors::BottomAnchor || + usedAnchors & QDeclarative1Anchors::VCenterAnchor)) { + qmlInfo(item) << QDeclarative1Anchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."); return false; } return true; } -bool QDeclarativeAnchorsPrivate::checkVAnchorValid(QDeclarativeAnchorLine anchor) const +bool QDeclarative1AnchorsPrivate::checkVAnchorValid(QDeclarative1AnchorLine anchor) const { if (!anchor.item) { - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to a null item."); + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to a null item."); return false; - } else if (anchor.anchorLine & QDeclarativeAnchorLine::Horizontal_Mask) { - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor a vertical edge to a horizontal edge."); + } else if (anchor.anchorLine & QDeclarative1AnchorLine::Horizontal_Mask) { + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor a vertical edge to a horizontal edge."); return false; } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor to an item that isn't a parent or sibling."); + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to an item that isn't a parent or sibling."); return false; } else if (anchor.item == item){ - qmlInfo(item) << QDeclarativeAnchors::tr("Cannot anchor item to self."); + qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor item to self."); return false; } return true; } + + QT_END_NAMESPACE #include diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p.h b/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h similarity index 70% rename from src/declarative/graphicsitems/qdeclarativeanchors_p.h rename to src/qtquick1/graphicsitems/qdeclarativeanchors_p.h index d222ef5491..96a5f27f1e 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h @@ -44,11 +44,11 @@ #include "qdeclarativeitem.h" -#include +#include #include -#include +#include QT_BEGIN_HEADER @@ -56,19 +56,19 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeAnchorsPrivate; -class QDeclarativeAnchorLine; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject +class QDeclarative1AnchorsPrivate; +class QDeclarative1AnchorLine; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Anchors : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativeAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged) - Q_PROPERTY(QDeclarativeAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged) - Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged) - Q_PROPERTY(QDeclarativeAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged) - Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged) - Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged) - Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged) + Q_PROPERTY(QDeclarative1AnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged) + Q_PROPERTY(QDeclarative1AnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged) + Q_PROPERTY(QDeclarative1AnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged) + Q_PROPERTY(QDeclarative1AnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged) + Q_PROPERTY(QDeclarative1AnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged) + Q_PROPERTY(QDeclarative1AnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged) + Q_PROPERTY(QDeclarative1AnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged) Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) @@ -82,9 +82,9 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject Q_PROPERTY(bool mirrored READ mirrored NOTIFY mirroredChanged REVISION 1) public: - QDeclarativeAnchors(QObject *parent=0); - QDeclarativeAnchors(QGraphicsObject *item, QObject *parent=0); - virtual ~QDeclarativeAnchors(); + QDeclarative1Anchors(QObject *parent=0); + QDeclarative1Anchors(QGraphicsObject *item, QObject *parent=0); + virtual ~QDeclarative1Anchors(); enum Anchor { LeftAnchor = 0x01, @@ -99,32 +99,32 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject }; Q_DECLARE_FLAGS(Anchors, Anchor) - QDeclarativeAnchorLine left() const; - void setLeft(const QDeclarativeAnchorLine &edge); + QDeclarative1AnchorLine left() const; + void setLeft(const QDeclarative1AnchorLine &edge); void resetLeft(); - QDeclarativeAnchorLine right() const; - void setRight(const QDeclarativeAnchorLine &edge); + QDeclarative1AnchorLine right() const; + void setRight(const QDeclarative1AnchorLine &edge); void resetRight(); - QDeclarativeAnchorLine horizontalCenter() const; - void setHorizontalCenter(const QDeclarativeAnchorLine &edge); + QDeclarative1AnchorLine horizontalCenter() const; + void setHorizontalCenter(const QDeclarative1AnchorLine &edge); void resetHorizontalCenter(); - QDeclarativeAnchorLine top() const; - void setTop(const QDeclarativeAnchorLine &edge); + QDeclarative1AnchorLine top() const; + void setTop(const QDeclarative1AnchorLine &edge); void resetTop(); - QDeclarativeAnchorLine bottom() const; - void setBottom(const QDeclarativeAnchorLine &edge); + QDeclarative1AnchorLine bottom() const; + void setBottom(const QDeclarative1AnchorLine &edge); void resetBottom(); - QDeclarativeAnchorLine verticalCenter() const; - void setVerticalCenter(const QDeclarativeAnchorLine &edge); + QDeclarative1AnchorLine verticalCenter() const; + void setVerticalCenter(const QDeclarative1AnchorLine &edge); void resetVerticalCenter(); - QDeclarativeAnchorLine baseline() const; - void setBaseline(const QDeclarativeAnchorLine &edge); + QDeclarative1AnchorLine baseline() const; + void setBaseline(const QDeclarative1AnchorLine &edge); void resetBaseline(); qreal leftMargin() const; @@ -189,17 +189,17 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAnchors : public QObject private: friend class QDeclarativeItem; friend class QDeclarativeItemPrivate; - friend class QDeclarativeGraphicsWidget; - Q_DISABLE_COPY(QDeclarativeAnchors) - Q_DECLARE_PRIVATE(QDeclarativeAnchors) + friend class QDeclarative1GraphicsWidget; + Q_DISABLE_COPY(QDeclarative1Anchors) + Q_DECLARE_PRIVATE(QDeclarative1Anchors) Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged()) Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj)) }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeAnchors::Anchors) +Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarative1Anchors::Anchors) QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeAnchors) +QML_DECLARE_TYPE(QDeclarative1Anchors) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h similarity index 76% rename from src/declarative/graphicsitems/qdeclarativeanchors_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h index 2ceb5a4a73..225f112636 100644 --- a/src/declarative/graphicsitems/qdeclarativeanchors_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h @@ -53,16 +53,17 @@ // We mean it. // -#include "private/qdeclarativeanchors_p.h" -#include "private/qdeclarativeitemchangelistener_p.h" +#include "QtQuick1/private/qdeclarativeanchors_p.h" +#include "QtQuick1/private/qdeclarativeitemchangelistener_p.h" #include QT_BEGIN_NAMESPACE -class QDeclarativeAnchorLine +// NOTE: if you change this then also update the copy in qdeclarativev4compiler_p_p.h +class QDeclarative1AnchorLine { public: - QDeclarativeAnchorLine() : item(0), anchorLine(Invalid) {} + QDeclarative1AnchorLine() : item(0), anchorLine(Invalid) {} enum AnchorLine { Invalid = 0x0, @@ -81,16 +82,16 @@ class QDeclarativeAnchorLine AnchorLine anchorLine; }; -inline bool operator==(const QDeclarativeAnchorLine& a, const QDeclarativeAnchorLine& b) +inline bool operator==(const QDeclarative1AnchorLine& a, const QDeclarative1AnchorLine& b) { return a.item == b.item && a.anchorLine == b.anchorLine; } -class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener +class QDeclarative1AnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener { - Q_DECLARE_PUBLIC(QDeclarativeAnchors) + Q_DECLARE_PUBLIC(QDeclarative1Anchors) public: - QDeclarativeAnchorsPrivate(QGraphicsObject *i) + QDeclarative1AnchorsPrivate(QGraphicsObject *i) : componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0), updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0), centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), @@ -125,13 +126,13 @@ class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeIte void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &); void _q_widgetDestroyed(QObject *); void _q_widgetGeometryChanged(); - QDeclarativeAnchorsPrivate *anchorPrivate() { return this; } + QDeclarative1AnchorsPrivate *anchorPrivate() { return this; } bool checkHValid() const; bool checkVValid() const; - bool checkHAnchorValid(QDeclarativeAnchorLine anchor) const; - bool checkVAnchorValid(QDeclarativeAnchorLine anchor) const; - bool calcStretch(const QDeclarativeAnchorLine &edge1, const QDeclarativeAnchorLine &edge2, qreal offset1, qreal offset2, QDeclarativeAnchorLine::AnchorLine line, qreal &stretch); + bool checkHAnchorValid(QDeclarative1AnchorLine anchor) const; + bool checkVAnchorValid(QDeclarative1AnchorLine anchor) const; + bool calcStretch(const QDeclarative1AnchorLine &edge1, const QDeclarative1AnchorLine &edge2, qreal offset1, qreal offset2, QDeclarative1AnchorLine::AnchorLine line, qreal &stretch); bool isMirrored() const; void updateHorizontalAnchors(); @@ -140,18 +141,18 @@ class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeIte void centerInChanged(); QGraphicsObject *item; - QDeclarativeAnchors::Anchors usedAnchors; + QDeclarative1Anchors::Anchors usedAnchors; QGraphicsObject *fill; QGraphicsObject *centerIn; - QDeclarativeAnchorLine left; - QDeclarativeAnchorLine right; - QDeclarativeAnchorLine top; - QDeclarativeAnchorLine bottom; - QDeclarativeAnchorLine vCenter; - QDeclarativeAnchorLine hCenter; - QDeclarativeAnchorLine baseline; + QDeclarative1AnchorLine left; + QDeclarative1AnchorLine right; + QDeclarative1AnchorLine top; + QDeclarative1AnchorLine bottom; + QDeclarative1AnchorLine vCenter; + QDeclarative1AnchorLine hCenter; + QDeclarative1AnchorLine baseline; qreal leftMargin; qreal rightMargin; @@ -165,6 +166,6 @@ class QDeclarativeAnchorsPrivate : public QObjectPrivate, public QDeclarativeIte QT_END_NAMESPACE -Q_DECLARE_METATYPE(QDeclarativeAnchorLine) +Q_DECLARE_METATYPE(QDeclarative1AnchorLine) #endif diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp similarity index 85% rename from src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp rename to src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp index 8787a5ed68..5d7ad80bbb 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp @@ -39,13 +39,13 @@ ** ****************************************************************************/ -#include "private/qdeclarativeanimatedimage_p.h" -#include "private/qdeclarativeanimatedimage_p_p.h" +#include "QtQuick1/private/qdeclarativeanimatedimage_p.h" +#include "QtQuick1/private/qdeclarativeanimatedimage_p_p.h" #ifndef QT_NO_MOVIE -#include -#include +#include +#include #include #include @@ -53,8 +53,10 @@ QT_BEGIN_NAMESPACE + + /*! - \qmlclass AnimatedImage QDeclarativeAnimatedImage + \qmlclass AnimatedImage QDeclarative1AnimatedImage \inherits Image \since 4.7 \ingroup basic-visual-elements @@ -131,14 +133,14 @@ QT_BEGIN_NAMESPACE The default value is false. */ -QDeclarativeAnimatedImage::QDeclarativeAnimatedImage(QDeclarativeItem *parent) - : QDeclarativeImage(*(new QDeclarativeAnimatedImagePrivate), parent) +QDeclarative1AnimatedImage::QDeclarative1AnimatedImage(QDeclarativeItem *parent) + : QDeclarative1Image(*(new QDeclarative1AnimatedImagePrivate), parent) { } -QDeclarativeAnimatedImage::~QDeclarativeAnimatedImage() +QDeclarative1AnimatedImage::~QDeclarative1AnimatedImage() { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); delete d->_movie; } @@ -149,17 +151,17 @@ QDeclarativeAnimatedImage::~QDeclarativeAnimatedImage() By default, this property is false. Set it to true when you want to pause the animation. */ -bool QDeclarativeAnimatedImage::isPaused() const +bool QDeclarative1AnimatedImage::isPaused() const { - Q_D(const QDeclarativeAnimatedImage); + Q_D(const QDeclarative1AnimatedImage); if(!d->_movie) return false; return d->_movie->state()==QMovie::Paused; } -void QDeclarativeAnimatedImage::setPaused(bool pause) +void QDeclarative1AnimatedImage::setPaused(bool pause) { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); if(pause == d->paused) return; d->paused = pause; @@ -174,17 +176,17 @@ void QDeclarativeAnimatedImage::setPaused(bool pause) By default, this property is true, meaning that the animation will start playing immediately. */ -bool QDeclarativeAnimatedImage::isPlaying() const +bool QDeclarative1AnimatedImage::isPlaying() const { - Q_D(const QDeclarativeAnimatedImage); + Q_D(const QDeclarative1AnimatedImage); if (!d->_movie) return false; return d->_movie->state()!=QMovie::NotRunning; } -void QDeclarativeAnimatedImage::setPlaying(bool play) +void QDeclarative1AnimatedImage::setPlaying(bool play) { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); if(play == d->playing) return; d->playing = play; @@ -206,17 +208,17 @@ void QDeclarativeAnimatedImage::setPlaying(bool play) frameCount is the number of frames in the animation. For some animation formats, frameCount is unknown and has a value of zero. */ -int QDeclarativeAnimatedImage::currentFrame() const +int QDeclarative1AnimatedImage::currentFrame() const { - Q_D(const QDeclarativeAnimatedImage); + Q_D(const QDeclarative1AnimatedImage); if (!d->_movie) return d->preset_currentframe; return d->_movie->currentFrameNumber(); } -void QDeclarativeAnimatedImage::setCurrentFrame(int frame) +void QDeclarative1AnimatedImage::setCurrentFrame(int frame) { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); if (!d->_movie) { d->preset_currentframe = frame; return; @@ -224,17 +226,17 @@ void QDeclarativeAnimatedImage::setCurrentFrame(int frame) d->_movie->jumpToFrame(frame); } -int QDeclarativeAnimatedImage::frameCount() const +int QDeclarative1AnimatedImage::frameCount() const { - Q_D(const QDeclarativeAnimatedImage); + Q_D(const QDeclarative1AnimatedImage); if (!d->_movie) return 0; return d->_movie->frameCount(); } -void QDeclarativeAnimatedImage::setSource(const QUrl &url) +void QDeclarative1AnimatedImage::setSource(const QUrl &url) { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); if (url == d->url) return; @@ -253,11 +255,11 @@ void QDeclarativeAnimatedImage::setSource(const QUrl &url) load(); } -void QDeclarativeAnimatedImage::load() +void QDeclarative1AnimatedImage::load() { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); - QDeclarativeImageBase::Status oldStatus = d->status; + QDeclarative1ImageBase::Status oldStatus = d->status; qreal oldProgress = d->progress; if (d->url.isEmpty()) { @@ -321,9 +323,9 @@ void QDeclarativeAnimatedImage::load() #define ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION 16 -void QDeclarativeAnimatedImage::movieRequestFinished() +void QDeclarative1AnimatedImage::movieRequestFinished() { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); d->redirectCount++; if (d->redirectCount < ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION) { @@ -367,16 +369,16 @@ void QDeclarativeAnimatedImage::movieRequestFinished() emit statusChanged(d->status); } -void QDeclarativeAnimatedImage::movieUpdate() +void QDeclarative1AnimatedImage::movieUpdate() { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); d->setPixmap(d->_movie->currentPixmap()); emit frameChanged(); } -void QDeclarativeAnimatedImage::playingStatusChanged() +void QDeclarative1AnimatedImage::playingStatusChanged() { - Q_D(QDeclarativeAnimatedImage); + Q_D(QDeclarative1AnimatedImage); if((d->_movie->state() != QMovie::NotRunning) != d->playing){ d->playing = (d->_movie->state() != QMovie::NotRunning); emit playingChanged(); @@ -387,10 +389,10 @@ void QDeclarativeAnimatedImage::playingStatusChanged() } } -void QDeclarativeAnimatedImage::componentComplete() +void QDeclarative1AnimatedImage::componentComplete() { - Q_D(QDeclarativeAnimatedImage); - QDeclarativeItem::componentComplete(); // NOT QDeclarativeImage + Q_D(QDeclarative1AnimatedImage); + QDeclarativeItem::componentComplete(); // NOT QDeclarative1Image if (d->url.isValid()) load(); if (!d->reply) { @@ -399,6 +401,8 @@ void QDeclarativeAnimatedImage::componentComplete() } } + + QT_END_NAMESPACE #endif // QT_NO_MOVIE diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h rename to src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h index bc3255e808..e4f3939c01 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h @@ -50,12 +50,13 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +class QMovie; + QT_MODULE(Declarative) -class QMovie; -class QDeclarativeAnimatedImagePrivate; +class QDeclarative1AnimatedImagePrivate; -class Q_AUTOTEST_EXPORT QDeclarativeAnimatedImage : public QDeclarativeImage +class Q_AUTOTEST_EXPORT QDeclarative1AnimatedImage : public QDeclarative1Image { Q_OBJECT @@ -68,8 +69,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeAnimatedImage : public QDeclarativeImage Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) public: - QDeclarativeAnimatedImage(QDeclarativeItem *parent=0); - ~QDeclarativeAnimatedImage(); + QDeclarative1AnimatedImage(QDeclarativeItem *parent=0); + ~QDeclarative1AnimatedImage(); bool isPlaying() const; void setPlaying(bool play); @@ -82,7 +83,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeAnimatedImage : public QDeclarativeImage int frameCount() const; - // Extends QDeclarativeImage's src property*/ + // Extends QDeclarative1Image's src property*/ virtual void setSource(const QUrl&); Q_SIGNALS: @@ -101,13 +102,13 @@ private Q_SLOTS: void componentComplete(); private: - Q_DISABLE_COPY(QDeclarativeAnimatedImage) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeAnimatedImage) + Q_DISABLE_COPY(QDeclarative1AnimatedImage) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1AnimatedImage) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeAnimatedImage) +QML_DECLARE_TYPE(QDeclarative1AnimatedImage) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h similarity index 93% rename from src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h index 0b7614e84b..bf6c2f9460 100644 --- a/src/declarative/graphicsitems/qdeclarativeanimatedimage_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h @@ -62,12 +62,12 @@ QT_BEGIN_NAMESPACE class QMovie; class QNetworkReply; -class QDeclarativeAnimatedImagePrivate : public QDeclarativeImagePrivate +class QDeclarative1AnimatedImagePrivate : public QDeclarative1ImagePrivate { - Q_DECLARE_PUBLIC(QDeclarativeAnimatedImage) + Q_DECLARE_PUBLIC(QDeclarative1AnimatedImage) public: - QDeclarativeAnimatedImagePrivate() + QDeclarative1AnimatedImagePrivate() : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0), redirectCount(0) { } diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp similarity index 87% rename from src/declarative/graphicsitems/qdeclarativeborderimage.cpp rename to src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp index 9c274e93fa..4588d14753 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#include "private/qdeclarativeborderimage_p.h" -#include "private/qdeclarativeborderimage_p_p.h" +#include "QtQuick1/private/qdeclarativeborderimage_p.h" +#include "QtQuick1/private/qdeclarativeborderimage_p_p.h" -#include -#include +#include +#include #include #include @@ -51,8 +51,10 @@ QT_BEGIN_NAMESPACE + + /*! - \qmlclass BorderImage QDeclarativeBorderImage + \qmlclass BorderImage QDeclarative1BorderImage \brief The BorderImage element provides an image that can be used as a border. \inherits Item \since 4.7 @@ -163,14 +165,14 @@ QT_BEGIN_NAMESPACE local filesystem. Images loaded via a network resource (e.g. HTTP) are always loaded asynchonously. */ -QDeclarativeBorderImage::QDeclarativeBorderImage(QDeclarativeItem *parent) - : QDeclarativeImageBase(*(new QDeclarativeBorderImagePrivate), parent) +QDeclarative1BorderImage::QDeclarative1BorderImage(QDeclarativeItem *parent) + : QDeclarative1ImageBase(*(new QDeclarative1BorderImagePrivate), parent) { } -QDeclarativeBorderImage::~QDeclarativeBorderImage() +QDeclarative1BorderImage::~QDeclarative1BorderImage() { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); if (d->sciReply) d->sciReply->deleteLater(); } @@ -269,9 +271,9 @@ QDeclarativeBorderImage::~QDeclarativeBorderImage() \sa Image::sourceSize */ -void QDeclarativeBorderImage::setSource(const QUrl &url) +void QDeclarative1BorderImage::setSource(const QUrl &url) { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); //equality is fairly expensive, so we bypass for simple, common case if ((d->url.isEmpty() == url.isEmpty()) && url == d->url) return; @@ -289,9 +291,9 @@ void QDeclarativeBorderImage::setSource(const QUrl &url) load(); } -void QDeclarativeBorderImage::load() +void QDeclarative1BorderImage::load() { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); if (d->progress != 0.0) { d->progress = 0.0; emit progressChanged(d->progress); @@ -312,7 +314,7 @@ void QDeclarativeBorderImage::load() if (!lf.isEmpty()) { QFile file(lf); file.open(QIODevice::ReadOnly); - setGridScaledImage(QDeclarativeGridScaledImage(&file)); + setGridScaledImage(QDeclarative1GridScaledImage(&file)); } else #endif { @@ -325,7 +327,7 @@ void QDeclarativeBorderImage::load() sciReplyFinished = QNetworkReply::staticMetaObject.indexOfSignal("finished()"); thisSciRequestFinished = - QDeclarativeBorderImage::staticMetaObject.indexOfSlot("sciRequestFinished()"); + QDeclarative1BorderImage::staticMetaObject.indexOfSlot("sciRequestFinished()"); } QMetaObject::connect(d->sciReply, sciReplyFinished, this, @@ -333,11 +335,11 @@ void QDeclarativeBorderImage::load() } } else { - QDeclarativePixmap::Options options; + QDeclarative1Pixmap::Options options; if (d->async) - options |= QDeclarativePixmap::Asynchronous; + options |= QDeclarative1Pixmap::Asynchronous; if (d->cache) - options |= QDeclarativePixmap::Cache; + options |= QDeclarative1Pixmap::Cache; d->pix.clear(this); d->pix.load(qmlEngine(this), d->url, options); @@ -397,9 +399,9 @@ void QDeclarativeBorderImage::load() \l {BorderImage::source}{.sci file}. */ -QDeclarativeScaleGrid *QDeclarativeBorderImage::border() +QDeclarative1ScaleGrid *QDeclarative1BorderImage::border() { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); return d->getScaleGrid(); } @@ -417,15 +419,15 @@ QDeclarativeScaleGrid *QDeclarativeBorderImage::border() The default tile mode for each property is BorderImage.Stretch. */ -QDeclarativeBorderImage::TileMode QDeclarativeBorderImage::horizontalTileMode() const +QDeclarative1BorderImage::TileMode QDeclarative1BorderImage::horizontalTileMode() const { - Q_D(const QDeclarativeBorderImage); + Q_D(const QDeclarative1BorderImage); return d->horizontalTileMode; } -void QDeclarativeBorderImage::setHorizontalTileMode(TileMode t) +void QDeclarative1BorderImage::setHorizontalTileMode(TileMode t) { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); if (t != d->horizontalTileMode) { d->horizontalTileMode = t; emit horizontalTileModeChanged(); @@ -433,15 +435,15 @@ void QDeclarativeBorderImage::setHorizontalTileMode(TileMode t) } } -QDeclarativeBorderImage::TileMode QDeclarativeBorderImage::verticalTileMode() const +QDeclarative1BorderImage::TileMode QDeclarative1BorderImage::verticalTileMode() const { - Q_D(const QDeclarativeBorderImage); + Q_D(const QDeclarative1BorderImage); return d->verticalTileMode; } -void QDeclarativeBorderImage::setVerticalTileMode(TileMode t) +void QDeclarative1BorderImage::setVerticalTileMode(TileMode t) { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); if (t != d->verticalTileMode) { d->verticalTileMode = t; emit verticalTileModeChanged(); @@ -449,14 +451,14 @@ void QDeclarativeBorderImage::setVerticalTileMode(TileMode t) } } -void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledImage& sci) +void QDeclarative1BorderImage::setGridScaledImage(const QDeclarative1GridScaledImage& sci) { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); if (!sci.isValid()) { d->status = Error; emit statusChanged(d->status); } else { - QDeclarativeScaleGrid *sg = border(); + QDeclarative1ScaleGrid *sg = border(); sg->setTop(sci.gridTop()); sg->setBottom(sci.gridBottom()); sg->setLeft(sci.gridLeft()); @@ -466,11 +468,11 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - QDeclarativePixmap::Options options; + QDeclarative1Pixmap::Options options; if (d->async) - options |= QDeclarativePixmap::Asynchronous; + options |= QDeclarative1Pixmap::Asynchronous; if (d->cache) - options |= QDeclarativePixmap::Cache; + options |= QDeclarative1Pixmap::Cache; d->pix.clear(this); d->pix.load(qmlEngine(this), d->sciurl, options); @@ -479,9 +481,9 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma static int thisRequestFinished = -1; if (thisRequestProgress == -1) { thisRequestProgress = - QDeclarativeBorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); + QDeclarative1BorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); thisRequestFinished = - QDeclarativeBorderImage::staticMetaObject.indexOfSlot("requestFinished()"); + QDeclarative1BorderImage::staticMetaObject.indexOfSlot("requestFinished()"); } d->pix.connectFinished(this, thisRequestFinished); @@ -509,9 +511,9 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma } } -void QDeclarativeBorderImage::requestFinished() +void QDeclarative1BorderImage::requestFinished() { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); QSize impsize = d->pix.implicitSize(); if (d->pix.isError()) { @@ -535,9 +537,9 @@ void QDeclarativeBorderImage::requestFinished() #define BORDERIMAGE_MAX_REDIRECT 16 -void QDeclarativeBorderImage::sciRequestFinished() +void QDeclarative1BorderImage::sciRequestFinished() { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); d->redirectCount++; if (d->redirectCount < BORDERIMAGE_MAX_REDIRECT) { @@ -556,21 +558,21 @@ void QDeclarativeBorderImage::sciRequestFinished() d->sciReply = 0; emit statusChanged(d->status); } else { - QDeclarativeGridScaledImage sci(d->sciReply); + QDeclarative1GridScaledImage sci(d->sciReply); d->sciReply->deleteLater(); d->sciReply = 0; setGridScaledImage(sci); } } -void QDeclarativeBorderImage::doUpdate() +void QDeclarative1BorderImage::doUpdate() { update(); } -void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) +void QDeclarative1BorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { - Q_D(QDeclarativeBorderImage); + Q_D(QDeclarative1BorderImage); if (d->pix.isNull() || d->width() <= 0.0 || d->height() <= 0.0) return; @@ -586,7 +588,7 @@ void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem p->setWorldTransform(mirror * oldTransform); } - const QDeclarativeScaleGrid *border = d->getScaleGrid(); + const QDeclarative1ScaleGrid *border = d->getScaleGrid(); int left = border->left(); int right = border->right(); qreal borderWidth = left + right; @@ -614,4 +616,6 @@ void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem p->setWorldTransform(oldTransform); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h similarity index 84% rename from src/declarative/graphicsitems/qdeclarativeborderimage_p.h rename to src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h index 6a50c3cfec..f2349b26c6 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h @@ -51,15 +51,15 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeScaleGrid; -class QDeclarativeGridScaledImage; -class QDeclarativeBorderImagePrivate; -class Q_AUTOTEST_EXPORT QDeclarativeBorderImage : public QDeclarativeImageBase +class QDeclarative1ScaleGrid; +class QDeclarative1GridScaledImage; +class QDeclarative1BorderImagePrivate; +class Q_AUTOTEST_EXPORT QDeclarative1BorderImage : public QDeclarative1ImageBase { Q_OBJECT Q_ENUMS(TileMode) - Q_PROPERTY(QDeclarativeScaleGrid *border READ border CONSTANT) + Q_PROPERTY(QDeclarative1ScaleGrid *border READ border CONSTANT) Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged) Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged) @@ -67,10 +67,10 @@ class Q_AUTOTEST_EXPORT QDeclarativeBorderImage : public QDeclarativeImageBase Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) public: - QDeclarativeBorderImage(QDeclarativeItem *parent=0); - ~QDeclarativeBorderImage(); + QDeclarative1BorderImage(QDeclarativeItem *parent=0); + ~QDeclarative1BorderImage(); - QDeclarativeScaleGrid *border(); + QDeclarative1ScaleGrid *border(); enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile }; @@ -92,7 +92,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeBorderImage : public QDeclarativeImageBase virtual void load(); private: - void setGridScaledImage(const QDeclarativeGridScaledImage& sci); + void setGridScaledImage(const QDeclarative1GridScaledImage& sci); private Q_SLOTS: void doUpdate(); @@ -100,12 +100,12 @@ private Q_SLOTS: void sciRequestFinished(); private: - Q_DISABLE_COPY(QDeclarativeBorderImage) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeBorderImage) + Q_DISABLE_COPY(QDeclarative1BorderImage) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1BorderImage) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeBorderImage) +QML_DECLARE_TYPE(QDeclarative1BorderImage) QT_END_HEADER #endif // QDECLARATIVEBORDERIMAGE_H diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h similarity index 76% rename from src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h index d847e222b7..0d1c30ee2a 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h @@ -59,45 +59,46 @@ QT_BEGIN_NAMESPACE class QNetworkReply; -class QDeclarativeBorderImagePrivate : public QDeclarativeImageBasePrivate + +class QDeclarative1BorderImagePrivate : public QDeclarative1ImageBasePrivate { - Q_DECLARE_PUBLIC(QDeclarativeBorderImage) + Q_DECLARE_PUBLIC(QDeclarative1BorderImage) public: - QDeclarativeBorderImagePrivate() + QDeclarative1BorderImagePrivate() : border(0), sciReply(0), - horizontalTileMode(QDeclarativeBorderImage::Stretch), - verticalTileMode(QDeclarativeBorderImage::Stretch), + horizontalTileMode(QDeclarative1BorderImage::Stretch), + verticalTileMode(QDeclarative1BorderImage::Stretch), redirectCount(0) { } - ~QDeclarativeBorderImagePrivate() + ~QDeclarative1BorderImagePrivate() { } - QDeclarativeScaleGrid *getScaleGrid() + QDeclarative1ScaleGrid *getScaleGrid() { - Q_Q(QDeclarativeBorderImage); + Q_Q(QDeclarative1BorderImage); if (!border) { - border = new QDeclarativeScaleGrid(q); + border = new QDeclarative1ScaleGrid(q); static int borderChangedSignalIdx = -1; static int doUpdateSlotIdx = -1; if (borderChangedSignalIdx < 0) - borderChangedSignalIdx = QDeclarativeScaleGrid::staticMetaObject.indexOfSignal("borderChanged()"); + borderChangedSignalIdx = QDeclarative1ScaleGrid::staticMetaObject.indexOfSignal("borderChanged()"); if (doUpdateSlotIdx < 0) - doUpdateSlotIdx = QDeclarativeBorderImage::staticMetaObject.indexOfSlot("doUpdate()"); + doUpdateSlotIdx = QDeclarative1BorderImage::staticMetaObject.indexOfSlot("doUpdate()"); QMetaObject::connect(border, borderChangedSignalIdx, q, doUpdateSlotIdx); } return border; } - QDeclarativeScaleGrid *border; + QDeclarative1ScaleGrid *border; QUrl sciurl; QNetworkReply *sciReply; - QDeclarativeBorderImage::TileMode horizontalTileMode; - QDeclarativeBorderImage::TileMode verticalTileMode; + QDeclarative1BorderImage::TileMode horizontalTileMode; + QDeclarative1BorderImage::TileMode verticalTileMode; int redirectCount; }; diff --git a/src/declarative/graphicsitems/qdeclarativeevents.cpp b/src/qtquick1/graphicsitems/qdeclarativeevents.cpp similarity index 97% rename from src/declarative/graphicsitems/qdeclarativeevents.cpp rename to src/qtquick1/graphicsitems/qdeclarativeevents.cpp index c0f71d46ee..227ad6d662 100644 --- a/src/declarative/graphicsitems/qdeclarativeevents.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeevents.cpp @@ -39,11 +39,13 @@ ** ****************************************************************************/ -#include "private/qdeclarativeevents_p_p.h" +#include "QtQuick1/private/qdeclarativeevents_p_p.h" QT_BEGIN_NAMESPACE + + /*! - \qmlclass KeyEvent QDeclarativeKeyEvent + \qmlclass KeyEvent QDeclarative1KeyEvent \since 4.7 \ingroup qml-event-elements @@ -138,7 +140,7 @@ Item { /*! - \qmlclass MouseEvent QDeclarativeMouseEvent + \qmlclass MouseEvent QDeclarative1MouseEvent \since 4.7 \ingroup qml-event-elements @@ -152,7 +154,7 @@ Item { /*! \internal - \class QDeclarativeMouseEvent + \class QDeclarative1MouseEvent */ /*! @@ -234,4 +236,6 @@ Item { \endqml */ + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeevents_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h similarity index 88% rename from src/declarative/graphicsitems/qdeclarativeevents_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h index e22f64913a..bda4814a52 100644 --- a/src/declarative/graphicsitems/qdeclarativeevents_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h @@ -53,14 +53,14 @@ // We mean it. // -#include +#include #include #include QT_BEGIN_NAMESPACE -class QDeclarativeKeyEvent : public QObject +class QDeclarative1KeyEvent : public QObject { Q_OBJECT Q_PROPERTY(int key READ key) @@ -71,9 +71,9 @@ class QDeclarativeKeyEvent : public QObject Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) public: - QDeclarativeKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1) + QDeclarative1KeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1) : event(type, key, modifiers, text, autorep, count) { event.setAccepted(false); } - QDeclarativeKeyEvent(const QKeyEvent &ke) + QDeclarative1KeyEvent(const QKeyEvent &ke) : event(ke) { event.setAccepted(false); } int key() const { return event.key(); } @@ -89,7 +89,7 @@ class QDeclarativeKeyEvent : public QObject QKeyEvent event; }; -class QDeclarativeMouseEvent : public QObject +class QDeclarative1MouseEvent : public QObject { Q_OBJECT Q_PROPERTY(int x READ x) @@ -102,7 +102,7 @@ class QDeclarativeMouseEvent : public QObject Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) public: - QDeclarativeMouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers + QDeclarative1MouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers , bool isClick=false, bool wasHeld=false) : _x(x), _y(y), _button(button), _buttons(buttons), _modifiers(modifiers) , _wasHeld(wasHeld), _isClick(isClick), _accepted(true) {} @@ -135,7 +135,7 @@ class QDeclarativeMouseEvent : public QObject QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeKeyEvent) -QML_DECLARE_TYPE(QDeclarativeMouseEvent) +QML_DECLARE_TYPE(QDeclarative1KeyEvent) +QML_DECLARE_TYPE(QDeclarative1MouseEvent) #endif // QDECLARATIVEEVENTS_P_H diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp similarity index 79% rename from src/declarative/graphicsitems/qdeclarativeflickable.cpp rename to src/qtquick1/graphicsitems/qdeclarativeflickable.cpp index ce7566b9c1..37a784f480 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp @@ -39,9 +39,9 @@ ** ****************************************************************************/ -#include "private/qdeclarativeflickable_p.h" -#include "private/qdeclarativeflickable_p_p.h" -#include +#include "QtQuick1/private/qdeclarativeflickable_p.h" +#include "QtQuick1/private/qdeclarativeflickable_p_p.h" +#include #include #include #include @@ -49,6 +49,8 @@ QT_BEGIN_NAMESPACE + + // The maximum number of pixels a flick can overshoot #ifndef QML_FLICK_OVERSHOOT #define QML_FLICK_OVERSHOOT 200 @@ -88,35 +90,35 @@ static const int FlickThreshold = 20; // will ensure the Flickable retains the grab on consecutive flicks. static const int RetainGrabVelocity = 15; -QDeclarativeFlickableVisibleArea::QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent) +QDeclarative1FlickableVisibleArea::QDeclarative1FlickableVisibleArea(QDeclarative1Flickable *parent) : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.) , m_yPosition(0.), m_heightRatio(0.) { } -qreal QDeclarativeFlickableVisibleArea::widthRatio() const +qreal QDeclarative1FlickableVisibleArea::widthRatio() const { return m_widthRatio; } -qreal QDeclarativeFlickableVisibleArea::xPosition() const +qreal QDeclarative1FlickableVisibleArea::xPosition() const { return m_xPosition; } -qreal QDeclarativeFlickableVisibleArea::heightRatio() const +qreal QDeclarative1FlickableVisibleArea::heightRatio() const { return m_heightRatio; } -qreal QDeclarativeFlickableVisibleArea::yPosition() const +qreal QDeclarative1FlickableVisibleArea::yPosition() const { return m_yPosition; } -void QDeclarativeFlickableVisibleArea::updateVisible() +void QDeclarative1FlickableVisibleArea::updateVisible() { - QDeclarativeFlickablePrivate *p = static_cast(QGraphicsItemPrivate::get(flickable)); + QDeclarative1FlickablePrivate *p = static_cast(QGraphicsItemPrivate::get(flickable)); bool changeX = false; bool changeY = false; @@ -164,10 +166,10 @@ void QDeclarativeFlickableVisibleArea::updateVisible() } -QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate() +QDeclarative1FlickablePrivate::QDeclarative1FlickablePrivate() : contentItem(new QDeclarativeItem) - , hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX) - , vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY) + , hData(this, &QDeclarative1FlickablePrivate::setRoundedViewportX) + , vData(this, &QDeclarative1FlickablePrivate::setRoundedViewportY) , flickingHorizontally(false), flickingVertically(false) , hMoved(false), vMoved(false) , movingHorizontally(false), movingVertically(false) @@ -176,14 +178,14 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate() , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100) , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(400) , fixupMode(Normal), vTime(0), visibleArea(0) - , flickableDirection(QDeclarativeFlickable::AutoFlickDirection) - , boundsBehavior(QDeclarativeFlickable::DragAndOvershootBounds) + , flickableDirection(QDeclarative1Flickable::AutoFlickDirection) + , boundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds) { } -void QDeclarativeFlickablePrivate::init() +void QDeclarative1FlickablePrivate::init() { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); QDeclarative_setParent_noEvent(contentItem, q); contentItem->setParentItem(q); static int timelineUpdatedIdx = -1; @@ -191,10 +193,10 @@ void QDeclarativeFlickablePrivate::init() static int flickableTickedIdx = -1; static int flickableMovementEndingIdx = -1; if (timelineUpdatedIdx == -1) { - timelineUpdatedIdx = QDeclarativeTimeLine::staticMetaObject.indexOfSignal("updated()"); - timelineCompletedIdx = QDeclarativeTimeLine::staticMetaObject.indexOfSignal("completed()"); - flickableTickedIdx = QDeclarativeFlickable::staticMetaObject.indexOfSlot("ticked()"); - flickableMovementEndingIdx = QDeclarativeFlickable::staticMetaObject.indexOfSlot("movementEnding()"); + timelineUpdatedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("updated()"); + timelineCompletedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("completed()"); + flickableTickedIdx = QDeclarative1Flickable::staticMetaObject.indexOfSlot("ticked()"); + flickableMovementEndingIdx = QDeclarative1Flickable::staticMetaObject.indexOfSlot("movementEnding()"); } QMetaObject::connect(&timeline, timelineUpdatedIdx, q, flickableTickedIdx, Qt::DirectConnection); @@ -211,7 +213,7 @@ void QDeclarativeFlickablePrivate::init() Returns the amount to overshoot by given a view size. Will be up to the lesser of 1/3 of the view size or QML_FLICK_OVERSHOOT */ -qreal QDeclarativeFlickablePrivate::overShootDistance(qreal size) +qreal QDeclarative1FlickablePrivate::overShootDistance(qreal size) { if (maxVelocity <= 0) return 0.0; @@ -219,7 +221,7 @@ qreal QDeclarativeFlickablePrivate::overShootDistance(qreal size) return qMin(qreal(QML_FLICK_OVERSHOOT), size/3); } -void QDeclarativeFlickablePrivate::AxisData::addVelocitySample(qreal v, qreal maxVelocity) +void QDeclarative1FlickablePrivate::AxisData::addVelocitySample(qreal v, qreal maxVelocity) { if (v > maxVelocity) v = maxVelocity; @@ -230,7 +232,7 @@ void QDeclarativeFlickablePrivate::AxisData::addVelocitySample(qreal v, qreal ma velocityBuffer.remove(0); } -void QDeclarativeFlickablePrivate::AxisData::updateVelocity() +void QDeclarative1FlickablePrivate::AxisData::updateVelocity() { if (velocityBuffer.count() > QML_FLICK_DISCARDSAMPLES) { velocity = 0; @@ -243,9 +245,9 @@ void QDeclarativeFlickablePrivate::AxisData::updateVelocity() } } -void QDeclarativeFlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeom, const QRectF &oldGeom) +void QDeclarative1FlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeom, const QRectF &oldGeom) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); if (item == contentItem) { if (newGeom.x() != oldGeom.x()) emit q->contentXChanged(); @@ -254,22 +256,22 @@ void QDeclarativeFlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, c } } -void QDeclarativeFlickablePrivate::flickX(qreal velocity) +void QDeclarative1FlickablePrivate::flickX(qreal velocity) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); flick(hData, q->minXExtent(), q->maxXExtent(), q->width(), fixupX_callback, velocity); } -void QDeclarativeFlickablePrivate::flickY(qreal velocity) +void QDeclarative1FlickablePrivate::flickY(qreal velocity) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); flick(vData, q->minYExtent(), q->maxYExtent(), q->height(), fixupY_callback, velocity); } -void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal, - QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity) +void QDeclarative1FlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal, + QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); qreal maxDistance = -1; data.fixingUp = false; // -ve velocity means list is moving up @@ -289,11 +291,11 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal v = maxVelocity; } timeline.reset(data.move); - if (boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds) + if (boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds) timeline.accel(data.move, v, deceleration); else timeline.accel(data.move, v, deceleration, maxDistance); - timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); + timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); if (!flickingHorizontally && q->xflick()) { flickingHorizontally = true; emit q->flickingChanged(); @@ -314,29 +316,29 @@ void QDeclarativeFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal } } -void QDeclarativeFlickablePrivate::fixupY_callback(void *data) +void QDeclarative1FlickablePrivate::fixupY_callback(void *data) { - ((QDeclarativeFlickablePrivate *)data)->fixupY(); + ((QDeclarative1FlickablePrivate *)data)->fixupY(); } -void QDeclarativeFlickablePrivate::fixupX_callback(void *data) +void QDeclarative1FlickablePrivate::fixupX_callback(void *data) { - ((QDeclarativeFlickablePrivate *)data)->fixupX(); + ((QDeclarative1FlickablePrivate *)data)->fixupX(); } -void QDeclarativeFlickablePrivate::fixupX() +void QDeclarative1FlickablePrivate::fixupX() { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); fixup(hData, q->minXExtent(), q->maxXExtent()); } -void QDeclarativeFlickablePrivate::fixupY() +void QDeclarative1FlickablePrivate::fixupY() { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); fixup(vData, q->minYExtent(), q->maxYExtent()); } -void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) +void QDeclarative1FlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) { if (data.move.value() > minExtent || maxExtent > minExtent) { timeline.reset(data.move); @@ -384,9 +386,9 @@ void QDeclarativeFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal vTime = timeline.time(); } -void QDeclarativeFlickablePrivate::updateBeginningEnd() +void QDeclarative1FlickablePrivate::updateBeginningEnd() { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); bool atBoundaryChange = false; // Vertical @@ -427,7 +429,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() } /*! - \qmlclass Flickable QDeclarativeFlickable + \qmlclass Flickable QDeclarative1Flickable \since 4.7 \ingroup qml-basic-interaction-elements @@ -528,21 +530,21 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() \sa {declarative/ui-components/scrollbar}{scrollbar example} */ -QDeclarativeFlickable::QDeclarativeFlickable(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativeFlickablePrivate), parent) +QDeclarative1Flickable::QDeclarative1Flickable(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1FlickablePrivate), parent) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); d->init(); } -QDeclarativeFlickable::QDeclarativeFlickable(QDeclarativeFlickablePrivate &dd, QDeclarativeItem *parent) +QDeclarative1Flickable::QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent) : QDeclarativeItem(dd, parent) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); d->init(); } -QDeclarativeFlickable::~QDeclarativeFlickable() +QDeclarative1Flickable::~QDeclarative1Flickable() { } @@ -554,15 +556,15 @@ QDeclarativeFlickable::~QDeclarativeFlickable() corner of the Flickable. For example, if you flick an image up 100 pixels, \c contentY will be 100. */ -qreal QDeclarativeFlickable::contentX() const +qreal QDeclarative1Flickable::contentX() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return -d->contentItem->x(); } -void QDeclarativeFlickable::setContentX(qreal pos) +void QDeclarative1Flickable::setContentX(qreal pos) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); d->timeline.reset(d->hData.move); d->vTime = d->timeline.time(); movementXEnding(); @@ -572,15 +574,15 @@ void QDeclarativeFlickable::setContentX(qreal pos) } } -qreal QDeclarativeFlickable::contentY() const +qreal QDeclarative1Flickable::contentY() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return -d->contentItem->y(); } -void QDeclarativeFlickable::setContentY(qreal pos) +void QDeclarative1Flickable::setContentY(qreal pos) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); d->timeline.reset(d->vData.move); d->vTime = d->timeline.time(); movementYEnding(); @@ -603,15 +605,15 @@ void QDeclarativeFlickable::setContentY(qreal pos) to freeze a flickable map while scrolling through a pop-up dialog that is a child of the Flickable. */ -bool QDeclarativeFlickable::isInteractive() const +bool QDeclarative1Flickable::isInteractive() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->interactive; } -void QDeclarativeFlickable::setInteractive(bool interactive) +void QDeclarative1Flickable::setInteractive(bool interactive) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (interactive != d->interactive) { d->interactive = interactive; if (!interactive && (d->flickingHorizontally || d->flickingVertically)) { @@ -636,15 +638,15 @@ void QDeclarativeFlickable::setInteractive(bool interactive) The reported velocity is smoothed to avoid erratic output. */ -qreal QDeclarativeFlickable::horizontalVelocity() const +qreal QDeclarative1Flickable::horizontalVelocity() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->hData.smoothVelocity.value(); } -qreal QDeclarativeFlickable::verticalVelocity() const +qreal QDeclarative1Flickable::verticalVelocity() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->vData.smoothVelocity.value(); } @@ -657,31 +659,31 @@ qreal QDeclarativeFlickable::verticalVelocity() const These properties are true if the flickable view is positioned at the beginning, or end respecively. */ -bool QDeclarativeFlickable::isAtXEnd() const +bool QDeclarative1Flickable::isAtXEnd() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->hData.atEnd; } -bool QDeclarativeFlickable::isAtXBeginning() const +bool QDeclarative1Flickable::isAtXBeginning() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->hData.atBeginning; } -bool QDeclarativeFlickable::isAtYEnd() const +bool QDeclarative1Flickable::isAtYEnd() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->vData.atEnd; } -bool QDeclarativeFlickable::isAtYBeginning() const +bool QDeclarative1Flickable::isAtYBeginning() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->vData.atBeginning; } -void QDeclarativeFlickable::ticked() +void QDeclarative1Flickable::ticked() { viewportMoved(); } @@ -704,17 +706,17 @@ void QDeclarativeFlickable::ticked() } \endcode */ -QDeclarativeItem *QDeclarativeFlickable::contentItem() +QDeclarativeItem *QDeclarative1Flickable::contentItem() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); return d->contentItem; } -QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea() +QDeclarative1FlickableVisibleArea *QDeclarative1Flickable::visibleArea() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (!d->visibleArea) - d->visibleArea = new QDeclarativeFlickableVisibleArea(this); + d->visibleArea = new QDeclarative1FlickableVisibleArea(this); return d->visibleArea; } @@ -733,24 +735,24 @@ QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea() \o Flickable.HorizontalAndVerticalFlick - allows flicking in both directions. \endlist */ -QDeclarativeFlickable::FlickableDirection QDeclarativeFlickable::flickableDirection() const +QDeclarative1Flickable::FlickableDirection QDeclarative1Flickable::flickableDirection() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->flickableDirection; } -void QDeclarativeFlickable::setFlickableDirection(FlickableDirection direction) +void QDeclarative1Flickable::setFlickableDirection(FlickableDirection direction) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (direction != d->flickableDirection) { d->flickableDirection = direction; emit flickableDirectionChanged(); } } -void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1FlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); if (interactive && timeline.isActive() && (qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity || qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity)) stealMouse = true; // If we've been flicked then steal the click. @@ -777,9 +779,9 @@ void QDeclarativeFlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEven QDeclarativeItemPrivate::start(velocityTime); } -void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1FlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); if (!interactive || !lastPosTime.isValid()) return; bool rejectY = false; @@ -800,7 +802,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent newY = minY + (newY - minY) / 2; if (newY < maxY && maxY - minY <= 0) newY = maxY + (newY - maxY) / 2; - if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newY > minY || newY < maxY)) { + if (boundsBehavior == QDeclarative1Flickable::StopAtBounds && (newY > minY || newY < maxY)) { rejectY = true; if (newY < maxY) { newY = maxY; @@ -832,7 +834,7 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent newX = minX + (newX - minX) / 2; if (newX < maxX && maxX - minX <= 0) newX = maxX + (newX - maxX) / 2; - if (boundsBehavior == QDeclarativeFlickable::StopAtBounds && (newX > minX || newX < maxX)) { + if (boundsBehavior == QDeclarative1Flickable::StopAtBounds && (newX > minX || newX < maxX)) { rejectX = true; if (newX < maxX) { newX = maxX; @@ -887,9 +889,9 @@ void QDeclarativeFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent lastPos = event->pos(); } -void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1FlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); stealMouse = false; q->setKeepMouseGrab(false); pressed = false; @@ -927,9 +929,9 @@ void QDeclarativeFlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEv q->movementEnding(); } -void QDeclarativeFlickable::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1Flickable::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->interactive) { if (!d->pressed) d->handleMousePressEvent(event); @@ -939,9 +941,9 @@ void QDeclarativeFlickable::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1Flickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->interactive) { d->handleMouseMoveEvent(event); event->accept(); @@ -950,9 +952,9 @@ void QDeclarativeFlickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativeFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1Flickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->interactive) { d->clearDelayedPress(); d->handleMouseReleaseEvent(event); @@ -963,9 +965,9 @@ void QDeclarativeFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) +void QDeclarative1Flickable::wheelEvent(QGraphicsSceneWheelEvent *event) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (!d->interactive) { QDeclarativeItem::wheelEvent(event); } else if (yflick() && event->orientation() == Qt::Vertical) { @@ -1009,12 +1011,12 @@ void QDeclarativeFlickable::wheelEvent(QGraphicsSceneWheelEvent *event) } } -bool QDeclarativeFlickablePrivate::isOutermostPressDelay() const +bool QDeclarative1FlickablePrivate::isOutermostPressDelay() const { - Q_Q(const QDeclarativeFlickable); + Q_Q(const QDeclarative1Flickable); QDeclarativeItem *item = q->parentItem(); while (item) { - QDeclarativeFlickable *flick = qobject_cast(item); + QDeclarative1Flickable *flick = qobject_cast(item); if (flick && flick->pressDelay() > 0 && flick->isInteractive()) return false; item = item->parentItem(); @@ -1023,9 +1025,9 @@ bool QDeclarativeFlickablePrivate::isOutermostPressDelay() const return true; } -void QDeclarativeFlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event) +void QDeclarative1FlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event) { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); if (!q->scene() || pressDelay <= 0) return; if (!isOutermostPressDelay()) @@ -1053,7 +1055,7 @@ void QDeclarativeFlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent delayedPressTimer.start(pressDelay, q); } -void QDeclarativeFlickablePrivate::clearDelayedPress() +void QDeclarative1FlickablePrivate::clearDelayedPress() { if (delayedPressEvent) { delayedPressTimer.stop(); @@ -1062,19 +1064,19 @@ void QDeclarativeFlickablePrivate::clearDelayedPress() } } -void QDeclarativeFlickablePrivate::setRoundedViewportX(qreal x) +void QDeclarative1FlickablePrivate::setRoundedViewportX(qreal x) { contentItem->setX(qRound(x)); } -void QDeclarativeFlickablePrivate::setRoundedViewportY(qreal y) +void QDeclarative1FlickablePrivate::setRoundedViewportY(qreal y) { contentItem->setY(qRound(y)); } -void QDeclarativeFlickable::timerEvent(QTimerEvent *event) +void QDeclarative1Flickable::timerEvent(QTimerEvent *event) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (event->timerId() == d->delayedPressTimer.timerId()) { d->delayedPressTimer.stop(); if (d->delayedPressEvent) { @@ -1094,30 +1096,30 @@ void QDeclarativeFlickable::timerEvent(QTimerEvent *event) } } -qreal QDeclarativeFlickable::minYExtent() const +qreal QDeclarative1Flickable::minYExtent() const { return 0.0; } -qreal QDeclarativeFlickable::minXExtent() const +qreal QDeclarative1Flickable::minXExtent() const { return 0.0; } /* returns -ve */ -qreal QDeclarativeFlickable::maxXExtent() const +qreal QDeclarative1Flickable::maxXExtent() const { return width() - vWidth(); } /* returns -ve */ -qreal QDeclarativeFlickable::maxYExtent() const +qreal QDeclarative1Flickable::maxYExtent() const { return height() - vHeight(); } -void QDeclarativeFlickable::viewportMoved() +void QDeclarative1Flickable::viewportMoved() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); qreal prevX = d->lastFlickablePosition.x(); qreal prevY = d->lastFlickablePosition.y(); @@ -1149,7 +1151,7 @@ void QDeclarativeFlickable::viewportMoved() qreal maxDistance = d->overShootDistance(height()); d->timeline.reset(d->vData.move); d->timeline.accel(d->vData.move, -d->vData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); - d->timeline.callback(QDeclarativeTimeLineCallback(&d->vData.move, d->fixupY_callback, d)); + d->timeline.callback(QDeclarative1TimeLineCallback(&d->vData.move, d->fixupY_callback, d)); } if (!d->hData.inOvershoot && !d->hData.fixingUp && d->flickingHorizontally && (d->hData.move.value() > minXExtent() || d->hData.move.value() < maxXExtent()) @@ -1159,7 +1161,7 @@ void QDeclarativeFlickable::viewportMoved() qreal maxDistance = d->overShootDistance(width()); d->timeline.reset(d->hData.move); d->timeline.accel(d->hData.move, -d->hData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); - d->timeline.callback(QDeclarativeTimeLineCallback(&d->hData.move, d->fixupX_callback, d)); + d->timeline.callback(QDeclarative1TimeLineCallback(&d->hData.move, d->fixupX_callback, d)); } d->lastFlickablePosition = QPointF(d->hData.move.value(), d->vData.move.value()); @@ -1168,10 +1170,10 @@ void QDeclarativeFlickable::viewportMoved() d->updateBeginningEnd(); } -void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry, +void QDeclarative1Flickable::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); bool changed = false; @@ -1184,7 +1186,7 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry, } // Make sure that we're entirely in view. if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { - d->fixupMode = QDeclarativeFlickablePrivate::Immediate; + d->fixupMode = QDeclarative1FlickablePrivate::Immediate; d->fixupX(); } } @@ -1197,7 +1199,7 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry, } // Make sure that we're entirely in view. if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { - d->fixupMode = QDeclarativeFlickablePrivate::Immediate; + d->fixupMode = QDeclarative1FlickablePrivate::Immediate; d->fixupY(); } } @@ -1206,38 +1208,38 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry, d->updateBeginningEnd(); } -void QDeclarativeFlickable::cancelFlick() +void QDeclarative1Flickable::cancelFlick() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); d->timeline.reset(d->hData.move); d->timeline.reset(d->vData.move); movementEnding(); } -void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty *prop, QObject *o) +void QDeclarative1FlickablePrivate::data_append(QDeclarativeListProperty *prop, QObject *o) { QGraphicsObject *i = qobject_cast(o); if (i) { QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(i); if (static_cast(d)->componentComplete) { - i->setParentItem(static_cast(prop->data)->contentItem); + i->setParentItem(static_cast(prop->data)->contentItem); } else { - d->setParentItemHelper(static_cast(prop->data)->contentItem, 0, 0); + d->setParentItemHelper(static_cast(prop->data)->contentItem, 0, 0); } } else { o->setParent(prop->object); } } -int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty *property) +int QDeclarative1FlickablePrivate::data_count(QDeclarativeListProperty *property) { - QDeclarativeItem *contentItem= static_cast(property->data)->contentItem; + QDeclarativeItem *contentItem= static_cast(property->data)->contentItem; return contentItem->childItems().count() + contentItem->children().count(); } -QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty *property, int index) +QObject *QDeclarative1FlickablePrivate::data_at(QDeclarativeListProperty *property, int index) { - QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; + QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; int childItemCount = contentItem->childItems().count(); @@ -1253,9 +1255,9 @@ QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty return 0; } -void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty *property) +void QDeclarative1FlickablePrivate::data_clear(QDeclarativeListProperty *property) { - QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; + QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; const QList graphicsItems = contentItem->childItems(); for (int i = 0; i < graphicsItems.count(); i++) @@ -1266,18 +1268,18 @@ void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty objects[i]->setParent(0); } -QDeclarativeListProperty QDeclarativeFlickable::flickableData() +QDeclarativeListProperty QDeclarative1Flickable::flickableData() { - Q_D(QDeclarativeFlickable); - return QDeclarativeListProperty(this, (void *)d, QDeclarativeFlickablePrivate::data_append, - QDeclarativeFlickablePrivate::data_count, - QDeclarativeFlickablePrivate::data_at, - QDeclarativeFlickablePrivate::data_clear); + Q_D(QDeclarative1Flickable); + return QDeclarativeListProperty(this, (void *)d, QDeclarative1FlickablePrivate::data_append, + QDeclarative1FlickablePrivate::data_count, + QDeclarative1FlickablePrivate::data_at, + QDeclarative1FlickablePrivate::data_clear); } -QDeclarativeListProperty QDeclarativeFlickable::flickableChildren() +QDeclarativeListProperty QDeclarative1Flickable::flickableChildren() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); return QGraphicsItemPrivate::get(d->contentItem)->childrenList(); } @@ -1302,15 +1304,15 @@ QDeclarativeListProperty QDeclarativeFlickable::flickableChildr boundary when flicked. \endlist */ -QDeclarativeFlickable::BoundsBehavior QDeclarativeFlickable::boundsBehavior() const +QDeclarative1Flickable::BoundsBehavior QDeclarative1Flickable::boundsBehavior() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->boundsBehavior; } -void QDeclarativeFlickable::setBoundsBehavior(BoundsBehavior b) +void QDeclarative1Flickable::setBoundsBehavior(BoundsBehavior b) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (b == d->boundsBehavior) return; d->boundsBehavior = b; @@ -1334,15 +1336,15 @@ void QDeclarativeFlickable::setBoundsBehavior(BoundsBehavior b) using the \l {Item::childrenRect.width}{childrenRect.width} and \l {Item::childrenRect.height}{childrenRect.height} properties. */ -qreal QDeclarativeFlickable::contentWidth() const +qreal QDeclarative1Flickable::contentWidth() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->hData.viewSize; } -void QDeclarativeFlickable::setContentWidth(qreal w) +void QDeclarative1Flickable::setContentWidth(qreal w) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->hData.viewSize == w) return; d->hData.viewSize = w; @@ -1352,25 +1354,25 @@ void QDeclarativeFlickable::setContentWidth(qreal w) d->contentItem->setWidth(w); // Make sure that we're entirely in view. if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { - d->fixupMode = QDeclarativeFlickablePrivate::Immediate; + d->fixupMode = QDeclarative1FlickablePrivate::Immediate; d->fixupX(); } else if (!d->pressed && d->hData.fixingUp) { - d->fixupMode = QDeclarativeFlickablePrivate::ExtentChanged; + d->fixupMode = QDeclarative1FlickablePrivate::ExtentChanged; d->fixupX(); } emit contentWidthChanged(); d->updateBeginningEnd(); } -qreal QDeclarativeFlickable::contentHeight() const +qreal QDeclarative1Flickable::contentHeight() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->vData.viewSize; } -void QDeclarativeFlickable::setContentHeight(qreal h) +void QDeclarative1Flickable::setContentHeight(qreal h) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->vData.viewSize == h) return; d->vData.viewSize = h; @@ -1380,10 +1382,10 @@ void QDeclarativeFlickable::setContentHeight(qreal h) d->contentItem->setHeight(h); // Make sure that we're entirely in view. if (!d->pressed && !d->movingHorizontally && !d->movingVertically) { - d->fixupMode = QDeclarativeFlickablePrivate::Immediate; + d->fixupMode = QDeclarative1FlickablePrivate::Immediate; d->fixupY(); } else if (!d->pressed && d->vData.fixingUp) { - d->fixupMode = QDeclarativeFlickablePrivate::ExtentChanged; + d->fixupMode = QDeclarative1FlickablePrivate::ExtentChanged; d->fixupY(); } emit contentHeightChanged(); @@ -1404,9 +1406,9 @@ void QDeclarativeFlickable::setContentHeight(qreal h) the bounds of the Flickable. Calling \l returnToBounds() will move the content back within legal bounds. */ -void QDeclarativeFlickable::resizeContent(qreal w, qreal h, QPointF center) +void QDeclarative1Flickable::resizeContent(qreal w, qreal h, QPointF center) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (w != d->hData.viewSize) { qreal oldSize = d->hData.viewSize; d->hData.viewSize = w; @@ -1440,52 +1442,52 @@ void QDeclarativeFlickable::resizeContent(qreal w, qreal h, QPointF center) This may be called to ensure that the content is within legal bounds after manually positioning the content. */ -void QDeclarativeFlickable::returnToBounds() +void QDeclarative1Flickable::returnToBounds() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); d->fixupX(); d->fixupY(); } -qreal QDeclarativeFlickable::vWidth() const +qreal QDeclarative1Flickable::vWidth() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); if (d->hData.viewSize < 0) return width(); else return d->hData.viewSize; } -qreal QDeclarativeFlickable::vHeight() const +qreal QDeclarative1Flickable::vHeight() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); if (d->vData.viewSize < 0) return height(); else return d->vData.viewSize; } -bool QDeclarativeFlickable::xflick() const +bool QDeclarative1Flickable::xflick() const { - Q_D(const QDeclarativeFlickable); - if (d->flickableDirection == QDeclarativeFlickable::AutoFlickDirection) + Q_D(const QDeclarative1Flickable); + if (d->flickableDirection == QDeclarative1Flickable::AutoFlickDirection) return vWidth() != width(); - return d->flickableDirection & QDeclarativeFlickable::HorizontalFlick; + return d->flickableDirection & QDeclarative1Flickable::HorizontalFlick; } -bool QDeclarativeFlickable::yflick() const +bool QDeclarative1Flickable::yflick() const { - Q_D(const QDeclarativeFlickable); - if (d->flickableDirection == QDeclarativeFlickable::AutoFlickDirection) + Q_D(const QDeclarative1Flickable); + if (d->flickableDirection == QDeclarative1Flickable::AutoFlickDirection) return vHeight() != height(); - return d->flickableDirection & QDeclarativeFlickable::VerticalFlick; + return d->flickableDirection & QDeclarative1Flickable::VerticalFlick; } -bool QDeclarativeFlickable::sceneEvent(QEvent *event) +bool QDeclarative1Flickable::sceneEvent(QEvent *event) { bool rv = QDeclarativeItem::sceneEvent(event); if (event->type() == QEvent::UngrabMouse) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->pressed) { // if our mouse grab has been removed (probably by another Flickable), // fix our state @@ -1497,9 +1499,9 @@ bool QDeclarativeFlickable::sceneEvent(QEvent *event) return rv; } -bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) +bool QDeclarative1Flickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); QGraphicsSceneMouseEvent mouseEvent(event->type()); QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); @@ -1573,9 +1575,9 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) return false; } -bool QDeclarativeFlickable::sceneEventFilter(QGraphicsItem *i, QEvent *e) +bool QDeclarative1Flickable::sceneEventFilter(QGraphicsItem *i, QEvent *e) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (!isVisible() || !d->interactive) return QDeclarativeItem::sceneEventFilter(i, e); switch (e->type()) { @@ -1596,15 +1598,15 @@ bool QDeclarativeFlickable::sceneEventFilter(QGraphicsItem *i, QEvent *e) The default value is platform dependent. */ -qreal QDeclarativeFlickable::maximumFlickVelocity() const +qreal QDeclarative1Flickable::maximumFlickVelocity() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->maxVelocity; } -void QDeclarativeFlickable::setMaximumFlickVelocity(qreal v) +void QDeclarative1Flickable::setMaximumFlickVelocity(qreal v) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (v == d->maxVelocity) return; d->maxVelocity = v; @@ -1617,24 +1619,24 @@ void QDeclarativeFlickable::setMaximumFlickVelocity(qreal v) The default value is platform dependent. */ -qreal QDeclarativeFlickable::flickDeceleration() const +qreal QDeclarative1Flickable::flickDeceleration() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->deceleration; } -void QDeclarativeFlickable::setFlickDeceleration(qreal deceleration) +void QDeclarative1Flickable::setFlickDeceleration(qreal deceleration) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (deceleration == d->deceleration) return; d->deceleration = deceleration; emit flickDecelerationChanged(); } -bool QDeclarativeFlickable::isFlicking() const +bool QDeclarative1Flickable::isFlicking() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->flickingHorizontally || d->flickingVertically; } @@ -1646,15 +1648,15 @@ bool QDeclarativeFlickable::isFlicking() const These properties describe whether the view is currently moving horizontally, vertically or in either direction, due to the user flicking the view. */ -bool QDeclarativeFlickable::isFlickingHorizontally() const +bool QDeclarative1Flickable::isFlickingHorizontally() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->flickingHorizontally; } -bool QDeclarativeFlickable::isFlickingVertically() const +bool QDeclarative1Flickable::isFlickingVertically() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->flickingVertically; } @@ -1672,15 +1674,15 @@ bool QDeclarativeFlickable::isFlickingVertically() const Note that for nested Flickables with pressDelay set, the pressDelay of inner Flickables is overridden by the outermost Flickable. */ -int QDeclarativeFlickable::pressDelay() const +int QDeclarative1Flickable::pressDelay() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->pressDelay; } -void QDeclarativeFlickable::setPressDelay(int delay) +void QDeclarative1Flickable::setPressDelay(int delay) { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->pressDelay == delay) return; d->pressDelay = delay; @@ -1688,9 +1690,9 @@ void QDeclarativeFlickable::setPressDelay(int delay) } -bool QDeclarativeFlickable::isMoving() const +bool QDeclarative1Flickable::isMoving() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->movingHorizontally || d->movingVertically; } @@ -1703,21 +1705,21 @@ bool QDeclarativeFlickable::isMoving() const vertically or in either direction, due to the user either dragging or flicking the view. */ -bool QDeclarativeFlickable::isMovingHorizontally() const +bool QDeclarative1Flickable::isMovingHorizontally() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->movingHorizontally; } -bool QDeclarativeFlickable::isMovingVertically() const +bool QDeclarative1Flickable::isMovingVertically() const { - Q_D(const QDeclarativeFlickable); + Q_D(const QDeclarative1Flickable); return d->movingVertically; } -void QDeclarativeFlickable::movementStarting() +void QDeclarative1Flickable::movementStarting() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->hMoved && !d->movingHorizontally) { d->movingHorizontally = true; emit movingChanged(); @@ -1734,18 +1736,18 @@ void QDeclarativeFlickable::movementStarting() } } -void QDeclarativeFlickable::movementEnding() +void QDeclarative1Flickable::movementEnding() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); movementXEnding(); movementYEnding(); d->hData.smoothVelocity.setValue(0); d->vData.smoothVelocity.setValue(0); } -void QDeclarativeFlickable::movementXEnding() +void QDeclarative1Flickable::movementXEnding() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->flickingHorizontally) { d->flickingHorizontally = false; emit flickingChanged(); @@ -1766,9 +1768,9 @@ void QDeclarativeFlickable::movementXEnding() d->hData.fixingUp = false; } -void QDeclarativeFlickable::movementYEnding() +void QDeclarative1Flickable::movementYEnding() { - Q_D(QDeclarativeFlickable); + Q_D(QDeclarative1Flickable); if (d->flickingVertically) { d->flickingVertically = false; emit flickingChanged(); @@ -1789,11 +1791,13 @@ void QDeclarativeFlickable::movementYEnding() d->vData.fixingUp = false; } -void QDeclarativeFlickablePrivate::updateVelocity() +void QDeclarative1FlickablePrivate::updateVelocity() { - Q_Q(QDeclarativeFlickable); + Q_Q(QDeclarative1Flickable); emit q->horizontalVelocityChanged(); emit q->verticalVelocityChanged(); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h similarity index 92% rename from src/declarative/graphicsitems/qdeclarativeflickable_p.h rename to src/qtquick1/graphicsitems/qdeclarativeflickable_p.h index 90eb00b123..63428840a0 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h @@ -50,9 +50,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeFlickablePrivate; -class QDeclarativeFlickableVisibleArea; -class Q_AUTOTEST_EXPORT QDeclarativeFlickable : public QDeclarativeItem +class QDeclarative1FlickablePrivate; +class QDeclarative1FlickableVisibleArea; +class Q_AUTOTEST_EXPORT QDeclarative1Flickable : public QDeclarativeItem { Q_OBJECT @@ -84,7 +84,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeFlickable : public QDeclarativeItem Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged) Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged) - Q_PROPERTY(QDeclarativeFlickableVisibleArea *visibleArea READ visibleArea CONSTANT) + Q_PROPERTY(QDeclarative1FlickableVisibleArea *visibleArea READ visibleArea CONSTANT) Q_PROPERTY(QDeclarativeListProperty flickableData READ flickableData) Q_PROPERTY(QDeclarativeListProperty flickableChildren READ flickableChildren) @@ -94,8 +94,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeFlickable : public QDeclarativeItem Q_ENUMS(BoundsBehavior) public: - QDeclarativeFlickable(QDeclarativeItem *parent=0); - ~QDeclarativeFlickable(); + QDeclarative1Flickable(QDeclarativeItem *parent=0); + ~QDeclarative1Flickable(); QDeclarativeListProperty flickableData(); QDeclarativeListProperty flickableChildren(); @@ -185,7 +185,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeFlickable : public QDeclarativeItem void wheelEvent(QGraphicsSceneWheelEvent *event); void timerEvent(QTimerEvent *event); - QDeclarativeFlickableVisibleArea *visibleArea(); + QDeclarative1FlickableVisibleArea *visibleArea(); protected Q_SLOTS: virtual void ticked(); @@ -212,17 +212,17 @@ protected Q_SLOTS: void cancelFlick(); protected: - QDeclarativeFlickable(QDeclarativeFlickablePrivate &dd, QDeclarativeItem *parent); + QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent); private: - Q_DISABLE_COPY(QDeclarativeFlickable) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlickable) - friend class QDeclarativeFlickableVisibleArea; + Q_DISABLE_COPY(QDeclarative1Flickable) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flickable) + friend class QDeclarative1FlickableVisibleArea; }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeFlickable) +QML_DECLARE_TYPE(QDeclarative1Flickable) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h similarity index 81% rename from src/declarative/graphicsitems/qdeclarativeflickable_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h index 46b2104384..5bbeb27c9e 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h @@ -58,9 +58,9 @@ #include "private/qdeclarativeitem_p.h" #include "private/qdeclarativeitemchangelistener_p.h" -#include -#include -#include +#include +#include +#include #include @@ -69,30 +69,30 @@ QT_BEGIN_NAMESPACE // Really slow flicks can be annoying. const qreal MinimumFlickVelocity = 75.0; -class QDeclarativeFlickableVisibleArea; -class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener +class QDeclarative1FlickableVisibleArea; +class QDeclarative1FlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener { - Q_DECLARE_PUBLIC(QDeclarativeFlickable) + Q_DECLARE_PUBLIC(QDeclarative1Flickable) public: - QDeclarativeFlickablePrivate(); + QDeclarative1FlickablePrivate(); void init(); - struct Velocity : public QDeclarativeTimeLineValue + struct Velocity : public QDeclarative1TimeLineValue { - Velocity(QDeclarativeFlickablePrivate *p) + Velocity(QDeclarative1FlickablePrivate *p) : parent(p) {} virtual void setValue(qreal v) { if (v != value()) { - QDeclarativeTimeLineValue::setValue(v); + QDeclarative1TimeLineValue::setValue(v); parent->updateVelocity(); } } - QDeclarativeFlickablePrivate *parent; + QDeclarative1FlickablePrivate *parent; }; struct AxisData { - AxisData(QDeclarativeFlickablePrivate *fp, void (QDeclarativeFlickablePrivate::*func)(qreal)) + AxisData(QDeclarative1FlickablePrivate *fp, void (QDeclarative1FlickablePrivate::*func)(qreal)) : move(fp, func), viewSize(-1), smoothVelocity(fp), atEnd(false), atBeginning(true) , fixingUp(false), inOvershoot(false) {} @@ -107,7 +107,7 @@ class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDec void addVelocitySample(qreal v, qreal maxVelocity); void updateVelocity(); - QDeclarativeTimeLineValueProxy move; + QDeclarative1TimeLineValueProxy move; qreal viewSize; qreal pressPos; qreal dragStartOffset; @@ -115,7 +115,7 @@ class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDec qreal dragMaxBound; qreal velocity; qreal flickTarget; - QDeclarativeFlickablePrivate::Velocity smoothVelocity; + QDeclarative1FlickablePrivate::Velocity smoothVelocity; QPODVector velocityBuffer; bool atEnd : 1; bool atBeginning : 1; @@ -126,7 +126,7 @@ class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDec void flickX(qreal velocity); void flickY(qreal velocity); virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity); + QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); void fixupX(); void fixupY(); @@ -151,7 +151,7 @@ class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDec AxisData hData; AxisData vData; - QDeclarativeTimeLine timeline; + QDeclarative1TimeLine timeline; bool flickingHorizontally : 1; bool flickingVertically : 1; bool hMoved : 1; @@ -185,10 +185,10 @@ class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDec void updateVelocity(); int vTime; - QDeclarativeTimeLine velocityTimeline; - QDeclarativeFlickableVisibleArea *visibleArea; - QDeclarativeFlickable::FlickableDirection flickableDirection; - QDeclarativeFlickable::BoundsBehavior boundsBehavior; + QDeclarative1TimeLine velocityTimeline; + QDeclarative1FlickableVisibleArea *visibleArea; + QDeclarative1Flickable::FlickableDirection flickableDirection; + QDeclarative1Flickable::BoundsBehavior boundsBehavior; void handleMousePressEvent(QGraphicsSceneMouseEvent *); void handleMouseMoveEvent(QGraphicsSceneMouseEvent *); @@ -201,7 +201,7 @@ class QDeclarativeFlickablePrivate : public QDeclarativeItemPrivate, public QDec static void data_clear(QDeclarativeListProperty *); }; -class QDeclarativeFlickableVisibleArea : public QObject +class QDeclarative1FlickableVisibleArea : public QObject { Q_OBJECT @@ -211,7 +211,7 @@ class QDeclarativeFlickableVisibleArea : public QObject Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged) public: - QDeclarativeFlickableVisibleArea(QDeclarativeFlickable *parent=0); + QDeclarative1FlickableVisibleArea(QDeclarative1Flickable *parent=0); qreal xPosition() const; qreal widthRatio() const; @@ -227,7 +227,7 @@ class QDeclarativeFlickableVisibleArea : public QObject void heightRatioChanged(qreal heightRatio); private: - QDeclarativeFlickable *flickable; + QDeclarative1Flickable *flickable; qreal m_xPosition; qreal m_widthRatio; qreal m_yPosition; @@ -236,6 +236,6 @@ class QDeclarativeFlickableVisibleArea : public QObject QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeFlickableVisibleArea) +QML_DECLARE_TYPE(QDeclarative1FlickableVisibleArea) #endif diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp similarity index 77% rename from src/declarative/graphicsitems/qdeclarativeflipable.cpp rename to src/qtquick1/graphicsitems/qdeclarativeflipable.cpp index 70fc702bee..d25f33a129 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp @@ -39,27 +39,29 @@ ** ****************************************************************************/ -#include "private/qdeclarativeflipable_p.h" +#include "QtQuick1/private/qdeclarativeflipable_p.h" -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativeguard_p.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" +#include "QtDeclarative/private/qdeclarativeguard_p.h" -#include +#include #include QT_BEGIN_NAMESPACE -class QDeclarativeFlipablePrivate : public QDeclarativeItemPrivate + + +class QDeclarative1FlipablePrivate : public QDeclarativeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeFlipable) + Q_DECLARE_PUBLIC(QDeclarative1Flipable) public: - QDeclarativeFlipablePrivate() : current(QDeclarativeFlipable::Front), front(0), back(0) {} + QDeclarative1FlipablePrivate() : current(QDeclarative1Flipable::Front), front(0), back(0) {} void updateSceneTransformFromParent(); void setBackTransform(); - QDeclarativeFlipable::Side current; + QDeclarative1Flipable::Side current; QDeclarativeGuard front; QDeclarativeGuard back; @@ -68,7 +70,7 @@ class QDeclarativeFlipablePrivate : public QDeclarativeItemPrivate }; /*! - \qmlclass Flipable QDeclarativeFlipable + \qmlclass Flipable QDeclarative1Flipable \since 4.7 \ingroup qml-basic-interaction-elements \brief The Flipable item provides a surface that can be flipped. @@ -109,12 +111,12 @@ class QDeclarativeFlipablePrivate : public QDeclarativeItemPrivate \sa {declarative/ui-components/flipable}{Flipable example} */ -QDeclarativeFlipable::QDeclarativeFlipable(QDeclarativeItem *parent) -: QDeclarativeItem(*(new QDeclarativeFlipablePrivate), parent) +QDeclarative1Flipable::QDeclarative1Flipable(QDeclarativeItem *parent) +: QDeclarativeItem(*(new QDeclarative1FlipablePrivate), parent) { } -QDeclarativeFlipable::~QDeclarativeFlipable() +QDeclarative1Flipable::~QDeclarative1Flipable() { } @@ -125,15 +127,15 @@ QDeclarativeFlipable::~QDeclarativeFlipable() The front and back sides of the flipable. */ -QGraphicsObject *QDeclarativeFlipable::front() +QGraphicsObject *QDeclarative1Flipable::front() { - Q_D(const QDeclarativeFlipable); + Q_D(const QDeclarative1Flipable); return d->front; } -void QDeclarativeFlipable::setFront(QGraphicsObject *front) +void QDeclarative1Flipable::setFront(QGraphicsObject *front) { - Q_D(QDeclarativeFlipable); + Q_D(QDeclarative1Flipable); if (d->front) { qmlInfo(this) << tr("front is a write-once property"); return; @@ -145,15 +147,15 @@ void QDeclarativeFlipable::setFront(QGraphicsObject *front) emit frontChanged(); } -QGraphicsObject *QDeclarativeFlipable::back() +QGraphicsObject *QDeclarative1Flipable::back() { - Q_D(const QDeclarativeFlipable); + Q_D(const QDeclarative1Flipable); return d->back; } -void QDeclarativeFlipable::setBack(QGraphicsObject *back) +void QDeclarative1Flipable::setBack(QGraphicsObject *back) { - Q_D(QDeclarativeFlipable); + Q_D(QDeclarative1Flipable); if (d->back) { qmlInfo(this) << tr("back is a write-once property"); return; @@ -169,10 +171,10 @@ void QDeclarativeFlipable::setBack(QGraphicsObject *back) emit backChanged(); } -void QDeclarativeFlipable::retransformBack() +void QDeclarative1Flipable::retransformBack() { - Q_D(QDeclarativeFlipable); - if (d->current == QDeclarativeFlipable::Back && d->back) + Q_D(QDeclarative1Flipable); + if (d->current == QDeclarative1Flipable::Back && d->back) d->setBackTransform(); } @@ -182,11 +184,11 @@ void QDeclarativeFlipable::retransformBack() The side of the Flipable currently visible. Possible values are \c Flipable.Front and \c Flipable.Back. */ -QDeclarativeFlipable::Side QDeclarativeFlipable::side() const +QDeclarative1Flipable::Side QDeclarative1Flipable::side() const { - Q_D(const QDeclarativeFlipable); + Q_D(const QDeclarative1Flipable); if (d->dirtySceneTransform) - const_cast(d)->ensureSceneTransform(); + const_cast(d)->ensureSceneTransform(); return d->current; } @@ -194,9 +196,9 @@ QDeclarativeFlipable::Side QDeclarativeFlipable::side() const // determination on the currently visible side of the flipable // has to be done on the complete scene transform to give // correct results. -void QDeclarativeFlipablePrivate::updateSceneTransformFromParent() +void QDeclarative1FlipablePrivate::updateSceneTransformFromParent() { - Q_Q(QDeclarativeFlipable); + Q_Q(QDeclarative1Flipable); QDeclarativeItemPrivate::updateSceneTransformFromParent(); QPointF p1(0, 0); @@ -216,21 +218,21 @@ void QDeclarativeFlipablePrivate::updateSceneTransformFromParent() wantBackYFlipped = p1.x() >= p2.x(); wantBackXFlipped = p2.y() >= p3.y(); - QDeclarativeFlipable::Side newSide; + QDeclarative1Flipable::Side newSide; if (cross > 0) { - newSide = QDeclarativeFlipable::Back; + newSide = QDeclarative1Flipable::Back; } else { - newSide = QDeclarativeFlipable::Front; + newSide = QDeclarative1Flipable::Front; } if (newSide != current) { current = newSide; - if (current == QDeclarativeFlipable::Back && back) + if (current == QDeclarative1Flipable::Back && back) setBackTransform(); if (front) - front->setOpacity((current==QDeclarativeFlipable::Front)?1.:0.); + front->setOpacity((current==QDeclarative1Flipable::Front)?1.:0.); if (back) - back->setOpacity((current==QDeclarativeFlipable::Back)?1.:0.); + back->setOpacity((current==QDeclarative1Flipable::Back)?1.:0.); emit q->sideChanged(); } } @@ -238,7 +240,7 @@ void QDeclarativeFlipablePrivate::updateSceneTransformFromParent() /* Depends on the width/height of the back item, and so needs reevaulating if those change. */ -void QDeclarativeFlipablePrivate::setBackTransform() +void QDeclarative1FlipablePrivate::setBackTransform() { QTransform mat; QGraphicsItemPrivate *dBack = QGraphicsItemPrivate::get(back); @@ -251,4 +253,6 @@ void QDeclarativeFlipablePrivate::setBackTransform() back->setTransform(mat); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeflipable_p.h b/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h similarity index 90% rename from src/declarative/graphicsitems/qdeclarativeflipable_p.h rename to src/qtquick1/graphicsitems/qdeclarativeflipable_p.h index c1dbe6f44d..f4cdb86126 100644 --- a/src/declarative/graphicsitems/qdeclarativeflipable_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h @@ -54,8 +54,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeFlipablePrivate; -class Q_AUTOTEST_EXPORT QDeclarativeFlipable : public QDeclarativeItem +class QDeclarative1FlipablePrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Flipable : public QDeclarativeItem { Q_OBJECT @@ -66,8 +66,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeFlipable : public QDeclarativeItem //### flipAxis //### flipRotation public: - QDeclarativeFlipable(QDeclarativeItem *parent=0); - ~QDeclarativeFlipable(); + QDeclarative1Flipable(QDeclarativeItem *parent=0); + ~QDeclarative1Flipable(); QGraphicsObject *front(); void setFront(QGraphicsObject *); @@ -87,13 +87,13 @@ private Q_SLOTS: void retransformBack(); private: - Q_DISABLE_COPY(QDeclarativeFlipable) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlipable) + Q_DISABLE_COPY(QDeclarative1Flipable) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flipable) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeFlipable) +QML_DECLARE_TYPE(QDeclarative1Flipable) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativefocuspanel.cpp b/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp similarity index 88% rename from src/declarative/graphicsitems/qdeclarativefocuspanel.cpp rename to src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp index 7ad0f41182..e50df2ace5 100644 --- a/src/declarative/graphicsitems/qdeclarativefocuspanel.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp @@ -39,17 +39,19 @@ ** ****************************************************************************/ -#include "private/qdeclarativefocuspanel_p.h" +#include "QtQuick1/private/qdeclarativefocuspanel_p.h" -#include "private/qdeclarativeitem_p.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" #include #include QT_BEGIN_NAMESPACE + + /*! - \qmlclass FocusPanel QDeclarativeFocusPanel + \qmlclass FocusPanel QDeclarative1FocusPanel \since 4.7 \ingroup qml-basic-interaction-elements @@ -61,14 +63,14 @@ QT_BEGIN_NAMESPACE \l {qmlfocus}{keyboard focus documentation}. */ -QDeclarativeFocusPanel::QDeclarativeFocusPanel(QDeclarativeItem *parent) : +QDeclarative1FocusPanel::QDeclarative1FocusPanel(QDeclarativeItem *parent) : QDeclarativeItem(parent) { Q_D(QDeclarativeItem); d->flags |= QGraphicsItem::ItemIsPanel; } -QDeclarativeFocusPanel::~QDeclarativeFocusPanel() +QDeclarative1FocusPanel::~QDeclarative1FocusPanel() { } @@ -78,7 +80,7 @@ QDeclarativeFocusPanel::~QDeclarativeFocusPanel() Sets whether the item is the active focus panel. */ -bool QDeclarativeFocusPanel::sceneEvent(QEvent *event) +bool QDeclarative1FocusPanel::sceneEvent(QEvent *event) { if (event->type() == QEvent::WindowActivate || event->type() == QEvent::WindowDeactivate) @@ -86,4 +88,6 @@ bool QDeclarativeFocusPanel::sceneEvent(QEvent *event) return QDeclarativeItem::sceneEvent(event); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h b/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativefocuspanel_p.h rename to src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h index 5965a74259..38eadfdba3 100644 --- a/src/declarative/graphicsitems/qdeclarativefocuspanel_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h @@ -50,13 +50,13 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_AUTOTEST_EXPORT QDeclarativeFocusPanel : public QDeclarativeItem +class Q_AUTOTEST_EXPORT QDeclarative1FocusPanel : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) public: - QDeclarativeFocusPanel(QDeclarativeItem *parent=0); - virtual ~QDeclarativeFocusPanel(); + QDeclarative1FocusPanel(QDeclarativeItem *parent=0); + virtual ~QDeclarative1FocusPanel(); Q_SIGNALS: void activeChanged(); @@ -65,13 +65,13 @@ class Q_AUTOTEST_EXPORT QDeclarativeFocusPanel : public QDeclarativeItem bool sceneEvent(QEvent *event); private: - Q_DISABLE_COPY(QDeclarativeFocusPanel) + Q_DISABLE_COPY(QDeclarative1FocusPanel) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeFocusPanel) +QML_DECLARE_TYPE(QDeclarative1FocusPanel) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativefocusscope.cpp b/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp similarity index 88% rename from src/declarative/graphicsitems/qdeclarativefocusscope.cpp rename to src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp index c9b62b344a..5d942de9bc 100644 --- a/src/declarative/graphicsitems/qdeclarativefocusscope.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp @@ -39,14 +39,16 @@ ** ****************************************************************************/ -#include "private/qdeclarativefocusscope_p.h" +#include "QtQuick1/private/qdeclarativefocusscope_p.h" -#include "private/qdeclarativeitem_p.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" QT_BEGIN_NAMESPACE + + /*! - \qmlclass FocusScope QDeclarativeFocusScope + \qmlclass FocusScope QDeclarative1FocusScope \since 4.7 \ingroup qml-basic-interaction-elements @@ -60,14 +62,16 @@ QT_BEGIN_NAMESPACE \sa {declarative/keyinteraction/focus}{Keyboard focus example} */ -QDeclarativeFocusScope::QDeclarativeFocusScope(QDeclarativeItem *parent) : +QDeclarative1FocusScope::QDeclarative1FocusScope(QDeclarativeItem *parent) : QDeclarativeItem(parent) { Q_D(QDeclarativeItem); d->flags |= QGraphicsItem::ItemIsFocusScope; } -QDeclarativeFocusScope::~QDeclarativeFocusScope() +QDeclarative1FocusScope::~QDeclarative1FocusScope() { } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativefocusscope_p.h b/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h similarity index 90% rename from src/declarative/graphicsitems/qdeclarativefocusscope_p.h rename to src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h index 9b515e6571..ee31d94347 100644 --- a/src/declarative/graphicsitems/qdeclarativefocusscope_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h @@ -51,18 +51,18 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) //### set component root as focusscope -class Q_AUTOTEST_EXPORT QDeclarativeFocusScope : public QDeclarativeItem +class Q_AUTOTEST_EXPORT QDeclarative1FocusScope : public QDeclarativeItem { Q_OBJECT Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) public: - QDeclarativeFocusScope(QDeclarativeItem *parent=0); - virtual ~QDeclarativeFocusScope(); + QDeclarative1FocusScope(QDeclarativeItem *parent=0); + virtual ~QDeclarative1FocusScope(); }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeFocusScope) +QML_DECLARE_TYPE(QDeclarative1FocusScope) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativegraphicswidget.cpp b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp similarity index 60% rename from src/declarative/graphicsitems/qdeclarativegraphicswidget.cpp rename to src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp index cb9a6d9587..8ccf23221a 100644 --- a/src/declarative/graphicsitems/qdeclarativegraphicswidget.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp @@ -39,87 +39,91 @@ ** ****************************************************************************/ -#include "qdeclarativegraphicswidget_p.h" -#include "private/qdeclarativeanchors_p.h" -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativeanchors_p_p.h" +#include "QtQuick1/private/qdeclarativegraphicswidget_p.h" +#include "QtQuick1/private/qdeclarativeanchors_p.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" +#include "QtQuick1/private/qdeclarativeanchors_p_p.h" QT_BEGIN_NAMESPACE -class QDeclarativeGraphicsWidgetPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QDeclarativeGraphicsWidget) + + +class QDeclarative1GraphicsWidgetPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QDeclarative1GraphicsWidget) public : - QDeclarativeGraphicsWidgetPrivate() : + QDeclarative1GraphicsWidgetPrivate() : _anchors(0), _anchorLines(0) {} QDeclarativeItemPrivate::AnchorLines *anchorLines() const; - QDeclarativeAnchors *_anchors; + QDeclarative1Anchors *_anchors; mutable QDeclarativeItemPrivate::AnchorLines *_anchorLines; }; -QDeclarativeGraphicsWidget::QDeclarativeGraphicsWidget(QObject *parent) : - QObject(*new QDeclarativeGraphicsWidgetPrivate, parent) +QDeclarative1GraphicsWidget::QDeclarative1GraphicsWidget(QObject *parent) : + QObject(*new QDeclarative1GraphicsWidgetPrivate, parent) { } -QDeclarativeGraphicsWidget::~QDeclarativeGraphicsWidget() +QDeclarative1GraphicsWidget::~QDeclarative1GraphicsWidget() { - Q_D(QDeclarativeGraphicsWidget); + Q_D(QDeclarative1GraphicsWidget); delete d->_anchorLines; d->_anchorLines = 0; delete d->_anchors; d->_anchors = 0; } -QDeclarativeAnchors *QDeclarativeGraphicsWidget::anchors() +QDeclarative1Anchors *QDeclarative1GraphicsWidget::anchors() { - Q_D(QDeclarativeGraphicsWidget); + Q_D(QDeclarative1GraphicsWidget); if (!d->_anchors) - d->_anchors = new QDeclarativeAnchors(static_cast(parent())); + d->_anchors = new QDeclarative1Anchors(static_cast(parent())); return d->_anchors; } -QDeclarativeItemPrivate::AnchorLines *QDeclarativeGraphicsWidgetPrivate::anchorLines() const +QDeclarativeItemPrivate::AnchorLines *QDeclarative1GraphicsWidgetPrivate::anchorLines() const { - Q_Q(const QDeclarativeGraphicsWidget); + Q_Q(const QDeclarative1GraphicsWidget); if (!_anchorLines) _anchorLines = new QDeclarativeItemPrivate::AnchorLines(static_cast(q->parent())); return _anchorLines; } -QDeclarativeAnchorLine QDeclarativeGraphicsWidget::left() const +QDeclarative1AnchorLine QDeclarative1GraphicsWidget::left() const { - Q_D(const QDeclarativeGraphicsWidget); + Q_D(const QDeclarative1GraphicsWidget); return d->anchorLines()->left; } -QDeclarativeAnchorLine QDeclarativeGraphicsWidget::right() const +QDeclarative1AnchorLine QDeclarative1GraphicsWidget::right() const { - Q_D(const QDeclarativeGraphicsWidget); + Q_D(const QDeclarative1GraphicsWidget); return d->anchorLines()->right; } -QDeclarativeAnchorLine QDeclarativeGraphicsWidget::horizontalCenter() const +QDeclarative1AnchorLine QDeclarative1GraphicsWidget::horizontalCenter() const { - Q_D(const QDeclarativeGraphicsWidget); + Q_D(const QDeclarative1GraphicsWidget); return d->anchorLines()->hCenter; } -QDeclarativeAnchorLine QDeclarativeGraphicsWidget::top() const +QDeclarative1AnchorLine QDeclarative1GraphicsWidget::top() const { - Q_D(const QDeclarativeGraphicsWidget); + Q_D(const QDeclarative1GraphicsWidget); return d->anchorLines()->top; } -QDeclarativeAnchorLine QDeclarativeGraphicsWidget::bottom() const +QDeclarative1AnchorLine QDeclarative1GraphicsWidget::bottom() const { - Q_D(const QDeclarativeGraphicsWidget); + Q_D(const QDeclarative1GraphicsWidget); return d->anchorLines()->bottom; } -QDeclarativeAnchorLine QDeclarativeGraphicsWidget::verticalCenter() const +QDeclarative1AnchorLine QDeclarative1GraphicsWidget::verticalCenter() const { - Q_D(const QDeclarativeGraphicsWidget); + Q_D(const QDeclarative1GraphicsWidget); return d->anchorLines()->vCenter; } + + QT_END_NAMESPACE #include diff --git a/src/declarative/graphicsitems/qdeclarativegraphicswidget_p.h b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h similarity index 63% rename from src/declarative/graphicsitems/qdeclarativegraphicswidget_p.h rename to src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h index 5b0cdb4812..2e433d78aa 100644 --- a/src/declarative/graphicsitems/qdeclarativegraphicswidget_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h @@ -51,36 +51,36 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeAnchorLine; -class QDeclarativeAnchors; class QGraphicsObject; -class QDeclarativeGraphicsWidgetPrivate; +class QDeclarative1AnchorLine; +class QDeclarative1Anchors; +class QDeclarative1GraphicsWidgetPrivate; // ### TODO can the extension object be the anchor directly? We save one allocation -> awesome. -class QDeclarativeGraphicsWidget : public QObject +class QDeclarative1GraphicsWidget : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine left READ left CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine right READ right CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine top READ top CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine bottom READ bottom CONSTANT FINAL) - Q_PROPERTY(QDeclarativeAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) + Q_PROPERTY(QDeclarative1Anchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) + Q_PROPERTY(QDeclarative1AnchorLine left READ left CONSTANT FINAL) + Q_PROPERTY(QDeclarative1AnchorLine right READ right CONSTANT FINAL) + Q_PROPERTY(QDeclarative1AnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) + Q_PROPERTY(QDeclarative1AnchorLine top READ top CONSTANT FINAL) + Q_PROPERTY(QDeclarative1AnchorLine bottom READ bottom CONSTANT FINAL) + Q_PROPERTY(QDeclarative1AnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) // ### TODO : QGraphicsWidget don't have a baseline concept yet. - //Q_PROPERTY(QDeclarativeAnchorLine baseline READ baseline CONSTANT FINAL) + //Q_PROPERTY(QDeclarative1AnchorLine baseline READ baseline CONSTANT FINAL) public: - QDeclarativeGraphicsWidget(QObject *parent = 0); - ~QDeclarativeGraphicsWidget(); - QDeclarativeAnchors *anchors(); - QDeclarativeAnchorLine left() const; - QDeclarativeAnchorLine right() const; - QDeclarativeAnchorLine horizontalCenter() const; - QDeclarativeAnchorLine top() const; - QDeclarativeAnchorLine bottom() const; - QDeclarativeAnchorLine verticalCenter() const; - Q_DISABLE_COPY(QDeclarativeGraphicsWidget) - Q_DECLARE_PRIVATE(QDeclarativeGraphicsWidget) + QDeclarative1GraphicsWidget(QObject *parent = 0); + ~QDeclarative1GraphicsWidget(); + QDeclarative1Anchors *anchors(); + QDeclarative1AnchorLine left() const; + QDeclarative1AnchorLine right() const; + QDeclarative1AnchorLine horizontalCenter() const; + QDeclarative1AnchorLine top() const; + QDeclarative1AnchorLine bottom() const; + QDeclarative1AnchorLine verticalCenter() const; + Q_DISABLE_COPY(QDeclarative1GraphicsWidget) + Q_DECLARE_PRIVATE(QDeclarative1GraphicsWidget) }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/qtquick1/graphicsitems/qdeclarativegridview.cpp similarity index 81% rename from src/declarative/graphicsitems/qdeclarativegridview.cpp rename to src/qtquick1/graphicsitems/qdeclarativegridview.cpp index aee91e1135..228cd2aba1 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativegridview.cpp @@ -39,15 +39,14 @@ ** ****************************************************************************/ -#include "private/qdeclarativegridview_p.h" +#include "QtQuick1/private/qdeclarativegridview_p.h" -#include "private/qdeclarativevisualitemmodel_p.h" -#include "private/qdeclarativeflickable_p_p.h" +#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" +#include "QtQuick1/private/qdeclarativeflickable_p_p.h" -#include "private/qdeclarativesmoothedanimation_p_p.h" -#include +#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h" +#include -#include #include #include @@ -56,21 +55,23 @@ QT_BEGIN_NAMESPACE + + //---------------------------------------------------------------------------- -class FxGridItem +class FxGridItem1 { public: - FxGridItem(QDeclarativeItem *i, QDeclarativeGridView *v) : item(i), view(v) { - attached = static_cast(qmlAttachedPropertiesObject(item)); + FxGridItem1(QDeclarativeItem *i, QDeclarative1GridView *v) : item(i), view(v) { + attached = static_cast(qmlAttachedPropertiesObject(item)); if (attached) attached->setView(view); } - ~FxGridItem() {} + ~FxGridItem1() {} qreal rowPos() const { qreal rowPos = 0; - if (view->flow() == QDeclarativeGridView::LeftToRight) { + if (view->flow() == QDeclarative1GridView::LeftToRight) { rowPos = item->y(); } else { if (view->effectiveLayoutDirection() == Qt::RightToLeft) @@ -82,7 +83,7 @@ class FxGridItem } qreal colPos() const { qreal colPos = 0; - if (view->flow() == QDeclarativeGridView::LeftToRight) { + if (view->flow() == QDeclarative1GridView::LeftToRight) { if (view->effectiveLayoutDirection() == Qt::RightToLeft) { int colSize = view->cellWidth(); int columns = view->width()/colSize; @@ -98,7 +99,7 @@ class FxGridItem } qreal endRowPos() const { - if (view->flow() == QDeclarativeGridView::LeftToRight) { + if (view->flow() == QDeclarative1GridView::LeftToRight) { return item->y() + view->cellHeight() - 1; } else { if (view->effectiveLayoutDirection() == Qt::RightToLeft) @@ -109,14 +110,14 @@ class FxGridItem } void setPosition(qreal col, qreal row) { if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - if (view->flow() == QDeclarativeGridView::LeftToRight) { + if (view->flow() == QDeclarative1GridView::LeftToRight) { int columns = view->width()/view->cellWidth(); item->setPos(QPointF((view->cellWidth() * (columns-1) - col), row)); } else { item->setPos(QPointF(-view->cellWidth()-row, col)); } } else { - if (view->flow() == QDeclarativeGridView::LeftToRight) + if (view->flow() == QDeclarative1GridView::LeftToRight) item->setPos(QPointF(col, row)); else item->setPos(QPointF(row, col)); @@ -129,38 +130,38 @@ class FxGridItem } QDeclarativeItem *item; - QDeclarativeGridView *view; - QDeclarativeGridViewAttached *attached; + QDeclarative1GridView *view; + QDeclarative1GridViewAttached *attached; int index; }; //---------------------------------------------------------------------------- -class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate +class QDeclarative1GridViewPrivate : public QDeclarative1FlickablePrivate { - Q_DECLARE_PUBLIC(QDeclarativeGridView) + Q_DECLARE_PUBLIC(QDeclarative1GridView) public: - QDeclarativeGridViewPrivate() - : currentItem(0), layoutDirection(Qt::LeftToRight), flow(QDeclarativeGridView::LeftToRight) + QDeclarative1GridViewPrivate() + : currentItem(0), layoutDirection(Qt::LeftToRight), flow(QDeclarative1GridView::LeftToRight) , visibleIndex(0) , currentIndex(-1) , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1), itemCount(0) , highlightRangeStart(0), highlightRangeEnd(0) , highlightRangeStartValid(false), highlightRangeEndValid(false) - , highlightRange(QDeclarativeGridView::NoHighlightRange) + , highlightRange(QDeclarative1GridView::NoHighlightRange) , highlightComponent(0), highlight(0), trackedItem(0) , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0) , highlightMoveDuration(150) , footerComponent(0), footer(0), headerComponent(0), header(0) - , bufferMode(BufferBefore | BufferAfter), snapMode(QDeclarativeGridView::NoSnap) + , bufferMode(BufferBefore | BufferAfter), snapMode(QDeclarative1GridView::NoSnap) , ownModel(false), wrap(false), autoHighlight(true) , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) , deferredRelease(false), haveHighlightRange(false), currentIndexCleared(false) {} void init(); void clear(); - FxGridItem *createItem(int modelIndex); - void releaseItem(FxGridItem *item); + FxGridItem1 *createItem(int modelIndex); + void releaseItem(FxGridItem1 *item); void refill(qreal from, qreal to, bool doBuffer=false); void updateGrid(); @@ -176,10 +177,10 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate void updateFooter(); void fixupPosition(); - FxGridItem *visibleItem(int modelIndex) const { + FxGridItem1 *visibleItem(int modelIndex) const { if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) { for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) { - FxGridItem *item = visibleItems.at(i); + FxGridItem1 *item = visibleItems.at(i); if (item->index == modelIndex) return item; } @@ -188,12 +189,12 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate } bool isRightToLeftTopToBottom() const { - Q_Q(const QDeclarativeGridView); - return flow == QDeclarativeGridView::TopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft; + Q_Q(const QDeclarative1GridView); + return flow == QDeclarative1GridView::TopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft; } void regenerate() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (q->isComponentComplete()) { clear(); updateGrid(); @@ -204,31 +205,31 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate } void mirrorChange() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); regenerate(); emit q->effectiveLayoutDirectionChanged(); } qreal position() const { - Q_Q(const QDeclarativeGridView); - return flow == QDeclarativeGridView::LeftToRight ? q->contentY() : q->contentX(); + Q_Q(const QDeclarative1GridView); + return flow == QDeclarative1GridView::LeftToRight ? q->contentY() : q->contentX(); } void setPosition(qreal pos) { - Q_Q(QDeclarativeGridView); - if (flow == QDeclarativeGridView::LeftToRight) { - q->QDeclarativeFlickable::setContentY(pos); - q->QDeclarativeFlickable::setContentX(0); + Q_Q(QDeclarative1GridView); + if (flow == QDeclarative1GridView::LeftToRight) { + q->QDeclarative1Flickable::setContentY(pos); + q->QDeclarative1Flickable::setContentX(0); } else { if (q->effectiveLayoutDirection() == Qt::LeftToRight) - q->QDeclarativeFlickable::setContentX(pos); + q->QDeclarative1Flickable::setContentX(pos); else - q->QDeclarativeFlickable::setContentX(-pos-size()); - q->QDeclarativeFlickable::setContentY(0); + q->QDeclarative1Flickable::setContentX(-pos-size()); + q->QDeclarative1Flickable::setContentY(0); } } int size() const { - Q_Q(const QDeclarativeGridView); - return flow == QDeclarativeGridView::LeftToRight ? q->height() : q->width(); + Q_Q(const QDeclarative1GridView); + return flow == QDeclarative1GridView::LeftToRight ? q->height() : q->width(); } qreal originPosition() const { qreal pos = 0; @@ -258,14 +259,14 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate } int rowSize() const { - return flow == QDeclarativeGridView::LeftToRight ? cellHeight : cellWidth; + return flow == QDeclarative1GridView::LeftToRight ? cellHeight : cellWidth; } int colSize() const { - return flow == QDeclarativeGridView::LeftToRight ? cellWidth : cellHeight; + return flow == QDeclarative1GridView::LeftToRight ? cellWidth : cellHeight; } qreal colPosAt(int modelIndex) const { - if (FxGridItem *item = visibleItem(modelIndex)) + if (FxGridItem1 *item = visibleItem(modelIndex)) return item->colPos(); if (!visibleItems.isEmpty()) { if (modelIndex < visibleIndex) { @@ -283,7 +284,7 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate return 0; } qreal rowPosAt(int modelIndex) const { - if (FxGridItem *item = visibleItem(modelIndex)) + if (FxGridItem1 *item = visibleItem(modelIndex)) return item->rowPos(); if (!visibleItems.isEmpty()) { if (modelIndex < visibleIndex) { @@ -306,10 +307,10 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate return 0; } - FxGridItem *firstVisibleItem() const { + FxGridItem1 *firstVisibleItem() const { const qreal pos = isRightToLeftTopToBottom() ? -position()-size() : position(); for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem *item = visibleItems.at(i); + FxGridItem1 *item = visibleItems.at(i); if (item->index != -1 && item->endRowPos() > pos) return item; } @@ -318,7 +319,7 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate int lastVisibleIndex() const { for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem *item = visibleItems.at(i); + FxGridItem1 *item = visibleItems.at(i); if (item->index != -1) return item->index; } @@ -332,7 +333,7 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count()) return -1; for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem *listItem = visibleItems.at(i); + FxGridItem1 *listItem = visibleItems.at(i); if (listItem->index == modelIndex) return i + visibleIndex; if (listItem->index > modelIndex) @@ -342,7 +343,7 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate } qreal snapPosAt(qreal pos) const { - Q_Q(const QDeclarativeGridView); + Q_Q(const QDeclarative1GridView); qreal snapPos = 0; if (!visibleItems.isEmpty()) { pos += rowSize()/2; @@ -354,8 +355,8 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate maxExtent = q->minXExtent(); minExtent = q->maxXExtent(); } else { - maxExtent = flow == QDeclarativeGridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent(); - minExtent = flow == QDeclarativeGridView::LeftToRight ? -q->minYExtent() : -q->minXExtent(); + maxExtent = flow == QDeclarative1GridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent(); + minExtent = flow == QDeclarative1GridView::LeftToRight ? -q->minYExtent() : -q->minXExtent(); } if (snapPos > maxExtent) snapPos = maxExtent; @@ -365,9 +366,9 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate return snapPos; } - FxGridItem *snapItemAt(qreal pos) { + FxGridItem1 *snapItemAt(qreal pos) { for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem *item = visibleItems[i]; + FxGridItem1 *item = visibleItems[i]; if (item->index == -1) continue; qreal itemTop = item->rowPos(); @@ -380,7 +381,7 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate int snapIndex() { int index = currentIndex; for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem *item = visibleItems[i]; + FxGridItem1 *item = visibleItems[i]; if (item->index == -1) continue; qreal itemTop = item->rowPos(); @@ -397,15 +398,15 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate if (!header) return 0.0; - return flow == QDeclarativeGridView::LeftToRight + return flow == QDeclarative1GridView::LeftToRight ? header->item->height() : header->item->width(); } virtual void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_Q(const QDeclarativeGridView); - QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); + Q_Q(const QDeclarative1GridView); + QDeclarative1FlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); if (item == q) { if (newGeometry.height() != oldGeometry.height() || newGeometry.width() != oldGeometry.width()) { @@ -425,13 +426,13 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate void positionViewAtIndex(int index, int mode); virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity); + QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); // for debugging only void checkVisible() const { int skip = 0; for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem *listItem = visibleItems.at(i); + FxGridItem1 *listItem = visibleItems.at(i); if (listItem->index == -1) { ++skip; } else if (listItem->index != visibleIndex + i - skip) { @@ -442,13 +443,13 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate } } - QDeclarativeGuard model; + QDeclarativeGuard model; QVariant modelVariant; - QList visibleItems; + QList visibleItems; QHash unrequestedItems; - FxGridItem *currentItem; + FxGridItem1 *currentItem; Qt::LayoutDirection layoutDirection; - QDeclarativeGridView::Flow flow; + QDeclarative1GridView::Flow flow; int visibleIndex; int currentIndex; int cellWidth; @@ -460,23 +461,23 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate qreal highlightRangeEnd; bool highlightRangeStartValid; bool highlightRangeEndValid; - QDeclarativeGridView::HighlightRangeMode highlightRange; + QDeclarative1GridView::HighlightRangeMode highlightRange; QDeclarativeComponent *highlightComponent; - FxGridItem *highlight; - FxGridItem *trackedItem; + FxGridItem1 *highlight; + FxGridItem1 *trackedItem; enum MovementReason { Other, SetIndex, Mouse }; MovementReason moveReason; int buffer; - QSmoothedAnimation *highlightXAnimator; - QSmoothedAnimation *highlightYAnimator; + QSmoothedAnimation_1 *highlightXAnimator; + QSmoothedAnimation_1 *highlightYAnimator; int highlightMoveDuration; QDeclarativeComponent *footerComponent; - FxGridItem *footer; + FxGridItem1 *footer; QDeclarativeComponent *headerComponent; - FxGridItem *header; + FxGridItem1 *header; enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }; int bufferMode; - QDeclarativeGridView::SnapMode snapMode; + QDeclarative1GridView::SnapMode snapMode; bool ownModel : 1; bool wrap : 1; @@ -489,16 +490,16 @@ class QDeclarativeGridViewPrivate : public QDeclarativeFlickablePrivate bool currentIndexCleared : 1; }; -void QDeclarativeGridViewPrivate::init() +void QDeclarative1GridViewPrivate::init() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); q->setFlag(QGraphicsItem::ItemIsFocusScope); - q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick); + q->setFlickableDirection(QDeclarative1Flickable::VerticalFlick); addItemChangeListener(this, Geometry); } -void QDeclarativeGridViewPrivate::clear() +void QDeclarative1GridViewPrivate::clear() { for (int i = 0; i < visibleItems.count(); ++i) releaseItem(visibleItems.at(i)); @@ -511,14 +512,14 @@ void QDeclarativeGridViewPrivate::clear() itemCount = 0; } -FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex) +FxGridItem1 *QDeclarative1GridViewPrivate::createItem(int modelIndex) { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); // create object requestedIndex = modelIndex; - FxGridItem *listItem = 0; + FxGridItem1 *listItem = 0; if (QDeclarativeItem *item = model->item(modelIndex, false)) { - listItem = new FxGridItem(item, q); + listItem = new FxGridItem1(item, q); listItem->index = modelIndex; if (model->completePending()) { // complete @@ -535,9 +536,9 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex) } -void QDeclarativeGridViewPrivate::releaseItem(FxGridItem *item) +void QDeclarative1GridViewPrivate::releaseItem(FxGridItem1 *item) { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (!item || !model) return; if (trackedItem == item) { @@ -552,9 +553,9 @@ void QDeclarativeGridViewPrivate::releaseItem(FxGridItem *item) delete item; } -void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) +void QDeclarative1GridViewPrivate::refill(qreal from, qreal to, bool doBuffer) { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (!isValid() || !q->isComponentComplete()) return; itemCount = model->count(); @@ -606,7 +607,7 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) int colNum = colPos / colSize(); - FxGridItem *item = 0; + FxGridItem1 *item = 0; // Item creation and release is staggered in order to avoid // creating/releasing multiple items in one frame @@ -690,7 +691,7 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) updateHeader(); if (footer) updateFooter(); - if (flow == QDeclarativeGridView::LeftToRight) + if (flow == QDeclarative1GridView::LeftToRight) q->setContentHeight(endPosition() - startPosition()); else q->setContentWidth(endPosition() - startPosition()); @@ -700,31 +701,31 @@ void QDeclarativeGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) lazyRelease = false; } -void QDeclarativeGridViewPrivate::updateGrid() +void QDeclarative1GridViewPrivate::updateGrid() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); - columns = (int)qMax((flow == QDeclarativeGridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.)); + columns = (int)qMax((flow == QDeclarative1GridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.)); if (isValid()) { - if (flow == QDeclarativeGridView::LeftToRight) + if (flow == QDeclarative1GridView::LeftToRight) q->setContentHeight(endPosition() - startPosition()); else q->setContentWidth(lastPosition() - originPosition()); } } -void QDeclarativeGridViewPrivate::scheduleLayout() +void QDeclarative1GridViewPrivate::scheduleLayout() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (!layoutScheduled) { layoutScheduled = true; QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority); } } -void QDeclarativeGridViewPrivate::layout() +void QDeclarative1GridViewPrivate::layout() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); layoutScheduled = false; if (!isValid() && !visibleItems.count()) { clear(); @@ -739,7 +740,7 @@ void QDeclarativeGridViewPrivate::layout() visibleItems.first()->setPosition(colPos, rowPos); } for (int i = 1; i < visibleItems.count(); ++i) { - FxGridItem *item = visibleItems.at(i); + FxGridItem1 *item = visibleItems.at(i); colPos += colSize(); if (colPos > colSize() * (columns-1)) { colPos = 0; @@ -755,7 +756,7 @@ void QDeclarativeGridViewPrivate::layout() q->refill(); updateHighlight(); moveReason = Other; - if (flow == QDeclarativeGridView::LeftToRight) { + if (flow == QDeclarative1GridView::LeftToRight) { q->setContentHeight(endPosition() - startPosition()); fixupY(); } else { @@ -765,20 +766,20 @@ void QDeclarativeGridViewPrivate::layout() updateUnrequestedPositions(); } -void QDeclarativeGridViewPrivate::updateUnrequestedIndexes() +void QDeclarative1GridViewPrivate::updateUnrequestedIndexes() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); QHash::iterator it; for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) *it = model->indexOf(it.key(), q); } -void QDeclarativeGridViewPrivate::updateUnrequestedPositions() +void QDeclarative1GridViewPrivate::updateUnrequestedPositions() { QHash::const_iterator it; for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { QDeclarativeItem *item = it.key(); - if (flow == QDeclarativeGridView::LeftToRight) { + if (flow == QDeclarative1GridView::LeftToRight) { item->setPos(QPointF(colPosAt(*it), rowPosAt(*it))); } else { if (isRightToLeftTopToBottom()) @@ -789,10 +790,10 @@ void QDeclarativeGridViewPrivate::updateUnrequestedPositions() } } -void QDeclarativeGridViewPrivate::updateTrackedItem() +void QDeclarative1GridViewPrivate::updateTrackedItem() { - Q_Q(QDeclarativeGridView); - FxGridItem *item = currentItem; + Q_Q(QDeclarative1GridView); + FxGridItem1 *item = currentItem; if (highlight) item = highlight; @@ -811,9 +812,9 @@ void QDeclarativeGridViewPrivate::updateTrackedItem() q->trackedPositionChanged(); } -void QDeclarativeGridViewPrivate::createHighlight() +void QDeclarative1GridViewPrivate::createHighlight() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); bool changed = false; if (highlight) { if (trackedItem == highlight) @@ -851,13 +852,13 @@ void QDeclarativeGridViewPrivate::createHighlight() if (item) { QDeclarative_setParent_noEvent(item, q->contentItem()); item->setParentItem(q->contentItem()); - highlight = new FxGridItem(item, q); + highlight = new FxGridItem1(item, q); if (currentItem && autoHighlight) highlight->setPosition(currentItem->colPos(), currentItem->rowPos()); - highlightXAnimator = new QSmoothedAnimation(q); + highlightXAnimator = new QSmoothedAnimation_1(q); highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x")); highlightXAnimator->userDuration = highlightMoveDuration; - highlightYAnimator = new QSmoothedAnimation(q); + highlightYAnimator = new QSmoothedAnimation_1(q); highlightYAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("y")); highlightYAnimator->userDuration = highlightMoveDuration; if (autoHighlight) { @@ -871,7 +872,7 @@ void QDeclarativeGridViewPrivate::createHighlight() emit q->highlightItemChanged(); } -void QDeclarativeGridViewPrivate::updateHighlight() +void QDeclarative1GridViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); @@ -887,9 +888,9 @@ void QDeclarativeGridViewPrivate::updateHighlight() updateTrackedItem(); } -void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) +void QDeclarative1GridViewPrivate::updateCurrent(int modelIndex) { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) { if (currentItem) { currentItem->attached->setIsCurrentItem(false); @@ -910,7 +911,7 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) return; } - FxGridItem *oldCurrentItem = currentItem; + FxGridItem1 *oldCurrentItem = currentItem; currentIndex = modelIndex; currentItem = createItem(modelIndex); fixCurrentVisibility = true; @@ -926,9 +927,9 @@ void QDeclarativeGridViewPrivate::updateCurrent(int modelIndex) releaseItem(oldCurrentItem); } -void QDeclarativeGridViewPrivate::updateFooter() +void QDeclarative1GridViewPrivate::updateFooter() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (!footer && footerComponent) { QDeclarativeItem *item = 0; QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); @@ -947,7 +948,7 @@ void QDeclarativeGridViewPrivate::updateFooter() item->setZValue(1); QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - footer = new FxGridItem(item, q); + footer = new FxGridItem1(item, q); } } if (footer) { @@ -972,16 +973,16 @@ void QDeclarativeGridViewPrivate::updateFooter() } else { qreal endPos = 0; if (header) { - endPos += flow == QDeclarativeGridView::LeftToRight ? header->item->height() : header->item->width(); + endPos += flow == QDeclarative1GridView::LeftToRight ? header->item->height() : header->item->width(); } footer->setPosition(colOffset, endPos); } } } -void QDeclarativeGridViewPrivate::updateHeader() +void QDeclarative1GridViewPrivate::updateHeader() { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (!header && headerComponent) { QDeclarativeItem *item = 0; QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); @@ -1000,7 +1001,7 @@ void QDeclarativeGridViewPrivate::updateHeader() item->setZValue(1); QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - header = new FxGridItem(item, q); + header = new FxGridItem1(item, q); } } if (header) { @@ -1029,19 +1030,19 @@ void QDeclarativeGridViewPrivate::updateHeader() } } -void QDeclarativeGridViewPrivate::fixupPosition() +void QDeclarative1GridViewPrivate::fixupPosition() { moveReason = Other; - if (flow == QDeclarativeGridView::LeftToRight) + if (flow == QDeclarative1GridView::LeftToRight) fixupY(); else fixupX(); } -void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) +void QDeclarative1GridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) { - if ((flow == QDeclarativeGridView::TopToBottom && &data == &vData) - || (flow == QDeclarativeGridView::LeftToRight && &data == &hData)) + if ((flow == QDeclarative1GridView::TopToBottom && &data == &vData) + || (flow == QDeclarative1GridView::LeftToRight && &data == &hData)) return; fixupMode = moveReason == Mouse ? fixupMode : Immediate; @@ -1060,12 +1061,12 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m highlightEnd = highlightRangeEnd; } - if (snapMode != QDeclarativeGridView::NoSnap) { + if (snapMode != QDeclarative1GridView::NoSnap) { qreal tempPosition = isRightToLeftTopToBottom() ? -position()-size() : position(); - FxGridItem *topItem = snapItemAt(tempPosition+highlightStart); - FxGridItem *bottomItem = snapItemAt(tempPosition+highlightEnd); + FxGridItem1 *topItem = snapItemAt(tempPosition+highlightStart); + FxGridItem1 *bottomItem = snapItemAt(tempPosition+highlightEnd); qreal pos; - if (topItem && bottomItem && haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { + if (topItem && bottomItem && haveHighlightRange && highlightRange == QDeclarative1GridView::StrictlyEnforceRange) { qreal topPos = qMin(topItem->rowPos() - highlightStart, -maxExtent); qreal bottomPos = qMax(bottomItem->rowPos() - highlightEnd, -minExtent); pos = qAbs(data.move + topPos) < qAbs(data.move + bottomPos) ? topPos : bottomPos; @@ -1087,10 +1088,10 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m else pos = qMax(qMin(bottomItem->rowPos() - highlightStart, -maxExtent), -minExtent); } else { - QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); + QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); return; } - if (currentItem && haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { + if (currentItem && haveHighlightRange && highlightRange == QDeclarative1GridView::StrictlyEnforceRange) { updateHighlight(); qreal currPos = currentItem->rowPos(); if (isRightToLeftTopToBottom()) @@ -1113,7 +1114,7 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } vTime = timeline.time(); } - } else if (haveHighlightRange && highlightRange == QDeclarativeGridView::StrictlyEnforceRange) { + } else if (haveHighlightRange && highlightRange == QDeclarative1GridView::StrictlyEnforceRange) { if (currentItem) { updateHighlight(); qreal pos = currentItem->rowPos(); @@ -1135,21 +1136,21 @@ void QDeclarativeGridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m vTime = timeline.time(); } } else { - QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); + QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); } data.inOvershoot = false; fixupMode = Normal; } -void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity) +void QDeclarative1GridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, + QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); data.fixingUp = false; moveReason = Mouse; - if ((!haveHighlightRange || highlightRange != QDeclarativeGridView::StrictlyEnforceRange) - && snapMode == QDeclarativeGridView::NoSnap) { - QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); + if ((!haveHighlightRange || highlightRange != QDeclarative1GridView::StrictlyEnforceRange) + && snapMode == QDeclarative1GridView::NoSnap) { + QDeclarative1FlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); return; } qreal maxDistance = 0; @@ -1157,30 +1158,30 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m // -ve velocity means list is moving up/left if (velocity > 0) { if (data.move.value() < minExtent) { - if (snapMode == QDeclarativeGridView::SnapOneRow) { - if (FxGridItem *item = firstVisibleItem()) { + if (snapMode == QDeclarative1GridView::SnapOneRow) { + if (FxGridItem1 *item = firstVisibleItem()) { maxDistance = qAbs(item->rowPos() + dataValue); } } else { maxDistance = qAbs(minExtent - data.move.value()); } } - if (snapMode == QDeclarativeGridView::NoSnap && highlightRange != QDeclarativeGridView::StrictlyEnforceRange) + if (snapMode == QDeclarative1GridView::NoSnap && highlightRange != QDeclarative1GridView::StrictlyEnforceRange) data.flickTarget = minExtent; } else { if (data.move.value() > maxExtent) { - if (snapMode == QDeclarativeGridView::SnapOneRow) { + if (snapMode == QDeclarative1GridView::SnapOneRow) { qreal pos = snapPosAt(-dataValue) + (isRightToLeftTopToBottom() ? 0 : rowSize()); maxDistance = qAbs(pos + dataValue); } else { maxDistance = qAbs(maxExtent - data.move.value()); } } - if (snapMode == QDeclarativeGridView::NoSnap && highlightRange != QDeclarativeGridView::StrictlyEnforceRange) + if (snapMode == QDeclarative1GridView::NoSnap && highlightRange != QDeclarative1GridView::StrictlyEnforceRange) data.flickTarget = maxExtent; } - bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds; + bool overShoot = boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds; qreal highlightStart = isRightToLeftTopToBottom() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; if (maxDistance > 0 || overShoot) { @@ -1195,7 +1196,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m qreal accel = deceleration; qreal v2 = v * v; qreal overshootDist = 0.0; - if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarativeGridView::SnapOneRow) { + if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarative1GridView::SnapOneRow) { // + rowSize()/4 to encourage moving at least one item in the flick direction qreal dist = v2 / (accel * 2.0) + rowSize()/4; dist = qMin(dist, maxDistance); @@ -1223,7 +1224,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m } timeline.reset(data.move); timeline.accel(data.move, v, accel, maxDistance + overshootDist); - timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); + timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); if (!flickingHorizontally && q->xflick()) { flickingHorizontally = true; emit q->flickingChanged(); @@ -1246,7 +1247,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m //---------------------------------------------------------------------------- /*! - \qmlclass GridView QDeclarativeGridView + \qmlclass GridView QDeclarative1GridView \since 4.7 \ingroup qml-view-elements @@ -1319,16 +1320,16 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m \sa {declarative/modelviews/gridview}{GridView example} */ -QDeclarativeGridView::QDeclarativeGridView(QDeclarativeItem *parent) - : QDeclarativeFlickable(*(new QDeclarativeGridViewPrivate), parent) +QDeclarative1GridView::QDeclarative1GridView(QDeclarativeItem *parent) + : QDeclarative1Flickable(*(new QDeclarative1GridViewPrivate), parent) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->init(); } -QDeclarativeGridView::~QDeclarativeGridView() +QDeclarative1GridView::~QDeclarative1GridView() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->clear(); if (d->ownModel) delete d->model; @@ -1389,22 +1390,22 @@ QDeclarativeGridView::~QDeclarativeGridView() \sa {qmlmodels}{Data Models} */ -QVariant QDeclarativeGridView::model() const +QVariant QDeclarative1GridView::model() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->modelVariant; } // For internal use -int QDeclarativeGridView::modelCount() const +int QDeclarative1GridView::modelCount() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->model->count(); } -void QDeclarativeGridView::setModel(const QVariant &model) +void QDeclarative1GridView::setModel(const QVariant &model) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->modelVariant == model) return; if (d->model) { @@ -1418,8 +1419,8 @@ void QDeclarativeGridView::setModel(const QVariant &model) d->clear(); d->modelVariant = model; QObject *object = qvariant_cast(model); - QDeclarativeVisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { + QDeclarative1VisualModel *vim = 0; + if (object && (vim = qobject_cast(object))) { if (d->ownModel) { delete d->model; d->ownModel = false; @@ -1427,27 +1428,27 @@ void QDeclarativeGridView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); + d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); d->ownModel = true; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) dataModel->setModel(model); } if (d->model) { - d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore | QDeclarativeGridViewPrivate::BufferAfter; + d->bufferMode = QDeclarative1GridViewPrivate::BufferBefore | QDeclarative1GridViewPrivate::BufferAfter; if (isComponentComplete()) { refill(); if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { setCurrentIndex(0); } else { - d->moveReason = QDeclarativeGridViewPrivate::SetIndex; + d->moveReason = QDeclarative1GridViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); if (d->highlight && d->currentItem) { if (d->autoHighlight) d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); d->updateTrackedItem(); } - d->moveReason = QDeclarativeGridViewPrivate::Other; + d->moveReason = QDeclarative1GridViewPrivate::Other; } } connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); @@ -1479,28 +1480,28 @@ void QDeclarativeGridView::setModel(const QVariant &model) \note Delegates are instantiated as needed and may be destroyed at any time. State should \e never be stored in a delegate. */ -QDeclarativeComponent *QDeclarativeGridView::delegate() const +QDeclarativeComponent *QDeclarative1GridView::delegate() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); if (d->model) { - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) return dataModel->delegate(); } return 0; } -void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) +void QDeclarative1GridView::setDelegate(QDeclarativeComponent *delegate) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (delegate == this->delegate()) return; if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarative1VisualDataModel(qmlContext(this)); d->ownModel = true; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) { + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { int oldCount = dataModel->count(); dataModel->setDelegate(delegate); if (isComponentComplete()) { @@ -1510,14 +1511,14 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) d->releaseItem(d->currentItem); d->currentItem = 0; refill(); - d->moveReason = QDeclarativeGridViewPrivate::SetIndex; + d->moveReason = QDeclarative1GridViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); if (d->highlight && d->currentItem) { if (d->autoHighlight) d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); d->updateTrackedItem(); } - d->moveReason = QDeclarativeGridViewPrivate::Other; + d->moveReason = QDeclarative1GridViewPrivate::Other; } if (oldCount != dataModel->count()) emit countChanged(); @@ -1540,22 +1541,22 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) Note that the position of the current item may only be approximate until it becomes visible in the view. */ -int QDeclarativeGridView::currentIndex() const +int QDeclarative1GridView::currentIndex() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->currentIndex; } -void QDeclarativeGridView::setCurrentIndex(int index) +void QDeclarative1GridView::setCurrentIndex(int index) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->requestedIndex >= 0) // currently creating item return; d->currentIndexCleared = (index == -1); if (index == d->currentIndex) return; if (isComponentComplete() && d->isValid()) { - d->moveReason = QDeclarativeGridViewPrivate::SetIndex; + d->moveReason = QDeclarative1GridViewPrivate::SetIndex; d->updateCurrent(index); } else { d->currentIndex = index; @@ -1563,9 +1564,9 @@ void QDeclarativeGridView::setCurrentIndex(int index) } } -QDeclarativeItem *QDeclarativeGridView::currentItem() +QDeclarativeItem *QDeclarative1GridView::currentItem() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!d->currentItem) return 0; return d->currentItem->item; @@ -1581,9 +1582,9 @@ QDeclarativeItem *QDeclarativeGridView::currentItem() \sa highlight, highlightFollowsCurrentItem */ -QDeclarativeItem *QDeclarativeGridView::highlightItem() +QDeclarativeItem *QDeclarative1GridView::highlightItem() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!d->highlight) return 0; return d->highlight->item; @@ -1593,9 +1594,9 @@ QDeclarativeItem *QDeclarativeGridView::highlightItem() \qmlproperty int GridView::count This property holds the number of items in the view. */ -int QDeclarativeGridView::count() const +int QDeclarative1GridView::count() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); if (d->model) return d->model->count(); return 0; @@ -1611,15 +1612,15 @@ int QDeclarativeGridView::count() const \sa highlightItem, highlightFollowsCurrentItem */ -QDeclarativeComponent *QDeclarativeGridView::highlight() const +QDeclarativeComponent *QDeclarative1GridView::highlight() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->highlightComponent; } -void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight) +void QDeclarative1GridView::setHighlight(QDeclarativeComponent *highlight) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (highlight != d->highlightComponent) { d->highlightComponent = highlight; d->updateCurrent(d->currentIndex); @@ -1640,15 +1641,15 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight) \snippet doc/src/snippets/declarative/gridview/gridview.qml highlightFollowsCurrentItem */ -bool QDeclarativeGridView::highlightFollowsCurrentItem() const +bool QDeclarative1GridView::highlightFollowsCurrentItem() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->autoHighlight; } -void QDeclarativeGridView::setHighlightFollowsCurrentItem(bool autoHighlight) +void QDeclarative1GridView::setHighlightFollowsCurrentItem(bool autoHighlight) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->autoHighlight != autoHighlight) { d->autoHighlight = autoHighlight; if (autoHighlight) { @@ -1671,15 +1672,15 @@ void QDeclarativeGridView::setHighlightFollowsCurrentItem(bool autoHighlight) \sa highlightFollowsCurrentItem */ -int QDeclarativeGridView::highlightMoveDuration() const +int QDeclarative1GridView::highlightMoveDuration() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->highlightMoveDuration; } -void QDeclarativeGridView::setHighlightMoveDuration(int duration) +void QDeclarative1GridView::setHighlightMoveDuration(int duration) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->highlightMoveDuration != duration) { d->highlightMoveDuration = duration; if (d->highlightYAnimator) { @@ -1721,15 +1722,15 @@ void QDeclarativeGridView::setHighlightMoveDuration(int duration) \o GridView.NoHighlightRange - this is the default value. \endlist */ -qreal QDeclarativeGridView::preferredHighlightBegin() const +qreal QDeclarative1GridView::preferredHighlightBegin() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->highlightRangeStart; } -void QDeclarativeGridView::setPreferredHighlightBegin(qreal start) +void QDeclarative1GridView::setPreferredHighlightBegin(qreal start) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->highlightRangeStartValid = true; if (d->highlightRangeStart == start) return; @@ -1738,9 +1739,9 @@ void QDeclarativeGridView::setPreferredHighlightBegin(qreal start) emit preferredHighlightBeginChanged(); } -void QDeclarativeGridView::resetPreferredHighlightBegin() +void QDeclarative1GridView::resetPreferredHighlightBegin() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->highlightRangeStartValid = false; if (d->highlightRangeStart == 0) return; @@ -1748,15 +1749,15 @@ void QDeclarativeGridView::resetPreferredHighlightBegin() emit preferredHighlightBeginChanged(); } -qreal QDeclarativeGridView::preferredHighlightEnd() const +qreal QDeclarative1GridView::preferredHighlightEnd() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->highlightRangeEnd; } -void QDeclarativeGridView::setPreferredHighlightEnd(qreal end) +void QDeclarative1GridView::setPreferredHighlightEnd(qreal end) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->highlightRangeEndValid = true; if (d->highlightRangeEnd == end) return; @@ -1765,9 +1766,9 @@ void QDeclarativeGridView::setPreferredHighlightEnd(qreal end) emit preferredHighlightEndChanged(); } -void QDeclarativeGridView::resetPreferredHighlightEnd() +void QDeclarative1GridView::resetPreferredHighlightEnd() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->highlightRangeEndValid = false; if (d->highlightRangeEnd == 0) return; @@ -1775,15 +1776,15 @@ void QDeclarativeGridView::resetPreferredHighlightEnd() emit preferredHighlightEndChanged(); } -QDeclarativeGridView::HighlightRangeMode QDeclarativeGridView::highlightRangeMode() const +QDeclarative1GridView::HighlightRangeMode QDeclarative1GridView::highlightRangeMode() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->highlightRange; } -void QDeclarativeGridView::setHighlightRangeMode(HighlightRangeMode mode) +void QDeclarative1GridView::setHighlightRangeMode(HighlightRangeMode mode) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->highlightRange == mode) return; d->highlightRange = mode; @@ -1809,15 +1810,15 @@ void QDeclarativeGridView::setHighlightRangeMode(HighlightRangeMode mode) indicates that the flow is horizontal. */ -Qt::LayoutDirection QDeclarativeGridView::layoutDirection() const +Qt::LayoutDirection QDeclarative1GridView::layoutDirection() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->layoutDirection; } -void QDeclarativeGridView::setLayoutDirection(Qt::LayoutDirection layoutDirection) +void QDeclarative1GridView::setLayoutDirection(Qt::LayoutDirection layoutDirection) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; d->regenerate(); @@ -1837,9 +1838,9 @@ void QDeclarativeGridView::setLayoutDirection(Qt::LayoutDirection layoutDirectio \sa GridView::layoutDirection, {LayoutMirroring}{LayoutMirroring} */ -Qt::LayoutDirection QDeclarativeGridView::effectiveLayoutDirection() const +Qt::LayoutDirection QDeclarative1GridView::effectiveLayoutDirection() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); if (d->effectiveLayoutMirror) return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; else @@ -1857,23 +1858,23 @@ Qt::LayoutDirection QDeclarativeGridView::effectiveLayoutDirection() const \o GridView.TopToBottom - Items are laid out from top to bottom, and the view scrolls horizontally \endlist */ -QDeclarativeGridView::Flow QDeclarativeGridView::flow() const +QDeclarative1GridView::Flow QDeclarative1GridView::flow() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->flow; } -void QDeclarativeGridView::setFlow(Flow flow) +void QDeclarative1GridView::setFlow(Flow flow) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->flow != flow) { d->flow = flow; if (d->flow == LeftToRight) { setContentWidth(-1); - setFlickableDirection(QDeclarativeFlickable::VerticalFlick); + setFlickableDirection(QDeclarative1Flickable::VerticalFlick); } else { setContentHeight(-1); - setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); + setFlickableDirection(QDeclarative1Flickable::HorizontalFlick); } setContentX(0); setContentY(0); @@ -1892,15 +1893,15 @@ void QDeclarativeGridView::setFlow(Flow flow) By default, key navigation is not wrapped. */ -bool QDeclarativeGridView::isWrapEnabled() const +bool QDeclarative1GridView::isWrapEnabled() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->wrap; } -void QDeclarativeGridView::setWrapEnabled(bool wrap) +void QDeclarative1GridView::setWrapEnabled(bool wrap) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->wrap == wrap) return; d->wrap = wrap; @@ -1926,15 +1927,15 @@ void QDeclarativeGridView::setWrapEnabled(bool wrap) delegates; the fewer elements in a delegate, the faster a view may be scrolled. */ -int QDeclarativeGridView::cacheBuffer() const +int QDeclarative1GridView::cacheBuffer() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->buffer; } -void QDeclarativeGridView::setCacheBuffer(int buffer) +void QDeclarative1GridView::setCacheBuffer(int buffer) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->buffer != buffer) { d->buffer = buffer; if (isComponentComplete()) @@ -1951,15 +1952,15 @@ void QDeclarativeGridView::setCacheBuffer(int buffer) The default cell size is 100x100. */ -int QDeclarativeGridView::cellWidth() const +int QDeclarative1GridView::cellWidth() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->cellWidth; } -void QDeclarativeGridView::setCellWidth(int cellWidth) +void QDeclarative1GridView::setCellWidth(int cellWidth) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (cellWidth != d->cellWidth && cellWidth > 0) { d->cellWidth = qMax(1, cellWidth); d->updateGrid(); @@ -1968,15 +1969,15 @@ void QDeclarativeGridView::setCellWidth(int cellWidth) } } -int QDeclarativeGridView::cellHeight() const +int QDeclarative1GridView::cellHeight() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->cellHeight; } -void QDeclarativeGridView::setCellHeight(int cellHeight) +void QDeclarative1GridView::setCellHeight(int cellHeight) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (cellHeight != d->cellHeight && cellHeight > 0) { d->cellHeight = qMax(1, cellHeight); d->updateGrid(); @@ -2000,15 +2001,15 @@ void QDeclarativeGridView::setCellHeight(int cellHeight) \endlist */ -QDeclarativeGridView::SnapMode QDeclarativeGridView::snapMode() const +QDeclarative1GridView::SnapMode QDeclarative1GridView::snapMode() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->snapMode; } -void QDeclarativeGridView::setSnapMode(SnapMode mode) +void QDeclarative1GridView::setSnapMode(SnapMode mode) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->snapMode != mode) { d->snapMode = mode; emit snapModeChanged(); @@ -2024,15 +2025,15 @@ void QDeclarativeGridView::setSnapMode(SnapMode mode) \sa header */ -QDeclarativeComponent *QDeclarativeGridView::footer() const +QDeclarativeComponent *QDeclarative1GridView::footer() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->footerComponent; } -void QDeclarativeGridView::setFooter(QDeclarativeComponent *footer) +void QDeclarative1GridView::setFooter(QDeclarativeComponent *footer) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->footerComponent != footer) { if (d->footer) { if (scene()) @@ -2060,15 +2061,15 @@ void QDeclarativeGridView::setFooter(QDeclarativeComponent *footer) \sa footer */ -QDeclarativeComponent *QDeclarativeGridView::header() const +QDeclarativeComponent *QDeclarative1GridView::header() const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); return d->headerComponent; } -void QDeclarativeGridView::setHeader(QDeclarativeComponent *header) +void QDeclarative1GridView::setHeader(QDeclarativeComponent *header) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->headerComponent != header) { if (d->header) { if (scene()) @@ -2088,59 +2089,59 @@ void QDeclarativeGridView::setHeader(QDeclarativeComponent *header) } } -void QDeclarativeGridView::setContentX(qreal pos) +void QDeclarative1GridView::setContentX(qreal pos) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); // Positioning the view manually should override any current movement state - d->moveReason = QDeclarativeGridViewPrivate::Other; - QDeclarativeFlickable::setContentX(pos); + d->moveReason = QDeclarative1GridViewPrivate::Other; + QDeclarative1Flickable::setContentX(pos); } -void QDeclarativeGridView::setContentY(qreal pos) +void QDeclarative1GridView::setContentY(qreal pos) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); // Positioning the view manually should override any current movement state - d->moveReason = QDeclarativeGridViewPrivate::Other; - QDeclarativeFlickable::setContentY(pos); + d->moveReason = QDeclarative1GridViewPrivate::Other; + QDeclarative1Flickable::setContentY(pos); } -bool QDeclarativeGridView::event(QEvent *event) +bool QDeclarative1GridView::event(QEvent *event) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (event->type() == QEvent::User) { d->layout(); return true; } - return QDeclarativeFlickable::event(event); + return QDeclarative1Flickable::event(event); } -void QDeclarativeGridView::viewportMoved() +void QDeclarative1GridView::viewportMoved() { - Q_D(QDeclarativeGridView); - QDeclarativeFlickable::viewportMoved(); + Q_D(QDeclarative1GridView); + QDeclarative1Flickable::viewportMoved(); if (!d->itemCount) return; d->lazyRelease = true; if (d->flickingHorizontally || d->flickingVertically) { if (yflick()) { if (d->vData.velocity > 0) - d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore; + d->bufferMode = QDeclarative1GridViewPrivate::BufferBefore; else if (d->vData.velocity < 0) - d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter; + d->bufferMode = QDeclarative1GridViewPrivate::BufferAfter; } if (xflick()) { if (d->hData.velocity > 0) - d->bufferMode = QDeclarativeGridViewPrivate::BufferBefore; + d->bufferMode = QDeclarative1GridViewPrivate::BufferBefore; else if (d->hData.velocity < 0) - d->bufferMode = QDeclarativeGridViewPrivate::BufferAfter; + d->bufferMode = QDeclarative1GridViewPrivate::BufferAfter; } } refill(); if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) - d->moveReason = QDeclarativeGridViewPrivate::Mouse; - if (d->moveReason != QDeclarativeGridViewPrivate::SetIndex) { + d->moveReason = QDeclarative1GridViewPrivate::Mouse; + if (d->moveReason != QDeclarative1GridViewPrivate::SetIndex) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { // reposition highlight qreal pos = d->highlight->rowPos(); @@ -2178,11 +2179,11 @@ void QDeclarativeGridView::viewportMoved() } } -qreal QDeclarativeGridView::minYExtent() const +qreal QDeclarative1GridView::minYExtent() const { - Q_D(const QDeclarativeGridView); - if (d->flow == QDeclarativeGridView::TopToBottom) - return QDeclarativeFlickable::minYExtent(); + Q_D(const QDeclarative1GridView); + if (d->flow == QDeclarative1GridView::TopToBottom) + return QDeclarative1Flickable::minYExtent(); qreal extent = -d->startPosition(); if (d->header && d->visibleItems.count()) extent += d->header->item->height(); @@ -2193,11 +2194,11 @@ qreal QDeclarativeGridView::minYExtent() const return extent; } -qreal QDeclarativeGridView::maxYExtent() const +qreal QDeclarative1GridView::maxYExtent() const { - Q_D(const QDeclarativeGridView); - if (d->flow == QDeclarativeGridView::TopToBottom) - return QDeclarativeFlickable::maxYExtent(); + Q_D(const QDeclarative1GridView); + if (d->flow == QDeclarative1GridView::TopToBottom) + return QDeclarative1Flickable::maxYExtent(); qreal extent; if (!d->model || !d->model->count()) { extent = 0; @@ -2216,11 +2217,11 @@ qreal QDeclarativeGridView::maxYExtent() const return extent; } -qreal QDeclarativeGridView::minXExtent() const +qreal QDeclarative1GridView::minXExtent() const { - Q_D(const QDeclarativeGridView); - if (d->flow == QDeclarativeGridView::LeftToRight) - return QDeclarativeFlickable::minXExtent(); + Q_D(const QDeclarative1GridView); + if (d->flow == QDeclarative1GridView::LeftToRight) + return QDeclarative1Flickable::minXExtent(); qreal extent = -d->startPosition(); qreal highlightStart; qreal highlightEnd; @@ -2247,11 +2248,11 @@ qreal QDeclarativeGridView::minXExtent() const return extent; } -qreal QDeclarativeGridView::maxXExtent() const +qreal QDeclarative1GridView::maxXExtent() const { - Q_D(const QDeclarativeGridView); - if (d->flow == QDeclarativeGridView::LeftToRight) - return QDeclarativeFlickable::maxXExtent(); + Q_D(const QDeclarative1GridView); + if (d->flow == QDeclarative1GridView::LeftToRight) + return QDeclarative1Flickable::maxXExtent(); qreal extent; qreal highlightStart; qreal highlightEnd; @@ -2292,14 +2293,14 @@ qreal QDeclarativeGridView::maxXExtent() const return extent; } -void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) +void QDeclarative1GridView::keyPressEvent(QKeyEvent *event) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); keyPressPreHandler(event); if (event->isAccepted()) return; if (d->model && d->model->count() && d->interactive) { - d->moveReason = QDeclarativeGridViewPrivate::SetIndex; + d->moveReason = QDeclarative1GridViewPrivate::SetIndex; int oldCurrent = currentIndex(); switch (event->key()) { case Qt::Key_Up: @@ -2322,9 +2323,9 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) return; } } - d->moveReason = QDeclarativeGridViewPrivate::Other; + d->moveReason = QDeclarative1GridViewPrivate::Other; event->ignore(); - QDeclarativeFlickable::keyPressEvent(event); + QDeclarative1Flickable::keyPressEvent(event); } /*! @@ -2336,13 +2337,13 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event) \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativeGridView::moveCurrentIndexUp() +void QDeclarative1GridView::moveCurrentIndexUp() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); const int count = d->model ? d->model->count() : 0; if (!count) return; - if (d->flow == QDeclarativeGridView::LeftToRight) { + if (d->flow == QDeclarative1GridView::LeftToRight) { if (currentIndex() >= d->columns || d->wrap) { int index = currentIndex() - d->columns; setCurrentIndex((index >= 0 && index < count) ? index : count-1); @@ -2364,13 +2365,13 @@ void QDeclarativeGridView::moveCurrentIndexUp() \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativeGridView::moveCurrentIndexDown() +void QDeclarative1GridView::moveCurrentIndexDown() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); const int count = d->model ? d->model->count() : 0; if (!count) return; - if (d->flow == QDeclarativeGridView::LeftToRight) { + if (d->flow == QDeclarative1GridView::LeftToRight) { if (currentIndex() < count - d->columns || d->wrap) { int index = currentIndex()+d->columns; setCurrentIndex((index >= 0 && index < count) ? index : 0); @@ -2392,15 +2393,15 @@ void QDeclarativeGridView::moveCurrentIndexDown() \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativeGridView::moveCurrentIndexLeft() +void QDeclarative1GridView::moveCurrentIndexLeft() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); const int count = d->model ? d->model->count() : 0; if (!count) return; if (effectiveLayoutDirection() == Qt::LeftToRight) { - if (d->flow == QDeclarativeGridView::LeftToRight) { + if (d->flow == QDeclarative1GridView::LeftToRight) { if (currentIndex() > 0 || d->wrap) { int index = currentIndex() - 1; setCurrentIndex((index >= 0 && index < count) ? index : count-1); @@ -2412,7 +2413,7 @@ void QDeclarativeGridView::moveCurrentIndexLeft() } } } else { - if (d->flow == QDeclarativeGridView::LeftToRight) { + if (d->flow == QDeclarative1GridView::LeftToRight) { if (currentIndex() < count - 1 || d->wrap) { int index = currentIndex() + 1; setCurrentIndex((index >= 0 && index < count) ? index : 0); @@ -2435,15 +2436,15 @@ void QDeclarativeGridView::moveCurrentIndexLeft() \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativeGridView::moveCurrentIndexRight() +void QDeclarative1GridView::moveCurrentIndexRight() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); const int count = d->model ? d->model->count() : 0; if (!count) return; if (effectiveLayoutDirection() == Qt::LeftToRight) { - if (d->flow == QDeclarativeGridView::LeftToRight) { + if (d->flow == QDeclarative1GridView::LeftToRight) { if (currentIndex() < count - 1 || d->wrap) { int index = currentIndex() + 1; setCurrentIndex((index >= 0 && index < count) ? index : 0); @@ -2455,7 +2456,7 @@ void QDeclarativeGridView::moveCurrentIndexRight() } } } else { - if (d->flow == QDeclarativeGridView::LeftToRight) { + if (d->flow == QDeclarative1GridView::LeftToRight) { if (currentIndex() > 0 || d->wrap) { int index = currentIndex() - 1; setCurrentIndex((index >= 0 && index < count) ? index : count-1); @@ -2469,12 +2470,12 @@ void QDeclarativeGridView::moveCurrentIndexRight() } } -void QDeclarativeGridViewPrivate::positionViewAtIndex(int index, int mode) +void QDeclarative1GridViewPrivate::positionViewAtIndex(int index, int mode) { - Q_Q(QDeclarativeGridView); + Q_Q(QDeclarative1GridView); if (!isValid()) return; - if (mode < QDeclarativeGridView::Beginning || mode > QDeclarativeGridView::Contain) + if (mode < QDeclarative1GridView::Beginning || mode > QDeclarative1GridView::Contain) return; int idx = qMax(qMin(index, model->count()-1), 0); @@ -2482,9 +2483,9 @@ void QDeclarativeGridViewPrivate::positionViewAtIndex(int index, int mode) if (layoutScheduled) layout(); qreal pos = isRightToLeftTopToBottom() ? -position() - size() : position(); - FxGridItem *item = visibleItem(idx); + FxGridItem1 *item = visibleItem(idx); qreal maxExtent; - if (flow == QDeclarativeGridView::LeftToRight) + if (flow == QDeclarative1GridView::LeftToRight) maxExtent = -q->maxYExtent(); else maxExtent = isRightToLeftTopToBottom() ? q->minXExtent()-size() : -q->maxXExtent(); @@ -2492,10 +2493,10 @@ void QDeclarativeGridViewPrivate::positionViewAtIndex(int index, int mode) if (!item) { int itemPos = rowPosAt(idx); // save the currently visible items in case any of them end up visible again - QList oldVisible = visibleItems; + QList oldVisible = visibleItems; visibleItems.clear(); visibleIndex = idx - idx % columns; - if (flow == QDeclarativeGridView::LeftToRight) + if (flow == QDeclarative1GridView::LeftToRight) maxExtent = -q->maxYExtent(); else maxExtent = isRightToLeftTopToBottom() ? q->minXExtent()-size() : -q->maxXExtent(); @@ -2508,32 +2509,32 @@ void QDeclarativeGridViewPrivate::positionViewAtIndex(int index, int mode) if (item) { qreal itemPos = item->rowPos(); switch (mode) { - case QDeclarativeGridView::Beginning: + case QDeclarative1GridView::Beginning: pos = itemPos; if (index < 0 && header) { - pos -= flow == QDeclarativeGridView::LeftToRight + pos -= flow == QDeclarative1GridView::LeftToRight ? header->item->height() : header->item->width(); } break; - case QDeclarativeGridView::Center: + case QDeclarative1GridView::Center: pos = itemPos - (size() - rowSize())/2; break; - case QDeclarativeGridView::End: + case QDeclarative1GridView::End: pos = itemPos - size() + rowSize(); if (index >= model->count() && footer) { - pos += flow == QDeclarativeGridView::LeftToRight + pos += flow == QDeclarative1GridView::LeftToRight ? footer->item->height() : footer->item->width(); } break; - case QDeclarativeGridView::Visible: + case QDeclarative1GridView::Visible: if (itemPos > pos + size()) pos = itemPos - size() + rowSize(); else if (item->endRowPos() < pos) pos = itemPos; break; - case QDeclarativeGridView::Contain: + case QDeclarative1GridView::Contain: if (item->endRowPos() > pos + size()) pos = itemPos - size() + rowSize(); if (itemPos < pos) @@ -2542,12 +2543,12 @@ void QDeclarativeGridViewPrivate::positionViewAtIndex(int index, int mode) pos = qMin(pos, maxExtent); qreal minExtent; - if (flow == QDeclarativeGridView::LeftToRight) + if (flow == QDeclarative1GridView::LeftToRight) minExtent = -q->minYExtent(); else minExtent = isRightToLeftTopToBottom() ? q->maxXExtent()-size() : -q->minXExtent(); pos = qMax(pos, minExtent); - moveReason = QDeclarativeGridViewPrivate::Other; + moveReason = QDeclarative1GridViewPrivate::Other; q->cancelFlick(); setPosition(pos); } @@ -2586,9 +2587,9 @@ void QDeclarativeGridViewPrivate::positionViewAtIndex(int index, int mode) Component.onCompleted: positionViewAtIndex(count - 1, GridView.Beginning) \endcode */ -void QDeclarativeGridView::positionViewAtIndex(int index, int mode) +void QDeclarative1GridView::positionViewAtIndex(int index, int mode) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!d->isValid() || index < 0 || index >= d->model->count()) return; d->positionViewAtIndex(index, mode); @@ -2614,17 +2615,17 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode) Component.onCompleted: positionViewAtEnd() \endcode */ -void QDeclarativeGridView::positionViewAtBeginning() +void QDeclarative1GridView::positionViewAtBeginning() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!d->isValid()) return; d->positionViewAtIndex(-1, Beginning); } -void QDeclarativeGridView::positionViewAtEnd() +void QDeclarative1GridView::positionViewAtEnd() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!d->isValid()) return; d->positionViewAtIndex(d->model->count(), End); @@ -2642,11 +2643,11 @@ void QDeclarativeGridView::positionViewAtEnd() \bold Note: methods should only be called after the Component has completed. */ -int QDeclarativeGridView::indexAt(qreal x, qreal y) const +int QDeclarative1GridView::indexAt(qreal x, qreal y) const { - Q_D(const QDeclarativeGridView); + Q_D(const QDeclarative1GridView); for (int i = 0; i < d->visibleItems.count(); ++i) { - const FxGridItem *listItem = d->visibleItems.at(i); + const FxGridItem1 *listItem = d->visibleItems.at(i); if(listItem->contains(x, y)) return listItem->index; } @@ -2654,16 +2655,16 @@ int QDeclarativeGridView::indexAt(qreal x, qreal y) const return -1; } -void QDeclarativeGridView::componentComplete() +void QDeclarative1GridView::componentComplete() { - Q_D(QDeclarativeGridView); - QDeclarativeFlickable::componentComplete(); + Q_D(QDeclarative1GridView); + QDeclarative1Flickable::componentComplete(); d->updateHeader(); d->updateFooter(); d->updateGrid(); if (d->isValid()) { refill(); - d->moveReason = QDeclarativeGridViewPrivate::SetIndex; + d->moveReason = QDeclarative1GridViewPrivate::SetIndex; if (d->currentIndex < 0 && !d->currentIndexCleared) d->updateCurrent(0); else @@ -2673,17 +2674,17 @@ void QDeclarativeGridView::componentComplete() d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); d->updateTrackedItem(); } - d->moveReason = QDeclarativeGridViewPrivate::Other; + d->moveReason = QDeclarative1GridViewPrivate::Other; d->fixupPosition(); } } -void QDeclarativeGridView::trackedPositionChanged() +void QDeclarative1GridView::trackedPositionChanged() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!d->trackedItem || !d->currentItem) return; - if (d->moveReason == QDeclarativeGridViewPrivate::SetIndex) { + if (d->moveReason == QDeclarative1GridViewPrivate::SetIndex) { const qreal trackedPos = d->trackedItem->rowPos(); qreal viewPos; qreal highlightStart; @@ -2744,9 +2745,9 @@ void QDeclarativeGridView::trackedPositionChanged() } } -void QDeclarativeGridView::itemsInserted(int modelIndex, int count) +void QDeclarative1GridView::itemsInserted(int modelIndex, int count) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!isComponentComplete()) return; @@ -2763,7 +2764,7 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) // Insert before visible items d->visibleIndex += count; for (int i = 0; i < d->visibleItems.count(); ++i) { - FxGridItem *listItem = d->visibleItems.at(i); + FxGridItem1 *listItem = d->visibleItems.at(i); if (listItem->index != -1 && listItem->index >= modelIndex) listItem->index += count; } @@ -2813,20 +2814,20 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) // Update the indexes of the following visible items. for (int i = 0; i < d->visibleItems.count(); ++i) { - FxGridItem *listItem = d->visibleItems.at(i); + FxGridItem1 *listItem = d->visibleItems.at(i); if (listItem->index != -1 && listItem->index >= modelIndex) listItem->index += count; } bool addedVisible = false; - QList added; + QList added; int i = 0; while (i < insertCount && rowPos <= to + d->rowSize()*(d->columns - (colPos/d->colSize()))/qreal(d->columns)) { if (!addedVisible) { d->scheduleLayout(); addedVisible = true; } - FxGridItem *item = d->createItem(modelIndex + i); + FxGridItem1 *item = d->createItem(modelIndex + i); d->visibleItems.insert(index, item); item->setPosition(colPos, rowPos); added.append(item); @@ -2848,7 +2849,7 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) // update visibleIndex d->visibleIndex = 0; - for (QList::Iterator it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + for (QList::Iterator it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { if ((*it)->index != -1) { d->visibleIndex = (*it)->index; break; @@ -2875,9 +2876,9 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) emit countChanged(); } -void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) +void QDeclarative1GridView::itemsRemoved(int modelIndex, int count) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!isComponentComplete()) return; @@ -2886,9 +2887,9 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) bool removedVisible = false; // Remove the items from the visible list, skipping anything already marked for removal - QList::Iterator it = d->visibleItems.begin(); + QList::Iterator it = d->visibleItems.begin(); while (it != d->visibleItems.end()) { - FxGridItem *item = *it; + FxGridItem1 *item = *it; if (item->index == -1 || item->index < modelIndex) { // already removed, or before removed items if (item->index < modelIndex && !removedVisible) { @@ -2957,12 +2958,12 @@ void QDeclarativeGridView::itemsRemoved(int modelIndex, int count) emit countChanged(); } -void QDeclarativeGridView::destroyRemoved() +void QDeclarative1GridView::destroyRemoved() { - Q_D(QDeclarativeGridView); - for (QList::Iterator it = d->visibleItems.begin(); + Q_D(QDeclarative1GridView); + for (QList::Iterator it = d->visibleItems.begin(); it != d->visibleItems.end();) { - FxGridItem *listItem = *it; + FxGridItem1 *listItem = *it; if (listItem->index == -1 && listItem->attached->delayRemove() == false) { d->releaseItem(listItem); it = d->visibleItems.erase(it); @@ -2975,18 +2976,18 @@ void QDeclarativeGridView::destroyRemoved() d->layout(); } -void QDeclarativeGridView::itemsMoved(int from, int to, int count) +void QDeclarative1GridView::itemsMoved(int from, int to, int count) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (!isComponentComplete()) return; - QHash moved; + QHash moved; - FxGridItem *firstItem = d->firstVisibleItem(); + FxGridItem1 *firstItem = d->firstVisibleItem(); - QList::Iterator it = d->visibleItems.begin(); + QList::Iterator it = d->visibleItems.begin(); while (it != d->visibleItems.end()) { - FxGridItem *item = *it; + FxGridItem1 *item = *it; if (item->index >= from && item->index < from + count) { // take the items that are moving item->index += (to-from); @@ -3007,10 +3008,10 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count) int endIndex = d->visibleIndex; it = d->visibleItems.begin(); while (it != d->visibleItems.end()) { - FxGridItem *item = *it; + FxGridItem1 *item = *it; if (remaining && item->index >= to && item->index < to + count) { // place items in the target position, reusing any existing items - FxGridItem *movedItem = moved.take(item->index); + FxGridItem1 *movedItem = moved.take(item->index); if (!movedItem) movedItem = d->createItem(item->index); it = d->visibleItems.insert(it, movedItem); @@ -3032,7 +3033,7 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count) // If we have moved items to the end of the visible items // then add any existing moved items that we have - while (FxGridItem *item = moved.take(endIndex+1)) { + while (FxGridItem1 *item = moved.take(endIndex+1)) { d->visibleItems.append(item); ++endIndex; } @@ -3058,7 +3059,7 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count) // Whatever moved items remain are no longer visible items. while (moved.count()) { int idx = moved.begin().key(); - FxGridItem *item = moved.take(idx); + FxGridItem1 *item = moved.take(idx); if (d->currentItem && item->item == d->currentItem->item) item->setPosition(d->colPosAt(idx), d->rowPosAt(idx)); d->releaseItem(item); @@ -3067,30 +3068,30 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count) d->layout(); } -void QDeclarativeGridView::modelReset() +void QDeclarative1GridView::modelReset() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->clear(); refill(); - d->moveReason = QDeclarativeGridViewPrivate::SetIndex; + d->moveReason = QDeclarative1GridViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); if (d->highlight && d->currentItem) { if (d->autoHighlight) d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); d->updateTrackedItem(); } - d->moveReason = QDeclarativeGridViewPrivate::Other; + d->moveReason = QDeclarative1GridViewPrivate::Other; emit countChanged(); } -void QDeclarativeGridView::createdItem(int index, QDeclarativeItem *item) +void QDeclarative1GridView::createdItem(int index, QDeclarativeItem *item) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->requestedIndex != index) { item->setParentItem(this); d->unrequestedItems.insert(item, index); - if (d->flow == QDeclarativeGridView::LeftToRight) { + if (d->flow == QDeclarative1GridView::LeftToRight) { item->setPos(QPointF(d->colPosAt(index), d->rowPosAt(index))); } else { item->setPos(QPointF(d->rowPosAt(index), d->colPosAt(index))); @@ -3098,23 +3099,23 @@ void QDeclarativeGridView::createdItem(int index, QDeclarativeItem *item) } } -void QDeclarativeGridView::destroyingItem(QDeclarativeItem *item) +void QDeclarative1GridView::destroyingItem(QDeclarativeItem *item) { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); d->unrequestedItems.remove(item); } -void QDeclarativeGridView::animStopped() +void QDeclarative1GridView::animStopped() { - Q_D(QDeclarativeGridView); - d->bufferMode = QDeclarativeGridViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarativeGridView::StrictlyEnforceRange) + Q_D(QDeclarative1GridView); + d->bufferMode = QDeclarative1GridViewPrivate::NoBuffer; + if (d->haveHighlightRange && d->highlightRange == QDeclarative1GridView::StrictlyEnforceRange) d->updateHighlight(); } -void QDeclarativeGridView::refill() +void QDeclarative1GridView::refill() { - Q_D(QDeclarativeGridView); + Q_D(QDeclarative1GridView); if (d->isRightToLeftTopToBottom()) d->refill(-d->position()-d->size()+1, -d->position()); else @@ -3122,9 +3123,11 @@ void QDeclarativeGridView::refill() } -QDeclarativeGridViewAttached *QDeclarativeGridView::qmlAttachedProperties(QObject *obj) +QDeclarative1GridViewAttached *QDeclarative1GridView::qmlAttachedProperties(QObject *obj) { - return new QDeclarativeGridViewAttached(obj); + return new QDeclarative1GridViewAttached(obj); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/qtquick1/graphicsitems/qdeclarativegridview_p.h similarity index 91% rename from src/declarative/graphicsitems/qdeclarativegridview_p.h rename to src/qtquick1/graphicsitems/qdeclarativegridview_p.h index d2dff48dc6..c53a34507d 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativegridview_p.h @@ -43,20 +43,20 @@ #define QDECLARATIVEGRIDVIEW_H #include "private/qdeclarativeflickable_p.h" -#include "private/qdeclarativeguard_p.h" +#include "QtDeclarative/private/qdeclarativeguard_p.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeVisualModel; -class QDeclarativeGridViewAttached; -class QDeclarativeGridViewPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeGridView : public QDeclarativeFlickable +class QDeclarative1VisualModel; +class QDeclarative1GridViewAttached; +class QDeclarative1GridViewPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1GridView : public QDeclarative1Flickable { Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGridView) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1GridView) Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) @@ -93,8 +93,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeGridView : public QDeclarativeFlickable Q_CLASSINFO("DefaultProperty", "data") public: - QDeclarativeGridView(QDeclarativeItem *parent=0); - ~QDeclarativeGridView(); + QDeclarative1GridView(QDeclarativeItem *parent=0); + ~QDeclarative1GridView(); QVariant model() const; int modelCount() const; @@ -171,7 +171,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeGridView : public QDeclarativeFlickable Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning(); Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd(); - static QDeclarativeGridViewAttached *qmlAttachedProperties(QObject *); + static QDeclarative1GridViewAttached *qmlAttachedProperties(QObject *); public Q_SLOTS: void moveCurrentIndexUp(); @@ -226,17 +226,17 @@ private Q_SLOTS: void refill(); }; -class QDeclarativeGridViewAttached : public QObject +class QDeclarative1GridViewAttached : public QObject { Q_OBJECT public: - QDeclarativeGridViewAttached(QObject *parent) + QDeclarative1GridViewAttached(QObject *parent) : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} - ~QDeclarativeGridViewAttached() {} + ~QDeclarative1GridViewAttached() {} - Q_PROPERTY(QDeclarativeGridView *view READ view NOTIFY viewChanged) - QDeclarativeGridView *view() { return m_view; } - void setView(QDeclarativeGridView *view) { + Q_PROPERTY(QDeclarative1GridView *view READ view NOTIFY viewChanged) + QDeclarative1GridView *view() { return m_view; } + void setView(QDeclarative1GridView *view) { if (view != m_view) { m_view = view; emit viewChanged(); @@ -272,7 +272,7 @@ class QDeclarativeGridViewAttached : public QObject void viewChanged(); public: - QDeclarativeGuard m_view; + QDeclarativeGuard m_view; bool m_isCurrent : 1; bool m_delayRemove : 1; }; @@ -280,8 +280,8 @@ class QDeclarativeGridViewAttached : public QObject QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeGridView) -QML_DECLARE_TYPEINFO(QDeclarativeGridView, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarative1GridView) +QML_DECLARE_TYPEINFO(QDeclarative1GridView, QML_HAS_ATTACHED_PROPERTIES) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeimage.cpp similarity index 91% rename from src/declarative/graphicsitems/qdeclarativeimage.cpp rename to src/qtquick1/graphicsitems/qdeclarativeimage.cpp index e6bb798ece..c3d0802e8c 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeimage.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "private/qdeclarativeimage_p.h" -#include "private/qdeclarativeimage_p_p.h" +#include "QtQuick1/private/qdeclarativeimage_p.h" +#include "QtQuick1/private/qdeclarativeimage_p_p.h" #include #include @@ -48,8 +48,10 @@ QT_BEGIN_NAMESPACE + + /*! - \qmlclass Image QDeclarativeImage + \qmlclass Image QDeclarative1Image \since 4.7 \ingroup qml-basic-visual-elements \brief The Image element displays an image in a declarative user interface @@ -103,41 +105,41 @@ QT_BEGIN_NAMESPACE \sa {declarative/imageelements/image}{Image example}, QDeclarativeImageProvider */ -QDeclarativeImage::QDeclarativeImage(QDeclarativeItem *parent) - : QDeclarativeImageBase(*(new QDeclarativeImagePrivate), parent) +QDeclarative1Image::QDeclarative1Image(QDeclarativeItem *parent) + : QDeclarative1ImageBase(*(new QDeclarative1ImagePrivate), parent) { } -QDeclarativeImage::QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent) - : QDeclarativeImageBase(dd, parent) +QDeclarative1Image::QDeclarative1Image(QDeclarative1ImagePrivate &dd, QDeclarativeItem *parent) + : QDeclarative1ImageBase(dd, parent) { } -QDeclarativeImage::~QDeclarativeImage() +QDeclarative1Image::~QDeclarative1Image() { } -QPixmap QDeclarativeImage::pixmap() const +QPixmap QDeclarative1Image::pixmap() const { - Q_D(const QDeclarativeImage); + Q_D(const QDeclarative1Image); return d->pix.pixmap(); } -void QDeclarativeImage::setPixmap(const QPixmap &pix) +void QDeclarative1Image::setPixmap(const QPixmap &pix) { - Q_D(QDeclarativeImage); + Q_D(QDeclarative1Image); if (!d->url.isEmpty()) return; d->setPixmap(pix); } -void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap) +void QDeclarative1ImagePrivate::setPixmap(const QPixmap &pixmap) { - Q_Q(QDeclarativeImage); + Q_Q(QDeclarative1Image); pix.setPixmap(pixmap); q->pixmapChange(); - status = pix.isNull() ? QDeclarativeImageBase::Null : QDeclarativeImageBase::Ready; + status = pix.isNull() ? QDeclarative1ImageBase::Null : QDeclarative1ImageBase::Ready; q->update(); } @@ -237,15 +239,15 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap) \sa {declarative/imageelements/image}{Image example} */ -QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const +QDeclarative1Image::FillMode QDeclarative1Image::fillMode() const { - Q_D(const QDeclarativeImage); + Q_D(const QDeclarative1Image); return d->fillMode; } -void QDeclarativeImage::setFillMode(FillMode mode) +void QDeclarative1Image::setFillMode(FillMode mode) { - Q_D(QDeclarativeImage); + Q_D(QDeclarative1Image); if (d->fillMode == mode) return; d->fillMode = mode; @@ -265,15 +267,15 @@ void QDeclarativeImage::setFillMode(FillMode mode) \c paintedWidth or \c paintedHeight can be smaller or larger than \c width and \c height of the Image element. */ -qreal QDeclarativeImage::paintedWidth() const +qreal QDeclarative1Image::paintedWidth() const { - Q_D(const QDeclarativeImage); + Q_D(const QDeclarative1Image); return d->paintedWidth; } -qreal QDeclarativeImage::paintedHeight() const +qreal QDeclarative1Image::paintedHeight() const { - Q_D(const QDeclarativeImage); + Q_D(const QDeclarative1Image); return d->paintedHeight; } @@ -383,9 +385,9 @@ qreal QDeclarativeImage::paintedHeight() const potentially even from the network, if it is not in the disk cache.} */ -void QDeclarativeImage::updatePaintedGeometry() +void QDeclarative1Image::updatePaintedGeometry() { - Q_D(QDeclarativeImage); + Q_D(QDeclarative1Image); if (d->fillMode == PreserveAspectFit) { if (!d->pix.width() || !d->pix.height()) { @@ -434,15 +436,15 @@ void QDeclarativeImage::updatePaintedGeometry() emit paintedGeometryChanged(); } -void QDeclarativeImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +void QDeclarative1Image::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - QDeclarativeImageBase::geometryChanged(newGeometry, oldGeometry); + QDeclarative1ImageBase::geometryChanged(newGeometry, oldGeometry); updatePaintedGeometry(); } -QRectF QDeclarativeImage::boundingRect() const +QRectF QDeclarative1Image::boundingRect() const { - Q_D(const QDeclarativeImage); + Q_D(const QDeclarative1Image); return QRectF(0, 0, qMax(d->mWidth, d->paintedWidth), qMax(d->mHeight, d->paintedHeight)); } @@ -491,9 +493,9 @@ QRectF QDeclarativeImage::boundingRect() const */ -void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) +void QDeclarative1Image::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { - Q_D(QDeclarativeImage); + Q_D(QDeclarative1Image); if (d->pix.pixmap().isNull() ) return; @@ -569,16 +571,18 @@ void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWi p->setWorldTransform(oldTransform); } -void QDeclarativeImage::pixmapChange() +void QDeclarative1Image::pixmapChange() { - Q_D(QDeclarativeImage); + Q_D(QDeclarative1Image); // PreserveAspectFit calculates the implicit size differently so we // don't call our superclass pixmapChange(), since that would // result in the implicit size being set incorrectly, then updated // in updatePaintedGeometry() if (d->fillMode != PreserveAspectFit) - QDeclarativeImageBase::pixmapChange(); + QDeclarative1ImageBase::pixmapChange(); updatePaintedGeometry(); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeimage_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativeimage_p.h rename to src/qtquick1/graphicsitems/qdeclarativeimage_p.h index 82c4396914..615587c384 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeimage_p.h @@ -51,8 +51,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeImagePrivate; -class Q_AUTOTEST_EXPORT QDeclarativeImage : public QDeclarativeImageBase +class QDeclarative1ImagePrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Image : public QDeclarative1ImageBase { Q_OBJECT Q_ENUMS(FillMode) @@ -62,8 +62,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeImage : public QDeclarativeImageBase Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged) public: - QDeclarativeImage(QDeclarativeItem *parent=0); - ~QDeclarativeImage(); + QDeclarative1Image(QDeclarativeItem *parent=0); + ~QDeclarative1Image(); enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally }; FillMode fillMode() const; @@ -83,18 +83,18 @@ class Q_AUTOTEST_EXPORT QDeclarativeImage : public QDeclarativeImageBase void paintedGeometryChanged(); protected: - QDeclarativeImage(QDeclarativeImagePrivate &dd, QDeclarativeItem *parent); + QDeclarative1Image(QDeclarative1ImagePrivate &dd, QDeclarativeItem *parent); void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); void pixmapChange(); void updatePaintedGeometry(); private: - Q_DISABLE_COPY(QDeclarativeImage) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImage) + Q_DISABLE_COPY(QDeclarative1Image) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Image) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeImage) +QML_DECLARE_TYPE(QDeclarative1Image) QT_END_HEADER #endif // QDECLARATIVEIMAGE_H diff --git a/src/declarative/graphicsitems/qdeclarativeimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeimage_p_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativeimage_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeimage_p_p.h index 29b004c9d6..19b8642892 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeimage_p_p.h @@ -58,17 +58,17 @@ QT_BEGIN_NAMESPACE -class QDeclarativeImagePrivate : public QDeclarativeImageBasePrivate +class QDeclarative1ImagePrivate : public QDeclarative1ImageBasePrivate { - Q_DECLARE_PUBLIC(QDeclarativeImage) + Q_DECLARE_PUBLIC(QDeclarative1Image) public: - QDeclarativeImagePrivate() - : fillMode(QDeclarativeImage::Stretch), paintedWidth(0), paintedHeight(0) + QDeclarative1ImagePrivate() + : fillMode(QDeclarative1Image::Stretch), paintedWidth(0), paintedHeight(0) { } - QDeclarativeImage::FillMode fillMode; + QDeclarative1Image::FillMode fillMode; qreal paintedWidth; qreal paintedHeight; void setPixmap(const QPixmap &pix); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/qtquick1/graphicsitems/qdeclarativeimagebase.cpp similarity index 66% rename from src/declarative/graphicsitems/qdeclarativeimagebase.cpp rename to src/qtquick1/graphicsitems/qdeclarativeimagebase.cpp index 92303fc051..a4f2f72d9f 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeimagebase.cpp @@ -39,67 +39,69 @@ ** ****************************************************************************/ -#include "private/qdeclarativeimagebase_p.h" -#include "private/qdeclarativeimagebase_p_p.h" +#include "QtQuick1/private/qdeclarativeimagebase_p.h" +#include "QtQuick1/private/qdeclarativeimagebase_p_p.h" -#include -#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE -QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeItem *parent) - : QDeclarativeImplicitSizeItem(*(new QDeclarativeImageBasePrivate), parent) + + +QDeclarative1ImageBase::QDeclarative1ImageBase(QDeclarativeItem *parent) + : QDeclarative1ImplicitSizeItem(*(new QDeclarative1ImageBasePrivate), parent) { } -QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent) - : QDeclarativeImplicitSizeItem(dd, parent) +QDeclarative1ImageBase::QDeclarative1ImageBase(QDeclarative1ImageBasePrivate &dd, QDeclarativeItem *parent) + : QDeclarative1ImplicitSizeItem(dd, parent) { } -QDeclarativeImageBase::~QDeclarativeImageBase() +QDeclarative1ImageBase::~QDeclarative1ImageBase() { } -QDeclarativeImageBase::Status QDeclarativeImageBase::status() const +QDeclarative1ImageBase::Status QDeclarative1ImageBase::status() const { - Q_D(const QDeclarativeImageBase); + Q_D(const QDeclarative1ImageBase); return d->status; } -qreal QDeclarativeImageBase::progress() const +qreal QDeclarative1ImageBase::progress() const { - Q_D(const QDeclarativeImageBase); + Q_D(const QDeclarative1ImageBase); return d->progress; } -bool QDeclarativeImageBase::asynchronous() const +bool QDeclarative1ImageBase::asynchronous() const { - Q_D(const QDeclarativeImageBase); + Q_D(const QDeclarative1ImageBase); return d->async; } -void QDeclarativeImageBase::setAsynchronous(bool async) +void QDeclarative1ImageBase::setAsynchronous(bool async) { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); if (d->async != async) { d->async = async; emit asynchronousChanged(); } } -QUrl QDeclarativeImageBase::source() const +QUrl QDeclarative1ImageBase::source() const { - Q_D(const QDeclarativeImageBase); + Q_D(const QDeclarative1ImageBase); return d->url; } -void QDeclarativeImageBase::setSource(const QUrl &url) +void QDeclarative1ImageBase::setSource(const QUrl &url) { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); //equality is fairly expensive, so we bypass for simple, common case if ((d->url.isEmpty() == url.isEmpty()) && url == d->url) return; @@ -111,9 +113,9 @@ void QDeclarativeImageBase::setSource(const QUrl &url) load(); } -void QDeclarativeImageBase::setSourceSize(const QSize& size) +void QDeclarative1ImageBase::setSourceSize(const QSize& size) { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); if (d->sourcesize == size) return; @@ -124,18 +126,18 @@ void QDeclarativeImageBase::setSourceSize(const QSize& size) load(); } -QSize QDeclarativeImageBase::sourceSize() const +QSize QDeclarative1ImageBase::sourceSize() const { - Q_D(const QDeclarativeImageBase); + Q_D(const QDeclarative1ImageBase); int width = d->sourcesize.width(); int height = d->sourcesize.height(); return QSize(width != -1 ? width : d->pix.width(), height != -1 ? height : d->pix.height()); } -void QDeclarativeImageBase::resetSourceSize() +void QDeclarative1ImageBase::resetSourceSize() { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); if (!d->explicitSourceSize) return; d->explicitSourceSize = false; @@ -145,15 +147,15 @@ void QDeclarativeImageBase::resetSourceSize() load(); } -bool QDeclarativeImageBase::cache() const +bool QDeclarative1ImageBase::cache() const { - Q_D(const QDeclarativeImageBase); + Q_D(const QDeclarative1ImageBase); return d->cache; } -void QDeclarativeImageBase::setCache(bool cache) +void QDeclarative1ImageBase::setCache(bool cache) { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); if (d->cache == cache) return; @@ -163,9 +165,9 @@ void QDeclarativeImageBase::setCache(bool cache) load(); } -void QDeclarativeImageBase::setMirror(bool mirror) +void QDeclarative1ImageBase::setMirror(bool mirror) { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); if (mirror == d->mirror) return; @@ -177,15 +179,15 @@ void QDeclarativeImageBase::setMirror(bool mirror) emit mirrorChanged(); } -bool QDeclarativeImageBase::mirror() const +bool QDeclarative1ImageBase::mirror() const { - Q_D(const QDeclarativeImageBase); + Q_D(const QDeclarative1ImageBase); return d->mirror; } -void QDeclarativeImageBase::load() +void QDeclarative1ImageBase::load() { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); if (d->url.isEmpty()) { d->pix.clear(this); @@ -196,11 +198,11 @@ void QDeclarativeImageBase::load() emit statusChanged(d->status); update(); } else { - QDeclarativePixmap::Options options; + QDeclarative1Pixmap::Options options; if (d->async) - options |= QDeclarativePixmap::Asynchronous; + options |= QDeclarative1Pixmap::Asynchronous; if (d->cache) - options |= QDeclarativePixmap::Cache; + options |= QDeclarative1Pixmap::Cache; d->pix.clear(this); d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), options); @@ -214,9 +216,9 @@ void QDeclarativeImageBase::load() static int thisRequestFinished = -1; if (thisRequestProgress == -1) { thisRequestProgress = - QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); + QDeclarative1ImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); thisRequestFinished = - QDeclarativeImageBase::staticMetaObject.indexOfSlot("requestFinished()"); + QDeclarative1ImageBase::staticMetaObject.indexOfSlot("requestFinished()"); } d->pix.connectFinished(this, thisRequestFinished); @@ -228,11 +230,11 @@ void QDeclarativeImageBase::load() } } -void QDeclarativeImageBase::requestFinished() +void QDeclarative1ImageBase::requestFinished() { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); - QDeclarativeImageBase::Status oldStatus = d->status; + QDeclarative1ImageBase::Status oldStatus = d->status; qreal oldProgress = d->progress; if (d->pix.isError()) { @@ -257,28 +259,30 @@ void QDeclarativeImageBase::requestFinished() update(); } -void QDeclarativeImageBase::requestProgress(qint64 received, qint64 total) +void QDeclarative1ImageBase::requestProgress(qint64 received, qint64 total) { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); if (d->status == Loading && total > 0) { d->progress = qreal(received)/total; emit progressChanged(d->progress); } } -void QDeclarativeImageBase::componentComplete() +void QDeclarative1ImageBase::componentComplete() { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); QDeclarativeItem::componentComplete(); if (d->url.isValid()) load(); } -void QDeclarativeImageBase::pixmapChange() +void QDeclarative1ImageBase::pixmapChange() { - Q_D(QDeclarativeImageBase); + Q_D(QDeclarative1ImageBase); setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h b/src/qtquick1/graphicsitems/qdeclarativeimagebase_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativeimagebase_p.h rename to src/qtquick1/graphicsitems/qdeclarativeimagebase_p.h index 4352299874..85af4a5d7f 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeimagebase_p.h @@ -48,8 +48,8 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QDeclarativeImageBasePrivate; -class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeImplicitSizeItem +class QDeclarative1ImageBasePrivate; +class Q_AUTOTEST_EXPORT QDeclarative1ImageBase : public QDeclarative1ImplicitSizeItem { Q_OBJECT Q_ENUMS(Status) @@ -63,8 +63,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeImplicitSizeI Q_PROPERTY(bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged REVISION 1) public: - QDeclarativeImageBase(QDeclarativeItem *parent=0); - ~QDeclarativeImageBase(); + QDeclarative1ImageBase(QDeclarativeItem *parent=0); + ~QDeclarative1ImageBase(); enum Status { Null, Ready, Loading, Error }; Status status() const; qreal progress() const; @@ -88,7 +88,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeImplicitSizeI Q_SIGNALS: void sourceChanged(const QUrl &); void sourceSizeChanged(); - void statusChanged(QDeclarativeImageBase::Status); + void statusChanged(QDeclarative1ImageBase::Status); void progressChanged(qreal progress); void asynchronousChanged(); Q_REVISION(1) void cacheChanged(); @@ -98,15 +98,15 @@ class Q_AUTOTEST_EXPORT QDeclarativeImageBase : public QDeclarativeImplicitSizeI virtual void load(); virtual void componentComplete(); virtual void pixmapChange(); - QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent); + QDeclarative1ImageBase(QDeclarative1ImageBasePrivate &dd, QDeclarativeItem *parent); private Q_SLOTS: virtual void requestFinished(); void requestProgress(qint64,qint64); private: - Q_DISABLE_COPY(QDeclarativeImageBase) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImageBase) + Q_DISABLE_COPY(QDeclarative1ImageBase) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ImageBase) }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeimagebase_p_p.h similarity index 88% rename from src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeimagebase_p_p.h index adff87f2e1..bccf953d1c 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeimagebase_p_p.h @@ -54,20 +54,21 @@ // #include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include "private/qdeclarativepixmapcache_p.h" +#include "QtQuick1/private/qdeclarativepixmapcache_p.h" #include QT_BEGIN_NAMESPACE class QNetworkReply; -class QDeclarativeImageBasePrivate : public QDeclarativeImplicitSizeItemPrivate + +class QDeclarative1ImageBasePrivate : public QDeclarative1ImplicitSizeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeImageBase) + Q_DECLARE_PUBLIC(QDeclarative1ImageBase) public: - QDeclarativeImageBasePrivate() - : status(QDeclarativeImageBase::Null), + QDeclarative1ImageBasePrivate() + : status(QDeclarative1ImageBase::Null), progress(0.0), explicitSourceSize(false), async(false), @@ -77,8 +78,8 @@ class QDeclarativeImageBasePrivate : public QDeclarativeImplicitSizeItemPrivate QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; } - QDeclarativePixmap pix; - QDeclarativeImageBase::Status status; + QDeclarative1Pixmap pix; + QDeclarative1ImageBase::Status status; QUrl url; qreal progress; QSize sourcesize; diff --git a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem.cpp b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem.cpp similarity index 61% rename from src/declarative/graphicsitems/qdeclarativeimplicitsizeitem.cpp rename to src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem.cpp index 8798d71073..08fdc83170 100644 --- a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem.cpp @@ -39,54 +39,58 @@ ** ****************************************************************************/ -#include "private/qdeclarativeimplicitsizeitem_p.h" -#include "private/qdeclarativeimplicitsizeitem_p_p.h" +#include "QtQuick1/private/qdeclarativeimplicitsizeitem_p.h" +#include "QtQuick1/private/qdeclarativeimplicitsizeitem_p_p.h" QT_BEGIN_NAMESPACE -void QDeclarativeImplicitSizeItemPrivate::implicitWidthChanged() + + +void QDeclarative1ImplicitSizeItemPrivate::implicitWidthChanged() { - Q_Q(QDeclarativeImplicitSizeItem); + Q_Q(QDeclarative1ImplicitSizeItem); emit q->implicitWidthChanged(); } -void QDeclarativeImplicitSizeItemPrivate::implicitHeightChanged() +void QDeclarative1ImplicitSizeItemPrivate::implicitHeightChanged() { - Q_Q(QDeclarativeImplicitSizeItem); + Q_Q(QDeclarative1ImplicitSizeItem); emit q->implicitHeightChanged(); } -QDeclarativeImplicitSizeItem::QDeclarativeImplicitSizeItem(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativeImplicitSizeItemPrivate), parent) +QDeclarative1ImplicitSizeItem::QDeclarative1ImplicitSizeItem(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1ImplicitSizeItemPrivate), parent) { } -QDeclarativeImplicitSizeItem::QDeclarativeImplicitSizeItem(QDeclarativeImplicitSizeItemPrivate &dd, QDeclarativeItem *parent) +QDeclarative1ImplicitSizeItem::QDeclarative1ImplicitSizeItem(QDeclarative1ImplicitSizeItemPrivate &dd, QDeclarativeItem *parent) : QDeclarativeItem(dd, parent) { } -void QDeclarativeImplicitSizePaintedItemPrivate::implicitWidthChanged() +void QDeclarative1ImplicitSizePaintedItemPrivate::implicitWidthChanged() { - Q_Q(QDeclarativeImplicitSizePaintedItem); + Q_Q(QDeclarative1ImplicitSizePaintedItem); emit q->implicitWidthChanged(); } -void QDeclarativeImplicitSizePaintedItemPrivate::implicitHeightChanged() +void QDeclarative1ImplicitSizePaintedItemPrivate::implicitHeightChanged() { - Q_Q(QDeclarativeImplicitSizePaintedItem); + Q_Q(QDeclarative1ImplicitSizePaintedItem); emit q->implicitHeightChanged(); } -QDeclarativeImplicitSizePaintedItem::QDeclarativeImplicitSizePaintedItem(QDeclarativeItem *parent) - : QDeclarativePaintedItem(*(new QDeclarativeImplicitSizePaintedItemPrivate), parent) +QDeclarative1ImplicitSizePaintedItem::QDeclarative1ImplicitSizePaintedItem(QDeclarativeItem *parent) + : QDeclarative1PaintedItem(*(new QDeclarative1ImplicitSizePaintedItemPrivate), parent) { } -QDeclarativeImplicitSizePaintedItem::QDeclarativeImplicitSizePaintedItem(QDeclarativeImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent) - : QDeclarativePaintedItem(dd, parent) +QDeclarative1ImplicitSizePaintedItem::QDeclarative1ImplicitSizePaintedItem(QDeclarative1ImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent) + : QDeclarative1PaintedItem(dd, parent) { } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p.h b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p.h similarity index 78% rename from src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p.h rename to src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p.h index 4770af275b..15275acba0 100644 --- a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p.h @@ -48,40 +48,40 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QDeclarativeImplicitSizeItemPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeImplicitSizeItem : public QDeclarativeItem +class QDeclarative1ImplicitSizeItemPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1ImplicitSizeItem : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged REVISION 1) Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged REVISION 1) public: - QDeclarativeImplicitSizeItem(QDeclarativeItem *parent = 0); + QDeclarative1ImplicitSizeItem(QDeclarativeItem *parent = 0); protected: - QDeclarativeImplicitSizeItem(QDeclarativeImplicitSizeItemPrivate &dd, QDeclarativeItem *parent); + QDeclarative1ImplicitSizeItem(QDeclarative1ImplicitSizeItemPrivate &dd, QDeclarativeItem *parent); Q_SIGNALS: Q_REVISION(1) void implicitWidthChanged(); Q_REVISION(1) void implicitHeightChanged(); private: - Q_DISABLE_COPY(QDeclarativeImplicitSizeItem) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImplicitSizeItem) + Q_DISABLE_COPY(QDeclarative1ImplicitSizeItem) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ImplicitSizeItem) }; -class QDeclarativeImplicitSizePaintedItemPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeImplicitSizePaintedItem : public QDeclarativePaintedItem +class QDeclarative1ImplicitSizePaintedItemPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1ImplicitSizePaintedItem : public QDeclarative1PaintedItem { Q_OBJECT Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged REVISION 1) Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged REVISION 1) public: - QDeclarativeImplicitSizePaintedItem(QDeclarativeItem *parent = 0); + QDeclarative1ImplicitSizePaintedItem(QDeclarativeItem *parent = 0); protected: - QDeclarativeImplicitSizePaintedItem(QDeclarativeImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent); + QDeclarative1ImplicitSizePaintedItem(QDeclarative1ImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent); virtual void drawContents(QPainter *, const QRect &) {}; Q_SIGNALS: @@ -89,8 +89,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeImplicitSizePaintedItem : public QDeclarativ Q_REVISION(1) void implicitHeightChanged(); private: - Q_DISABLE_COPY(QDeclarativeImplicitSizePaintedItem) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeImplicitSizePaintedItem) + Q_DISABLE_COPY(QDeclarative1ImplicitSizePaintedItem) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ImplicitSizePaintedItem) }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h similarity index 86% rename from src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h index b96bf98d4c..4802b2754d 100644 --- a/src/declarative/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h @@ -58,12 +58,12 @@ QT_BEGIN_NAMESPACE -class QDeclarativeImplicitSizeItemPrivate : public QDeclarativeItemPrivate +class QDeclarative1ImplicitSizeItemPrivate : public QDeclarativeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeImplicitSizeItem) + Q_DECLARE_PUBLIC(QDeclarative1ImplicitSizeItem) public: - QDeclarativeImplicitSizeItemPrivate() + QDeclarative1ImplicitSizeItemPrivate() { } @@ -72,12 +72,12 @@ class QDeclarativeImplicitSizeItemPrivate : public QDeclarativeItemPrivate }; -class QDeclarativeImplicitSizePaintedItemPrivate : public QDeclarativePaintedItemPrivate +class QDeclarative1ImplicitSizePaintedItemPrivate : public QDeclarative1PaintedItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeImplicitSizePaintedItem) + Q_DECLARE_PUBLIC(QDeclarative1ImplicitSizePaintedItem) public: - QDeclarativeImplicitSizePaintedItemPrivate() + QDeclarative1ImplicitSizePaintedItemPrivate() { } diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/qtquick1/graphicsitems/qdeclarativeitem.cpp similarity index 92% rename from src/declarative/graphicsitems/qdeclarativeitem.cpp rename to src/qtquick1/graphicsitems/qdeclarativeitem.cpp index 87e058037f..46cfe526e4 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeitem.cpp @@ -39,20 +39,20 @@ ** ****************************************************************************/ -#include "qdeclarativeitem.h" +#include "QtQuick1/qdeclarativeitem.h" -#include "private/qdeclarativeevents_p_p.h" -#include +#include "QtQuick1/private/qdeclarativeevents_p_p.h" +#include #include -#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -61,7 +61,6 @@ #include #include #include -#include #include @@ -92,7 +91,7 @@ QT_BEGIN_NAMESPACE */ /*! - \qmlclass Translate QDeclarativeTranslate + \qmlclass Translate QDeclarative1Translate \ingroup qml-transform-elements \since 4.7 \brief The Translate object provides a way to move an Item without changing its x or y properties. @@ -231,13 +230,13 @@ QT_BEGIN_NAMESPACE The angle to rotate, in degrees clockwise. */ -QDeclarativeContents::QDeclarativeContents(QDeclarativeItem *item) : m_item(item), m_x(0), m_y(0), m_width(0), m_height(0) +QDeclarative1Contents::QDeclarative1Contents(QDeclarativeItem *item) : m_item(item), m_x(0), m_y(0), m_width(0), m_height(0) { //### optimize connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); } -QDeclarativeContents::~QDeclarativeContents() +QDeclarative1Contents::~QDeclarative1Contents() { QList children = m_item->childItems(); for (int i = 0; i < children.count(); ++i) { @@ -248,12 +247,12 @@ QDeclarativeContents::~QDeclarativeContents() } } -QRectF QDeclarativeContents::rectF() const +QRectF QDeclarative1Contents::rectF() const { return QRectF(m_x, m_y, m_width, m_height); } -void QDeclarativeContents::calcHeight(QDeclarativeItem *changed) +void QDeclarative1Contents::calcHeight(QDeclarativeItem *changed) { qreal oldy = m_y; qreal oldheight = m_height; @@ -291,7 +290,7 @@ void QDeclarativeContents::calcHeight(QDeclarativeItem *changed) emit rectChanged(rectF()); } -void QDeclarativeContents::calcWidth(QDeclarativeItem *changed) +void QDeclarative1Contents::calcWidth(QDeclarativeItem *changed) { qreal oldx = m_x; qreal oldwidth = m_width; @@ -329,7 +328,7 @@ void QDeclarativeContents::calcWidth(QDeclarativeItem *changed) emit rectChanged(rectF()); } -void QDeclarativeContents::complete() +void QDeclarative1Contents::complete() { QList children = m_item->childItems(); for (int i = 0; i < children.count(); ++i) { @@ -343,7 +342,7 @@ void QDeclarativeContents::complete() calcGeometry(); } -void QDeclarativeContents::itemGeometryChanged(QDeclarativeItem *changed, const QRectF &newGeometry, const QRectF &oldGeometry) +void QDeclarative1Contents::itemGeometryChanged(QDeclarativeItem *changed, const QRectF &newGeometry, const QRectF &oldGeometry) { Q_UNUSED(changed) //### we can only pass changed if the left edge has moved left, or the right edge has moved right @@ -353,21 +352,21 @@ void QDeclarativeContents::itemGeometryChanged(QDeclarativeItem *changed, const calcHeight(/*changed*/); } -void QDeclarativeContents::itemDestroyed(QDeclarativeItem *item) +void QDeclarative1Contents::itemDestroyed(QDeclarativeItem *item) { if (item) QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); calcGeometry(); } -void QDeclarativeContents::childRemoved(QDeclarativeItem *item) +void QDeclarative1Contents::childRemoved(QDeclarativeItem *item) { if (item) QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); calcGeometry(); } -void QDeclarativeContents::childAdded(QDeclarativeItem *item) +void QDeclarative1Contents::childAdded(QDeclarativeItem *item) { if (item) QDeclarativeItemPrivate::get(item)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); @@ -418,7 +417,7 @@ void QDeclarativeItemKeyFilter::componentComplete() /*! - \qmlclass KeyNavigation QDeclarativeKeyNavigationAttached + \qmlclass KeyNavigation QDeclarative1KeyNavigationAttached \ingroup qml-basic-interaction-elements \since 4.7 \brief The KeyNavigation attached property supports key navigation by arrow keys. @@ -481,34 +480,34 @@ void QDeclarativeItemKeyFilter::componentComplete() when the Tab key or Shift+Tab key combination (Backtab) are pressed. */ -QDeclarativeKeyNavigationAttached::QDeclarativeKeyNavigationAttached(QObject *parent) -: QObject(*(new QDeclarativeKeyNavigationAttachedPrivate), parent), +QDeclarative1KeyNavigationAttached::QDeclarative1KeyNavigationAttached(QObject *parent) +: QObject(*(new QDeclarative1KeyNavigationAttachedPrivate), parent), QDeclarativeItemKeyFilter(qobject_cast(parent)) { m_processPost = true; } -QDeclarativeKeyNavigationAttached * -QDeclarativeKeyNavigationAttached::qmlAttachedProperties(QObject *obj) +QDeclarative1KeyNavigationAttached * +QDeclarative1KeyNavigationAttached::qmlAttachedProperties(QObject *obj) { - return new QDeclarativeKeyNavigationAttached(obj); + return new QDeclarative1KeyNavigationAttached(obj); } -QDeclarativeItem *QDeclarativeKeyNavigationAttached::left() const +QDeclarativeItem *QDeclarative1KeyNavigationAttached::left() const { - Q_D(const QDeclarativeKeyNavigationAttached); + Q_D(const QDeclarative1KeyNavigationAttached); return d->left; } -void QDeclarativeKeyNavigationAttached::setLeft(QDeclarativeItem *i) +void QDeclarative1KeyNavigationAttached::setLeft(QDeclarativeItem *i) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); if (d->left == i) return; d->left = i; d->leftSet = true; - QDeclarativeKeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); + QDeclarative1KeyNavigationAttached* other = + qobject_cast(qmlAttachedPropertiesObject(i)); if(other && !other->d_func()->rightSet){ other->d_func()->right = qobject_cast(parent()); emit other->rightChanged(); @@ -516,21 +515,21 @@ void QDeclarativeKeyNavigationAttached::setLeft(QDeclarativeItem *i) emit leftChanged(); } -QDeclarativeItem *QDeclarativeKeyNavigationAttached::right() const +QDeclarativeItem *QDeclarative1KeyNavigationAttached::right() const { - Q_D(const QDeclarativeKeyNavigationAttached); + Q_D(const QDeclarative1KeyNavigationAttached); return d->right; } -void QDeclarativeKeyNavigationAttached::setRight(QDeclarativeItem *i) +void QDeclarative1KeyNavigationAttached::setRight(QDeclarativeItem *i) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); if (d->right == i) return; d->right = i; d->rightSet = true; - QDeclarativeKeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); + QDeclarative1KeyNavigationAttached* other = + qobject_cast(qmlAttachedPropertiesObject(i)); if(other && !other->d_func()->leftSet){ other->d_func()->left = qobject_cast(parent()); emit other->leftChanged(); @@ -538,21 +537,21 @@ void QDeclarativeKeyNavigationAttached::setRight(QDeclarativeItem *i) emit rightChanged(); } -QDeclarativeItem *QDeclarativeKeyNavigationAttached::up() const +QDeclarativeItem *QDeclarative1KeyNavigationAttached::up() const { - Q_D(const QDeclarativeKeyNavigationAttached); + Q_D(const QDeclarative1KeyNavigationAttached); return d->up; } -void QDeclarativeKeyNavigationAttached::setUp(QDeclarativeItem *i) +void QDeclarative1KeyNavigationAttached::setUp(QDeclarativeItem *i) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); if (d->up == i) return; d->up = i; d->upSet = true; - QDeclarativeKeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); + QDeclarative1KeyNavigationAttached* other = + qobject_cast(qmlAttachedPropertiesObject(i)); if(other && !other->d_func()->downSet){ other->d_func()->down = qobject_cast(parent()); emit other->downChanged(); @@ -560,21 +559,21 @@ void QDeclarativeKeyNavigationAttached::setUp(QDeclarativeItem *i) emit upChanged(); } -QDeclarativeItem *QDeclarativeKeyNavigationAttached::down() const +QDeclarativeItem *QDeclarative1KeyNavigationAttached::down() const { - Q_D(const QDeclarativeKeyNavigationAttached); + Q_D(const QDeclarative1KeyNavigationAttached); return d->down; } -void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i) +void QDeclarative1KeyNavigationAttached::setDown(QDeclarativeItem *i) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); if (d->down == i) return; d->down = i; d->downSet = true; - QDeclarativeKeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); + QDeclarative1KeyNavigationAttached* other = + qobject_cast(qmlAttachedPropertiesObject(i)); if(other && !other->d_func()->upSet){ other->d_func()->up = qobject_cast(parent()); emit other->upChanged(); @@ -582,21 +581,21 @@ void QDeclarativeKeyNavigationAttached::setDown(QDeclarativeItem *i) emit downChanged(); } -QDeclarativeItem *QDeclarativeKeyNavigationAttached::tab() const +QDeclarativeItem *QDeclarative1KeyNavigationAttached::tab() const { - Q_D(const QDeclarativeKeyNavigationAttached); + Q_D(const QDeclarative1KeyNavigationAttached); return d->tab; } -void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i) +void QDeclarative1KeyNavigationAttached::setTab(QDeclarativeItem *i) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); if (d->tab == i) return; d->tab = i; d->tabSet = true; - QDeclarativeKeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); + QDeclarative1KeyNavigationAttached* other = + qobject_cast(qmlAttachedPropertiesObject(i)); if(other && !other->d_func()->backtabSet){ other->d_func()->backtab = qobject_cast(parent()); emit other->backtabChanged(); @@ -604,21 +603,21 @@ void QDeclarativeKeyNavigationAttached::setTab(QDeclarativeItem *i) emit tabChanged(); } -QDeclarativeItem *QDeclarativeKeyNavigationAttached::backtab() const +QDeclarativeItem *QDeclarative1KeyNavigationAttached::backtab() const { - Q_D(const QDeclarativeKeyNavigationAttached); + Q_D(const QDeclarative1KeyNavigationAttached); return d->backtab; } -void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i) +void QDeclarative1KeyNavigationAttached::setBacktab(QDeclarativeItem *i) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); if (d->backtab == i) return; d->backtab = i; d->backtabSet = true; - QDeclarativeKeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); + QDeclarative1KeyNavigationAttached* other = + qobject_cast(qmlAttachedPropertiesObject(i)); if(other && !other->d_func()->tabSet){ other->d_func()->tab = qobject_cast(parent()); emit other->tabChanged(); @@ -641,12 +640,12 @@ void QDeclarativeKeyNavigationAttached::setBacktab(QDeclarativeItem *i) handled by the KeyNavigation attached property handler. \endlist */ -QDeclarativeKeyNavigationAttached::Priority QDeclarativeKeyNavigationAttached::priority() const +QDeclarative1KeyNavigationAttached::Priority QDeclarative1KeyNavigationAttached::priority() const { return m_processPost ? AfterItem : BeforeItem; } -void QDeclarativeKeyNavigationAttached::setPriority(Priority order) +void QDeclarative1KeyNavigationAttached::setPriority(Priority order) { bool processPost = order == AfterItem; if (processPost != m_processPost) { @@ -655,9 +654,9 @@ void QDeclarativeKeyNavigationAttached::setPriority(Priority order) } } -void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event, bool post) +void QDeclarative1KeyNavigationAttached::keyPressed(QKeyEvent *event, bool post) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); event->ignore(); if (post != m_processPost) { @@ -718,9 +717,9 @@ void QDeclarativeKeyNavigationAttached::keyPressed(QKeyEvent *event, bool post) if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); } -void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) +void QDeclarative1KeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) { - Q_D(QDeclarativeKeyNavigationAttached); + Q_D(QDeclarative1KeyNavigationAttached); event->ignore(); if (post != m_processPost) { @@ -769,7 +768,7 @@ void QDeclarativeKeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); } -void QDeclarativeKeyNavigationAttached::setFocusNavigation(QDeclarativeItem *currentItem, const char *dir) +void QDeclarative1KeyNavigationAttached::setFocusNavigation(QDeclarativeItem *currentItem, const char *dir) { QDeclarativeItem *initialItem = currentItem; bool isNextItem = false; @@ -779,7 +778,7 @@ void QDeclarativeKeyNavigationAttached::setFocusNavigation(QDeclarativeItem *cur currentItem->setFocus(true); } else { QObject *attached = - qmlAttachedPropertiesObject(currentItem, false); + qmlAttachedPropertiesObject(currentItem, false); if (attached) { QDeclarativeItem *tempItem = qvariant_cast(attached->property(dir)); if (tempItem) { @@ -793,7 +792,7 @@ void QDeclarativeKeyNavigationAttached::setFocusNavigation(QDeclarativeItem *cur } /*! - \qmlclass LayoutMirroring QDeclarativeLayoutMirroringAttached + \qmlclass LayoutMirroring QDeclarative1LayoutMirroringAttached \since QtQuick 1.1 \ingroup qml-utility-elements \brief The LayoutMirroring attached property is used to mirror layout behavior. @@ -855,7 +854,7 @@ void QDeclarativeKeyNavigationAttached::setFocusNavigation(QDeclarativeItem *cur The default value is false. */ -QDeclarativeLayoutMirroringAttached::QDeclarativeLayoutMirroringAttached(QObject *parent) : QObject(parent), itemPrivate(0) +QDeclarative1LayoutMirroringAttached::QDeclarative1LayoutMirroringAttached(QObject *parent) : QObject(parent), itemPrivate(0) { if (QDeclarativeItem *item = qobject_cast(parent)) { itemPrivate = QDeclarativeItemPrivate::get(item); @@ -864,17 +863,17 @@ QDeclarativeLayoutMirroringAttached::QDeclarativeLayoutMirroringAttached(QObject qmlInfo(parent) << tr("LayoutDirection attached property only works with Items"); } -QDeclarativeLayoutMirroringAttached * QDeclarativeLayoutMirroringAttached::qmlAttachedProperties(QObject *object) +QDeclarative1LayoutMirroringAttached * QDeclarative1LayoutMirroringAttached::qmlAttachedProperties(QObject *object) { - return new QDeclarativeLayoutMirroringAttached(object); + return new QDeclarative1LayoutMirroringAttached(object); } -bool QDeclarativeLayoutMirroringAttached::enabled() const +bool QDeclarative1LayoutMirroringAttached::enabled() const { return itemPrivate ? itemPrivate->effectiveLayoutMirror : false; } -void QDeclarativeLayoutMirroringAttached::setEnabled(bool enabled) +void QDeclarative1LayoutMirroringAttached::setEnabled(bool enabled) { if (!itemPrivate) return; @@ -887,7 +886,7 @@ void QDeclarativeLayoutMirroringAttached::setEnabled(bool enabled) } } -void QDeclarativeLayoutMirroringAttached::resetEnabled() +void QDeclarative1LayoutMirroringAttached::resetEnabled() { if (itemPrivate && !itemPrivate->isMirrorImplicit) { itemPrivate->isMirrorImplicit = true; @@ -895,12 +894,12 @@ void QDeclarativeLayoutMirroringAttached::resetEnabled() } } -bool QDeclarativeLayoutMirroringAttached::childrenInherit() const +bool QDeclarative1LayoutMirroringAttached::childrenInherit() const { return itemPrivate ? itemPrivate->inheritMirrorFromItem : false; } -void QDeclarativeLayoutMirroringAttached::setChildrenInherit(bool childrenInherit) { +void QDeclarative1LayoutMirroringAttached::setChildrenInherit(bool childrenInherit) { if (itemPrivate && childrenInherit != itemPrivate->inheritMirrorFromItem) { itemPrivate->inheritMirrorFromItem = childrenInherit; itemPrivate->resolveLayoutMirror(); @@ -958,7 +957,7 @@ void QDeclarativeItemPrivate::setLayoutMirror(bool mirror) } /*! - \qmlclass Keys QDeclarativeKeysAttached + \qmlclass Keys QDeclarative1KeysAttached \ingroup qml-basic-interaction-elements \since 4.7 \brief The Keys attached property provides key handling to Items. @@ -1344,7 +1343,7 @@ void QDeclarativeItemPrivate::setLayoutMirror(bool mirror) parameter provides information about the event. */ -const QDeclarativeKeysAttached::SigMap QDeclarativeKeysAttached::sigMap[] = { +const QDeclarative1KeysAttached::SigMap QDeclarative1KeysAttached::sigMap[] = { { Qt::Key_Left, "leftPressed" }, { Qt::Key_Right, "rightPressed" }, { Qt::Key_Up, "upPressed" }, @@ -1376,30 +1375,30 @@ const QDeclarativeKeysAttached::SigMap QDeclarativeKeysAttached::sigMap[] = { { 0, 0 } }; -bool QDeclarativeKeysAttachedPrivate::isConnected(const char *signalName) +bool QDeclarative1KeysAttachedPrivate::isConnected(const char *signalName) { return isSignalConnected(signalIndex(signalName)); } -QDeclarativeKeysAttached::QDeclarativeKeysAttached(QObject *parent) -: QObject(*(new QDeclarativeKeysAttachedPrivate), parent), +QDeclarative1KeysAttached::QDeclarative1KeysAttached(QObject *parent) +: QObject(*(new QDeclarative1KeysAttachedPrivate), parent), QDeclarativeItemKeyFilter(qobject_cast(parent)) { - Q_D(QDeclarativeKeysAttached); + Q_D(QDeclarative1KeysAttached); m_processPost = false; d->item = qobject_cast(parent); } -QDeclarativeKeysAttached::~QDeclarativeKeysAttached() +QDeclarative1KeysAttached::~QDeclarative1KeysAttached() { } -QDeclarativeKeysAttached::Priority QDeclarativeKeysAttached::priority() const +QDeclarative1KeysAttached::Priority QDeclarative1KeysAttached::priority() const { return m_processPost ? AfterItem : BeforeItem; } -void QDeclarativeKeysAttached::setPriority(Priority order) +void QDeclarative1KeysAttached::setPriority(Priority order) { bool processPost = order == AfterItem; if (processPost != m_processPost) { @@ -1408,9 +1407,9 @@ void QDeclarativeKeysAttached::setPriority(Priority order) } } -void QDeclarativeKeysAttached::componentComplete() +void QDeclarative1KeysAttached::componentComplete() { - Q_D(QDeclarativeKeysAttached); + Q_D(QDeclarative1KeysAttached); if (d->item) { for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *targetItem = d->finalFocusProxy(d->targets.at(ii)); @@ -1422,9 +1421,9 @@ void QDeclarativeKeysAttached::componentComplete() } } -void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event, bool post) +void QDeclarative1KeysAttached::keyPressed(QKeyEvent *event, bool post) { - Q_D(QDeclarativeKeysAttached); + Q_D(QDeclarative1KeysAttached); if (post != m_processPost || !d->enabled || d->inPress) { event->ignore(); QDeclarativeItemKeyFilter::keyPressed(event, post); @@ -1447,15 +1446,15 @@ void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event, bool post) d->inPress = false; } - QDeclarativeKeyEvent ke(*event); + QDeclarative1KeyEvent ke(*event); QByteArray keySignal = keyToSignal(event->key()); if (!keySignal.isEmpty()) { - keySignal += "(QDeclarativeKeyEvent*)"; + keySignal += "(QDeclarative1KeyEvent*)"; if (d->isConnected(keySignal)) { // If we specifically handle a key then default to accepted ke.setAccepted(true); - int idx = QDeclarativeKeysAttached::staticMetaObject.indexOfSignal(keySignal); - metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QDeclarativeKeyEvent*, &ke)); + int idx = QDeclarative1KeysAttached::staticMetaObject.indexOfSignal(keySignal); + metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QDeclarative1KeyEvent*, &ke)); } } if (!ke.isAccepted()) @@ -1465,9 +1464,9 @@ void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event, bool post) if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); } -void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event, bool post) +void QDeclarative1KeysAttached::keyReleased(QKeyEvent *event, bool post) { - Q_D(QDeclarativeKeysAttached); + Q_D(QDeclarative1KeysAttached); if (post != m_processPost || !d->enabled || d->inRelease) { event->ignore(); QDeclarativeItemKeyFilter::keyReleased(event, post); @@ -1489,16 +1488,16 @@ void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event, bool post) d->inRelease = false; } - QDeclarativeKeyEvent ke(*event); + QDeclarative1KeyEvent ke(*event); emit released(&ke); event->setAccepted(ke.isAccepted()); if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); } -void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) +void QDeclarative1KeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) { - Q_D(QDeclarativeKeysAttached); + Q_D(QDeclarative1KeysAttached); if (post == m_processPost && d->item && !d->inIM && d->item->scene()) { d->inIM = true; for (int ii = 0; ii < d->targets.count(); ++ii) { @@ -1525,9 +1524,9 @@ class QDeclarativeItemAccessor : public QGraphicsItem } }; -QVariant QDeclarativeKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const +QVariant QDeclarative1KeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const { - Q_D(const QDeclarativeKeysAttached); + Q_D(const QDeclarative1KeysAttached); if (d->item) { for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); @@ -1542,9 +1541,9 @@ QVariant QDeclarativeKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) return QDeclarativeItemKeyFilter::inputMethodQuery(query); } -QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObject *obj) +QDeclarative1KeysAttached *QDeclarative1KeysAttached::qmlAttachedProperties(QObject *obj) { - return new QDeclarativeKeysAttached(obj); + return new QDeclarative1KeysAttached(obj); } /*! @@ -1676,12 +1675,14 @@ QDeclarativeKeysAttached *QDeclarativeKeysAttached::qmlAttachedProperties(QObjec */ // ### Must fix +namespace { struct RegisterAnchorLineAtStartup { RegisterAnchorLineAtStartup() { - qRegisterMetaType("QDeclarativeAnchorLine"); + qRegisterMetaType("QDeclarative1AnchorLine"); } }; static RegisterAnchorLineAtStartup registerAnchorLineAtStartup; +} /*! @@ -1712,13 +1713,13 @@ QDeclarativeItem::~QDeclarativeItem() { Q_D(QDeclarativeItem); for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - QDeclarativeAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); + QDeclarative1AnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); if (anchor) anchor->clearItem(this); } if (!d->parent || (parentItem() && !parentItem()->QGraphicsItem::d_ptr->inDestructor)) { for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - QDeclarativeAnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); + QDeclarative1AnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); if (anchor && anchor->item && anchor->item->parentItem() != this) //child will be deleted anyway anchor->updateOnComplete(); } @@ -2037,7 +2038,7 @@ QRectF QDeclarativeItem::childrenRect() { Q_D(QDeclarativeItem); if (!d->_contents) { - d->_contents = new QDeclarativeContents(this); + d->_contents = new QDeclarative1Contents(this); if (d->componentComplete) d->_contents->complete(); } @@ -2311,7 +2312,7 @@ void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItemPrivate::left() const +QDeclarative1AnchorLine QDeclarativeItemPrivate::left() const { return anchorLines()->left; } @@ -2319,7 +2320,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::left() const /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItemPrivate::right() const +QDeclarative1AnchorLine QDeclarativeItemPrivate::right() const { return anchorLines()->right; } @@ -2327,7 +2328,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::right() const /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItemPrivate::horizontalCenter() const +QDeclarative1AnchorLine QDeclarativeItemPrivate::horizontalCenter() const { return anchorLines()->hCenter; } @@ -2335,7 +2336,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::horizontalCenter() const /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItemPrivate::top() const +QDeclarative1AnchorLine QDeclarativeItemPrivate::top() const { return anchorLines()->top; } @@ -2343,7 +2344,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::top() const /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItemPrivate::bottom() const +QDeclarative1AnchorLine QDeclarativeItemPrivate::bottom() const { return anchorLines()->bottom; } @@ -2351,7 +2352,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::bottom() const /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItemPrivate::verticalCenter() const +QDeclarative1AnchorLine QDeclarativeItemPrivate::verticalCenter() const { return anchorLines()->vCenter; } @@ -2360,7 +2361,7 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::verticalCenter() const /*! \internal */ -QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const +QDeclarative1AnchorLine QDeclarativeItemPrivate::baseline() const { return anchorLines()->baseline; } @@ -2482,7 +2483,7 @@ void QDeclarativeItem::setBaselineOffset(qreal offset) for(int ii = 0; ii < d->changeListeners.count(); ++ii) { const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); if (change.types & QDeclarativeItemPrivate::Geometry) { - QDeclarativeAnchorsPrivate *anchor = change.listener->anchorPrivate(); + QDeclarative1AnchorsPrivate *anchor = change.listener->anchorPrivate(); if (anchor) anchor->updateVerticalAnchors(); } @@ -2814,7 +2815,7 @@ QDeclarativeListProperty QDeclarativeItemPrivate::resources() \sa {qmlstate}{States} */ -QDeclarativeListProperty QDeclarativeItemPrivate::states() +QDeclarativeListProperty QDeclarativeItemPrivate::states() { return _states()->statesProperty(); } @@ -2841,7 +2842,7 @@ QDeclarativeListProperty QDeclarativeItemPrivate::states() */ -QDeclarativeListProperty QDeclarativeItemPrivate::transitions() +QDeclarativeListProperty QDeclarativeItemPrivate::transitions() { return _states()->transitionsProperty(); } @@ -2987,11 +2988,11 @@ void QDeclarativeItem::componentComplete() d->_contents->complete(); } -QDeclarativeStateGroup *QDeclarativeItemPrivate::_states() +QDeclarative1StateGroup *QDeclarativeItemPrivate::_states() { Q_Q(QDeclarativeItem); if (!_stateGroup) { - _stateGroup = new QDeclarativeStateGroup; + _stateGroup = new QDeclarative1StateGroup; if (!componentComplete) _stateGroup->classBegin(); QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)), @@ -3004,19 +3005,19 @@ QDeclarativeStateGroup *QDeclarativeItemPrivate::_states() QDeclarativeItemPrivate::AnchorLines::AnchorLines(QGraphicsObject *q) { left.item = q; - left.anchorLine = QDeclarativeAnchorLine::Left; + left.anchorLine = QDeclarative1AnchorLine::Left; right.item = q; - right.anchorLine = QDeclarativeAnchorLine::Right; + right.anchorLine = QDeclarative1AnchorLine::Right; hCenter.item = q; - hCenter.anchorLine = QDeclarativeAnchorLine::HCenter; + hCenter.anchorLine = QDeclarative1AnchorLine::HCenter; top.item = q; - top.anchorLine = QDeclarativeAnchorLine::Top; + top.anchorLine = QDeclarative1AnchorLine::Top; bottom.item = q; - bottom.anchorLine = QDeclarativeAnchorLine::Bottom; + bottom.anchorLine = QDeclarative1AnchorLine::Bottom; vCenter.item = q; - vCenter.anchorLine = QDeclarativeAnchorLine::VCenter; + vCenter.anchorLine = QDeclarative1AnchorLine::VCenter; baseline.item = q; - baseline.anchorLine = QDeclarativeAnchorLine::Baseline; + baseline.anchorLine = QDeclarative1AnchorLine::Baseline; } QPointF QDeclarativeItemPrivate::computeTransformOrigin() const @@ -3763,7 +3764,7 @@ void QDeclarativeItemPrivate::setConsistentTime(qint64 t) consistentTime = t; } -class QElapsedTimerConsistentTimeHack +class QElapsedTimerConsistentTimeHack_1 { public: void start() { @@ -3790,7 +3791,7 @@ void QDeclarativeItemPrivate::start(QElapsedTimer &t) if (QDeclarativeItemPrivate::consistentTime == -1) t.start(); else - ((QElapsedTimerConsistentTimeHack*)&t)->start(); + ((QElapsedTimerConsistentTimeHack_1*)&t)->start(); } qint64 QDeclarativeItemPrivate::elapsed(QElapsedTimer &t) @@ -3798,7 +3799,7 @@ qint64 QDeclarativeItemPrivate::elapsed(QElapsedTimer &t) if (QDeclarativeItemPrivate::consistentTime == -1) return t.elapsed(); else - return ((QElapsedTimerConsistentTimeHack*)&t)->elapsed(); + return ((QElapsedTimerConsistentTimeHack_1*)&t)->elapsed(); } qint64 QDeclarativeItemPrivate::restart(QElapsedTimer &t) @@ -3806,7 +3807,7 @@ qint64 QDeclarativeItemPrivate::restart(QElapsedTimer &t) if (QDeclarativeItemPrivate::consistentTime == -1) return t.restart(); else - return ((QElapsedTimerConsistentTimeHack*)&t)->restart(); + return ((QElapsedTimerConsistentTimeHack_1*)&t)->restart(); } QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/qtquick1/graphicsitems/qdeclarativeitem.h similarity index 86% rename from src/declarative/graphicsitems/qdeclarativeitem.h rename to src/qtquick1/graphicsitems/qdeclarativeitem.h index 1bb9b3de42..a3f4931316 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/qtquick1/graphicsitems/qdeclarativeitem.h @@ -58,11 +58,11 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeState; -class QDeclarativeAnchorLine; -class QDeclarativeTransition; -class QDeclarativeKeyEvent; -class QDeclarativeAnchors; +class QDeclarative1State; +class QDeclarative1AnchorLine; +class QDeclarative1Transition; +class QDeclarative1KeyEvent; +class QDeclarative1Anchors; class QDeclarativeItemPrivate; class QDeclarativeV8Function; class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDeclarativeParserStatus @@ -73,18 +73,18 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItem : public QGraphicsObject, public QDe Q_PROPERTY(QDeclarativeItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL) Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty data READ data DESIGNABLE false) Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty resources READ resources DESIGNABLE false) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty states READ states DESIGNABLE false) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty transitions READ transitions DESIGNABLE false) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty states READ states DESIGNABLE false) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty transitions READ transitions DESIGNABLE false) Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine left READ left CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine right READ right CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine top READ top CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine bottom READ bottom CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeAnchorLine baseline READ baseline CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1Anchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine left READ left CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine right READ right CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine top READ top CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine bottom READ bottom CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) + Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine baseline READ baseline CONSTANT FINAL) Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/qtquick1/graphicsitems/qdeclarativeitem_p.h similarity index 74% rename from src/declarative/graphicsitems/qdeclarativeitem_p.h rename to src/qtquick1/graphicsitems/qdeclarativeitem_p.h index 80131d137a..58d57abbf3 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeitem_p.h @@ -53,22 +53,23 @@ // We mean it. // -#include "qdeclarativeitem.h" +#include "QtQuick1/qdeclarativeitem.h" -#include "private/qdeclarativeanchors_p.h" -#include "private/qdeclarativeanchors_p_p.h" -#include "private/qdeclarativeitemchangelistener_p.h" -#include +#include "QtQuick1/private/qdeclarativeanchors_p.h" +#include "QtQuick1/private/qdeclarativeanchors_p_p.h" +#include "QtQuick1/private/qdeclarativeitemchangelistener_p.h" +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include #include +#include #include #include @@ -76,16 +77,17 @@ QT_BEGIN_NAMESPACE class QNetworkReply; + class QDeclarativeItemKeyFilter; -class QDeclarativeLayoutMirroringAttached; +class QDeclarative1LayoutMirroringAttached; //### merge into private? -class QDeclarativeContents : public QObject, public QDeclarativeItemChangeListener +class QDeclarative1Contents : public QObject, public QDeclarativeItemChangeListener { Q_OBJECT public: - QDeclarativeContents(QDeclarativeItem *item); - ~QDeclarativeContents(); + QDeclarative1Contents(QDeclarativeItem *item); + ~QDeclarative1Contents(); QRectF rectF() const; @@ -177,19 +179,19 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate QDeclarativeListProperty data(); QDeclarativeListProperty resources(); - QDeclarativeListProperty states(); - QDeclarativeListProperty transitions(); + QDeclarativeListProperty states(); + QDeclarativeListProperty transitions(); QString state() const; void setState(const QString &); - QDeclarativeAnchorLine left() const; - QDeclarativeAnchorLine right() const; - QDeclarativeAnchorLine horizontalCenter() const; - QDeclarativeAnchorLine top() const; - QDeclarativeAnchorLine bottom() const; - QDeclarativeAnchorLine verticalCenter() const; - QDeclarativeAnchorLine baseline() const; + QDeclarative1AnchorLine left() const; + QDeclarative1AnchorLine right() const; + QDeclarative1AnchorLine horizontalCenter() const; + QDeclarative1AnchorLine top() const; + QDeclarative1AnchorLine bottom() const; + QDeclarative1AnchorLine verticalCenter() const; + QDeclarative1AnchorLine baseline() const; // data property static void data_append(QDeclarativeListProperty *, QObject *); @@ -218,29 +220,29 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate QDeclarativeNotifier parentNotifier; static void parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e); - QDeclarativeAnchors *anchors() { + QDeclarative1Anchors *anchors() { if (!_anchors) { Q_Q(QDeclarativeItem); - _anchors = new QDeclarativeAnchors(q); + _anchors = new QDeclarative1Anchors(q); if (!componentComplete) _anchors->classBegin(); } return _anchors; } - QDeclarativeAnchors *_anchors; - QDeclarativeContents *_contents; + QDeclarative1Anchors *_anchors; + QDeclarative1Contents *_contents; QDeclarativeNullableValue baselineOffset; struct AnchorLines { AnchorLines(QGraphicsObject *); - QDeclarativeAnchorLine left; - QDeclarativeAnchorLine right; - QDeclarativeAnchorLine hCenter; - QDeclarativeAnchorLine top; - QDeclarativeAnchorLine bottom; - QDeclarativeAnchorLine vCenter; - QDeclarativeAnchorLine baseline; + QDeclarative1AnchorLine left; + QDeclarative1AnchorLine right; + QDeclarative1AnchorLine hCenter; + QDeclarative1AnchorLine top; + QDeclarative1AnchorLine bottom; + QDeclarative1AnchorLine vCenter; + QDeclarative1AnchorLine baseline; }; mutable AnchorLines *_anchorLines; AnchorLines *anchorLines() const { @@ -273,8 +275,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types); QPODVector changeListeners; - QDeclarativeStateGroup *_states(); - QDeclarativeStateGroup *_stateGroup; + QDeclarative1StateGroup *_states(); + QDeclarative1StateGroup *_stateGroup; QDeclarativeItem::TransformOrigin origin:5; bool widthValid:1; @@ -297,7 +299,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate qreal mImplicitWidth; qreal mImplicitHeight; - QDeclarativeLayoutMirroringAttached* attachedLayoutDirection; + QDeclarative1LayoutMirroringAttached* attachedLayoutDirection; bool hadSubFocusItem; @@ -378,10 +380,10 @@ class QDeclarativeItemKeyFilter QDeclarativeItemKeyFilter *m_next; }; -class QDeclarativeKeyNavigationAttachedPrivate : public QObjectPrivate +class QDeclarative1KeyNavigationAttachedPrivate : public QObjectPrivate { public: - QDeclarativeKeyNavigationAttachedPrivate() + QDeclarative1KeyNavigationAttachedPrivate() : QObjectPrivate(), left(0), right(0), up(0), down(0), tab(0), backtab(0), leftSet(false), rightSet(false), upSet(false), downSet(false), @@ -401,10 +403,10 @@ class QDeclarativeKeyNavigationAttachedPrivate : public QObjectPrivate bool backtabSet : 1; }; -class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter +class QDeclarative1KeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter { Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeKeyNavigationAttached) + Q_DECLARE_PRIVATE(QDeclarative1KeyNavigationAttached) Q_PROPERTY(QDeclarativeItem *left READ left WRITE setLeft NOTIFY leftChanged) Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY rightChanged) @@ -417,7 +419,7 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte Q_ENUMS(Priority) public: - QDeclarativeKeyNavigationAttached(QObject * = 0); + QDeclarative1KeyNavigationAttached(QObject * = 0); QDeclarativeItem *left() const; void setLeft(QDeclarativeItem *); @@ -436,7 +438,7 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte Priority priority() const; void setPriority(Priority); - static QDeclarativeKeyNavigationAttached *qmlAttachedProperties(QObject *); + static QDeclarative1KeyNavigationAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: void leftChanged(); @@ -453,14 +455,14 @@ class QDeclarativeKeyNavigationAttached : public QObject, public QDeclarativeIte void setFocusNavigation(QDeclarativeItem *currentItem, const char *dir); }; -class QDeclarativeLayoutMirroringAttached : public QObject +class QDeclarative1LayoutMirroringAttached : public QObject { Q_OBJECT Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged) Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged) public: - explicit QDeclarativeLayoutMirroringAttached(QObject *parent = 0); + explicit QDeclarative1LayoutMirroringAttached(QObject *parent = 0); bool enabled() const; void setEnabled(bool); @@ -469,7 +471,7 @@ class QDeclarativeLayoutMirroringAttached : public QObject bool childrenInherit() const; void setChildrenInherit(bool); - static QDeclarativeLayoutMirroringAttached *qmlAttachedProperties(QObject *); + static QDeclarative1LayoutMirroringAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: void enabledChanged(); void childrenInheritChanged(); @@ -478,10 +480,10 @@ class QDeclarativeLayoutMirroringAttached : public QObject QDeclarativeItemPrivate *itemPrivate; }; -class QDeclarativeKeysAttachedPrivate : public QObjectPrivate +class QDeclarative1KeysAttachedPrivate : public QObjectPrivate { public: - QDeclarativeKeysAttachedPrivate() + QDeclarative1KeysAttachedPrivate() : QObjectPrivate(), inPress(false), inRelease(false) , inIM(false), enabled(true), imeItem(0), item(0) {} @@ -508,10 +510,10 @@ class QDeclarativeKeysAttachedPrivate : public QObjectPrivate QDeclarativeItem *item; }; -class QDeclarativeKeysAttached : public QObject, public QDeclarativeItemKeyFilter +class QDeclarative1KeysAttached : public QObject, public QDeclarativeItemKeyFilter { Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeKeysAttached) + Q_DECLARE_PRIVATE(QDeclarative1KeysAttached) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(QDeclarativeListProperty forwardTo READ forwardTo) @@ -520,12 +522,12 @@ class QDeclarativeKeysAttached : public QObject, public QDeclarativeItemKeyFilte Q_ENUMS(Priority) public: - QDeclarativeKeysAttached(QObject *parent=0); - ~QDeclarativeKeysAttached(); + QDeclarative1KeysAttached(QObject *parent=0); + ~QDeclarative1KeysAttached(); - bool enabled() const { Q_D(const QDeclarativeKeysAttached); return d->enabled; } + bool enabled() const { Q_D(const QDeclarative1KeysAttached); return d->enabled; } void setEnabled(bool enabled) { - Q_D(QDeclarativeKeysAttached); + Q_D(QDeclarative1KeysAttached); if (enabled != d->enabled) { d->enabled = enabled; emit enabledChanged(); @@ -537,59 +539,59 @@ class QDeclarativeKeysAttached : public QObject, public QDeclarativeItemKeyFilte void setPriority(Priority); QDeclarativeListProperty forwardTo() { - Q_D(QDeclarativeKeysAttached); + Q_D(QDeclarative1KeysAttached); return QDeclarativeListProperty(this, d->targets); } virtual void componentComplete(); - static QDeclarativeKeysAttached *qmlAttachedProperties(QObject *); + static QDeclarative1KeysAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: void enabledChanged(); void priorityChanged(); - void pressed(QDeclarativeKeyEvent *event); - void released(QDeclarativeKeyEvent *event); - void digit0Pressed(QDeclarativeKeyEvent *event); - void digit1Pressed(QDeclarativeKeyEvent *event); - void digit2Pressed(QDeclarativeKeyEvent *event); - void digit3Pressed(QDeclarativeKeyEvent *event); - void digit4Pressed(QDeclarativeKeyEvent *event); - void digit5Pressed(QDeclarativeKeyEvent *event); - void digit6Pressed(QDeclarativeKeyEvent *event); - void digit7Pressed(QDeclarativeKeyEvent *event); - void digit8Pressed(QDeclarativeKeyEvent *event); - void digit9Pressed(QDeclarativeKeyEvent *event); - - void leftPressed(QDeclarativeKeyEvent *event); - void rightPressed(QDeclarativeKeyEvent *event); - void upPressed(QDeclarativeKeyEvent *event); - void downPressed(QDeclarativeKeyEvent *event); - void tabPressed(QDeclarativeKeyEvent *event); - void backtabPressed(QDeclarativeKeyEvent *event); - - void asteriskPressed(QDeclarativeKeyEvent *event); - void numberSignPressed(QDeclarativeKeyEvent *event); - void escapePressed(QDeclarativeKeyEvent *event); - void returnPressed(QDeclarativeKeyEvent *event); - void enterPressed(QDeclarativeKeyEvent *event); - void deletePressed(QDeclarativeKeyEvent *event); - void spacePressed(QDeclarativeKeyEvent *event); - void backPressed(QDeclarativeKeyEvent *event); - void cancelPressed(QDeclarativeKeyEvent *event); - void selectPressed(QDeclarativeKeyEvent *event); - void yesPressed(QDeclarativeKeyEvent *event); - void noPressed(QDeclarativeKeyEvent *event); - void context1Pressed(QDeclarativeKeyEvent *event); - void context2Pressed(QDeclarativeKeyEvent *event); - void context3Pressed(QDeclarativeKeyEvent *event); - void context4Pressed(QDeclarativeKeyEvent *event); - void callPressed(QDeclarativeKeyEvent *event); - void hangupPressed(QDeclarativeKeyEvent *event); - void flipPressed(QDeclarativeKeyEvent *event); - void menuPressed(QDeclarativeKeyEvent *event); - void volumeUpPressed(QDeclarativeKeyEvent *event); - void volumeDownPressed(QDeclarativeKeyEvent *event); + void pressed(QDeclarative1KeyEvent *event); + void released(QDeclarative1KeyEvent *event); + void digit0Pressed(QDeclarative1KeyEvent *event); + void digit1Pressed(QDeclarative1KeyEvent *event); + void digit2Pressed(QDeclarative1KeyEvent *event); + void digit3Pressed(QDeclarative1KeyEvent *event); + void digit4Pressed(QDeclarative1KeyEvent *event); + void digit5Pressed(QDeclarative1KeyEvent *event); + void digit6Pressed(QDeclarative1KeyEvent *event); + void digit7Pressed(QDeclarative1KeyEvent *event); + void digit8Pressed(QDeclarative1KeyEvent *event); + void digit9Pressed(QDeclarative1KeyEvent *event); + + void leftPressed(QDeclarative1KeyEvent *event); + void rightPressed(QDeclarative1KeyEvent *event); + void upPressed(QDeclarative1KeyEvent *event); + void downPressed(QDeclarative1KeyEvent *event); + void tabPressed(QDeclarative1KeyEvent *event); + void backtabPressed(QDeclarative1KeyEvent *event); + + void asteriskPressed(QDeclarative1KeyEvent *event); + void numberSignPressed(QDeclarative1KeyEvent *event); + void escapePressed(QDeclarative1KeyEvent *event); + void returnPressed(QDeclarative1KeyEvent *event); + void enterPressed(QDeclarative1KeyEvent *event); + void deletePressed(QDeclarative1KeyEvent *event); + void spacePressed(QDeclarative1KeyEvent *event); + void backPressed(QDeclarative1KeyEvent *event); + void cancelPressed(QDeclarative1KeyEvent *event); + void selectPressed(QDeclarative1KeyEvent *event); + void yesPressed(QDeclarative1KeyEvent *event); + void noPressed(QDeclarative1KeyEvent *event); + void context1Pressed(QDeclarative1KeyEvent *event); + void context2Pressed(QDeclarative1KeyEvent *event); + void context3Pressed(QDeclarative1KeyEvent *event); + void context4Pressed(QDeclarative1KeyEvent *event); + void callPressed(QDeclarative1KeyEvent *event); + void hangupPressed(QDeclarative1KeyEvent *event); + void flipPressed(QDeclarative1KeyEvent *event); + void menuPressed(QDeclarative1KeyEvent *event); + void volumeUpPressed(QDeclarative1KeyEvent *event); + void volumeDownPressed(QDeclarative1KeyEvent *event); private: virtual void keyPressed(QKeyEvent *event, bool post); @@ -623,11 +625,11 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeItemPrivate::ChangeTypes); QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeKeysAttached) -QML_DECLARE_TYPEINFO(QDeclarativeKeysAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarativeKeyNavigationAttached) -QML_DECLARE_TYPEINFO(QDeclarativeKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarativeLayoutMirroringAttached) -QML_DECLARE_TYPEINFO(QDeclarativeLayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarative1KeysAttached) +QML_DECLARE_TYPEINFO(QDeclarative1KeysAttached, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarative1KeyNavigationAttached) +QML_DECLARE_TYPEINFO(QDeclarative1KeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarative1LayoutMirroringAttached) +QML_DECLARE_TYPEINFO(QDeclarative1LayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES) #endif // QDECLARATIVEITEM_P_H diff --git a/src/declarative/graphicsitems/qdeclarativeitemchangelistener_p.h b/src/qtquick1/graphicsitems/qdeclarativeitemchangelistener_p.h similarity index 96% rename from src/declarative/graphicsitems/qdeclarativeitemchangelistener_p.h rename to src/qtquick1/graphicsitems/qdeclarativeitemchangelistener_p.h index 75b127f11c..4b10a38660 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemchangelistener_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeitemchangelistener_p.h @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE class QRectF; class QDeclarativeItem; -class QDeclarativeAnchorsPrivate; +class QDeclarative1AnchorsPrivate; class QDeclarativeItemChangeListener { public: @@ -68,7 +68,7 @@ class QDeclarativeItemChangeListener virtual void itemVisibilityChanged(QDeclarativeItem *) {} virtual void itemOpacityChanged(QDeclarativeItem *) {} virtual void itemDestroyed(QDeclarativeItem *) {} - virtual QDeclarativeAnchorsPrivate *anchorPrivate() { return 0; } + virtual QDeclarative1AnchorsPrivate *anchorPrivate() { return 0; } }; QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp new file mode 100644 index 0000000000..78f13cdbd8 --- /dev/null +++ b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp @@ -0,0 +1,267 @@ +/**************************************************************************** +** +** 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativeitemsmodule_p.h" + +#include +#include +#include +#include + +#include "QtQuick1/private/qdeclarativeevents_p_p.h" +#include "QtQuick1/private/qdeclarativescalegrid_p_p.h" +#include "QtQuick1/private/qdeclarativeanimatedimage_p.h" +#include "QtQuick1/private/qdeclarativeborderimage_p.h" +#include "QtQuick1/private/qdeclarativepositioners_p.h" +#include "QtQuick1/private/qdeclarativemousearea_p.h" +#include "QtQuick1/private/qdeclarativeflickable_p.h" +#include "QtQuick1/private/qdeclarativeflickable_p_p.h" +#include "QtQuick1/private/qdeclarativeflipable_p.h" +#include "QtQuick1/private/qdeclarativefocuspanel_p.h" +#include "QtQuick1/private/qdeclarativefocusscope_p.h" +#include "QtQuick1/private/qdeclarativegridview_p.h" +#include "QtQuick1/private/qdeclarativeimage_p.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" +#include "QtQuick1/private/qdeclarativelayoutitem_p.h" +#include "QtQuick1/private/qdeclarativelistview_p.h" +#include "QtQuick1/private/qdeclarativeloader_p.h" +#include "QtQuick1/private/qdeclarativemousearea_p.h" +#include "QtQuick1/private/qdeclarativepath_p.h" +#include "QtQuick1/private/qdeclarativepathview_p.h" +#include "QtQuick1/private/qdeclarativerectangle_p.h" +#include "QtQuick1/private/qdeclarativerepeater_p.h" +#include "QtQuick1/private/qdeclarativetranslate_p.h" +#include "QtQuick1/private/qdeclarativetext_p.h" +#include "QtQuick1/private/qdeclarativetextedit_p.h" +#include "QtQuick1/private/qdeclarativetextinput_p.h" +#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" +#include "QtQuick1/private/qdeclarativegraphicswidget_p.h" +#ifdef QT_WEBKIT_LIB +#include "QtQuick1/private/qdeclarativewebview_p.h" +#include "QtQuick1/private/qdeclarativewebview_p_p.h" +#endif +#include "QtQuick1/private/qdeclarativeanchors_p.h" +#include "QtQuick1/private/qdeclarativepincharea_p.h" + +static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent) +{ + QGraphicsObject* gobj = qobject_cast(obj); + if (!gobj) + return QDeclarativePrivate::IncompatibleObject; + + QGraphicsObject* gparent = qobject_cast(parent); + if (!gparent) + return QDeclarativePrivate::IncompatibleParent; + + gobj->setParentItem(gparent); + return QDeclarativePrivate::Parented; +} + +void QDeclarative1ItemModule::defineModule(QDeclarativeQtQuick1Module::Module module) +{ + QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qgraphicsobject_autoParent }; + QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent); + + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); +#ifndef QT_NO_VALIDATOR + qmlRegisterType(); +#endif + qmlRegisterType(); +#ifndef QT_NO_ACTION + qmlRegisterType(); +#endif + qmlRegisterType(); + qmlRegisterType(); +#ifndef QT_NO_GRAPHICSEFFECT + qmlRegisterType(); +#endif + + if (module == QDeclarativeQtQuick1Module::QtQuick1) { +#ifdef QT_NO_MOVIE + qmlRegisterTypeNotAvailable("QtQuick",1,0,"AnimatedImage", + qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie")); +#else + qmlRegisterType("QtQuick",1,0,"AnimatedImage"); +#endif + qmlRegisterType("QtQuick",1,0,"BorderImage"); + qmlRegisterType("QtQuick",1,0,"Column"); + qmlRegisterType("QtQuick",1,0,"Drag"); + qmlRegisterType("QtQuick",1,0,"Flickable"); + qmlRegisterType("QtQuick",1,0,"Flipable"); + qmlRegisterType("QtQuick",1,0,"Flow"); + qmlRegisterType("QtQuick",1,0,"FocusPanel"); + qmlRegisterType("QtQuick",1,0,"FocusScope"); + qmlRegisterType("QtQuick",1,0,"Gradient"); + qmlRegisterType("QtQuick",1,0,"GradientStop"); + qmlRegisterType("QtQuick",1,0,"Grid"); + qmlRegisterType("QtQuick",1,0,"GridView"); + qmlRegisterType("QtQuick",1,0,"Image"); + qmlRegisterType("QtQuick",1,0,"Item"); + qmlRegisterType("QtQuick",1,0,"LayoutItem"); + qmlRegisterType("QtQuick",1,0,"ListView"); + qmlRegisterType("QtQuick",1,0,"Loader"); + qmlRegisterType("QtQuick",1,0,"MouseArea"); + qmlRegisterType("QtQuick",1,0,"Path"); + qmlRegisterType("QtQuick",1,0,"PathAttribute"); + qmlRegisterType("QtQuick",1,0,"PathCubic"); + qmlRegisterType("QtQuick",1,0,"PathLine"); + qmlRegisterType("QtQuick",1,0,"PathPercent"); + qmlRegisterType("QtQuick",1,0,"PathQuad"); + qmlRegisterType("QtQuick",1,0,"PathView"); +#ifndef QT_NO_VALIDATOR + qmlRegisterType("QtQuick",1,0,"IntValidator"); + qmlRegisterType("QtQuick",1,0,"DoubleValidator"); + qmlRegisterType("QtQuick",1,0,"RegExpValidator"); +#endif + qmlRegisterType("QtQuick",1,0,"Rectangle"); + qmlRegisterType("QtQuick",1,0,"Repeater"); + qmlRegisterType("QtQuick",1,0,"Rotation"); + qmlRegisterType("QtQuick",1,0,"Row"); + qmlRegisterType("QtQuick",1,0,"Translate"); + qmlRegisterType("QtQuick",1,0,"Scale"); + qmlRegisterType("QtQuick",1,0,"Text"); + qmlRegisterType("QtQuick",1,0,"TextEdit"); +#ifndef QT_NO_LINEEDIT + qmlRegisterType("QtQuick",1,0,"TextInput"); +#endif + qmlRegisterType("QtQuick",1,0,"ViewSection"); + qmlRegisterType("QtQuick",1,0,"VisualDataModel"); + qmlRegisterType("QtQuick",1,0,"VisualItemModel"); + + qmlRegisterType("QtQuick",1,0,"QGraphicsWidget"); + qmlRegisterExtendedType("QtQuick",1,0,"QGraphicsWidget"); + + qmlRegisterUncreatableType("QtQuick",1,0,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties")); + qmlRegisterUncreatableType("QtQuick",1,0,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties")); + + // QtQuick 1.1 items + qmlRegisterType("QtQuick",1,1,"PinchArea"); + qmlRegisterType("QtQuick",1,1,"Pinch"); + qmlRegisterType(); + qmlRegisterType("QtQuick",1,1,"Item"); + qmlRegisterType("QtQuick",1,1,"MouseArea"); + qmlRegisterType("QtQuick",1,1,"Flickable"); + qmlRegisterType("QtQuick",1,1,"ListView"); + qmlRegisterType("QtQuick",1,1,"GridView"); + qmlRegisterType("QtQuick",1,1,"Row"); + qmlRegisterType("QtQuick",1,1,"Grid"); + qmlRegisterType("QtQuick",1,1,"Flow"); + qmlRegisterType("QtQuick",1,1,"Repeater"); + qmlRegisterType("QtQuick",1,1,"Text"); + qmlRegisterType("QtQuick",1,1,"TextEdit"); +#ifndef QT_NO_LINEEDIT + qmlRegisterType("QtQuick",1,1,"TextInput"); +#endif + qmlRegisterRevision("QtQuick",1,1); + qmlRegisterRevision("QtQuick",1,0); + qmlRegisterRevision("QtQuick",1,1); + qmlRegisterRevision("QtQuick",1,0); + qmlRegisterRevision("QtQuick",1,1); + qmlRegisterUncreatableType("QtQuick",1,1,"LayoutMirroring", QDeclarative1LayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties")); + } else if (module == QDeclarativeQtQuick1Module::Qt47) { +#ifdef QT_NO_MOVIE + qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage", + qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie")); +#else + qmlRegisterType("Qt",4,7,"AnimatedImage"); +#endif + qmlRegisterType("Qt",4,7,"BorderImage"); + qmlRegisterType("Qt",4,7,"Column"); + qmlRegisterType("Qt",4,7,"Drag"); + qmlRegisterType("Qt",4,7,"Flickable"); + qmlRegisterType("Qt",4,7,"Flipable"); + qmlRegisterType("Qt",4,7,"Flow"); + qmlRegisterType("Qt",4,7,"FocusPanel"); + qmlRegisterType("Qt",4,7,"FocusScope"); + qmlRegisterType("Qt",4,7,"Gradient"); + qmlRegisterType("Qt",4,7,"GradientStop"); + qmlRegisterType("Qt",4,7,"Grid"); + qmlRegisterType("Qt",4,7,"GridView"); + qmlRegisterType("Qt",4,7,"Image"); + qmlRegisterType("Qt",4,7,"Item"); + qmlRegisterType("Qt",4,7,"LayoutItem"); + qmlRegisterType("Qt",4,7,"ListView"); + qmlRegisterType("Qt",4,7,"Loader"); + qmlRegisterType("Qt",4,7,"MouseArea"); + qmlRegisterType("Qt",4,7,"Path"); + qmlRegisterType("Qt",4,7,"PathAttribute"); + qmlRegisterType("Qt",4,7,"PathCubic"); + qmlRegisterType("Qt",4,7,"PathLine"); + qmlRegisterType("Qt",4,7,"PathPercent"); + qmlRegisterType("Qt",4,7,"PathQuad"); + qmlRegisterType("Qt",4,7,"PathView"); +#ifndef QT_NO_VALIDATOR + qmlRegisterType("Qt",4,7,"IntValidator"); + qmlRegisterType("Qt",4,7,"DoubleValidator"); + qmlRegisterType("Qt",4,7,"RegExpValidator"); +#endif + qmlRegisterType("Qt",4,7,"Rectangle"); + qmlRegisterType("Qt",4,7,"Repeater"); + qmlRegisterType("Qt",4,7,"Rotation"); + qmlRegisterType("Qt",4,7,"Row"); + qmlRegisterType("Qt",4,7,"Translate"); + qmlRegisterType("Qt",4,7,"Scale"); + qmlRegisterType("Qt",4,7,"Text"); + qmlRegisterType("Qt",4,7,"TextEdit"); +#ifndef QT_NO_LINEEDIT + qmlRegisterType("Qt",4,7,"TextInput"); +#endif + qmlRegisterType("Qt",4,7,"ViewSection"); + qmlRegisterType("Qt",4,7,"VisualDataModel"); + qmlRegisterType("Qt",4,7,"VisualItemModel"); + + qmlRegisterType("Qt",4,7,"QGraphicsWidget"); + qmlRegisterExtendedType("Qt",4,7,"QGraphicsWidget"); + + qmlRegisterUncreatableType("Qt",4,7,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties")); + qmlRegisterUncreatableType("Qt",4,7,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties")); + } +} + + + diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule_p.h b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule_p.h similarity index 91% rename from src/declarative/graphicsitems/qdeclarativeitemsmodule_p.h rename to src/qtquick1/graphicsitems/qdeclarativeitemsmodule_p.h index ad60002a4f..39d55f3b5e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitemsmodule_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule_p.h @@ -42,7 +42,8 @@ #ifndef QDECLARATIVEITEMMODULE_H #define QDECLARATIVEITEMMODULE_H -#include +#include +#include "../qtquick1_p.h" QT_BEGIN_HEADER @@ -50,10 +51,10 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeItemModule +class QDeclarative1ItemModule { public: - static void defineModule(); + static void defineModule(QDeclarativeQtQuick1Module::Module module); }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp b/src/qtquick1/graphicsitems/qdeclarativelayoutitem.cpp similarity index 93% rename from src/declarative/graphicsitems/qdeclarativelayoutitem.cpp rename to src/qtquick1/graphicsitems/qdeclarativelayoutitem.cpp index 6c66355d20..eea3830fca 100644 --- a/src/declarative/graphicsitems/qdeclarativelayoutitem.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativelayoutitem.cpp @@ -47,8 +47,10 @@ QT_BEGIN_NAMESPACE + + /*! - \qmlclass LayoutItem QDeclarativeLayoutItem + \qmlclass LayoutItem QDeclarative1LayoutItem \ingroup qml-utility-elements \since 4.7 \brief The LayoutItem element allows declarative UI elements to be placed inside Qt's Graphics View layouts. @@ -83,13 +85,13 @@ QT_BEGIN_NAMESPACE The preferredSize property can be set to specify the preferred size of this LayoutItem */ -QDeclarativeLayoutItem::QDeclarativeLayoutItem(QDeclarativeItem* parent) +QDeclarative1LayoutItem::QDeclarative1LayoutItem(QDeclarativeItem* parent) : QDeclarativeItem(parent), m_maximumSize(INT_MAX,INT_MAX), m_minimumSize(0,0), m_preferredSize(0,0) { setGraphicsItem(this); } -void QDeclarativeLayoutItem::setGeometry(const QRectF & rect) +void QDeclarative1LayoutItem::setGeometry(const QRectF & rect) { setX(rect.x()); setY(rect.y()); @@ -97,7 +99,7 @@ void QDeclarativeLayoutItem::setGeometry(const QRectF & rect) setHeight(rect.height()); } -QSizeF QDeclarativeLayoutItem::sizeHint(Qt::SizeHint w, const QSizeF &constraint) const +QSizeF QDeclarative1LayoutItem::sizeHint(Qt::SizeHint w, const QSizeF &constraint) const { Q_UNUSED(constraint); if(w == Qt::MinimumSize){ @@ -109,4 +111,6 @@ QSizeF QDeclarativeLayoutItem::sizeHint(Qt::SizeHint w, const QSizeF &constraint } } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativelayoutitem_p.h b/src/qtquick1/graphicsitems/qdeclarativelayoutitem_p.h similarity index 94% rename from src/declarative/graphicsitems/qdeclarativelayoutitem_p.h rename to src/qtquick1/graphicsitems/qdeclarativelayoutitem_p.h index ec6fa3b50f..9db5f19d44 100644 --- a/src/declarative/graphicsitems/qdeclarativelayoutitem_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativelayoutitem_p.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeLayoutItem : public QDeclarativeItem, public QGraphicsLayoutItem +class QDeclarative1LayoutItem : public QDeclarativeItem, public QGraphicsLayoutItem { Q_OBJECT Q_INTERFACES(QGraphicsLayoutItem) @@ -60,7 +60,7 @@ class QDeclarativeLayoutItem : public QDeclarativeItem, public QGraphicsLayoutIt Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged) Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize NOTIFY preferredSizeChanged) public: - QDeclarativeLayoutItem(QDeclarativeItem* parent=0); + QDeclarative1LayoutItem(QDeclarativeItem* parent=0); QSizeF maximumSize() const { return m_maximumSize; } void setMaximumSize(const QSizeF &s) { if(s==m_maximumSize) return; m_maximumSize = s; emit maximumSizeChanged(); } @@ -88,7 +88,7 @@ class QDeclarativeLayoutItem : public QDeclarativeItem, public QGraphicsLayoutIt QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeLayoutItem) +QML_DECLARE_TYPE(QDeclarative1LayoutItem) QT_END_HEADER #endif diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/qtquick1/graphicsitems/qdeclarativelistview.cpp similarity index 82% rename from src/declarative/graphicsitems/qdeclarativelistview.cpp rename to src/qtquick1/graphicsitems/qdeclarativelistview.cpp index 225b031530..42f1e1919b 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativelistview.cpp @@ -39,24 +39,25 @@ ** ****************************************************************************/ -#include "private/qdeclarativelistview_p.h" +#include "QtQuick1/private/qdeclarativelistview_p.h" -#include "private/qdeclarativeflickable_p_p.h" -#include "private/qdeclarativevisualitemmodel_p.h" +#include "QtQuick1/private/qdeclarativeflickable_p_p.h" +#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" -#include "private/qdeclarativesmoothedanimation_p_p.h" -#include -#include -#include -#include +#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h" +#include +#include +#include +#include -#include #include #include QT_BEGIN_NAMESPACE -void QDeclarativeViewSection::setProperty(const QString &property) + + +void QDeclarative1ViewSection::setProperty(const QString &property) { if (property != m_property) { m_property = property; @@ -64,7 +65,7 @@ void QDeclarativeViewSection::setProperty(const QString &property) } } -void QDeclarativeViewSection::setCriteria(QDeclarativeViewSection::SectionCriteria criteria) +void QDeclarative1ViewSection::setCriteria(QDeclarative1ViewSection::SectionCriteria criteria) { if (criteria != m_criteria) { m_criteria = criteria; @@ -72,7 +73,7 @@ void QDeclarativeViewSection::setCriteria(QDeclarativeViewSection::SectionCriter } } -void QDeclarativeViewSection::setDelegate(QDeclarativeComponent *delegate) +void QDeclarative1ViewSection::setDelegate(QDeclarativeComponent *delegate) { if (delegate != m_delegate) { m_delegate = delegate; @@ -80,7 +81,7 @@ void QDeclarativeViewSection::setDelegate(QDeclarativeComponent *delegate) } } -QString QDeclarativeViewSection::sectionString(const QString &value) +QString QDeclarative1ViewSection::sectionString(const QString &value) { if (m_criteria == FirstCharacter) return value.isEmpty() ? QString() : value.at(0); @@ -90,18 +91,18 @@ QString QDeclarativeViewSection::sectionString(const QString &value) //---------------------------------------------------------------------------- -class FxListItem +class FxListItem1 { public: - FxListItem(QDeclarativeItem *i, QDeclarativeListView *v) : item(i), section(0), view(v) { - attached = static_cast(qmlAttachedPropertiesObject(item)); + FxListItem1(QDeclarativeItem *i, QDeclarative1ListView *v) : item(i), section(0), view(v) { + attached = static_cast(qmlAttachedPropertiesObject(item)); if (attached) attached->setView(view); } - ~FxListItem() {} + ~FxListItem1() {} qreal position() const { if (section) { - if (view->orientation() == QDeclarativeListView::Vertical) + if (view->orientation() == QDeclarative1ListView::Vertical) return section->y(); else return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section->width()-section->x() : section->x()); @@ -111,27 +112,27 @@ class FxListItem } qreal itemPosition() const { - if (view->orientation() == QDeclarativeListView::Vertical) + if (view->orientation() == QDeclarative1ListView::Vertical) return item->y(); else return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -item->width()-item->x() : item->x()); } qreal size() const { if (section) - return (view->orientation() == QDeclarativeListView::Vertical ? item->height()+section->height() : item->width()+section->width()); + return (view->orientation() == QDeclarative1ListView::Vertical ? item->height()+section->height() : item->width()+section->width()); else - return (view->orientation() == QDeclarativeListView::Vertical ? item->height() : item->width()); + return (view->orientation() == QDeclarative1ListView::Vertical ? item->height() : item->width()); } qreal itemSize() const { - return (view->orientation() == QDeclarativeListView::Vertical ? item->height() : item->width()); + return (view->orientation() == QDeclarative1ListView::Vertical ? item->height() : item->width()); } qreal sectionSize() const { if (section) - return (view->orientation() == QDeclarativeListView::Vertical ? section->height() : section->width()); + return (view->orientation() == QDeclarative1ListView::Vertical ? section->height() : section->width()); return 0.0; } qreal endPosition() const { - if (view->orientation() == QDeclarativeListView::Vertical) { + if (view->orientation() == QDeclarative1ListView::Vertical) { return item->y() + (item->height() >= 1.0 ? item->height() : 1) - 1; } else { return (view->effectiveLayoutDirection() == Qt::RightToLeft @@ -140,7 +141,7 @@ class FxListItem } } void setPosition(qreal pos) { - if (view->orientation() == QDeclarativeListView::Vertical) { + if (view->orientation() == QDeclarative1ListView::Vertical) { if (section) { section->setY(pos); pos += section->height(); @@ -163,7 +164,7 @@ class FxListItem } } void setSize(qreal size) { - if (view->orientation() == QDeclarativeListView::Vertical) + if (view->orientation() == QDeclarative1ListView::Vertical) item->setHeight(size); else item->setWidth(size); @@ -175,20 +176,20 @@ class FxListItem QDeclarativeItem *item; QDeclarativeItem *section; - QDeclarativeListView *view; - QDeclarativeListViewAttached *attached; + QDeclarative1ListView *view; + QDeclarative1ListViewAttached *attached; int index; }; //---------------------------------------------------------------------------- -class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate +class QDeclarative1ListViewPrivate : public QDeclarative1FlickablePrivate { - Q_DECLARE_PUBLIC(QDeclarativeListView) + Q_DECLARE_PUBLIC(QDeclarative1ListView) public: - QDeclarativeListViewPrivate() - : currentItem(0), orient(QDeclarativeListView::Vertical), layoutDirection(Qt::LeftToRight) + QDeclarative1ListViewPrivate() + : currentItem(0), orient(QDeclarative1ListView::Vertical), layoutDirection(Qt::LeftToRight) , visiblePos(0), visibleIndex(0) , averageSize(100.0), currentIndex(-1), requestedIndex(-1) , itemCount(0), highlightRangeStart(0), highlightRangeEnd(0) @@ -197,8 +198,8 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0) , sectionCriteria(0), spacing(0.0) , highlightMoveSpeed(400), highlightMoveDuration(-1) - , highlightResizeSpeed(400), highlightResizeDuration(-1), highlightRange(QDeclarativeListView::NoHighlightRange) - , snapMode(QDeclarativeListView::NoSnap), overshootDist(0.0) + , highlightResizeSpeed(400), highlightResizeDuration(-1), highlightRange(QDeclarative1ListView::NoHighlightRange) + , snapMode(QDeclarative1ListView::NoSnap), overshootDist(0.0) , footerComponent(0), footer(0), headerComponent(0), header(0) , bufferMode(BufferBefore | BufferAfter) , ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false) @@ -210,13 +211,13 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate void init(); void clear(); - FxListItem *createItem(int modelIndex); - void releaseItem(FxListItem *item); + FxListItem1 *createItem(int modelIndex); + void releaseItem(FxListItem1 *item); - FxListItem *visibleItem(int modelIndex) const { + FxListItem1 *visibleItem(int modelIndex) const { if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) { for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) { - FxListItem *item = visibleItems.at(i); + FxListItem1 *item = visibleItems.at(i); if (item->index == modelIndex) return item; } @@ -224,21 +225,21 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate return 0; } - FxListItem *firstVisibleItem() const { + FxListItem1 *firstVisibleItem() const { const qreal pos = isRightToLeft() ? -position()-size() : position(); for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem *item = visibleItems.at(i); + FxListItem1 *item = visibleItems.at(i); if (item->index != -1 && item->endPosition() > pos) return item; } return visibleItems.count() ? visibleItems.first() : 0; } - FxListItem *nextVisibleItem() const { + FxListItem1 *nextVisibleItem() const { const qreal pos = isRightToLeft() ? -position()-size() : position(); bool foundFirst = false; for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem *item = visibleItems.at(i); + FxListItem1 *item = visibleItems.at(i); if (item->index != -1) { if (foundFirst) return item; @@ -251,13 +252,13 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate // Returns the item before modelIndex, if created. // May return an item marked for removal. - FxListItem *itemBefore(int modelIndex) const { + FxListItem1 *itemBefore(int modelIndex) const { if (modelIndex < visibleIndex) return 0; int idx = 1; int lastIndex = -1; while (idx < visibleItems.count()) { - FxListItem *item = visibleItems.at(idx); + FxListItem1 *item = visibleItems.at(idx); if (item->index != -1) lastIndex = item->index; if (item->index == modelIndex) @@ -270,7 +271,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } void regenerate() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (q->isComponentComplete()) { if (header) { if (q->scene()) @@ -296,35 +297,35 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } void mirrorChange() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); regenerate(); emit q->effectiveLayoutDirectionChanged(); } bool isRightToLeft() const { - Q_Q(const QDeclarativeListView); - return orient == QDeclarativeListView::Horizontal && q->effectiveLayoutDirection() == Qt::RightToLeft; + Q_Q(const QDeclarative1ListView); + return orient == QDeclarative1ListView::Horizontal && q->effectiveLayoutDirection() == Qt::RightToLeft; } qreal position() const { - Q_Q(const QDeclarativeListView); - return orient == QDeclarativeListView::Vertical ? q->contentY() : q->contentX(); + Q_Q(const QDeclarative1ListView); + return orient == QDeclarative1ListView::Vertical ? q->contentY() : q->contentX(); } void setPosition(qreal pos) { - Q_Q(QDeclarativeListView); - if (orient == QDeclarativeListView::Vertical) { - q->QDeclarativeFlickable::setContentY(pos); + Q_Q(QDeclarative1ListView); + if (orient == QDeclarative1ListView::Vertical) { + q->QDeclarative1Flickable::setContentY(pos); } else { if (isRightToLeft()) - q->QDeclarativeFlickable::setContentX(-pos-size()); + q->QDeclarative1Flickable::setContentX(-pos-size()); else - q->QDeclarativeFlickable::setContentX(pos); + q->QDeclarative1Flickable::setContentX(pos); } } qreal size() const { - Q_Q(const QDeclarativeListView); - return orient == QDeclarativeListView::Vertical ? q->height() : q->width(); + Q_Q(const QDeclarative1ListView); + return orient == QDeclarative1ListView::Vertical ? q->height() : q->width(); } qreal originPosition() const { @@ -363,7 +364,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } qreal positionAt(int modelIndex) const { - if (FxListItem *item = visibleItem(modelIndex)) + if (FxListItem1 *item = visibleItem(modelIndex)) return item->position(); if (!visibleItems.isEmpty()) { if (modelIndex < visibleIndex) { @@ -391,7 +392,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } qreal endPositionAt(int modelIndex) const { - if (FxListItem *item = visibleItem(modelIndex)) + if (FxListItem1 *item = visibleItem(modelIndex)) return item->endPosition(); if (!visibleItems.isEmpty()) { if (modelIndex < visibleIndex) { @@ -413,7 +414,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } QString sectionAt(int modelIndex) { - if (FxListItem *item = visibleItem(modelIndex)) + if (FxListItem1 *item = visibleItem(modelIndex)) return item->attached->section(); QString section; @@ -430,7 +431,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } qreal snapPosAt(qreal pos) { - if (FxListItem *snapItem = snapItemAt(pos)) + if (FxListItem1 *snapItem = snapItemAt(pos)) return snapItem->position(); if (visibleItems.count()) { qreal firstPos = visibleItems.first()->position(); @@ -443,10 +444,10 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate return qRound((pos - originPosition()) / averageSize) * averageSize + originPosition(); } - FxListItem *snapItemAt(qreal pos) { - FxListItem *snapItem = 0; + FxListItem1 *snapItemAt(qreal pos) { + FxListItem1 *snapItem = 0; for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem *item = visibleItems[i]; + FxListItem1 *item = visibleItems[i]; if (item->index == -1) continue; qreal itemTop = item->position(); @@ -461,7 +462,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate int lastVisibleIndex() const { int lastIndex = -1; for (int i = visibleItems.count()-1; i >= 0; --i) { - FxListItem *listItem = visibleItems.at(i); + FxListItem1 *listItem = visibleItems.at(i); if (listItem->index != -1) { lastIndex = listItem->index; break; @@ -475,7 +476,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count()) return -1; for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem *listItem = visibleItems.at(i); + FxListItem1 *listItem = visibleItems.at(i); if (listItem->index == modelIndex) return i; if (listItem->index > modelIndex) @@ -485,8 +486,8 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } void updateViewport() { - Q_Q(QDeclarativeListView); - if (orient == QDeclarativeListView::Vertical) { + Q_Q(QDeclarative1ListView); + if (orient == QDeclarative1ListView::Vertical) { q->setContentHeight(endPosition() - startPosition() + 1); } else { q->setContentWidth(endPosition() - startPosition() + 1); @@ -494,13 +495,13 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate } void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_Q(QDeclarativeListView); - QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); + Q_Q(QDeclarative1ListView); + QDeclarative1FlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); if (!q->isComponentComplete()) return; if (item != contentItem && (!highlight || item != highlight->item)) { - if ((orient == QDeclarativeListView::Vertical && newGeometry.height() != oldGeometry.height()) - || (orient == QDeclarativeListView::Horizontal && newGeometry.width() != oldGeometry.width())) { + if ((orient == QDeclarative1ListView::Vertical && newGeometry.height() != oldGeometry.height()) + || (orient == QDeclarative1ListView::Horizontal && newGeometry.width() != oldGeometry.width())) { scheduleLayout(); } } @@ -520,7 +521,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate void checkVisible() const { int skip = 0; for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem *listItem = visibleItems.at(i); + FxListItem1 *listItem = visibleItems.at(i); if (listItem->index == -1) { ++skip; } else if (listItem->index != visibleIndex + i - skip) { @@ -537,7 +538,7 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate void updateTrackedItem(); void createHighlight(); void updateHighlight(); - void createSection(FxListItem *); + void createSection(FxListItem1 *); void updateSections(); void updateCurrentSection(); void updateCurrent(int); @@ -547,15 +548,15 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate void fixupPosition(); void positionViewAtIndex(int index, int mode); virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - virtual void flick(QDeclarativeFlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity); + virtual void flick(QDeclarative1FlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, + QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); - QDeclarativeGuard model; + QDeclarativeGuard model; QVariant modelVariant; - QList visibleItems; + QList visibleItems; QHash unrequestedItems; - FxListItem *currentItem; - QDeclarativeListView::Orientation orient; + FxListItem1 *currentItem; + QDeclarative1ListView::Orientation orient; Qt::LayoutDirection layoutDirection; qreal visiblePos; int visibleIndex; @@ -568,14 +569,14 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate bool highlightRangeStartValid; bool highlightRangeEndValid; QDeclarativeComponent *highlightComponent; - FxListItem *highlight; - FxListItem *trackedItem; + FxListItem1 *highlight; + FxListItem1 *trackedItem; enum MovementReason { Other, SetIndex, Mouse }; MovementReason moveReason; int buffer; - QSmoothedAnimation *highlightPosAnimator; - QSmoothedAnimation *highlightSizeAnimator; - QDeclarativeViewSection *sectionCriteria; + QSmoothedAnimation_1 *highlightPosAnimator; + QSmoothedAnimation_1 *highlightSizeAnimator; + QDeclarative1ViewSection *sectionCriteria; QString currentSection; static const int sectionCacheSize = 4; QDeclarativeItem *sectionCache[sectionCacheSize]; @@ -584,13 +585,13 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate int highlightMoveDuration; qreal highlightResizeSpeed; int highlightResizeDuration; - QDeclarativeListView::HighlightRangeMode highlightRange; - QDeclarativeListView::SnapMode snapMode; + QDeclarative1ListView::HighlightRangeMode highlightRange; + QDeclarative1ListView::SnapMode snapMode; qreal overshootDist; QDeclarativeComponent *footerComponent; - FxListItem *footer; + FxListItem1 *footer; QDeclarativeComponent *headerComponent; - FxListItem *header; + FxListItem1 *header; enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }; int bufferMode; mutable qreal minExtent; @@ -611,17 +612,17 @@ class QDeclarativeListViewPrivate : public QDeclarativeFlickablePrivate mutable bool maxExtentDirty : 1; }; -void QDeclarativeListViewPrivate::init() +void QDeclarative1ListViewPrivate::init() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); q->setFlag(QGraphicsItem::ItemIsFocusScope); addItemChangeListener(this, Geometry); QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); - q->setFlickableDirection(QDeclarativeFlickable::VerticalFlick); + q->setFlickableDirection(QDeclarative1Flickable::VerticalFlick); ::memset(sectionCache, 0, sizeof(QDeclarativeItem*) * sectionCacheSize); } -void QDeclarativeListViewPrivate::clear() +void QDeclarative1ListViewPrivate::clear() { timeline.clear(); for (int i = 0; i < visibleItems.count(); ++i) @@ -642,27 +643,27 @@ void QDeclarativeListViewPrivate::clear() itemCount = 0; } -FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) +FxListItem1 *QDeclarative1ListViewPrivate::createItem(int modelIndex) { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); // create object requestedIndex = modelIndex; - FxListItem *listItem = 0; + FxListItem1 *listItem = 0; if (QDeclarativeItem *item = model->item(modelIndex, false)) { - listItem = new FxListItem(item, q); + listItem = new FxListItem1(item, q); listItem->index = modelIndex; // initialise attached properties if (sectionCriteria) { QString propValue = model->stringValue(modelIndex, sectionCriteria->property()); listItem->attached->m_section = sectionCriteria->sectionString(propValue); if (modelIndex > 0) { - if (FxListItem *item = itemBefore(modelIndex)) + if (FxListItem1 *item = itemBefore(modelIndex)) listItem->attached->m_prevSection = item->attached->section(); else listItem->attached->m_prevSection = sectionAt(modelIndex-1); } if (modelIndex < model->count()-1) { - if (FxListItem *item = visibleItem(modelIndex+1)) + if (FxListItem1 *item = visibleItem(modelIndex+1)) listItem->attached->m_nextSection = item->attached->section(); else listItem->attached->m_nextSection = sectionAt(modelIndex+1); @@ -689,9 +690,9 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex) return listItem; } -void QDeclarativeListViewPrivate::releaseItem(FxListItem *item) +void QDeclarative1ListViewPrivate::releaseItem(FxListItem1 *item) { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!item || !model) return; if (trackedItem == item) @@ -718,9 +719,9 @@ void QDeclarativeListViewPrivate::releaseItem(FxListItem *item) delete item; } -void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) +void QDeclarative1ListViewPrivate::refill(qreal from, qreal to, bool doBuffer) { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!isValid() || !q->isComponentComplete()) return; itemCount = model->count(); @@ -770,7 +771,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) } bool changed = false; - FxListItem *item = 0; + FxListItem1 *item = 0; qreal pos = itemEnd + 1; while (modelIndex < model->count() && pos <= fillTo) { // qDebug() << "refill: append item" << modelIndex << "pos" << pos; @@ -845,18 +846,18 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer) lazyRelease = false; } -void QDeclarativeListViewPrivate::scheduleLayout() +void QDeclarative1ListViewPrivate::scheduleLayout() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!layoutScheduled) { layoutScheduled = true; QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority); } } -void QDeclarativeListViewPrivate::layout() +void QDeclarative1ListViewPrivate::layout() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); layoutScheduled = false; if (!isValid() && !visibleItems.count()) { clear(); @@ -868,7 +869,7 @@ void QDeclarativeListViewPrivate::layout() qreal sum = visibleItems.first()->size(); qreal pos = visibleItems.first()->position() + visibleItems.first()->size() + spacing; for (int i=1; i < visibleItems.count(); ++i) { - FxListItem *item = visibleItems.at(i); + FxListItem1 *item = visibleItems.at(i); item->setPosition(pos); pos += item->size() + spacing; sum += item->size(); @@ -894,23 +895,23 @@ void QDeclarativeListViewPrivate::layout() updateViewport(); } -void QDeclarativeListViewPrivate::updateUnrequestedIndexes() +void QDeclarative1ListViewPrivate::updateUnrequestedIndexes() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); QHash::iterator it; for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) *it = model->indexOf(it.key(), q); } -void QDeclarativeListViewPrivate::updateUnrequestedPositions() +void QDeclarative1ListViewPrivate::updateUnrequestedPositions() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (unrequestedItems.count()) { qreal pos = position(); QHash::const_iterator it; for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { QDeclarativeItem *item = it.key(); - if (orient == QDeclarativeListView::Vertical) { + if (orient == QDeclarative1ListView::Vertical) { if (item->y() + item->height() > pos && item->y() < pos + q->height()) item->setY(positionAt(*it)); } else { @@ -925,10 +926,10 @@ void QDeclarativeListViewPrivate::updateUnrequestedPositions() } } -void QDeclarativeListViewPrivate::updateTrackedItem() +void QDeclarative1ListViewPrivate::updateTrackedItem() { - Q_Q(QDeclarativeListView); - FxListItem *item = currentItem; + Q_Q(QDeclarative1ListView); + FxListItem1 *item = currentItem; if (highlight) item = highlight; trackedItem = item; @@ -936,9 +937,9 @@ void QDeclarativeListViewPrivate::updateTrackedItem() q->trackedPositionChanged(); } -void QDeclarativeListViewPrivate::createHighlight() +void QDeclarative1ListViewPrivate::createHighlight() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); bool changed = false; if (highlight) { if (trackedItem == highlight) @@ -974,9 +975,9 @@ void QDeclarativeListViewPrivate::createHighlight() if (item) { QDeclarative_setParent_noEvent(item, q->contentItem()); item->setParentItem(q->contentItem()); - highlight = new FxListItem(item, q); + highlight = new FxListItem1(item, q); if (currentItem && autoHighlight) { - if (orient == QDeclarativeListView::Vertical) { + if (orient == QDeclarative1ListView::Vertical) { highlight->item->setHeight(currentItem->item->height()); } else { highlight->item->setWidth(currentItem->item->width()); @@ -985,13 +986,13 @@ void QDeclarativeListViewPrivate::createHighlight() } QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - const QLatin1String posProp(orient == QDeclarativeListView::Vertical ? "y" : "x"); - highlightPosAnimator = new QSmoothedAnimation(q); + const QLatin1String posProp(orient == QDeclarative1ListView::Vertical ? "y" : "x"); + highlightPosAnimator = new QSmoothedAnimation_1(q); highlightPosAnimator->target = QDeclarativeProperty(highlight->item, posProp); highlightPosAnimator->velocity = highlightMoveSpeed; highlightPosAnimator->userDuration = highlightMoveDuration; - const QLatin1String sizeProp(orient == QDeclarativeListView::Vertical ? "height" : "width"); - highlightSizeAnimator = new QSmoothedAnimation(q); + const QLatin1String sizeProp(orient == QDeclarative1ListView::Vertical ? "height" : "width"); + highlightSizeAnimator = new QSmoothedAnimation_1(q); highlightSizeAnimator->velocity = highlightResizeSpeed; highlightSizeAnimator->userDuration = highlightResizeDuration; highlightSizeAnimator->target = QDeclarativeProperty(highlight->item, sizeProp); @@ -1006,7 +1007,7 @@ void QDeclarativeListViewPrivate::createHighlight() emit q->highlightItemChanged(); } -void QDeclarativeListViewPrivate::updateHighlight() +void QDeclarative1ListViewPrivate::updateHighlight() { if ((!currentItem && highlight) || (currentItem && !highlight)) createHighlight(); @@ -1016,7 +1017,7 @@ void QDeclarativeListViewPrivate::updateHighlight() ? -currentItem->itemPosition()-currentItem->itemSize() : currentItem->itemPosition(); highlightSizeAnimator->to = currentItem->itemSize(); - if (orient == QDeclarativeListView::Vertical) { + if (orient == QDeclarative1ListView::Vertical) { if (highlight->item->width() == 0) highlight->item->setWidth(currentItem->item->width()); } else { @@ -1029,9 +1030,9 @@ void QDeclarativeListViewPrivate::updateHighlight() updateTrackedItem(); } -void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) +void QDeclarative1ListViewPrivate::createSection(FxListItem1 *listItem) { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!sectionCriteria || !sectionCriteria->delegate()) return; if (listItem->attached->m_prevSection != listItem->attached->m_section) { @@ -1088,16 +1089,16 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) } } -void QDeclarativeListViewPrivate::updateSections() +void QDeclarative1ListViewPrivate::updateSections() { if (sectionCriteria && !visibleItems.isEmpty()) { QString prevSection; if (visibleIndex > 0) prevSection = sectionAt(visibleIndex-1); - QDeclarativeListViewAttached *prevAtt = 0; + QDeclarative1ListViewAttached *prevAtt = 0; int idx = -1; for (int i = 0; i < visibleItems.count(); ++i) { - QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached; + QDeclarative1ListViewAttached *attached = visibleItems.at(i)->attached; attached->setPrevSection(prevSection); if (visibleItems.at(i)->index != -1) { QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property()); @@ -1119,9 +1120,9 @@ void QDeclarativeListViewPrivate::updateSections() } } -void QDeclarativeListViewPrivate::updateCurrentSection() +void QDeclarative1ListViewPrivate::updateCurrentSection() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!sectionCriteria || visibleItems.isEmpty()) { if (!currentSection.isEmpty()) { currentSection.clear(); @@ -1144,9 +1145,9 @@ void QDeclarativeListViewPrivate::updateCurrentSection() } } -void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) +void QDeclarative1ListViewPrivate::updateCurrent(int modelIndex) { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) { if (currentItem) { currentItem->attached->setIsCurrentItem(false); @@ -1166,7 +1167,7 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) updateHighlight(); return; } - FxListItem *oldCurrentItem = currentItem; + FxListItem1 *oldCurrentItem = currentItem; currentIndex = modelIndex; currentItem = createItem(modelIndex); if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) @@ -1196,7 +1197,7 @@ void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) releaseItem(oldCurrentItem); } -void QDeclarativeListViewPrivate::updateAverage() +void QDeclarative1ListViewPrivate::updateAverage() { if (!visibleItems.count()) return; @@ -1206,9 +1207,9 @@ void QDeclarativeListViewPrivate::updateAverage() averageSize = qRound(sum / visibleItems.count()); } -void QDeclarativeListViewPrivate::updateFooter() +void QDeclarative1ListViewPrivate::updateFooter() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!footer && footerComponent) { QDeclarativeItem *item = 0; QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); @@ -1227,7 +1228,7 @@ void QDeclarativeListViewPrivate::updateFooter() item->setZValue(1); QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - footer = new FxListItem(item, q); + footer = new FxListItem1(item, q); } } if (footer) { @@ -1246,9 +1247,9 @@ void QDeclarativeListViewPrivate::updateFooter() } } -void QDeclarativeListViewPrivate::updateHeader() +void QDeclarative1ListViewPrivate::updateHeader() { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!header && headerComponent) { QDeclarativeItem *item = 0; QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); @@ -1267,7 +1268,7 @@ void QDeclarativeListViewPrivate::updateHeader() item->setZValue(1); QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - header = new FxListItem(item, q); + header = new FxListItem1(item, q); } } if (header) { @@ -1287,21 +1288,21 @@ void QDeclarativeListViewPrivate::updateHeader() } } -void QDeclarativeListViewPrivate::fixupPosition() +void QDeclarative1ListViewPrivate::fixupPosition() { - if ((haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange) - || snapMode != QDeclarativeListView::NoSnap) + if ((haveHighlightRange && highlightRange == QDeclarative1ListView::StrictlyEnforceRange) + || snapMode != QDeclarative1ListView::NoSnap) moveReason = Other; - if (orient == QDeclarativeListView::Vertical) + if (orient == QDeclarative1ListView::Vertical) fixupY(); else fixupX(); } -void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) +void QDeclarative1ListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) { - if ((orient == QDeclarativeListView::Horizontal && &data == &vData) - || (orient == QDeclarativeListView::Vertical && &data == &hData)) + if ((orient == QDeclarative1ListView::Horizontal && &data == &vData) + || (orient == QDeclarative1ListView::Vertical && &data == &hData)) return; correctFlick = false; @@ -1321,8 +1322,8 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m highlightEnd = highlightRangeEnd; } - if (currentItem && haveHighlightRange && highlightRange == QDeclarativeListView::StrictlyEnforceRange - && moveReason != QDeclarativeListViewPrivate::SetIndex) { + if (currentItem && haveHighlightRange && highlightRange == QDeclarative1ListView::StrictlyEnforceRange + && moveReason != QDeclarative1ListViewPrivate::SetIndex) { updateHighlight(); qreal pos = currentItem->itemPosition(); if (viewPos < pos + currentItem->itemSize() - highlightEnd) @@ -1342,10 +1343,10 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m } } vTime = timeline.time(); - } else if (snapMode != QDeclarativeListView::NoSnap && moveReason != QDeclarativeListViewPrivate::SetIndex) { + } else if (snapMode != QDeclarative1ListView::NoSnap && moveReason != QDeclarative1ListViewPrivate::SetIndex) { qreal tempPosition = isRightToLeft() ? -position()-size() : position(); - FxListItem *topItem = snapItemAt(tempPosition+highlightStart); - FxListItem *bottomItem = snapItemAt(tempPosition+highlightEnd); + FxListItem1 *topItem = snapItemAt(tempPosition+highlightStart); + FxListItem1 *bottomItem = snapItemAt(tempPosition+highlightEnd); qreal pos; bool isInBounds = -position() > maxExtent && -position() < minExtent; if (topItem && isInBounds) { @@ -1363,7 +1364,7 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m else pos = qMax(qMin(bottomItem->position() - highlightStart, -maxExtent), -minExtent); } else { - QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); + QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); return; } @@ -1379,22 +1380,22 @@ void QDeclarativeListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal m vTime = timeline.time(); } } else { - QDeclarativeFlickablePrivate::fixup(data, minExtent, maxExtent); + QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); } data.inOvershoot = false; fixupMode = Normal; } -void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarativeTimeLineCallback::Callback fixupCallback, qreal velocity) +void QDeclarative1ListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, + QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); data.fixingUp = false; moveReason = Mouse; - if ((!haveHighlightRange || highlightRange != QDeclarativeListView::StrictlyEnforceRange) && snapMode == QDeclarativeListView::NoSnap) { + if ((!haveHighlightRange || highlightRange != QDeclarative1ListView::StrictlyEnforceRange) && snapMode == QDeclarative1ListView::NoSnap) { correctFlick = true; - QDeclarativeFlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); + QDeclarative1FlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); return; } qreal maxDistance = 0; @@ -1402,29 +1403,29 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m // -ve velocity means list is moving up/left if (velocity > 0) { if (data.move.value() < minExtent) { - if (snapMode == QDeclarativeListView::SnapOneItem) { - if (FxListItem *item = isRightToLeft() ? nextVisibleItem() : firstVisibleItem()) + if (snapMode == QDeclarative1ListView::SnapOneItem) { + if (FxListItem1 *item = isRightToLeft() ? nextVisibleItem() : firstVisibleItem()) maxDistance = qAbs(item->position() + dataValue); } else { maxDistance = qAbs(minExtent - data.move.value()); } } - if (snapMode == QDeclarativeListView::NoSnap && highlightRange != QDeclarativeListView::StrictlyEnforceRange) + if (snapMode == QDeclarative1ListView::NoSnap && highlightRange != QDeclarative1ListView::StrictlyEnforceRange) data.flickTarget = minExtent; } else { if (data.move.value() > maxExtent) { - if (snapMode == QDeclarativeListView::SnapOneItem) { - if (FxListItem *item = isRightToLeft() ? firstVisibleItem() : nextVisibleItem()) + if (snapMode == QDeclarative1ListView::SnapOneItem) { + if (FxListItem1 *item = isRightToLeft() ? firstVisibleItem() : nextVisibleItem()) maxDistance = qAbs(item->position() + dataValue); } else { maxDistance = qAbs(maxExtent - data.move.value()); } } - if (snapMode == QDeclarativeListView::NoSnap && highlightRange != QDeclarativeListView::StrictlyEnforceRange) + if (snapMode == QDeclarative1ListView::NoSnap && highlightRange != QDeclarative1ListView::StrictlyEnforceRange) data.flickTarget = maxExtent; } - bool overShoot = boundsBehavior == QDeclarativeFlickable::DragAndOvershootBounds; + bool overShoot = boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds; qreal highlightStart = isRightToLeft() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; if (maxDistance > 0 || overShoot) { @@ -1450,7 +1451,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m dist = qMin(dist, maxDistance); if (v > 0) dist = -dist; - if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarativeListView::SnapOneItem) { + if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarative1ListView::SnapOneItem) { qreal distTemp = isRightToLeft() ? -dist : dist; data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart; data.flickTarget = isRightToLeft() ? -data.flickTarget+size() : data.flickTarget; @@ -1489,7 +1490,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); timeline.accel(data.move, v, accel, maxDistance + overshootDist); - timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); + timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); if (!flickingHorizontally && q->xflick()) { flickingHorizontally = true; emit q->flickingChanged(); @@ -1506,7 +1507,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m } else { // reevaluate the target boundary. qreal newtarget = data.flickTarget; - if (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange) { + if (snapMode != QDeclarative1ListView::NoSnap || highlightRange == QDeclarative1ListView::StrictlyEnforceRange) { qreal tempFlickTarget = isRightToLeft() ? -data.flickTarget+size() : data.flickTarget; newtarget = -snapPosAt(-(tempFlickTarget - highlightStart)) + highlightStart; newtarget = isRightToLeft() ? -newtarget+size() : newtarget; @@ -1531,7 +1532,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m timeline.reset(data.move); timeline.accelDistance(data.move, v, -dist); - timeline.callback(QDeclarativeTimeLineCallback(&data.move, fixupCallback, this)); + timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); } } else { correctFlick = false; @@ -1543,7 +1544,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m //---------------------------------------------------------------------------- /*! - \qmlclass ListView QDeclarativeListView + \qmlclass ListView QDeclarative1ListView \ingroup qml-view-elements \since 4.7 \inherits Flickable @@ -1605,16 +1606,16 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m \sa {QML Data Models}, GridView, {declarative/modelviews/listview}{ListView examples} */ -QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent) - : QDeclarativeFlickable(*(new QDeclarativeListViewPrivate), parent) +QDeclarative1ListView::QDeclarative1ListView(QDeclarativeItem *parent) + : QDeclarative1Flickable(*(new QDeclarative1ListViewPrivate), parent) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->init(); } -QDeclarativeListView::~QDeclarativeListView() +QDeclarative1ListView::~QDeclarative1ListView() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->clear(); if (d->ownModel) delete d->model; @@ -1703,15 +1704,15 @@ QDeclarativeListView::~QDeclarativeListView() \sa {qmlmodels}{Data Models} */ -QVariant QDeclarativeListView::model() const +QVariant QDeclarative1ListView::model() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->modelVariant; } -void QDeclarativeListView::setModel(const QVariant &model) +void QDeclarative1ListView::setModel(const QVariant &model) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->modelVariant == model) return; if (d->model) { @@ -1724,13 +1725,13 @@ void QDeclarativeListView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); } d->clear(); - QDeclarativeVisualModel *oldModel = d->model; + QDeclarative1VisualModel *oldModel = d->model; d->model = 0; d->setPosition(0); d->modelVariant = model; QObject *object = qvariant_cast(model); - QDeclarativeVisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { + QDeclarative1VisualModel *vim = 0; + if (object && (vim = qobject_cast(object))) { if (d->ownModel) { delete oldModel; d->ownModel = false; @@ -1738,23 +1739,23 @@ void QDeclarativeListView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); + d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); d->ownModel = true; } else { d->model = oldModel; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) dataModel->setModel(model); } if (d->model) { - d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter; + d->bufferMode = QDeclarative1ListViewPrivate::BufferBefore | QDeclarative1ListViewPrivate::BufferAfter; if (isComponentComplete()) { updateSections(); refill(); if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { setCurrentIndex(0); } else { - d->moveReason = QDeclarativeListViewPrivate::SetIndex; + d->moveReason = QDeclarative1ListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); if (d->highlight && d->currentItem) { if (d->autoHighlight) @@ -1797,27 +1798,27 @@ void QDeclarativeListView::setModel(const QVariant &model) \note Delegates are instantiated as needed and may be destroyed at any time. State should \e never be stored in a delegate. */ -QDeclarativeComponent *QDeclarativeListView::delegate() const +QDeclarativeComponent *QDeclarative1ListView::delegate() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); if (d->model) { - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) return dataModel->delegate(); } return 0; } -void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) +void QDeclarative1ListView::setDelegate(QDeclarativeComponent *delegate) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (delegate == this->delegate()) return; if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarative1VisualDataModel(qmlContext(this)); d->ownModel = true; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) { + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { int oldCount = dataModel->count(); dataModel->setDelegate(delegate); if (isComponentComplete()) { @@ -1828,7 +1829,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) d->currentItem = 0; updateSections(); refill(); - d->moveReason = QDeclarativeListViewPrivate::SetIndex; + d->moveReason = QDeclarative1ListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); if (d->highlight && d->currentItem) { if (d->autoHighlight) @@ -1858,22 +1859,22 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) Note that the position of the current item may only be approximate until it becomes visible in the view. */ -int QDeclarativeListView::currentIndex() const +int QDeclarative1ListView::currentIndex() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->currentIndex; } -void QDeclarativeListView::setCurrentIndex(int index) +void QDeclarative1ListView::setCurrentIndex(int index) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->requestedIndex >= 0) // currently creating item return; d->currentIndexCleared = (index == -1); if (index == d->currentIndex) return; if (isComponentComplete() && d->isValid()) { - d->moveReason = QDeclarativeListViewPrivate::SetIndex; + d->moveReason = QDeclarative1ListViewPrivate::SetIndex; d->updateCurrent(index); } else if (d->currentIndex != index) { d->currentIndex = index; @@ -1881,9 +1882,9 @@ void QDeclarativeListView::setCurrentIndex(int index) } } -QDeclarativeItem *QDeclarativeListView::currentItem() +QDeclarativeItem *QDeclarative1ListView::currentItem() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!d->currentItem) return 0; return d->currentItem->item; @@ -1899,9 +1900,9 @@ QDeclarativeItem *QDeclarativeListView::currentItem() \sa highlight, highlightFollowsCurrentItem */ -QDeclarativeItem *QDeclarativeListView::highlightItem() +QDeclarativeItem *QDeclarative1ListView::highlightItem() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!d->highlight) return 0; return d->highlight->item; @@ -1911,9 +1912,9 @@ QDeclarativeItem *QDeclarativeListView::highlightItem() \qmlproperty int ListView::count This property holds the number of items in the view. */ -int QDeclarativeListView::count() const +int QDeclarative1ListView::count() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); if (d->model) return d->model->count(); return 0; @@ -1930,15 +1931,15 @@ int QDeclarativeListView::count() const \sa highlightItem, highlightFollowsCurrentItem, {declarative/modelviews/listview}{ListView examples} */ -QDeclarativeComponent *QDeclarativeListView::highlight() const +QDeclarativeComponent *QDeclarative1ListView::highlight() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->highlightComponent; } -void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight) +void QDeclarative1ListView::setHighlight(QDeclarativeComponent *highlight) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (highlight != d->highlightComponent) { d->highlightComponent = highlight; d->createHighlight(); @@ -1967,15 +1968,15 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight) \sa highlight, highlightMoveSpeed */ -bool QDeclarativeListView::highlightFollowsCurrentItem() const +bool QDeclarative1ListView::highlightFollowsCurrentItem() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->autoHighlight; } -void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight) +void QDeclarative1ListView::setHighlightFollowsCurrentItem(bool autoHighlight) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->autoHighlight != autoHighlight) { d->autoHighlight = autoHighlight; if (autoHighlight) { @@ -2021,15 +2022,15 @@ void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight) \o ListView.NoHighlightRange - this is the default value. \endlist */ -qreal QDeclarativeListView::preferredHighlightBegin() const +qreal QDeclarative1ListView::preferredHighlightBegin() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->highlightRangeStart; } -void QDeclarativeListView::setPreferredHighlightBegin(qreal start) +void QDeclarative1ListView::setPreferredHighlightBegin(qreal start) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->highlightRangeStartValid = true; if (d->highlightRangeStart == start) return; @@ -2038,9 +2039,9 @@ void QDeclarativeListView::setPreferredHighlightBegin(qreal start) emit preferredHighlightBeginChanged(); } -void QDeclarativeListView::resetPreferredHighlightBegin() +void QDeclarative1ListView::resetPreferredHighlightBegin() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->highlightRangeStartValid = false; if (d->highlightRangeStart == 0) return; @@ -2048,15 +2049,15 @@ void QDeclarativeListView::resetPreferredHighlightBegin() emit preferredHighlightBeginChanged(); } -qreal QDeclarativeListView::preferredHighlightEnd() const +qreal QDeclarative1ListView::preferredHighlightEnd() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->highlightRangeEnd; } -void QDeclarativeListView::setPreferredHighlightEnd(qreal end) +void QDeclarative1ListView::setPreferredHighlightEnd(qreal end) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->highlightRangeEndValid = true; if (d->highlightRangeEnd == end) return; @@ -2065,9 +2066,9 @@ void QDeclarativeListView::setPreferredHighlightEnd(qreal end) emit preferredHighlightEndChanged(); } -void QDeclarativeListView::resetPreferredHighlightEnd() +void QDeclarative1ListView::resetPreferredHighlightEnd() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->highlightRangeEndValid = false; if (d->highlightRangeEnd == 0) return; @@ -2075,15 +2076,15 @@ void QDeclarativeListView::resetPreferredHighlightEnd() emit preferredHighlightEndChanged(); } -QDeclarativeListView::HighlightRangeMode QDeclarativeListView::highlightRangeMode() const +QDeclarative1ListView::HighlightRangeMode QDeclarative1ListView::highlightRangeMode() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->highlightRange; } -void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode) +void QDeclarative1ListView::setHighlightRangeMode(HighlightRangeMode mode) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->highlightRange == mode) return; d->highlightRange = mode; @@ -2098,15 +2099,15 @@ void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode) The default value is 0. */ -qreal QDeclarativeListView::spacing() const +qreal QDeclarative1ListView::spacing() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->spacing; } -void QDeclarativeListView::setSpacing(qreal spacing) +void QDeclarative1ListView::setSpacing(qreal spacing) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (spacing != d->spacing) { d->spacing = spacing; d->layout(); @@ -2135,18 +2136,18 @@ void QDeclarativeListView::setSpacing(qreal spacing) \image listview-highlight.png \endtable */ -QDeclarativeListView::Orientation QDeclarativeListView::orientation() const +QDeclarative1ListView::Orientation QDeclarative1ListView::orientation() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->orient; } -void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orientation) +void QDeclarative1ListView::setOrientation(QDeclarative1ListView::Orientation orientation) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->orient != orientation) { d->orient = orientation; - if (d->orient == QDeclarativeListView::Vertical) { + if (d->orient == QDeclarative1ListView::Vertical) { setContentWidth(-1); setFlickableDirection(VerticalFlick); setContentX(0); @@ -2174,15 +2175,15 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie \sa ListView::effectiveLayoutDirection */ -Qt::LayoutDirection QDeclarativeListView::layoutDirection() const +Qt::LayoutDirection QDeclarative1ListView::layoutDirection() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->layoutDirection; } -void QDeclarativeListView::setLayoutDirection(Qt::LayoutDirection layoutDirection) +void QDeclarative1ListView::setLayoutDirection(Qt::LayoutDirection layoutDirection) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; d->regenerate(); @@ -2202,9 +2203,9 @@ void QDeclarativeListView::setLayoutDirection(Qt::LayoutDirection layoutDirectio \sa ListView::layoutDirection, {LayoutMirroring}{LayoutMirroring} */ -Qt::LayoutDirection QDeclarativeListView::effectiveLayoutDirection() const +Qt::LayoutDirection QDeclarative1ListView::effectiveLayoutDirection() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); if (d->effectiveLayoutMirror) return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; else @@ -2221,15 +2222,15 @@ Qt::LayoutDirection QDeclarativeListView::effectiveLayoutDirection() const By default, key navigation is not wrapped. */ -bool QDeclarativeListView::isWrapEnabled() const +bool QDeclarative1ListView::isWrapEnabled() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->wrap; } -void QDeclarativeListView::setWrapEnabled(bool wrap) +void QDeclarative1ListView::setWrapEnabled(bool wrap) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->wrap == wrap) return; d->wrap = wrap; @@ -2255,19 +2256,19 @@ void QDeclarativeListView::setWrapEnabled(bool wrap) delegates; the fewer elements in a delegate, the faster a view can be scrolled. */ -int QDeclarativeListView::cacheBuffer() const +int QDeclarative1ListView::cacheBuffer() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->buffer; } -void QDeclarativeListView::setCacheBuffer(int b) +void QDeclarative1ListView::setCacheBuffer(int b) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->buffer != b) { d->buffer = b; if (isComponentComplete()) { - d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter; + d->bufferMode = QDeclarative1ListViewPrivate::BufferBefore | QDeclarative1ListViewPrivate::BufferAfter; refill(); } emit cacheBufferChanged(); @@ -2325,11 +2326,11 @@ void QDeclarativeListView::setCacheBuffer(int b) \sa {declarative/modelviews/listview}{ListView examples} */ -QDeclarativeViewSection *QDeclarativeListView::sectionCriteria() +QDeclarative1ViewSection *QDeclarative1ListView::sectionCriteria() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!d->sectionCriteria) { - d->sectionCriteria = new QDeclarativeViewSection(this); + d->sectionCriteria = new QDeclarative1ViewSection(this); connect(d->sectionCriteria, SIGNAL(propertyChanged()), this, SLOT(updateSections())); } return d->sectionCriteria; @@ -2339,9 +2340,9 @@ QDeclarativeViewSection *QDeclarativeListView::sectionCriteria() \qmlproperty string ListView::currentSection This property holds the section that is currently at the beginning of the view. */ -QString QDeclarativeListView::currentSection() const +QString QDeclarative1ListView::currentSection() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->currentSection; } @@ -2364,15 +2365,15 @@ QString QDeclarativeListView::currentSection() const \sa highlightFollowsCurrentItem */ -qreal QDeclarativeListView::highlightMoveSpeed() const +qreal QDeclarative1ListView::highlightMoveSpeed() const { - Q_D(const QDeclarativeListView);\ + Q_D(const QDeclarative1ListView);\ return d->highlightMoveSpeed; } -void QDeclarativeListView::setHighlightMoveSpeed(qreal speed) +void QDeclarative1ListView::setHighlightMoveSpeed(qreal speed) { - Q_D(QDeclarativeListView);\ + Q_D(QDeclarative1ListView);\ if (d->highlightMoveSpeed != speed) { d->highlightMoveSpeed = speed; if (d->highlightPosAnimator) @@ -2381,15 +2382,15 @@ void QDeclarativeListView::setHighlightMoveSpeed(qreal speed) } } -int QDeclarativeListView::highlightMoveDuration() const +int QDeclarative1ListView::highlightMoveDuration() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->highlightMoveDuration; } -void QDeclarativeListView::setHighlightMoveDuration(int duration) +void QDeclarative1ListView::setHighlightMoveDuration(int duration) { - Q_D(QDeclarativeListView);\ + Q_D(QDeclarative1ListView);\ if (d->highlightMoveDuration != duration) { d->highlightMoveDuration = duration; if (d->highlightPosAnimator) @@ -2398,15 +2399,15 @@ void QDeclarativeListView::setHighlightMoveDuration(int duration) } } -qreal QDeclarativeListView::highlightResizeSpeed() const +qreal QDeclarative1ListView::highlightResizeSpeed() const { - Q_D(const QDeclarativeListView);\ + Q_D(const QDeclarative1ListView);\ return d->highlightResizeSpeed; } -void QDeclarativeListView::setHighlightResizeSpeed(qreal speed) +void QDeclarative1ListView::setHighlightResizeSpeed(qreal speed) { - Q_D(QDeclarativeListView);\ + Q_D(QDeclarative1ListView);\ if (d->highlightResizeSpeed != speed) { d->highlightResizeSpeed = speed; if (d->highlightSizeAnimator) @@ -2415,15 +2416,15 @@ void QDeclarativeListView::setHighlightResizeSpeed(qreal speed) } } -int QDeclarativeListView::highlightResizeDuration() const +int QDeclarative1ListView::highlightResizeDuration() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->highlightResizeDuration; } -void QDeclarativeListView::setHighlightResizeDuration(int duration) +void QDeclarative1ListView::setHighlightResizeDuration(int duration) { - Q_D(QDeclarativeListView);\ + Q_D(QDeclarative1ListView);\ if (d->highlightResizeDuration != duration) { d->highlightResizeDuration = duration; if (d->highlightSizeAnimator) @@ -2453,15 +2454,15 @@ void QDeclarativeListView::setHighlightResizeDuration(int duration) \sa highlightRangeMode */ -QDeclarativeListView::SnapMode QDeclarativeListView::snapMode() const +QDeclarative1ListView::SnapMode QDeclarative1ListView::snapMode() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->snapMode; } -void QDeclarativeListView::setSnapMode(SnapMode mode) +void QDeclarative1ListView::setSnapMode(SnapMode mode) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->snapMode != mode) { d->snapMode = mode; emit snapModeChanged(); @@ -2477,15 +2478,15 @@ void QDeclarativeListView::setSnapMode(SnapMode mode) \sa header */ -QDeclarativeComponent *QDeclarativeListView::footer() const +QDeclarativeComponent *QDeclarative1ListView::footer() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->footerComponent; } -void QDeclarativeListView::setFooter(QDeclarativeComponent *footer) +void QDeclarative1ListView::setFooter(QDeclarativeComponent *footer) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->footerComponent != footer) { if (d->footer) { if (scene()) @@ -2515,15 +2516,15 @@ void QDeclarativeListView::setFooter(QDeclarativeComponent *footer) \sa footer */ -QDeclarativeComponent *QDeclarativeListView::header() const +QDeclarativeComponent *QDeclarative1ListView::header() const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); return d->headerComponent; } -void QDeclarativeListView::setHeader(QDeclarativeComponent *header) +void QDeclarative1ListView::setHeader(QDeclarativeComponent *header) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->headerComponent != header) { if (d->header) { if (scene()) @@ -2545,37 +2546,37 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header) } } -void QDeclarativeListView::setContentX(qreal pos) +void QDeclarative1ListView::setContentX(qreal pos) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); // Positioning the view manually should override any current movement state - d->moveReason = QDeclarativeListViewPrivate::Other; - QDeclarativeFlickable::setContentX(pos); + d->moveReason = QDeclarative1ListViewPrivate::Other; + QDeclarative1Flickable::setContentX(pos); } -void QDeclarativeListView::setContentY(qreal pos) +void QDeclarative1ListView::setContentY(qreal pos) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); // Positioning the view manually should override any current movement state - d->moveReason = QDeclarativeListViewPrivate::Other; - QDeclarativeFlickable::setContentY(pos); + d->moveReason = QDeclarative1ListViewPrivate::Other; + QDeclarative1Flickable::setContentY(pos); } -bool QDeclarativeListView::event(QEvent *event) +bool QDeclarative1ListView::event(QEvent *event) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (event->type() == QEvent::User) { d->layout(); return true; } - return QDeclarativeFlickable::event(event); + return QDeclarative1Flickable::event(event); } -void QDeclarativeListView::viewportMoved() +void QDeclarative1ListView::viewportMoved() { - Q_D(QDeclarativeListView); - QDeclarativeFlickable::viewportMoved(); + Q_D(QDeclarative1ListView); + QDeclarative1Flickable::viewportMoved(); if (!d->itemCount) return; // Recursion can occur due to refill changing the content size. @@ -2585,8 +2586,8 @@ void QDeclarativeListView::viewportMoved() d->lazyRelease = true; refill(); if (d->flickingHorizontally || d->flickingVertically || d->movingHorizontally || d->movingVertically) - d->moveReason = QDeclarativeListViewPrivate::Mouse; - if (d->moveReason != QDeclarativeListViewPrivate::SetIndex) { + d->moveReason = QDeclarative1ListViewPrivate::Mouse; + if (d->moveReason != QDeclarative1ListViewPrivate::SetIndex) { if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { // reposition highlight qreal pos = d->highlight->position(); @@ -2611,7 +2612,7 @@ void QDeclarativeListView::viewportMoved() d->highlight->setPosition(qRound(pos)); // update current index - if (FxListItem *snapItem = d->snapItemAt(d->highlight->position())) { + if (FxListItem1 *snapItem = d->snapItemAt(d->highlight->position())) { if (snapItem->index >= 0 && snapItem->index != d->currentIndex) d->updateCurrent(snapItem->index); } @@ -2628,13 +2629,13 @@ void QDeclarativeListView::viewportMoved() if ((minY - d->vData.move.value() < height()/2 || d->vData.flickTarget - d->vData.move.value() < height()/2) && minY != d->vData.flickTarget) d->flickY(-d->vData.smoothVelocity.value()); - d->bufferMode = QDeclarativeListViewPrivate::BufferBefore; + d->bufferMode = QDeclarative1ListViewPrivate::BufferBefore; } else if (d->vData.velocity < 0) { const qreal maxY = maxYExtent(); if ((d->vData.move.value() - maxY < height()/2 || d->vData.move.value() - d->vData.flickTarget < height()/2) && maxY != d->vData.flickTarget) d->flickY(-d->vData.smoothVelocity.value()); - d->bufferMode = QDeclarativeListViewPrivate::BufferAfter; + d->bufferMode = QDeclarative1ListViewPrivate::BufferAfter; } } @@ -2645,14 +2646,14 @@ void QDeclarativeListView::viewportMoved() && minX != d->hData.flickTarget) d->flickX(-d->hData.smoothVelocity.value()); d->bufferMode = d->isRightToLeft() - ? QDeclarativeListViewPrivate::BufferAfter : QDeclarativeListViewPrivate::BufferBefore; + ? QDeclarative1ListViewPrivate::BufferAfter : QDeclarative1ListViewPrivate::BufferBefore; } else if (d->hData.velocity < 0) { const qreal maxX = maxXExtent(); if ((d->hData.move.value() - maxX < width()/2 || d->hData.move.value() - d->hData.flickTarget < width()/2) && maxX != d->hData.flickTarget) d->flickX(-d->hData.smoothVelocity.value()); d->bufferMode = d->isRightToLeft() - ? QDeclarativeListViewPrivate::BufferBefore : QDeclarativeListViewPrivate::BufferAfter; + ? QDeclarative1ListViewPrivate::BufferBefore : QDeclarative1ListViewPrivate::BufferAfter; } } d->inFlickCorrection = false; @@ -2660,11 +2661,11 @@ void QDeclarativeListView::viewportMoved() d->inViewportMoved = false; } -qreal QDeclarativeListView::minYExtent() const +qreal QDeclarative1ListView::minYExtent() const { - Q_D(const QDeclarativeListView); - if (d->orient == QDeclarativeListView::Horizontal) - return QDeclarativeFlickable::minYExtent(); + Q_D(const QDeclarative1ListView); + if (d->orient == QDeclarative1ListView::Horizontal) + return QDeclarative1Flickable::minYExtent(); if (d->minExtentDirty) { d->minExtent = -d->startPosition(); if (d->header && d->visibleItems.count()) @@ -2683,10 +2684,10 @@ qreal QDeclarativeListView::minYExtent() const return d->minExtent; } -qreal QDeclarativeListView::maxYExtent() const +qreal QDeclarative1ListView::maxYExtent() const { - Q_D(const QDeclarativeListView); - if (d->orient == QDeclarativeListView::Horizontal) + Q_D(const QDeclarative1ListView); + if (d->orient == QDeclarative1ListView::Horizontal) return height(); if (d->maxExtentDirty) { if (!d->model || !d->model->count()) { @@ -2709,11 +2710,11 @@ qreal QDeclarativeListView::maxYExtent() const return d->maxExtent; } -qreal QDeclarativeListView::minXExtent() const +qreal QDeclarative1ListView::minXExtent() const { - Q_D(const QDeclarativeListView); - if (d->orient == QDeclarativeListView::Vertical) - return QDeclarativeFlickable::minXExtent(); + Q_D(const QDeclarative1ListView); + if (d->orient == QDeclarative1ListView::Vertical) + return QDeclarative1Flickable::minXExtent(); if (d->minExtentDirty) { d->minExtent = -d->startPosition(); @@ -2751,10 +2752,10 @@ qreal QDeclarativeListView::minXExtent() const return d->minExtent; } -qreal QDeclarativeListView::maxXExtent() const +qreal QDeclarative1ListView::maxXExtent() const { - Q_D(const QDeclarativeListView); - if (d->orient == QDeclarativeListView::Vertical) + Q_D(const QDeclarative1ListView); + if (d->orient == QDeclarative1ListView::Vertical) return width(); if (d->maxExtentDirty) { qreal highlightStart; @@ -2800,17 +2801,17 @@ qreal QDeclarativeListView::maxXExtent() const return d->maxExtent; } -void QDeclarativeListView::keyPressEvent(QKeyEvent *event) +void QDeclarative1ListView::keyPressEvent(QKeyEvent *event) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); keyPressPreHandler(event); if (event->isAccepted()) return; if (d->model && d->model->count() && d->interactive) { - if ((d->orient == QDeclarativeListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Left) - || (d->orient == QDeclarativeListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Right) - || (d->orient == QDeclarativeListView::Vertical && event->key() == Qt::Key_Up)) { + if ((d->orient == QDeclarative1ListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Left) + || (d->orient == QDeclarative1ListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Right) + || (d->orient == QDeclarative1ListView::Vertical && event->key() == Qt::Key_Up)) { if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) { decrementCurrentIndex(); event->accept(); @@ -2819,9 +2820,9 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event) event->accept(); return; } - } else if ((d->orient == QDeclarativeListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Right) - || (d->orient == QDeclarativeListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Left) - || (d->orient == QDeclarativeListView::Vertical && event->key() == Qt::Key_Down)) { + } else if ((d->orient == QDeclarative1ListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Right) + || (d->orient == QDeclarative1ListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Left) + || (d->orient == QDeclarative1ListView::Vertical && event->key() == Qt::Key_Down)) { if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) { incrementCurrentIndex(); event->accept(); @@ -2833,21 +2834,21 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event) } } event->ignore(); - QDeclarativeFlickable::keyPressEvent(event); + QDeclarative1Flickable::keyPressEvent(event); } -void QDeclarativeListView::geometryChanged(const QRectF &newGeometry, +void QDeclarative1ListView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->maxExtentDirty = true; d->minExtentDirty = true; - if (d->isRightToLeft() && d->orient == QDeclarativeListView::Horizontal) { + if (d->isRightToLeft() && d->orient == QDeclarative1ListView::Horizontal) { // maintain position relative to the right edge int dx = newGeometry.width() - oldGeometry.width(); setContentX(contentX() - dx); } - QDeclarativeFlickable::geometryChanged(newGeometry, oldGeometry); + QDeclarative1Flickable::geometryChanged(newGeometry, oldGeometry); } @@ -2860,12 +2861,12 @@ void QDeclarativeListView::geometryChanged(const QRectF &newGeometry, \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativeListView::incrementCurrentIndex() +void QDeclarative1ListView::incrementCurrentIndex() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); int count = d->model ? d->model->count() : 0; if (count && (currentIndex() < count - 1 || d->wrap)) { - d->moveReason = QDeclarativeListViewPrivate::SetIndex; + d->moveReason = QDeclarative1ListViewPrivate::SetIndex; int index = currentIndex()+1; setCurrentIndex((index >= 0 && index < count) ? index : 0); } @@ -2880,32 +2881,32 @@ void QDeclarativeListView::incrementCurrentIndex() \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativeListView::decrementCurrentIndex() +void QDeclarative1ListView::decrementCurrentIndex() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); int count = d->model ? d->model->count() : 0; if (count && (currentIndex() > 0 || d->wrap)) { - d->moveReason = QDeclarativeListViewPrivate::SetIndex; + d->moveReason = QDeclarative1ListViewPrivate::SetIndex; int index = currentIndex()-1; setCurrentIndex((index >= 0 && index < count) ? index : count-1); } } -void QDeclarativeListViewPrivate::positionViewAtIndex(int index, int mode) +void QDeclarative1ListViewPrivate::positionViewAtIndex(int index, int mode) { - Q_Q(QDeclarativeListView); + Q_Q(QDeclarative1ListView); if (!isValid()) return; - if (mode < QDeclarativeListView::Beginning || mode > QDeclarativeListView::Contain) + if (mode < QDeclarative1ListView::Beginning || mode > QDeclarative1ListView::Contain) return; int idx = qMax(qMin(index, model->count()-1), 0); if (layoutScheduled) layout(); qreal pos = isRightToLeft() ? -position() - size() : position(); - FxListItem *item = visibleItem(idx); + FxListItem1 *item = visibleItem(idx); qreal maxExtent; - if (orient == QDeclarativeListView::Vertical) + if (orient == QDeclarative1ListView::Vertical) maxExtent = -q->maxYExtent(); else maxExtent = isRightToLeft() ? q->minXExtent()-size(): -q->maxXExtent(); @@ -2913,7 +2914,7 @@ void QDeclarativeListViewPrivate::positionViewAtIndex(int index, int mode) if (!item) { int itemPos = positionAt(idx); // save the currently visible items in case any of them end up visible again - QList oldVisible = visibleItems; + QList oldVisible = visibleItems; visibleItems.clear(); visiblePos = itemPos; visibleIndex = idx; @@ -2926,26 +2927,26 @@ void QDeclarativeListViewPrivate::positionViewAtIndex(int index, int mode) if (item) { const qreal itemPos = item->position(); switch (mode) { - case QDeclarativeListView::Beginning: + case QDeclarative1ListView::Beginning: pos = itemPos; if (index < 0 && header) pos -= header->size(); break; - case QDeclarativeListView::Center: + case QDeclarative1ListView::Center: pos = itemPos - (size() - item->size())/2; break; - case QDeclarativeListView::End: + case QDeclarative1ListView::End: pos = itemPos - size() + item->size(); if (index >= model->count() && footer) pos += footer->size(); break; - case QDeclarativeListView::Visible: + case QDeclarative1ListView::Visible: if (itemPos > pos + size()) pos = itemPos - size() + item->size(); else if (item->endPosition() < pos) pos = itemPos; break; - case QDeclarativeListView::Contain: + case QDeclarative1ListView::Contain: if (item->endPosition() > pos + size()) pos = itemPos - size() + item->size(); if (itemPos < pos) @@ -2953,13 +2954,13 @@ void QDeclarativeListViewPrivate::positionViewAtIndex(int index, int mode) } pos = qMin(pos, maxExtent); qreal minExtent; - if (orient == QDeclarativeListView::Vertical) { + if (orient == QDeclarative1ListView::Vertical) { minExtent = -q->minYExtent(); } else { minExtent = isRightToLeft() ? q->maxXExtent()-size(): -q->minXExtent(); } pos = qMax(pos, minExtent); - moveReason = QDeclarativeListViewPrivate::Other; + moveReason = QDeclarative1ListViewPrivate::Other; q->cancelFlick(); setPosition(pos); if (highlight) { @@ -3006,9 +3007,9 @@ void QDeclarativeListViewPrivate::positionViewAtIndex(int index, int mode) Component.onCompleted: positionViewAtIndex(count - 1, ListView.Beginning) \endcode */ -void QDeclarativeListView::positionViewAtIndex(int index, int mode) +void QDeclarative1ListView::positionViewAtIndex(int index, int mode) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!d->isValid() || index < 0 || index >= d->model->count()) return; d->positionViewAtIndex(index, mode); @@ -3034,17 +3035,17 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode) Component.onCompleted: positionViewAtEnd() \endcode */ -void QDeclarativeListView::positionViewAtBeginning() +void QDeclarative1ListView::positionViewAtBeginning() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!d->isValid()) return; d->positionViewAtIndex(-1, Beginning); } -void QDeclarativeListView::positionViewAtEnd() +void QDeclarative1ListView::positionViewAtEnd() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!d->isValid()) return; d->positionViewAtIndex(d->model->count(), End); @@ -3062,11 +3063,11 @@ void QDeclarativeListView::positionViewAtEnd() \bold Note: methods should only be called after the Component has completed. */ -int QDeclarativeListView::indexAt(qreal x, qreal y) const +int QDeclarative1ListView::indexAt(qreal x, qreal y) const { - Q_D(const QDeclarativeListView); + Q_D(const QDeclarative1ListView); for (int i = 0; i < d->visibleItems.count(); ++i) { - const FxListItem *listItem = d->visibleItems.at(i); + const FxListItem1 *listItem = d->visibleItems.at(i); if(listItem->contains(x, y)) return listItem->index; } @@ -3074,16 +3075,16 @@ int QDeclarativeListView::indexAt(qreal x, qreal y) const return -1; } -void QDeclarativeListView::componentComplete() +void QDeclarative1ListView::componentComplete() { - Q_D(QDeclarativeListView); - QDeclarativeFlickable::componentComplete(); + Q_D(QDeclarative1ListView); + QDeclarative1Flickable::componentComplete(); updateSections(); d->updateHeader(); d->updateFooter(); if (d->isValid()) { refill(); - d->moveReason = QDeclarativeListViewPrivate::SetIndex; + d->moveReason = QDeclarative1ListViewPrivate::SetIndex; if (d->currentIndex < 0 && !d->currentIndexCleared) d->updateCurrent(0); else @@ -3093,14 +3094,14 @@ void QDeclarativeListView::componentComplete() d->highlight->setPosition(d->currentItem->position()); d->updateTrackedItem(); } - d->moveReason = QDeclarativeListViewPrivate::Other; + d->moveReason = QDeclarative1ListViewPrivate::Other; d->fixupPosition(); } } -void QDeclarativeListView::updateSections() +void QDeclarative1ListView::updateSections() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (isComponentComplete() && d->model) { QList roles; if (d->sectionCriteria && !d->sectionCriteria->property().isEmpty()) @@ -3112,21 +3113,21 @@ void QDeclarativeListView::updateSections() } } -void QDeclarativeListView::refill() +void QDeclarative1ListView::refill() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->isRightToLeft()) d->refill(-d->position()-d->size()+1, -d->position()); else d->refill(d->position(), d->position()+d->size()-1); } -void QDeclarativeListView::trackedPositionChanged() +void QDeclarative1ListView::trackedPositionChanged() { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!d->trackedItem || !d->currentItem) return; - if (d->moveReason == QDeclarativeListViewPrivate::SetIndex) { + if (d->moveReason == QDeclarative1ListViewPrivate::SetIndex) { qreal trackedPos = qCeil(d->trackedItem->position()); qreal trackedSize = d->trackedItem->size(); if (d->trackedItem != d->currentItem) { @@ -3192,13 +3193,13 @@ void QDeclarativeListView::trackedPositionChanged() } } -void QDeclarativeListView::itemsInserted(int modelIndex, int count) +void QDeclarative1ListView::itemsInserted(int modelIndex, int count) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!isComponentComplete()) return; d->updateUnrequestedIndexes(); - d->moveReason = QDeclarativeListViewPrivate::Other; + d->moveReason = QDeclarative1ListViewPrivate::Other; qreal tempPos = d->isRightToLeft() ? -d->position()-d->size() : d->position(); int index = d->visibleItems.count() ? d->mapFromModel(modelIndex) : 0; @@ -3219,7 +3220,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) // Insert before visible items d->visibleIndex += count; for (int i = 0; i < d->visibleItems.count(); ++i) { - FxListItem *listItem = d->visibleItems.at(i); + FxListItem1 *listItem = d->visibleItems.at(i); if (listItem->index != -1 && listItem->index >= modelIndex) listItem->index += count; } @@ -3249,9 +3250,9 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) int initialPos = pos; int diff = 0; - QList added; + QList added; bool addedVisible = false; - FxListItem *firstVisible = d->firstVisibleItem(); + FxListItem1 *firstVisible = d->firstVisibleItem(); if (firstVisible && pos < firstVisible->position()) { // Insert items before the visible item. int insertionIdx = index; @@ -3262,7 +3263,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) d->scheduleLayout(); addedVisible = true; } - FxListItem *item = d->createItem(modelIndex + i); + FxListItem1 *item = d->createItem(modelIndex + i); d->visibleItems.insert(insertionIdx, item); pos -= item->size() + d->spacing; item->setPosition(pos); @@ -3272,7 +3273,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) // If we didn't insert all our new items - anything // before the current index is not visible - remove it. while (insertionIdx--) { - FxListItem *item = d->visibleItems.takeFirst(); + FxListItem1 *item = d->visibleItems.takeFirst(); if (item->index != -1) d->visibleIndex++; d->releaseItem(item); @@ -3280,7 +3281,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) } else { // adjust pos of items before inserted items. for (int i = insertionIdx-1; i >= 0; i--) { - FxListItem *listItem = d->visibleItems.at(i); + FxListItem1 *listItem = d->visibleItems.at(i); listItem->setPosition(listItem->position() - (initialPos - pos)); } } @@ -3292,7 +3293,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) d->scheduleLayout(); addedVisible = true; } - FxListItem *item = d->createItem(modelIndex + i); + FxListItem1 *item = d->createItem(modelIndex + i); d->visibleItems.insert(index, item); item->setPosition(pos); added.append(item); @@ -3320,7 +3321,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) } // Update the indexes of the following visible items. for (; index < d->visibleItems.count(); ++index) { - FxListItem *listItem = d->visibleItems.at(index); + FxListItem1 *listItem = d->visibleItems.at(index); if (d->currentItem && listItem->item != d->currentItem->item) listItem->setPosition(listItem->position() + diff); if (listItem->index != -1) @@ -3335,22 +3336,22 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) emit countChanged(); } -void QDeclarativeListView::itemsRemoved(int modelIndex, int count) +void QDeclarative1ListView::itemsRemoved(int modelIndex, int count) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!isComponentComplete()) return; - d->moveReason = QDeclarativeListViewPrivate::Other; + d->moveReason = QDeclarative1ListViewPrivate::Other; d->updateUnrequestedIndexes(); d->itemCount -= count; - FxListItem *firstVisible = d->firstVisibleItem(); + FxListItem1 *firstVisible = d->firstVisibleItem(); int preRemovedSize = 0; bool removedVisible = false; // Remove the items from the visible list, skipping anything already marked for removal - QList::Iterator it = d->visibleItems.begin(); + QList::Iterator it = d->visibleItems.begin(); while (it != d->visibleItems.end()) { - FxListItem *item = *it; + FxListItem1 *item = *it; if (item->index == -1 || item->index < modelIndex) { // already removed, or before removed items ++it; @@ -3431,12 +3432,12 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count) emit countChanged(); } -void QDeclarativeListView::destroyRemoved() +void QDeclarative1ListView::destroyRemoved() { - Q_D(QDeclarativeListView); - for (QList::Iterator it = d->visibleItems.begin(); + Q_D(QDeclarative1ListView); + for (QList::Iterator it = d->visibleItems.begin(); it != d->visibleItems.end();) { - FxListItem *listItem = *it; + FxListItem1 *listItem = *it; if (listItem->index == -1 && listItem->attached->delayRemove() == false) { d->releaseItem(listItem); it = d->visibleItems.erase(it); @@ -3450,9 +3451,9 @@ void QDeclarativeListView::destroyRemoved() d->layout(); } -void QDeclarativeListView::itemsMoved(int from, int to, int count) +void QDeclarative1ListView::itemsMoved(int from, int to, int count) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (!isComponentComplete()) return; d->updateUnrequestedIndexes(); @@ -3462,15 +3463,15 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) return; } - d->moveReason = QDeclarativeListViewPrivate::Other; - FxListItem *firstVisible = d->firstVisibleItem(); + d->moveReason = QDeclarative1ListViewPrivate::Other; + FxListItem1 *firstVisible = d->firstVisibleItem(); qreal firstItemPos = firstVisible->position(); - QHash moved; + QHash moved; int moveBy = 0; - QList::Iterator it = d->visibleItems.begin(); + QList::Iterator it = d->visibleItems.begin(); while (it != d->visibleItems.end()) { - FxListItem *item = *it; + FxListItem1 *item = *it; if (item->index >= from && item->index < from + count) { // take the items that are moving item->index += (to-from); @@ -3490,10 +3491,10 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) int endIndex = d->visibleIndex; it = d->visibleItems.begin(); while (it != d->visibleItems.end()) { - FxListItem *item = *it; + FxListItem1 *item = *it; if (remaining && item->index >= to && item->index < to + count) { // place items in the target position, reusing any existing items - FxListItem *movedItem = moved.take(item->index); + FxListItem1 *movedItem = moved.take(item->index); if (!movedItem) movedItem = d->createItem(item->index); if (item->index <= firstVisible->index) @@ -3515,7 +3516,7 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) // If we have moved items to the end of the visible items // then add any existing moved items that we have - while (FxListItem *item = moved.take(endIndex+1)) { + while (FxListItem1 *item = moved.take(endIndex+1)) { d->visibleItems.append(item); ++endIndex; } @@ -3541,7 +3542,7 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) // Whatever moved items remain are no longer visible items. while (moved.count()) { int idx = moved.begin().key(); - FxListItem *item = moved.take(idx); + FxListItem1 *item = moved.take(idx); if (d->currentItem && item->item == d->currentItem->item) item->setPosition(d->positionAt(idx)); d->releaseItem(item); @@ -3554,34 +3555,34 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) d->layout(); } -void QDeclarativeListView::itemsChanged(int, int) +void QDeclarative1ListView::itemsChanged(int, int) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->updateSections(); d->layout(); } -void QDeclarativeListView::modelReset() +void QDeclarative1ListView::modelReset() { - Q_D(QDeclarativeListView); - d->moveReason = QDeclarativeListViewPrivate::SetIndex; + Q_D(QDeclarative1ListView); + d->moveReason = QDeclarative1ListViewPrivate::SetIndex; d->regenerate(); if (d->highlight && d->currentItem) { if (d->autoHighlight) d->highlight->setPosition(d->currentItem->position()); d->updateTrackedItem(); } - d->moveReason = QDeclarativeListViewPrivate::Other; + d->moveReason = QDeclarative1ListViewPrivate::Other; emit countChanged(); } -void QDeclarativeListView::createdItem(int index, QDeclarativeItem *item) +void QDeclarative1ListView::createdItem(int index, QDeclarativeItem *item) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); if (d->requestedIndex != index) { item->setParentItem(contentItem()); d->unrequestedItems.insert(item, index); - if (d->orient == QDeclarativeListView::Vertical) { + if (d->orient == QDeclarative1ListView::Vertical) { item->setY(d->positionAt(index)); } else { if (d->isRightToLeft()) @@ -3592,23 +3593,25 @@ void QDeclarativeListView::createdItem(int index, QDeclarativeItem *item) } } -void QDeclarativeListView::destroyingItem(QDeclarativeItem *item) +void QDeclarative1ListView::destroyingItem(QDeclarativeItem *item) { - Q_D(QDeclarativeListView); + Q_D(QDeclarative1ListView); d->unrequestedItems.remove(item); } -void QDeclarativeListView::animStopped() +void QDeclarative1ListView::animStopped() { - Q_D(QDeclarativeListView); - d->bufferMode = QDeclarativeListViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarativeListView::StrictlyEnforceRange) + Q_D(QDeclarative1ListView); + d->bufferMode = QDeclarative1ListViewPrivate::NoBuffer; + if (d->haveHighlightRange && d->highlightRange == QDeclarative1ListView::StrictlyEnforceRange) d->updateHighlight(); } -QDeclarativeListViewAttached *QDeclarativeListView::qmlAttachedProperties(QObject *obj) +QDeclarative1ListViewAttached *QDeclarative1ListView::qmlAttachedProperties(QObject *obj) { - return new QDeclarativeListViewAttached(obj); + return new QDeclarative1ListViewAttached(obj); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/qtquick1/graphicsitems/qdeclarativelistview_p.h similarity index 90% rename from src/declarative/graphicsitems/qdeclarativelistview_p.h rename to src/qtquick1/graphicsitems/qdeclarativelistview_p.h index 2cd6ba7c1e..dc1ff3371f 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativelistview_p.h @@ -43,7 +43,7 @@ #define QDECLARATIVELISTVIEW_H #include "private/qdeclarativeflickable_p.h" -#include "private/qdeclarativeguard_p.h" +#include "QtDeclarative/private/qdeclarativeguard_p.h" QT_BEGIN_HEADER @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_AUTOTEST_EXPORT QDeclarativeViewSection : public QObject +class Q_AUTOTEST_EXPORT QDeclarative1ViewSection : public QObject { Q_OBJECT Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) @@ -59,7 +59,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeViewSection : public QObject Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_ENUMS(SectionCriteria) public: - QDeclarativeViewSection(QObject *parent=0) : QObject(parent), m_criteria(FullString), m_delegate(0) {} + QDeclarative1ViewSection(QObject *parent=0) : QObject(parent), m_criteria(FullString), m_delegate(0) {} QString property() const { return m_property; } void setProperty(const QString &); @@ -85,13 +85,13 @@ class Q_AUTOTEST_EXPORT QDeclarativeViewSection : public QObject }; -class QDeclarativeVisualModel; -class QDeclarativeListViewAttached; -class QDeclarativeListViewPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeListView : public QDeclarativeFlickable +class QDeclarative1VisualModel; +class QDeclarative1ListViewAttached; +class QDeclarative1ListViewPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1ListView : public QDeclarative1Flickable { Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeListView) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ListView) Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) @@ -117,7 +117,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeListView : public QDeclarativeFlickable Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged) Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) - Q_PROPERTY(QDeclarativeViewSection *section READ sectionCriteria CONSTANT) + Q_PROPERTY(QDeclarative1ViewSection *section READ sectionCriteria CONSTANT) Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged) Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged) @@ -132,8 +132,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeListView : public QDeclarativeFlickable Q_CLASSINFO("DefaultProperty", "data") public: - QDeclarativeListView(QDeclarativeItem *parent=0); - ~QDeclarativeListView(); + QDeclarative1ListView(QDeclarativeItem *parent=0); + ~QDeclarative1ListView(); QVariant model() const; void setModel(const QVariant &); @@ -183,7 +183,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeListView : public QDeclarativeFlickable int cacheBuffer() const; void setCacheBuffer(int); - QDeclarativeViewSection *sectionCriteria(); + QDeclarative1ViewSection *sectionCriteria(); QString currentSection() const; qreal highlightMoveSpeed() const; @@ -211,7 +211,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeListView : public QDeclarativeFlickable virtual void setContentX(qreal pos); virtual void setContentY(qreal pos); - static QDeclarativeListViewAttached *qmlAttachedProperties(QObject *); + static QDeclarative1ListViewAttached *qmlAttachedProperties(QObject *); enum PositionMode { Beginning, Center, End, Visible, Contain }; @@ -276,17 +276,17 @@ private Q_SLOTS: void animStopped(); }; -class QDeclarativeListViewAttached : public QObject +class QDeclarative1ListViewAttached : public QObject { Q_OBJECT public: - QDeclarativeListViewAttached(QObject *parent) + QDeclarative1ListViewAttached(QObject *parent) : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} - ~QDeclarativeListViewAttached() {} + ~QDeclarative1ListViewAttached() {} - Q_PROPERTY(QDeclarativeListView *view READ view NOTIFY viewChanged) - QDeclarativeListView *view() { return m_view; } - void setView(QDeclarativeListView *view) { + Q_PROPERTY(QDeclarative1ListView *view READ view NOTIFY viewChanged) + QDeclarative1ListView *view() { return m_view; } + void setView(QDeclarative1ListView *view) { if (view != m_view) { m_view = view; emit viewChanged(); @@ -352,7 +352,7 @@ class QDeclarativeListViewAttached : public QObject void viewChanged(); public: - QDeclarativeGuard m_view; + QDeclarativeGuard m_view; mutable QString m_section; QString m_prevSection; QString m_nextSection; @@ -360,12 +360,11 @@ class QDeclarativeListViewAttached : public QObject bool m_delayRemove : 1; }; - QT_END_NAMESPACE -QML_DECLARE_TYPEINFO(QDeclarativeListView, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarativeListView) -QML_DECLARE_TYPE(QDeclarativeViewSection) +QML_DECLARE_TYPEINFO(QDeclarative1ListView, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarative1ListView) +QML_DECLARE_TYPE(QDeclarative1ViewSection) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/qtquick1/graphicsitems/qdeclarativeloader.cpp similarity index 87% rename from src/declarative/graphicsitems/qdeclarativeloader.cpp rename to src/qtquick1/graphicsitems/qdeclarativeloader.cpp index 603b3f0b42..92b34d7001 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativeloader.cpp @@ -39,25 +39,27 @@ ** ****************************************************************************/ -#include "private/qdeclarativeloader_p_p.h" +#include "QtQuick1/private/qdeclarativeloader_p_p.h" -#include -#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE -QDeclarativeLoaderPrivate::QDeclarativeLoaderPrivate() + + +QDeclarative1LoaderPrivate::QDeclarative1LoaderPrivate() : item(0), component(0), ownComponent(false), updatingSize(false), itemWidthValid(false), itemHeightValid(false) { } -QDeclarativeLoaderPrivate::~QDeclarativeLoaderPrivate() +QDeclarative1LoaderPrivate::~QDeclarative1LoaderPrivate() { } -void QDeclarativeLoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry) +void QDeclarative1LoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry) { if (resizeItem == item) { if (!updatingSize && newGeometry.width() != oldGeometry.width()) @@ -69,7 +71,7 @@ void QDeclarativeLoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry); } -void QDeclarativeLoaderPrivate::clear() +void QDeclarative1LoaderPrivate::clear() { if (ownComponent) { component->deleteLater(); @@ -98,9 +100,9 @@ void QDeclarativeLoaderPrivate::clear() } } -void QDeclarativeLoaderPrivate::initResize() +void QDeclarative1LoaderPrivate::initResize() { - Q_Q(QDeclarativeLoader); + Q_Q(QDeclarative1Loader); if (QDeclarativeItem *qmlItem = qobject_cast(item)) { QDeclarativeItemPrivate *p = static_cast(QGraphicsItemPrivate::get(qmlItem)); @@ -117,7 +119,7 @@ void QDeclarativeLoaderPrivate::initResize() } /*! - \qmlclass Loader QDeclarativeLoader + \qmlclass Loader QDeclarative1Loader \ingroup qml-utility-elements \since 4.7 \inherits Item @@ -225,16 +227,16 @@ void QDeclarativeLoaderPrivate::initResize() \sa {dynamic-object-creation}{Dynamic Object Creation} */ -QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent) - : QDeclarativeImplicitSizeItem(*(new QDeclarativeLoaderPrivate), parent) +QDeclarative1Loader::QDeclarative1Loader(QDeclarativeItem *parent) + : QDeclarative1ImplicitSizeItem(*(new QDeclarative1LoaderPrivate), parent) { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); d->flags |= QGraphicsItem::ItemIsFocusScope; } -QDeclarativeLoader::~QDeclarativeLoader() +QDeclarative1Loader::~QDeclarative1Loader() { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); if (d->item) { if (QDeclarativeItem *qmlItem = qobject_cast(d->item)) { QDeclarativeItemPrivate *p = @@ -257,15 +259,15 @@ QDeclarativeLoader::~QDeclarativeLoader() \sa sourceComponent, status, progress */ -QUrl QDeclarativeLoader::source() const +QUrl QDeclarative1Loader::source() const { - Q_D(const QDeclarativeLoader); + Q_D(const QDeclarative1Loader); return d->source; } -void QDeclarativeLoader::setSource(const QUrl &url) +void QDeclarative1Loader::setSource(const QUrl &url) { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); if (d->source == url) return; @@ -310,15 +312,15 @@ void QDeclarativeLoader::setSource(const QUrl &url) \sa source, progress */ -QDeclarativeComponent *QDeclarativeLoader::sourceComponent() const +QDeclarativeComponent *QDeclarative1Loader::sourceComponent() const { - Q_D(const QDeclarativeLoader); + Q_D(const QDeclarative1Loader); return d->component; } -void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp) +void QDeclarative1Loader::setSourceComponent(QDeclarativeComponent *comp) { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); if (comp == d->component) return; @@ -339,14 +341,14 @@ void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp) d->load(); } -void QDeclarativeLoader::resetSourceComponent() +void QDeclarative1Loader::resetSourceComponent() { setSourceComponent(0); } -void QDeclarativeLoaderPrivate::load() +void QDeclarative1LoaderPrivate::load() { - Q_Q(QDeclarativeLoader); + Q_Q(QDeclarative1Loader); if (!q->isComponentComplete() || !component) return; @@ -365,9 +367,9 @@ void QDeclarativeLoaderPrivate::load() } } -void QDeclarativeLoaderPrivate::_q_sourceLoaded() +void QDeclarative1LoaderPrivate::_q_sourceLoaded() { - Q_Q(QDeclarativeLoader); + Q_Q(QDeclarative1Loader); if (component) { if (!component->errors().isEmpty()) { @@ -404,7 +406,7 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() // item->setFocus(true); initResize(); } else { - qmlInfo(q) << QDeclarativeLoader::tr("Loader does not support loading non-visual elements."); + qmlInfo(q) << QDeclarative1Loader::tr("Loader does not support loading non-visual elements."); delete obj; delete ctxt; } @@ -464,12 +466,12 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() \sa progress */ -QDeclarativeLoader::Status QDeclarativeLoader::status() const +QDeclarative1Loader::Status QDeclarative1Loader::status() const { - Q_D(const QDeclarativeLoader); + Q_D(const QDeclarative1Loader); if (d->component) - return static_cast(d->component->status()); + return static_cast(d->component->status()); if (d->item) return Ready; @@ -477,9 +479,9 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const return d->source.isEmpty() ? Null : Error; } -void QDeclarativeLoader::componentComplete() +void QDeclarative1Loader::componentComplete() { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); QDeclarativeItem::componentComplete(); d->load(); @@ -503,9 +505,9 @@ this value will rapidly change from 0 to 1. \sa status */ -qreal QDeclarativeLoader::progress() const +qreal QDeclarative1Loader::progress() const { - Q_D(const QDeclarativeLoader); + Q_D(const QDeclarative1Loader); if (d->item) return 1.0; @@ -516,9 +518,9 @@ qreal QDeclarativeLoader::progress() const return 0.0; } -void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) +void QDeclarative1LoaderPrivate::_q_updateSize(bool loaderGeometryChanged) { - Q_Q(QDeclarativeLoader); + Q_Q(QDeclarative1Loader); if (!item || updatingSize) return; @@ -555,24 +557,24 @@ void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) \qmlproperty Item Loader::item This property holds the top-level item that is currently loaded. */ -QGraphicsObject *QDeclarativeLoader::item() const +QGraphicsObject *QDeclarative1Loader::item() const { - Q_D(const QDeclarativeLoader); + Q_D(const QDeclarative1Loader); return d->item; } -void QDeclarativeLoader::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +void QDeclarative1Loader::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); if (newGeometry != oldGeometry) { d->_q_updateSize(); } QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } -QVariant QDeclarativeLoader::itemChange(GraphicsItemChange change, const QVariant &value) +QVariant QDeclarative1Loader::itemChange(GraphicsItemChange change, const QVariant &value) { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); if (change == ItemSceneHasChanged) { if (d->item && d->item->isWidget()) { d->item->removeEventFilter(this); @@ -582,9 +584,9 @@ QVariant QDeclarativeLoader::itemChange(GraphicsItemChange change, const QVarian return QDeclarativeItem::itemChange(change, value); } -bool QDeclarativeLoader::eventFilter(QObject *watched, QEvent *e) +bool QDeclarative1Loader::eventFilter(QObject *watched, QEvent *e) { - Q_D(QDeclarativeLoader); + Q_D(QDeclarative1Loader); if (watched == d->item && e->type() == QEvent::GraphicsSceneResize) { if (d->item && d->item->isWidget()) d->_q_updateSize(false); @@ -594,4 +596,6 @@ bool QDeclarativeLoader::eventFilter(QObject *watched, QEvent *e) #include + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/qtquick1/graphicsitems/qdeclarativeloader_p.h similarity index 91% rename from src/declarative/graphicsitems/qdeclarativeloader_p.h rename to src/qtquick1/graphicsitems/qdeclarativeloader_p.h index 06f47e1ea1..e2398005fd 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeloader_p.h @@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeLoaderPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeLoader : public QDeclarativeImplicitSizeItem +class QDeclarative1LoaderPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Loader : public QDeclarative1ImplicitSizeItem { Q_OBJECT Q_ENUMS(Status) @@ -63,8 +63,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeLoader : public QDeclarativeImplicitSizeItem Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) public: - QDeclarativeLoader(QDeclarativeItem *parent=0); - virtual ~QDeclarativeLoader(); + QDeclarative1Loader(QDeclarativeItem *parent=0); + virtual ~QDeclarative1Loader(); QUrl source() const; void setSource(const QUrl &); @@ -93,15 +93,15 @@ class Q_AUTOTEST_EXPORT QDeclarativeLoader : public QDeclarativeImplicitSizeItem void componentComplete(); private: - Q_DISABLE_COPY(QDeclarativeLoader) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeLoader) + Q_DISABLE_COPY(QDeclarative1Loader) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Loader) Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded()) Q_PRIVATE_SLOT(d_func(), void _q_updateSize()) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeLoader) +QML_DECLARE_TYPE(QDeclarative1Loader) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeloader_p_p.h similarity index 88% rename from src/declarative/graphicsitems/qdeclarativeloader_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativeloader_p_p.h index 04894eeccd..f80173536f 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativeloader_p_p.h @@ -55,19 +55,19 @@ #include "private/qdeclarativeloader_p.h" -#include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include "private/qdeclarativeitemchangelistener_p.h" +#include "QtQuick1/private/qdeclarativeimplicitsizeitem_p_p.h" +#include "QtQuick1/private/qdeclarativeitemchangelistener_p.h" QT_BEGIN_NAMESPACE class QDeclarativeContext; -class QDeclarativeLoaderPrivate : public QDeclarativeImplicitSizeItemPrivate, public QDeclarativeItemChangeListener +class QDeclarative1LoaderPrivate : public QDeclarative1ImplicitSizeItemPrivate, public QDeclarativeItemChangeListener { - Q_DECLARE_PUBLIC(QDeclarativeLoader) + Q_DECLARE_PUBLIC(QDeclarative1Loader) public: - QDeclarativeLoaderPrivate(); - ~QDeclarativeLoaderPrivate(); + QDeclarative1LoaderPrivate(); + ~QDeclarative1LoaderPrivate(); void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); void clear(); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/qtquick1/graphicsitems/qdeclarativemousearea.cpp similarity index 84% rename from src/declarative/graphicsitems/qdeclarativemousearea.cpp rename to src/qtquick1/graphicsitems/qdeclarativemousearea.cpp index 18f008a870..6cd41ff615 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativemousearea.cpp @@ -39,34 +39,36 @@ ** ****************************************************************************/ -#include "private/qdeclarativemousearea_p.h" -#include "private/qdeclarativemousearea_p_p.h" +#include "QtQuick1/private/qdeclarativemousearea_p.h" +#include "QtQuick1/private/qdeclarativemousearea_p_p.h" -#include "private/qdeclarativeevents_p_p.h" +#include "QtQuick1/private/qdeclarativeevents_p_p.h" #include #include QT_BEGIN_NAMESPACE + + static const int PressAndHoldDelay = 800; -QDeclarativeDrag::QDeclarativeDrag(QObject *parent) +QDeclarative1Drag::QDeclarative1Drag(QObject *parent) : QObject(parent), _target(0), _axis(XandYAxis), _xmin(-FLT_MAX), _xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), _active(false), _filterChildren(false) { } -QDeclarativeDrag::~QDeclarativeDrag() +QDeclarative1Drag::~QDeclarative1Drag() { } -QGraphicsObject *QDeclarativeDrag::target() const +QGraphicsObject *QDeclarative1Drag::target() const { return _target; } -void QDeclarativeDrag::setTarget(QGraphicsObject *t) +void QDeclarative1Drag::setTarget(QGraphicsObject *t) { if (_target == t) return; @@ -74,7 +76,7 @@ void QDeclarativeDrag::setTarget(QGraphicsObject *t) emit targetChanged(); } -void QDeclarativeDrag::resetTarget() +void QDeclarative1Drag::resetTarget() { if (!_target) return; @@ -82,12 +84,12 @@ void QDeclarativeDrag::resetTarget() emit targetChanged(); } -QDeclarativeDrag::Axis QDeclarativeDrag::axis() const +QDeclarative1Drag::Axis QDeclarative1Drag::axis() const { return _axis; } -void QDeclarativeDrag::setAxis(QDeclarativeDrag::Axis a) +void QDeclarative1Drag::setAxis(QDeclarative1Drag::Axis a) { if (_axis == a) return; @@ -95,12 +97,12 @@ void QDeclarativeDrag::setAxis(QDeclarativeDrag::Axis a) emit axisChanged(); } -qreal QDeclarativeDrag::xmin() const +qreal QDeclarative1Drag::xmin() const { return _xmin; } -void QDeclarativeDrag::setXmin(qreal m) +void QDeclarative1Drag::setXmin(qreal m) { if (_xmin == m) return; @@ -108,12 +110,12 @@ void QDeclarativeDrag::setXmin(qreal m) emit minimumXChanged(); } -qreal QDeclarativeDrag::xmax() const +qreal QDeclarative1Drag::xmax() const { return _xmax; } -void QDeclarativeDrag::setXmax(qreal m) +void QDeclarative1Drag::setXmax(qreal m) { if (_xmax == m) return; @@ -121,12 +123,12 @@ void QDeclarativeDrag::setXmax(qreal m) emit maximumXChanged(); } -qreal QDeclarativeDrag::ymin() const +qreal QDeclarative1Drag::ymin() const { return _ymin; } -void QDeclarativeDrag::setYmin(qreal m) +void QDeclarative1Drag::setYmin(qreal m) { if (_ymin == m) return; @@ -134,12 +136,12 @@ void QDeclarativeDrag::setYmin(qreal m) emit minimumYChanged(); } -qreal QDeclarativeDrag::ymax() const +qreal QDeclarative1Drag::ymax() const { return _ymax; } -void QDeclarativeDrag::setYmax(qreal m) +void QDeclarative1Drag::setYmax(qreal m) { if (_ymax == m) return; @@ -147,12 +149,12 @@ void QDeclarativeDrag::setYmax(qreal m) emit maximumYChanged(); } -bool QDeclarativeDrag::active() const +bool QDeclarative1Drag::active() const { return _active; } -void QDeclarativeDrag::setActive(bool drag) +void QDeclarative1Drag::setActive(bool drag) { if (_active == drag) return; @@ -160,12 +162,12 @@ void QDeclarativeDrag::setActive(bool drag) emit activeChanged(); } -bool QDeclarativeDrag::filterChildren() const +bool QDeclarative1Drag::filterChildren() const { return _filterChildren; } -void QDeclarativeDrag::setFilterChildren(bool filter) +void QDeclarative1Drag::setFilterChildren(bool filter) { if (_filterChildren == filter) return; @@ -173,13 +175,13 @@ void QDeclarativeDrag::setFilterChildren(bool filter) emit filterChildrenChanged(); } -QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() +QDeclarative1MouseAreaPrivate::~QDeclarative1MouseAreaPrivate() { delete drag; } /*! - \qmlclass MouseArea QDeclarativeMouseArea + \qmlclass MouseArea QDeclarative1MouseArea \ingroup qml-basic-interaction-elements \since 4.7 \brief The MouseArea item enables simple mouse handling. @@ -354,14 +356,14 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() \c onCanceled should be used in addition to onReleased. */ -QDeclarativeMouseArea::QDeclarativeMouseArea(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativeMouseAreaPrivate), parent) +QDeclarative1MouseArea::QDeclarative1MouseArea(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1MouseAreaPrivate), parent) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); d->init(); } -QDeclarativeMouseArea::~QDeclarativeMouseArea() +QDeclarative1MouseArea::~QDeclarative1MouseArea() { } @@ -384,15 +386,15 @@ QDeclarativeMouseArea::~QDeclarativeMouseArea() The coordinates are relative to the MouseArea. */ -qreal QDeclarativeMouseArea::mouseX() const +qreal QDeclarative1MouseArea::mouseX() const { - Q_D(const QDeclarativeMouseArea); + Q_D(const QDeclarative1MouseArea); return d->lastPos.x(); } -qreal QDeclarativeMouseArea::mouseY() const +qreal QDeclarative1MouseArea::mouseY() const { - Q_D(const QDeclarativeMouseArea); + Q_D(const QDeclarative1MouseArea); return d->lastPos.y(); } @@ -402,15 +404,15 @@ qreal QDeclarativeMouseArea::mouseY() const By default, this property is true. */ -bool QDeclarativeMouseArea::isEnabled() const +bool QDeclarative1MouseArea::isEnabled() const { - Q_D(const QDeclarativeMouseArea); + Q_D(const QDeclarative1MouseArea); return d->absorb; } -void QDeclarativeMouseArea::setEnabled(bool a) +void QDeclarative1MouseArea::setEnabled(bool a) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (a != d->absorb) { d->absorb = a; emit enabledChanged(); @@ -434,15 +436,15 @@ void QDeclarativeMouseArea::setEnabled(bool a) By default this property is false. */ -bool QDeclarativeMouseArea::preventStealing() const +bool QDeclarative1MouseArea::preventStealing() const { - Q_D(const QDeclarativeMouseArea); + Q_D(const QDeclarative1MouseArea); return d->preventStealing; } -void QDeclarativeMouseArea::setPreventStealing(bool prevent) +void QDeclarative1MouseArea::setPreventStealing(bool prevent) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (prevent != d->preventStealing) { d->preventStealing = prevent; setKeepMouseGrab(d->preventStealing && d->absorb); @@ -467,15 +469,15 @@ void QDeclarativeMouseArea::setPreventStealing(bool prevent) \sa acceptedButtons */ -Qt::MouseButtons QDeclarativeMouseArea::pressedButtons() const +Qt::MouseButtons QDeclarative1MouseArea::pressedButtons() const { - Q_D(const QDeclarativeMouseArea); + Q_D(const QDeclarative1MouseArea); return d->lastButtons; } -void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1MouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); d->moved = false; d->stealMouse = d->preventStealing; if (!d->absorb) @@ -484,8 +486,8 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) d->longPress = false; d->saveEvent(event); if (d->drag) { - d->dragX = drag()->axis() & QDeclarativeDrag::XAxis; - d->dragY = drag()->axis() & QDeclarativeDrag::YAxis; + d->dragX = drag()->axis() & QDeclarative1Drag::XAxis; + d->dragY = drag()->axis() & QDeclarative1Drag::YAxis; } if (d->drag) d->drag->setActive(false); @@ -499,9 +501,9 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1MouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (!d->absorb) { QDeclarativeItem::mouseMoveEvent(event); return; @@ -568,7 +570,7 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) d->moved = true; } - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress); + QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress); emit mousePositionChanged(&me); me.setX(d->lastPos.x()); me.setY(d->lastPos.y()); @@ -576,9 +578,9 @@ void QDeclarativeMouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } -void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1MouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); d->stealMouse = false; if (!d->absorb) { QDeclarativeItem::mouseReleaseEvent(event); @@ -598,43 +600,43 @@ void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) d->doubleClick = false; } -void QDeclarativeMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1MouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (!d->absorb) { QDeclarativeItem::mouseDoubleClickEvent(event); } else { if (d->isDoubleClickConnected()) d->doubleClick = true; d->saveEvent(event); - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false); + QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false); me.setAccepted(d->isDoubleClickConnected()); emit this->doubleClicked(&me); QDeclarativeItem::mouseDoubleClickEvent(event); } } -void QDeclarativeMouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +void QDeclarative1MouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (!d->absorb) QDeclarativeItem::hoverEnterEvent(event); else { d->lastPos = event->pos(); setHovered(true); - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false); + QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false); emit mousePositionChanged(&me); } } -void QDeclarativeMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +void QDeclarative1MouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (!d->absorb) { QDeclarativeItem::hoverMoveEvent(event); } else { d->lastPos = event->pos(); - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false); + QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false); emit mousePositionChanged(&me); me.setX(d->lastPos.x()); me.setY(d->lastPos.y()); @@ -642,9 +644,9 @@ void QDeclarativeMouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } } -void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +void QDeclarative1MouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (!d->absorb) QDeclarativeItem::hoverLeaveEvent(event); else @@ -652,7 +654,7 @@ void QDeclarativeMouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } #ifndef QT_NO_CONTEXTMENU -void QDeclarativeMouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) +void QDeclarative1MouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { bool acceptsContextMenuButton; #if defined(Q_OS_SYMBIAN) @@ -677,11 +679,11 @@ void QDeclarativeMouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *eve } #endif // QT_NO_CONTEXTMENU -bool QDeclarativeMouseArea::sceneEvent(QEvent *event) +bool QDeclarative1MouseArea::sceneEvent(QEvent *event) { bool rv = QDeclarativeItem::sceneEvent(event); if (event->type() == QEvent::UngrabMouse) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (d->pressed) { // if our mouse grab has been removed (probably by Flickable), fix our // state @@ -699,9 +701,9 @@ bool QDeclarativeMouseArea::sceneEvent(QEvent *event) return rv; } -bool QDeclarativeMouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) +bool QDeclarative1MouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); QGraphicsSceneMouseEvent mouseEvent(event->type()); QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); @@ -757,9 +759,9 @@ bool QDeclarativeMouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) return false; } -bool QDeclarativeMouseArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) +bool QDeclarative1MouseArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (!d->absorb || !isVisible() || !d->drag || !d->drag->filterChildren()) return QDeclarativeItem::sceneEventFilter(i, e); switch (e->type()) { @@ -774,24 +776,24 @@ bool QDeclarativeMouseArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) return QDeclarativeItem::sceneEventFilter(i, e); } -void QDeclarativeMouseArea::timerEvent(QTimerEvent *event) +void QDeclarative1MouseArea::timerEvent(QTimerEvent *event) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (event->timerId() == d->pressAndHoldTimer.timerId()) { d->pressAndHoldTimer.stop(); bool dragged = d->drag && d->drag->active(); if (d->pressed && dragged == false && d->hovered == true) { d->longPress = true; - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress); + QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress); emit pressAndHold(&me); } } } -void QDeclarativeMouseArea::geometryChanged(const QRectF &newGeometry, +void QDeclarative1MouseArea::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); if (d->lastScenePos.isNull) @@ -800,10 +802,10 @@ void QDeclarativeMouseArea::geometryChanged(const QRectF &newGeometry, d->lastPos = mapFromScene(d->lastScenePos); } -QVariant QDeclarativeMouseArea::itemChange(GraphicsItemChange change, +QVariant QDeclarative1MouseArea::itemChange(GraphicsItemChange change, const QVariant &value) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); switch (change) { case ItemVisibleHasChanged: if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) @@ -827,14 +829,14 @@ QVariant QDeclarativeMouseArea::itemChange(GraphicsItemChange change, This property affects the containsMouse property and the onEntered, onExited and onPositionChanged signals. */ -bool QDeclarativeMouseArea::hoverEnabled() const +bool QDeclarative1MouseArea::hoverEnabled() const { return acceptHoverEvents(); } -void QDeclarativeMouseArea::setHoverEnabled(bool h) +void QDeclarative1MouseArea::setHoverEnabled(bool h) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (h == acceptHoverEvents()) return; @@ -851,9 +853,9 @@ void QDeclarativeMouseArea::setHoverEnabled(bool h) \warning This property is not updated if the area moves under the mouse: \e containsMouse will not change. In addition, if hoverEnabled is false, containsMouse will only be valid when the mouse is pressed. */ -bool QDeclarativeMouseArea::hovered() const +bool QDeclarative1MouseArea::hovered() const { - Q_D(const QDeclarativeMouseArea); + Q_D(const QDeclarative1MouseArea); return d->hovered; } @@ -861,15 +863,15 @@ bool QDeclarativeMouseArea::hovered() const \qmlproperty bool MouseArea::pressed This property holds whether the mouse area is currently pressed. */ -bool QDeclarativeMouseArea::pressed() const +bool QDeclarative1MouseArea::pressed() const { - Q_D(const QDeclarativeMouseArea); + Q_D(const QDeclarative1MouseArea); return d->pressed; } -void QDeclarativeMouseArea::setHovered(bool h) +void QDeclarative1MouseArea::setHovered(bool h) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (d->hovered != h) { d->hovered = h; emit hoveredChanged(); @@ -897,12 +899,12 @@ void QDeclarativeMouseArea::setHovered(bool h) The default value is \c Qt.LeftButton. */ -Qt::MouseButtons QDeclarativeMouseArea::acceptedButtons() const +Qt::MouseButtons QDeclarative1MouseArea::acceptedButtons() const { return acceptedMouseButtons(); } -void QDeclarativeMouseArea::setAcceptedButtons(Qt::MouseButtons buttons) +void QDeclarative1MouseArea::setAcceptedButtons(Qt::MouseButtons buttons) { if (buttons != acceptedMouseButtons()) { setAcceptedMouseButtons(buttons); @@ -910,15 +912,15 @@ void QDeclarativeMouseArea::setAcceptedButtons(Qt::MouseButtons buttons) } } -bool QDeclarativeMouseArea::setPressed(bool p) +bool QDeclarative1MouseArea::setPressed(bool p) { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); bool dragged = d->drag && d->drag->active(); bool isclick = d->pressed == true && p == false && dragged == false && d->hovered == true; if (d->pressed != p) { d->pressed = p; - QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress); + QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress); if (d->pressed) { if (!d->doubleClick) emit pressed(&me); @@ -940,11 +942,11 @@ bool QDeclarativeMouseArea::setPressed(bool p) return false; } -QDeclarativeDrag *QDeclarativeMouseArea::drag() +QDeclarative1Drag *QDeclarative1MouseArea::drag() { - Q_D(QDeclarativeMouseArea); + Q_D(QDeclarative1MouseArea); if (!d->drag) - d->drag = new QDeclarativeDrag; + d->drag = new QDeclarative1Drag; return d->drag; } diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p.h b/src/qtquick1/graphicsitems/qdeclarativemousearea_p.h similarity index 85% rename from src/declarative/graphicsitems/qdeclarativemousearea_p.h rename to src/qtquick1/graphicsitems/qdeclarativemousearea_p.h index f6f970b4bb..082df9e7b7 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativemousearea_p.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_AUTOTEST_EXPORT QDeclarativeDrag : public QObject +class Q_AUTOTEST_EXPORT QDeclarative1Drag : public QObject { Q_OBJECT @@ -66,8 +66,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeDrag : public QObject //### consider drag and drop public: - QDeclarativeDrag(QObject *parent=0); - ~QDeclarativeDrag(); + QDeclarative1Drag(QObject *parent=0); + ~QDeclarative1Drag(); QGraphicsObject *target() const; void setTarget(QGraphicsObject *); @@ -111,12 +111,12 @@ class Q_AUTOTEST_EXPORT QDeclarativeDrag : public QObject qreal _ymax; bool _active : 1; bool _filterChildren: 1; - Q_DISABLE_COPY(QDeclarativeDrag) + Q_DISABLE_COPY(QDeclarative1Drag) }; -class QDeclarativeMouseEvent; -class QDeclarativeMouseAreaPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem +class QDeclarative1MouseEvent; +class QDeclarative1MouseAreaPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1MouseArea : public QDeclarativeItem { Q_OBJECT @@ -128,12 +128,12 @@ class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged) Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged) Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged) - Q_PROPERTY(QDeclarativeDrag *drag READ drag CONSTANT) //### add flicking to QDeclarativeDrag or add a QDeclarativeFlick ??? + Q_PROPERTY(QDeclarative1Drag *drag READ drag CONSTANT) //### add flicking to QDeclarative1Drag or add a QDeclarative1Flick ??? Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1) public: - QDeclarativeMouseArea(QDeclarativeItem *parent=0); - ~QDeclarativeMouseArea(); + QDeclarative1MouseArea(QDeclarativeItem *parent=0); + ~QDeclarative1MouseArea(); qreal mouseX() const; qreal mouseY() const; @@ -152,7 +152,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem bool hoverEnabled() const; void setHoverEnabled(bool h); - QDeclarativeDrag *drag(); + QDeclarative1Drag *drag(); bool preventStealing() const; void setPreventStealing(bool prevent); @@ -163,15 +163,15 @@ class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem void enabledChanged(); void acceptedButtonsChanged(); void hoverEnabledChanged(); - void positionChanged(QDeclarativeMouseEvent *mouse); - void mousePositionChanged(QDeclarativeMouseEvent *mouse); + void positionChanged(QDeclarative1MouseEvent *mouse); + void mousePositionChanged(QDeclarative1MouseEvent *mouse); Q_REVISION(1) void preventStealingChanged(); - void pressed(QDeclarativeMouseEvent *mouse); - void pressAndHold(QDeclarativeMouseEvent *mouse); - void released(QDeclarativeMouseEvent *mouse); - void clicked(QDeclarativeMouseEvent *mouse); - void doubleClicked(QDeclarativeMouseEvent *mouse); + void pressed(QDeclarative1MouseEvent *mouse); + void pressAndHold(QDeclarative1MouseEvent *mouse); + void released(QDeclarative1MouseEvent *mouse); + void clicked(QDeclarative1MouseEvent *mouse); + void doubleClicked(QDeclarative1MouseEvent *mouse); void entered(); void exited(); void canceled(); @@ -204,14 +204,14 @@ class Q_AUTOTEST_EXPORT QDeclarativeMouseArea : public QDeclarativeItem void handleRelease(); private: - Q_DISABLE_COPY(QDeclarativeMouseArea) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeMouseArea) + Q_DISABLE_COPY(QDeclarative1MouseArea) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1MouseArea) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeDrag) -QML_DECLARE_TYPE(QDeclarativeMouseArea) +QML_DECLARE_TYPE(QDeclarative1Drag) +QML_DECLARE_TYPE(QDeclarative1MouseArea) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/qtquick1/graphicsitems/qdeclarativemousearea_p_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativemousearea_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativemousearea_p_p.h index f6ea00dcf0..2bad671ffe 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativemousearea_p_p.h @@ -61,22 +61,22 @@ QT_BEGIN_NAMESPACE -class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate +class QDeclarative1MouseAreaPrivate : public QDeclarativeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeMouseArea) + Q_DECLARE_PUBLIC(QDeclarative1MouseArea) public: - QDeclarativeMouseAreaPrivate() + QDeclarative1MouseAreaPrivate() : absorb(true), hovered(false), pressed(false), longPress(false), moved(false), stealMouse(false), doubleClick(false), preventStealing(false), drag(0) { } - ~QDeclarativeMouseAreaPrivate(); + ~QDeclarative1MouseAreaPrivate(); void init() { - Q_Q(QDeclarativeMouseArea); + Q_Q(QDeclarative1MouseArea); q->setAcceptedMouseButtons(Qt::LeftButton); q->setFiltersChildEvents(true); } @@ -90,14 +90,14 @@ class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate } bool isPressAndHoldConnected() { - Q_Q(QDeclarativeMouseArea); - static int idx = QObjectPrivate::get(q)->signalIndex("pressAndHold(QDeclarativeMouseEvent*)"); + Q_Q(QDeclarative1MouseArea); + static int idx = QObjectPrivate::get(q)->signalIndex("pressAndHold(QDeclarative1MouseEvent*)"); return QObjectPrivate::get(q)->isSignalConnected(idx); } bool isDoubleClickConnected() { - Q_Q(QDeclarativeMouseArea); - static int idx = QObjectPrivate::get(q)->signalIndex("doubleClicked(QDeclarativeMouseEvent*)"); + Q_Q(QDeclarative1MouseArea); + static int idx = QObjectPrivate::get(q)->signalIndex("doubleClicked(QDeclarative1MouseEvent*)"); return QObjectPrivate::get(q)->isSignalConnected(idx); } @@ -111,7 +111,7 @@ class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate bool stealMouse : 1; bool doubleClick : 1; bool preventStealing : 1; - QDeclarativeDrag *drag; + QDeclarative1Drag *drag; QPointF startScene; qreal startX; qreal startY; diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/qtquick1/graphicsitems/qdeclarativepainteditem.cpp similarity index 81% rename from src/declarative/graphicsitems/qdeclarativepainteditem.cpp rename to src/qtquick1/graphicsitems/qdeclarativepainteditem.cpp index d2f9141023..396aed2160 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativepainteditem.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "private/qdeclarativepainteditem_p.h" -#include "private/qdeclarativepainteditem_p_p.h" +#include "QtQuick1/private/qdeclarativepainteditem_p.h" +#include "QtQuick1/private/qdeclarativepainteditem_p_p.h" #include #include @@ -53,9 +53,11 @@ QT_BEGIN_NAMESPACE + + /*! - \class QDeclarativePaintedItem - \brief The QDeclarativePaintedItem class is an abstract base class for QDeclarativeView items that want cached painting. + \class QDeclarative1PaintedItem + \brief The QDeclarative1PaintedItem class is an abstract base class for QDeclarative1View items that want cached painting. \internal This is a convenience class for implementing items that cache their painting. @@ -63,21 +65,21 @@ QT_BEGIN_NAMESPACE The dirtyCache() function should be called if the contents change to ensure the cache is refreshed the next time painting occurs. - To subclass QDeclarativePaintedItem, you must reimplement drawContents() to draw + To subclass QDeclarative1PaintedItem, you must reimplement drawContents() to draw the contents of the item. */ /*! - \fn void QDeclarativePaintedItem::drawContents(QPainter *painter, const QRect &rect) + \fn void QDeclarative1PaintedItem::drawContents(QPainter *painter, const QRect &rect) This function is called when the cache needs to be refreshed. When - sub-classing QDeclarativePaintedItem this function should be implemented so as to + sub-classing QDeclarative1PaintedItem this function should be implemented so as to paint the contents of the item using the given \a painter for the area of the contents specified by \a rect. */ /*! - \property QDeclarativePaintedItem::contentsSize + \property QDeclarative1PaintedItem::contentsSize \brief The size of the contents The contents size is the size of the item in regards to how it is painted @@ -97,15 +99,15 @@ extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; \sa clearCache() */ -void QDeclarativePaintedItem::dirtyCache(const QRect& rect) +void QDeclarative1PaintedItem::dirtyCache(const QRect& rect) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); QRect srect(qCeil(rect.x()*d->contentsScale), qCeil(rect.y()*d->contentsScale), qCeil(rect.width()*d->contentsScale), qCeil(rect.height()*d->contentsScale)); for (int i=0; i < d->imagecache.count(); ) { - QDeclarativePaintedItemPrivate::ImageCacheItem *c = d->imagecache[i]; + QDeclarative1PaintedItemPrivate::ImageCacheItem *c = d->imagecache[i]; QRect isect = (c->area & srect) | c->dirty; if (isect == c->area && !inpaint) { delete d->imagecache.takeAt(i); @@ -121,13 +123,13 @@ void QDeclarativePaintedItem::dirtyCache(const QRect& rect) \sa dirtyCache() */ -void QDeclarativePaintedItem::clearCache() +void QDeclarative1PaintedItem::clearCache() { if (inpaint) { inpaint_clearcache=1; return; } - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); qDeleteAll(d->imagecache); d->imagecache.clear(); } @@ -137,9 +139,9 @@ void QDeclarativePaintedItem::clearCache() \sa setContentsSize() */ -QSize QDeclarativePaintedItem::contentsSize() const +QSize QDeclarative1PaintedItem::contentsSize() const { - Q_D(const QDeclarativePaintedItem); + Q_D(const QDeclarative1PaintedItem); return d->contentsSize; } @@ -148,9 +150,9 @@ QSize QDeclarativePaintedItem::contentsSize() const \sa contentsSize() */ -void QDeclarativePaintedItem::setContentsSize(const QSize &size) +void QDeclarative1PaintedItem::setContentsSize(const QSize &size) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); if (d->contentsSize == size) return; prepareGeometryChange(); d->contentsSize = size; @@ -159,15 +161,15 @@ void QDeclarativePaintedItem::setContentsSize(const QSize &size) emit contentsSizeChanged(); } -qreal QDeclarativePaintedItem::contentsScale() const +qreal QDeclarative1PaintedItem::contentsScale() const { - Q_D(const QDeclarativePaintedItem); + Q_D(const QDeclarative1PaintedItem); return d->contentsScale; } -void QDeclarativePaintedItem::setContentsScale(qreal scale) +void QDeclarative1PaintedItem::setContentsScale(qreal scale) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); if (d->contentsScale == scale) return; d->contentsScale = scale; clearCache(); @@ -177,19 +179,19 @@ void QDeclarativePaintedItem::setContentsScale(qreal scale) /*! - Constructs a new QDeclarativePaintedItem with the given \a parent. + Constructs a new QDeclarative1PaintedItem with the given \a parent. */ -QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativePaintedItemPrivate), parent) +QDeclarative1PaintedItem::QDeclarative1PaintedItem(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1PaintedItemPrivate), parent) { } /*! \internal - Constructs a new QDeclarativePaintedItem with the given \a parent and + Constructs a new QDeclarative1PaintedItem with the given \a parent and initialized private data member \a dd. */ -QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativePaintedItemPrivate &dd, QDeclarativeItem *parent) +QDeclarative1PaintedItem::QDeclarative1PaintedItem(QDeclarative1PaintedItemPrivate &dd, QDeclarativeItem *parent) : QDeclarativeItem(dd, parent) { } @@ -197,12 +199,12 @@ QDeclarativePaintedItem::QDeclarativePaintedItem(QDeclarativePaintedItemPrivate /*! Destroys the image item. */ -QDeclarativePaintedItem::~QDeclarativePaintedItem() +QDeclarative1PaintedItem::~QDeclarative1PaintedItem() { clearCache(); } -void QDeclarativePaintedItem::geometryChanged(const QRectF &newGeometry, +void QDeclarative1PaintedItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { if (newGeometry.width() != oldGeometry.width() || @@ -212,7 +214,7 @@ void QDeclarativePaintedItem::geometryChanged(const QRectF &newGeometry, QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } -QVariant QDeclarativePaintedItem::itemChange(GraphicsItemChange change, +QVariant QDeclarative1PaintedItem::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemVisibleHasChanged) @@ -221,18 +223,18 @@ QVariant QDeclarativePaintedItem::itemChange(GraphicsItemChange change, return QDeclarativeItem::itemChange(change, value); } -void QDeclarativePaintedItem::setCacheFrozen(bool frozen) +void QDeclarative1PaintedItem::setCacheFrozen(bool frozen) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); if (d->cachefrozen == frozen) return; d->cachefrozen = frozen; // XXX clear cache? } -QRectF QDeclarativePaintedItem::boundingRect() const +QRectF QDeclarative1PaintedItem::boundingRect() const { - Q_D(const QDeclarativePaintedItem); + Q_D(const QDeclarative1PaintedItem); qreal w = d->mWidth; QSizeF sz = d->contentsSize * d->contentsScale; if (w < sz.width()) @@ -246,9 +248,9 @@ QRectF QDeclarativePaintedItem::boundingRect() const /*! \internal */ -void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) +void QDeclarative1PaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); const QRect content = boundingRect().toRect(); if (content.width() <= 0 || content.height() <= 0) return; @@ -375,7 +377,7 @@ void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem qCeil(r.height()/d->contentsScale+r.y()/d->contentsScale-qFloor(r.y()/d->contentsScale))); drawContents(&qp, sclip); } - QDeclarativePaintedItemPrivate::ImageCacheItem *newitem = new QDeclarativePaintedItemPrivate::ImageCacheItem; + QDeclarative1PaintedItemPrivate::ImageCacheItem *newitem = new QDeclarative1PaintedItemPrivate::ImageCacheItem; newitem->area = r; newitem->image = img; d->imagecache.append(newitem); @@ -404,21 +406,21 @@ void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem than the (unscaled) size of the WebView. */ /*! - \property QDeclarativePaintedItem::pixelCacheSize + \property QDeclarative1PaintedItem::pixelCacheSize The maximum number of pixels of image cache to allow. The default is 0.1 megapixels. The cache will not be larger than the (unscaled) - size of the QDeclarativePaintedItem. + size of the QDeclarative1PaintedItem. */ -int QDeclarativePaintedItem::pixelCacheSize() const +int QDeclarative1PaintedItem::pixelCacheSize() const { - Q_D(const QDeclarativePaintedItem); + Q_D(const QDeclarative1PaintedItem); return d->max_imagecache_size; } -void QDeclarativePaintedItem::setPixelCacheSize(int pixels) +void QDeclarative1PaintedItem::setPixelCacheSize(int pixels) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); if (pixels < d->max_imagecache_size) { int cachesize=0; for (int i=0; iimagecache.count(); ++i) { @@ -445,7 +447,7 @@ void QDeclarativePaintedItem::setPixelCacheSize(int pixels) /*! - \property QDeclarativePaintedItem::fillColor + \property QDeclarative1PaintedItem::fillColor The color to be used to fill the item prior to calling drawContents(). By default, this is Qt::transparent. @@ -453,9 +455,9 @@ void QDeclarativePaintedItem::setPixelCacheSize(int pixels) Performance improvements can be achieved if subclasses call this with either an invalid color (QColor()), or an appropriate solid color. */ -void QDeclarativePaintedItem::setFillColor(const QColor& c) +void QDeclarative1PaintedItem::setFillColor(const QColor& c) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); if (d->fillColor == c) return; d->fillColor = c; @@ -463,9 +465,9 @@ void QDeclarativePaintedItem::setFillColor(const QColor& c) update(); } -QColor QDeclarativePaintedItem::fillColor() const +QColor QDeclarative1PaintedItem::fillColor() const { - Q_D(const QDeclarativePaintedItem); + Q_D(const QDeclarative1PaintedItem); return d->fillColor; } @@ -478,15 +480,15 @@ QColor QDeclarativePaintedItem::fillColor() const This is in addition toe Item::smooth, which controls the smooth painting of the already-painted cached tiles under transformation. */ -bool QDeclarativePaintedItem::smoothCache() const +bool QDeclarative1PaintedItem::smoothCache() const { - Q_D(const QDeclarativePaintedItem); + Q_D(const QDeclarative1PaintedItem); return d->smoothCache; } -void QDeclarativePaintedItem::setSmoothCache(bool on) +void QDeclarative1PaintedItem::setSmoothCache(bool on) { - Q_D(QDeclarativePaintedItem); + Q_D(QDeclarative1PaintedItem); if (d->smoothCache != on) { d->smoothCache = on; clearCache(); @@ -494,4 +496,6 @@ void QDeclarativePaintedItem::setSmoothCache(bool on) } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h b/src/qtquick1/graphicsitems/qdeclarativepainteditem_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativepainteditem_p.h rename to src/qtquick1/graphicsitems/qdeclarativepainteditem_p.h index 6a0b7449d6..5e123219b1 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepainteditem_p.h @@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativePaintedItemPrivate; -class Q_AUTOTEST_EXPORT QDeclarativePaintedItem : public QDeclarativeItem +class QDeclarative1PaintedItemPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1PaintedItem : public QDeclarativeItem { Q_OBJECT @@ -63,8 +63,8 @@ class Q_AUTOTEST_EXPORT QDeclarativePaintedItem : public QDeclarativeItem public: - QDeclarativePaintedItem(QDeclarativeItem *parent=0); - ~QDeclarativePaintedItem(); + QDeclarative1PaintedItem(QDeclarativeItem *parent=0); + ~QDeclarative1PaintedItem(); QSize contentsSize() const; void setContentsSize(const QSize &); @@ -84,7 +84,7 @@ class Q_AUTOTEST_EXPORT QDeclarativePaintedItem : public QDeclarativeItem void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); protected: - QDeclarativePaintedItem(QDeclarativePaintedItemPrivate &dd, QDeclarativeItem *parent); + QDeclarative1PaintedItem(QDeclarative1PaintedItemPrivate &dd, QDeclarativeItem *parent); virtual void drawContents(QPainter *p, const QRect &) = 0; virtual void geometryChanged(const QRectF &newGeometry, @@ -105,13 +105,13 @@ protected Q_SLOTS: void clearCache(); private: - Q_DISABLE_COPY(QDeclarativePaintedItem) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePaintedItem) + Q_DISABLE_COPY(QDeclarative1PaintedItem) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PaintedItem) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativePaintedItem) +QML_DECLARE_TYPE(QDeclarative1PaintedItem) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepainteditem_p_p.h similarity index 94% rename from src/declarative/graphicsitems/qdeclarativepainteditem_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativepainteditem_p_p.h index c2eef4a0e1..44c825da9c 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepainteditem_p_p.h @@ -57,12 +57,12 @@ QT_BEGIN_NAMESPACE -class QDeclarativePaintedItemPrivate : public QDeclarativeItemPrivate +class QDeclarative1PaintedItemPrivate : public QDeclarativeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativePaintedItem) + Q_DECLARE_PUBLIC(QDeclarative1PaintedItem) public: - QDeclarativePaintedItemPrivate() + QDeclarative1PaintedItemPrivate() : max_imagecache_size(100000), contentsScale(1.0), fillColor(Qt::transparent), cachefrozen(false), smoothCache(true) { } diff --git a/src/qtquick1/graphicsitems/qdeclarativepath.cpp b/src/qtquick1/graphicsitems/qdeclarativepath.cpp new file mode 100644 index 0000000000..9328f2c5dd --- /dev/null +++ b/src/qtquick1/graphicsitems/qdeclarativepath.cpp @@ -0,0 +1,926 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativepath_p.h" +#include "QtQuick1/private/qdeclarativepath_p_p.h" + +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + + +/*! + \qmlclass PathElement QDeclarative1PathElement + \ingroup qml-view-elements + \since 4.7 + \brief PathElement is the base path type. + + This type is the base for all path types. It cannot + be instantiated. + + \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic +*/ + +/*! + \qmlclass Path QDeclarative1Path + \ingroup qml-view-elements + \since 4.7 + \brief A Path object defines a path for use by \l PathView. + + A Path is composed of one or more path segments - PathLine, PathQuad, + PathCubic. + + The spacing of the items along the Path can be adjusted via a + PathPercent object. + + PathAttribute allows named attributes with values to be defined + along the path. + + \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic +*/ +QDeclarative1Path::QDeclarative1Path(QObject *parent) + : QObject(*(new QDeclarative1PathPrivate), parent) +{ +} + +QDeclarative1Path::~QDeclarative1Path() +{ +} + +/*! + \qmlproperty real Path::startX + \qmlproperty real Path::startY + These properties hold the starting position of the path. +*/ +qreal QDeclarative1Path::startX() const +{ + Q_D(const QDeclarative1Path); + return d->startX; +} + +void QDeclarative1Path::setStartX(qreal x) +{ + Q_D(QDeclarative1Path); + if (qFuzzyCompare(x, d->startX)) + return; + d->startX = x; + emit startXChanged(); + processPath(); +} + +qreal QDeclarative1Path::startY() const +{ + Q_D(const QDeclarative1Path); + return d->startY; +} + +void QDeclarative1Path::setStartY(qreal y) +{ + Q_D(QDeclarative1Path); + if (qFuzzyCompare(y, d->startY)) + return; + d->startY = y; + emit startYChanged(); + processPath(); +} + +/*! + \qmlproperty bool Path::closed + This property holds whether the start and end of the path are identical. +*/ +bool QDeclarative1Path::isClosed() const +{ + Q_D(const QDeclarative1Path); + return d->closed; +} + +/*! + \qmlproperty list Path::pathElements + This property holds the objects composing the path. + + \default + + A path can contain the following path objects: + \list + \i \l PathLine - a straight line to a given position. + \i \l PathQuad - a quadratic Bezier curve to a given position with a control point. + \i \l PathCubic - a cubic Bezier curve to a given position with two control points. + \i \l PathAttribute - an attribute at a given position in the path. + \i \l PathPercent - a way to spread out items along various segments of the path. + \endlist + + \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 2 +*/ + +QDeclarativeListProperty QDeclarative1Path::pathElements() +{ + Q_D(QDeclarative1Path); + return QDeclarativeListProperty(this, d->_pathElements); +} + +void QDeclarative1Path::interpolate(int idx, const QString &name, qreal value) +{ + Q_D(QDeclarative1Path); + if (!idx) + return; + + qreal lastValue = 0; + qreal lastPercent = 0; + int search = idx - 1; + while(search >= 0) { + const AttributePoint &point = d->_attributePoints.at(search); + if (point.values.contains(name)) { + lastValue = point.values.value(name); + lastPercent = point.origpercent; + break; + } + --search; + } + + ++search; + + const AttributePoint &curPoint = d->_attributePoints.at(idx); + + for (int ii = search; ii < idx; ++ii) { + AttributePoint &point = d->_attributePoints[ii]; + + qreal val = lastValue + (value - lastValue) * (point.origpercent - lastPercent) / (curPoint.origpercent - lastPercent); + point.values.insert(name, val); + } +} + +void QDeclarative1Path::endpoint(const QString &name) +{ + Q_D(QDeclarative1Path); + const AttributePoint &first = d->_attributePoints.first(); + qreal val = first.values.value(name); + for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) { + const AttributePoint &point = d->_attributePoints.at(ii); + if (point.values.contains(name)) { + for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) { + AttributePoint &setPoint = d->_attributePoints[jj]; + setPoint.values.insert(name, val); + } + return; + } + } +} + +void QDeclarative1Path::processPath() +{ + Q_D(QDeclarative1Path); + + if (!d->componentComplete) + return; + + d->_pointCache.clear(); + d->_attributePoints.clear(); + d->_path = QPainterPath(); + + AttributePoint first; + for (int ii = 0; ii < d->_attributes.count(); ++ii) + first.values[d->_attributes.at(ii)] = 0; + d->_attributePoints << first; + + d->_path.moveTo(d->startX, d->startY); + + QDeclarative1Curve *lastCurve = 0; + foreach (QDeclarative1PathElement *pathElement, d->_pathElements) { + if (QDeclarative1Curve *curve = qobject_cast(pathElement)) { + curve->addToPath(d->_path); + AttributePoint p; + p.origpercent = d->_path.length(); + d->_attributePoints << p; + lastCurve = curve; + } else if (QDeclarative1PathAttribute *attribute = qobject_cast(pathElement)) { + AttributePoint &point = d->_attributePoints.last(); + point.values[attribute->name()] = attribute->value(); + interpolate(d->_attributePoints.count() - 1, attribute->name(), attribute->value()); + } else if (QDeclarative1PathPercent *percent = qobject_cast(pathElement)) { + AttributePoint &point = d->_attributePoints.last(); + point.values[QLatin1String("_qfx_percent")] = percent->value(); + interpolate(d->_attributePoints.count() - 1, QLatin1String("_qfx_percent"), percent->value()); + } + } + + // Fixup end points + const AttributePoint &last = d->_attributePoints.last(); + for (int ii = 0; ii < d->_attributes.count(); ++ii) { + if (!last.values.contains(d->_attributes.at(ii))) + endpoint(d->_attributes.at(ii)); + } + + // Adjust percent + qreal length = d->_path.length(); + qreal prevpercent = 0; + qreal prevorigpercent = 0; + for (int ii = 0; ii < d->_attributePoints.count(); ++ii) { + const AttributePoint &point = d->_attributePoints.at(ii); + if (point.values.contains(QLatin1String("_qfx_percent"))) { //special string for QDeclarative1PathPercent + if ( ii > 0) { + qreal scale = (d->_attributePoints[ii].origpercent/length - prevorigpercent) / + (point.values.value(QLatin1String("_qfx_percent"))-prevpercent); + d->_attributePoints[ii].scale = scale; + } + d->_attributePoints[ii].origpercent /= length; + d->_attributePoints[ii].percent = point.values.value(QLatin1String("_qfx_percent")); + prevorigpercent = d->_attributePoints[ii].origpercent; + prevpercent = d->_attributePoints[ii].percent; + } else { + d->_attributePoints[ii].origpercent /= length; + d->_attributePoints[ii].percent = d->_attributePoints[ii].origpercent; + } + } + + d->closed = lastCurve && d->startX == lastCurve->x() && d->startY == lastCurve->y(); + + emit changed(); +} + +void QDeclarative1Path::classBegin() +{ + Q_D(QDeclarative1Path); + d->componentComplete = false; +} + +void QDeclarative1Path::componentComplete() +{ + Q_D(QDeclarative1Path); + QSet attrs; + d->componentComplete = true; + + // First gather up all the attributes + foreach (QDeclarative1PathElement *pathElement, d->_pathElements) { + if (QDeclarative1PathAttribute *attribute = + qobject_cast(pathElement)) + attrs.insert(attribute->name()); + } + d->_attributes = attrs.toList(); + + processPath(); + + foreach (QDeclarative1PathElement *pathElement, d->_pathElements) + connect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); +} + +QPainterPath QDeclarative1Path::path() const +{ + Q_D(const QDeclarative1Path); + return d->_path; +} + +QStringList QDeclarative1Path::attributes() const +{ + Q_D(const QDeclarative1Path); + if (!d->componentComplete) { + QSet attrs; + + // First gather up all the attributes + foreach (QDeclarative1PathElement *pathElement, d->_pathElements) { + if (QDeclarative1PathAttribute *attribute = + qobject_cast(pathElement)) + attrs.insert(attribute->name()); + } + return attrs.toList(); + } + return d->_attributes; +} + +static inline QBezier nextBezier(const QPainterPath &path, int *from, qreal *bezLength) +{ + const int lastElement = path.elementCount() - 1; + for (int i=*from; i <= lastElement; ++i) { + const QPainterPath::Element &e = path.elementAt(i); + + switch (e.type) { + case QPainterPath::MoveToElement: + break; + case QPainterPath::LineToElement: + { + QLineF line(path.elementAt(i-1), e); + *bezLength = line.length(); + QPointF a = path.elementAt(i-1); + QPointF delta = e - a; + *from = i+1; + return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e); + } + case QPainterPath::CurveToElement: + { + QBezier b = QBezier::fromPoints(path.elementAt(i-1), + e, + path.elementAt(i+1), + path.elementAt(i+2)); + *bezLength = b.length(); + *from = i+3; + return b; + } + default: + break; + } + } + *from = lastElement; + *bezLength = 0; + return QBezier(); +} + +void QDeclarative1Path::createPointCache() const +{ + Q_D(const QDeclarative1Path); + qreal pathLength = d->_path.length(); + if (pathLength <= 0 || qIsNaN(pathLength)) + return; + // more points means less jitter between items as they move along the + // path, but takes longer to generate + const int points = qCeil(pathLength*5); + const int lastElement = d->_path.elementCount() - 1; + d->_pointCache.resize(points+1); + + int currElement = 0; + qreal bezLength = 0; + QBezier currBez = nextBezier(d->_path, &currElement, &bezLength); + qreal currLength = bezLength; + qreal epc = currLength / pathLength; + + for (int i = 0; i < d->_pointCache.size(); i++) { + //find which set we are in + qreal prevPercent = 0; + qreal prevOrigPercent = 0; + for (int ii = 0; ii < d->_attributePoints.count(); ++ii) { + qreal percent = qreal(i)/points; + const AttributePoint &point = d->_attributePoints.at(ii); + if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item + qreal elementPercent = (percent - prevPercent); + + qreal spc = prevOrigPercent + elementPercent * point.scale; + + while (spc > epc) { + if (currElement > lastElement) + break; + currBez = nextBezier(d->_path, &currElement, &bezLength); + if (bezLength == 0.0) { + currLength = pathLength; + epc = 1.0; + break; + } + currLength += bezLength; + epc = currLength / pathLength; + } + qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength; + d->_pointCache[i] = currBez.pointAt(qBound(qreal(0), realT, qreal(1))); + break; + } + prevOrigPercent = point.origpercent; + prevPercent = point.percent; + } + } +} + +QPointF QDeclarative1Path::pointAt(qreal p) const +{ + Q_D(const QDeclarative1Path); + if (d->_pointCache.isEmpty()) { + createPointCache(); + if (d->_pointCache.isEmpty()) + return QPointF(); + } + int idx = qRound(p*d->_pointCache.size()); + if (idx >= d->_pointCache.size()) + idx = d->_pointCache.size() - 1; + else if (idx < 0) + idx = 0; + return d->_pointCache.at(idx); +} + +qreal QDeclarative1Path::attributeAt(const QString &name, qreal percent) const +{ + Q_D(const QDeclarative1Path); + if (percent < 0 || percent > 1) + return 0; + + for (int ii = 0; ii < d->_attributePoints.count(); ++ii) { + const AttributePoint &point = d->_attributePoints.at(ii); + + if (point.percent == percent) { + return point.values.value(name); + } else if (point.percent > percent) { + qreal lastValue = + ii?(d->_attributePoints.at(ii - 1).values.value(name)):0; + qreal lastPercent = + ii?(d->_attributePoints.at(ii - 1).percent):0; + qreal curValue = point.values.value(name); + qreal curPercent = point.percent; + + return lastValue + (curValue - lastValue) * (percent - lastPercent) / (curPercent - lastPercent); + } + } + + return 0; +} + +/****************************************************************************/ + +qreal QDeclarative1Curve::x() const +{ + return _x; +} + +void QDeclarative1Curve::setX(qreal x) +{ + if (_x != x) { + _x = x; + emit xChanged(); + emit changed(); + } +} + +qreal QDeclarative1Curve::y() const +{ + return _y; +} + +void QDeclarative1Curve::setY(qreal y) +{ + if (_y != y) { + _y = y; + emit yChanged(); + emit changed(); + } +} + +/****************************************************************************/ + +/*! + \qmlclass PathAttribute QDeclarative1PathAttribute + \ingroup qml-view-elements + \since 4.7 + \brief The PathAttribute allows setting an attribute at a given position in a Path. + + The PathAttribute object allows attributes consisting of a name and + a value to be specified for various points along a path. The + attributes are exposed to the delegate as + \l{qdeclarativeintroduction.html#attached-properties} {Attached Properties}. + The value of an attribute at any particular point along the path is interpolated + from the PathAttributes bounding that point. + + The example below shows a path with the items scaled to 30% with + opacity 50% at the top of the path and scaled 100% with opacity + 100% at the bottom. Note the use of the PathView.iconScale and + PathView.iconOpacity attached properties to set the scale and opacity + of the delegate. + + \table + \row + \o \image declarative-pathattribute.png + \o + \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 0 + (see the PathView documentation for the specification of ContactModel.qml + used for ContactModel above.) + \endtable + + + \sa Path +*/ + +/*! + \qmlproperty string PathAttribute::name + This property holds the name of the attribute to change. + + This attribute will be available to the delegate as PathView. + + Note that using an existing Item property name such as "opacity" as an + attribute is allowed. This is because path attributes add a new + \l{qdeclarativeintroduction.html#attached-properties} {Attached Property} + which in no way clashes with existing properties. +*/ + +/*! + the name of the attribute to change. +*/ + +QString QDeclarative1PathAttribute::name() const +{ + return _name; +} + +void QDeclarative1PathAttribute::setName(const QString &name) +{ + if (_name == name) + return; + _name = name; + emit nameChanged(); +} + +/*! + \qmlproperty real PathAttribute::value + This property holds the value for the attribute. + + The value specified can be used to influence the visual appearance + of an item along the path. For example, the following Path specifies + an attribute named \e itemRotation, which has the value \e 0 at the + beginning of the path, and the value 90 at the end of the path. + + \qml + Path { + startX: 0 + startY: 0 + PathAttribute { name: "itemRotation"; value: 0 } + PathLine { x: 100; y: 100 } + PathAttribute { name: "itemRotation"; value: 90 } + } + \endqml + + In our delegate, we can then bind the \e rotation property to the + \l{qdeclarativeintroduction.html#attached-properties} {Attached Property} + \e PathView.itemRotation created for this attribute. + + \qml + Rectangle { + width: 10; height: 10 + rotation: PathView.itemRotation + } + \endqml + + As each item is positioned along the path, it will be rotated accordingly: + an item at the beginning of the path with be not be rotated, an item at + the end of the path will be rotated 90 degrees, and an item mid-way along + the path will be rotated 45 degrees. +*/ + +/*! + the new value of the attribute. +*/ +qreal QDeclarative1PathAttribute::value() const +{ + return _value; +} + +void QDeclarative1PathAttribute::setValue(qreal value) +{ + if (_value != value) { + _value = value; + emit valueChanged(); + emit changed(); + } +} + +/****************************************************************************/ + +/*! + \qmlclass PathLine QDeclarative1PathLine + \ingroup qml-view-elements + \since 4.7 + \brief The PathLine defines a straight line. + + The example below creates a path consisting of a straight line from + 0,100 to 200,100: + + \qml + Path { + startX: 0; startY: 100 + PathLine { x: 200; y: 100 } + } + \endqml + + \sa Path, PathQuad, PathCubic +*/ + +/*! + \qmlproperty real PathLine::x + \qmlproperty real PathLine::y + + Defines the end point of the line. +*/ + +void QDeclarative1PathLine::addToPath(QPainterPath &path) +{ + path.lineTo(x(), y()); +} + +/****************************************************************************/ + +/*! + \qmlclass PathQuad QDeclarative1PathQuad + \ingroup qml-view-elements + \since 4.7 + \brief The PathQuad defines a quadratic Bezier curve with a control point. + + The following QML produces the path shown below: + \table + \row + \o \image declarative-pathquad.png + \o + \qml + Path { + startX: 0; startY: 0 + PathQuad { x: 200; y: 0; controlX: 100; controlY: 150 } + } + \endqml + \endtable + + \sa Path, PathCubic, PathLine +*/ + +/*! + \qmlproperty real PathQuad::x + \qmlproperty real PathQuad::y + + Defines the end point of the curve. +*/ + +/*! + \qmlproperty real PathQuad::controlX + \qmlproperty real PathQuad::controlY + + Defines the position of the control point. +*/ + +/*! + the x position of the control point. +*/ +qreal QDeclarative1PathQuad::controlX() const +{ + return _controlX; +} + +void QDeclarative1PathQuad::setControlX(qreal x) +{ + if (_controlX != x) { + _controlX = x; + emit controlXChanged(); + emit changed(); + } +} + + +/*! + the y position of the control point. +*/ +qreal QDeclarative1PathQuad::controlY() const +{ + return _controlY; +} + +void QDeclarative1PathQuad::setControlY(qreal y) +{ + if (_controlY != y) { + _controlY = y; + emit controlYChanged(); + emit changed(); + } +} + +void QDeclarative1PathQuad::addToPath(QPainterPath &path) +{ + path.quadTo(controlX(), controlY(), x(), y()); +} + +/****************************************************************************/ + +/*! + \qmlclass PathCubic QDeclarative1PathCubic + \ingroup qml-view-elements + \since 4.7 + \brief The PathCubic defines a cubic Bezier curve with two control points. + + The following QML produces the path shown below: + \table + \row + \o \image declarative-pathcubic.png + \o + \qml + Path { + startX: 20; startY: 0 + PathCubic { + x: 180; y: 0 + control1X: -10; control1Y: 90 + control2X: 210; control2Y: 90 + } + } + \endqml + \endtable + + \sa Path, PathQuad, PathLine +*/ + +/*! + \qmlproperty real PathCubic::x + \qmlproperty real PathCubic::y + + Defines the end point of the curve. +*/ + +/*! + \qmlproperty real PathCubic::control1X + \qmlproperty real PathCubic::control1Y + + Defines the position of the first control point. +*/ +qreal QDeclarative1PathCubic::control1X() const +{ + return _control1X; +} + +void QDeclarative1PathCubic::setControl1X(qreal x) +{ + if (_control1X != x) { + _control1X = x; + emit control1XChanged(); + emit changed(); + } +} + +qreal QDeclarative1PathCubic::control1Y() const +{ + return _control1Y; +} + +void QDeclarative1PathCubic::setControl1Y(qreal y) +{ + if (_control1Y != y) { + _control1Y = y; + emit control1YChanged(); + emit changed(); + } +} + +/*! + \qmlproperty real PathCubic::control2X + \qmlproperty real PathCubic::control2Y + + Defines the position of the second control point. +*/ +qreal QDeclarative1PathCubic::control2X() const +{ + return _control2X; +} + +void QDeclarative1PathCubic::setControl2X(qreal x) +{ + if (_control2X != x) { + _control2X = x; + emit control2XChanged(); + emit changed(); + } +} + +qreal QDeclarative1PathCubic::control2Y() const +{ + return _control2Y; +} + +void QDeclarative1PathCubic::setControl2Y(qreal y) +{ + if (_control2Y != y) { + _control2Y = y; + emit control2YChanged(); + emit changed(); + } +} + +void QDeclarative1PathCubic::addToPath(QPainterPath &path) +{ + path.cubicTo(control1X(), control1Y(), control2X(), control2Y(), x(), y()); +} + +/****************************************************************************/ + +/*! + \qmlclass PathPercent QDeclarative1PathPercent + \ingroup qml-view-elements + \since 4.7 + \brief The PathPercent manipulates the way a path is interpreted. + + PathPercent allows you to manipulate the spacing between items on a + PathView's path. You can use it to bunch together items on part of + the path, and spread them out on other parts of the path. + + The examples below show the normal distrubution of items along a path + compared to a distribution which places 50% of the items along the + PathLine section of the path. + \table + \row + \o \image declarative-nopercent.png + \o + \qml + PathView { + // ... + Path { + startX: 20; startY: 0 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathLine { x: 150; y: 80 } + PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 } + } + } + \endqml + \row + \o \image declarative-percent.png + \o + \qml + PathView { + // ... + Path { + startX: 20; startY: 0 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathPercent { value: 0.25 } + PathLine { x: 150; y: 80 } + PathPercent { value: 0.75 } + PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 } + PathPercent { value: 1 } + } + } + \endqml + \endtable + + \sa Path +*/ + +/*! + \qmlproperty real PathPercent::value + The proporation of items that should be laid out up to this point. + + This value should always be higher than the last value specified + by a PathPercent at a previous position in the Path. + + In the following example we have a Path made up of three PathLines. + Normally, the items of the PathView would be laid out equally along + this path, with an equal number of items per line segment. PathPercent + allows us to specify that the first and third lines should each hold + 10% of the laid out items, while the second line should hold the remaining + 80%. + + \qml + PathView { + // ... + Path { + startX: 0; startY: 0 + PathLine { x:100; y: 0; } + PathPercent { value: 0.1 } + PathLine { x: 100; y: 100 } + PathPercent { value: 0.9 } + PathLine { x: 100; y: 0 } + PathPercent { value: 1 } + } + } + \endqml +*/ + +qreal QDeclarative1PathPercent::value() const +{ + return _value; +} + +void QDeclarative1PathPercent::setValue(qreal value) +{ + if (_value != value) { + _value = value; + emit valueChanged(); + emit changed(); + } +} + + +QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativepath_p.h b/src/qtquick1/graphicsitems/qdeclarativepath_p.h new file mode 100644 index 0000000000..e8dfad5e5f --- /dev/null +++ b/src/qtquick1/graphicsitems/qdeclarativepath_p.h @@ -0,0 +1,286 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEPATH_H +#define QDECLARATIVEPATH_H + +#include "qdeclarativeitem.h" + +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) +class Q_AUTOTEST_EXPORT QDeclarative1PathElement : public QObject +{ + Q_OBJECT +public: + QDeclarative1PathElement(QObject *parent=0) : QObject(parent) {} +Q_SIGNALS: + void changed(); +}; + +class Q_AUTOTEST_EXPORT QDeclarative1PathAttribute : public QDeclarative1PathElement +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) +public: + QDeclarative1PathAttribute(QObject *parent=0) : QDeclarative1PathElement(parent), _value(0) {} + + + QString name() const; + void setName(const QString &name); + + qreal value() const; + void setValue(qreal value); + +Q_SIGNALS: + void nameChanged(); + void valueChanged(); + +private: + QString _name; + qreal _value; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1Curve : public QDeclarative1PathElement +{ + Q_OBJECT + + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) +public: + QDeclarative1Curve(QObject *parent=0) : QDeclarative1PathElement(parent), _x(0), _y(0) {} + + qreal x() const; + void setX(qreal x); + + qreal y() const; + void setY(qreal y); + + virtual void addToPath(QPainterPath &) {} + +Q_SIGNALS: + void xChanged(); + void yChanged(); + +private: + qreal _x; + qreal _y; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1PathLine : public QDeclarative1Curve +{ + Q_OBJECT +public: + QDeclarative1PathLine(QObject *parent=0) : QDeclarative1Curve(parent) {} + + void addToPath(QPainterPath &path); +}; + +class Q_AUTOTEST_EXPORT QDeclarative1PathQuad : public QDeclarative1Curve +{ + Q_OBJECT + + Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY controlXChanged) + Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY controlYChanged) +public: + QDeclarative1PathQuad(QObject *parent=0) : QDeclarative1Curve(parent), _controlX(0), _controlY(0) {} + + qreal controlX() const; + void setControlX(qreal x); + + qreal controlY() const; + void setControlY(qreal y); + + void addToPath(QPainterPath &path); + +Q_SIGNALS: + void controlXChanged(); + void controlYChanged(); + +private: + qreal _controlX; + qreal _controlY; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1PathCubic : public QDeclarative1Curve +{ + Q_OBJECT + + Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY control1XChanged) + Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY control1YChanged) + Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY control2XChanged) + Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY control2YChanged) +public: + QDeclarative1PathCubic(QObject *parent=0) : QDeclarative1Curve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {} + + qreal control1X() const; + void setControl1X(qreal x); + + qreal control1Y() const; + void setControl1Y(qreal y); + + qreal control2X() const; + void setControl2X(qreal x); + + qreal control2Y() const; + void setControl2Y(qreal y); + + void addToPath(QPainterPath &path); + +Q_SIGNALS: + void control1XChanged(); + void control1YChanged(); + void control2XChanged(); + void control2YChanged(); + +private: + qreal _control1X; + qreal _control1Y; + qreal _control2X; + qreal _control2Y; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1PathPercent : public QDeclarative1PathElement +{ + Q_OBJECT + Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) +public: + QDeclarative1PathPercent(QObject *parent=0) : QDeclarative1PathElement(parent) {} + + qreal value() const; + void setValue(qreal value); + +signals: + void valueChanged(); + +private: + qreal _value; +}; + +class QDeclarative1PathPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Path : public QObject, public QDeclarativeParserStatus +{ + Q_OBJECT + + Q_INTERFACES(QDeclarativeParserStatus) + Q_PROPERTY(QDeclarativeListProperty pathElements READ pathElements) + Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged) + Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged) + Q_PROPERTY(bool closed READ isClosed NOTIFY changed) + Q_CLASSINFO("DefaultProperty", "pathElements") + Q_INTERFACES(QDeclarativeParserStatus) +public: + QDeclarative1Path(QObject *parent=0); + ~QDeclarative1Path(); + + QDeclarativeListProperty pathElements(); + + qreal startX() const; + void setStartX(qreal x); + + qreal startY() const; + void setStartY(qreal y); + + bool isClosed() const; + + QPainterPath path() const; + QStringList attributes() const; + qreal attributeAt(const QString &, qreal) const; + QPointF pointAt(qreal) const; + +Q_SIGNALS: + void changed(); + void startXChanged(); + void startYChanged(); + +protected: + virtual void componentComplete(); + virtual void classBegin(); + +private Q_SLOTS: + void processPath(); + +private: + struct AttributePoint { + AttributePoint() : percent(0), scale(1), origpercent(0) {} + AttributePoint(const AttributePoint &other) + : percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {} + AttributePoint &operator=(const AttributePoint &other) { + percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this; + } + qreal percent; //massaged percent along the painter path + qreal scale; + qreal origpercent; //'real' percent along the painter path + QHash values; + }; + + void interpolate(int idx, const QString &name, qreal value); + void endpoint(const QString &name); + void createPointCache() const; + +private: + Q_DISABLE_COPY(QDeclarative1Path) + Q_DECLARE_PRIVATE(QDeclarative1Path) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1PathElement) +QML_DECLARE_TYPE(QDeclarative1PathAttribute) +QML_DECLARE_TYPE(QDeclarative1Curve) +QML_DECLARE_TYPE(QDeclarative1PathLine) +QML_DECLARE_TYPE(QDeclarative1PathQuad) +QML_DECLARE_TYPE(QDeclarative1PathCubic) +QML_DECLARE_TYPE(QDeclarative1PathPercent) +QML_DECLARE_TYPE(QDeclarative1Path) + +QT_END_HEADER + +#endif // QDECLARATIVEPATH_H diff --git a/src/qtquick1/graphicsitems/qdeclarativepath_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepath_p_p.h new file mode 100644 index 0000000000..d712d777d1 --- /dev/null +++ b/src/qtquick1/graphicsitems/qdeclarativepath_p_p.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEPATH_P_H +#define QDECLARATIVEPATH_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "private/qdeclarativepath_p.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDeclarative1PathPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1Path) + +public: + QDeclarative1PathPrivate() : startX(0), startY(0), closed(false), componentComplete(true) { } + + QPainterPath _path; + QList _pathElements; + mutable QVector _pointCache; + QList _attributePoints; + QStringList _attributes; + int startX; + int startY; + bool closed; + bool componentComplete; +}; + +QT_END_NAMESPACE +#endif diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/qtquick1/graphicsitems/qdeclarativepathview.cpp similarity index 80% rename from src/declarative/graphicsitems/qdeclarativepathview.cpp rename to src/qtquick1/graphicsitems/qdeclarativepathview.cpp index 94f128dca8..ba914a9773 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativepathview.cpp @@ -39,14 +39,13 @@ ** ****************************************************************************/ -#include "private/qdeclarativepathview_p.h" -#include "private/qdeclarativepathview_p_p.h" +#include "QtQuick1/private/qdeclarativepathview_p.h" +#include "QtQuick1/private/qdeclarativepathview_p_p.h" -#include -#include +#include +#include #include #include -#include #include #include @@ -54,6 +53,8 @@ QT_BEGIN_NAMESPACE + + inline qreal qmlMod(qreal x, qreal y) { #ifdef QT_USE_MATH_H_FLOATS @@ -64,36 +65,36 @@ inline qreal qmlMod(qreal x, qreal y) return fmod(x, y); } -static QDeclarativeOpenMetaObjectType *qPathViewAttachedType = 0; +static QDeclarative1OpenMetaObjectType *qPathViewAttachedType = 0; -QDeclarativePathViewAttached::QDeclarativePathViewAttached(QObject *parent) +QDeclarative1PathViewAttached::QDeclarative1PathViewAttached(QObject *parent) : QObject(parent), m_percent(-1), m_view(0), m_onPath(false), m_isCurrent(false) { if (qPathViewAttachedType) { - m_metaobject = new QDeclarativeOpenMetaObject(this, qPathViewAttachedType); + m_metaobject = new QDeclarative1OpenMetaObject(this, qPathViewAttachedType); m_metaobject->setCached(true); } else { - m_metaobject = new QDeclarativeOpenMetaObject(this); + m_metaobject = new QDeclarative1OpenMetaObject(this); } } -QDeclarativePathViewAttached::~QDeclarativePathViewAttached() +QDeclarative1PathViewAttached::~QDeclarative1PathViewAttached() { } -QVariant QDeclarativePathViewAttached::value(const QByteArray &name) const +QVariant QDeclarative1PathViewAttached::value(const QByteArray &name) const { return m_metaobject->value(name); } -void QDeclarativePathViewAttached::setValue(const QByteArray &name, const QVariant &val) +void QDeclarative1PathViewAttached::setValue(const QByteArray &name, const QVariant &val) { m_metaobject->setValue(name, val); } -void QDeclarativePathViewPrivate::init() +void QDeclarative1PathViewPrivate::init() { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); offset = 0; q->setAcceptedMouseButtons(Qt::LeftButton); q->setFlag(QGraphicsItem::ItemIsFocusScope); @@ -103,27 +104,27 @@ void QDeclarativePathViewPrivate::init() static int timelineCompletedIdx = -1; static int movementEndingIdx = -1; if (timelineCompletedIdx == -1) { - timelineCompletedIdx = QDeclarativeTimeLine::staticMetaObject.indexOfSignal("completed()"); - movementEndingIdx = QDeclarativePathView::staticMetaObject.indexOfSlot("movementEnding()"); + timelineCompletedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("completed()"); + movementEndingIdx = QDeclarative1PathView::staticMetaObject.indexOfSlot("movementEnding()"); } QMetaObject::connect(&tl, timelineCompletedIdx, q, movementEndingIdx, Qt::DirectConnection); } -QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex) +QDeclarativeItem *QDeclarative1PathViewPrivate::getItem(int modelIndex) { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); requestedIndex = modelIndex; QDeclarativeItem *item = model->item(modelIndex, false); if (item) { if (!attType) { // pre-create one metatype to share with all attached objects - attType = new QDeclarativeOpenMetaObjectType(&QDeclarativePathViewAttached::staticMetaObject, qmlEngine(q)); + attType = new QDeclarative1OpenMetaObjectType(&QDeclarative1PathViewAttached::staticMetaObject, qmlEngine(q)); foreach(const QString &attr, path->attributes()) attType->createProperty(attr.toUtf8()); } qPathViewAttachedType = attType; - QDeclarativePathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); + QDeclarative1PathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); qPathViewAttachedType = 0; if (att) { att->m_view = q; @@ -137,7 +138,7 @@ QDeclarativeItem *QDeclarativePathViewPrivate::getItem(int modelIndex) return item; } -void QDeclarativePathViewPrivate::releaseItem(QDeclarativeItem *item) +void QDeclarative1PathViewPrivate::releaseItem(QDeclarativeItem *item) { if (!item || !model) return; @@ -145,17 +146,17 @@ void QDeclarativePathViewPrivate::releaseItem(QDeclarativeItem *item) itemPrivate->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); if (model->release(item) == 0) { // item was not destroyed, and we no longer reference it. - if (QDeclarativePathViewAttached *att = attached(item)) + if (QDeclarative1PathViewAttached *att = attached(item)) att->setOnPath(false); } } -QDeclarativePathViewAttached *QDeclarativePathViewPrivate::attached(QDeclarativeItem *item) +QDeclarative1PathViewAttached *QDeclarative1PathViewPrivate::attached(QDeclarativeItem *item) { - return static_cast(qmlAttachedPropertiesObject(item, false)); + return static_cast(qmlAttachedPropertiesObject(item, false)); } -void QDeclarativePathViewPrivate::clear() +void QDeclarative1PathViewPrivate::clear() { for (int i=0; i= 0 && index < modelCount) { qreal start = 0.0; - if (haveHighlightRange && highlightRangeMode != QDeclarativePathView::NoHighlightRange) + if (haveHighlightRange && highlightRangeMode != QDeclarative1PathView::NoHighlightRange) start = highlightRangeStart; qreal globalPos = index + offset; globalPos = qmlMod(globalPos, qreal(modelCount)) / modelCount; @@ -195,9 +196,9 @@ qreal QDeclarativePathViewPrivate::positionOfIndex(qreal index) const return pos; } -void QDeclarativePathViewPrivate::createHighlight() +void QDeclarative1PathViewPrivate::createHighlight() { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (!q->isComponentComplete()) return; @@ -235,13 +236,13 @@ void QDeclarativePathViewPrivate::createHighlight() emit q->highlightItemChanged(); } -void QDeclarativePathViewPrivate::updateHighlight() +void QDeclarative1PathViewPrivate::updateHighlight() { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (!q->isComponentComplete() || !isValid()) return; if (highlightItem) { - if (haveHighlightRange && highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + if (haveHighlightRange && highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { updateItem(highlightItem, highlightRangeStart); } else { qreal target = currentIndex; @@ -272,12 +273,12 @@ void QDeclarativePathViewPrivate::updateHighlight() } } -void QDeclarativePathViewPrivate::setHighlightPosition(qreal pos) +void QDeclarative1PathViewPrivate::setHighlightPosition(qreal pos) { if (pos != highlightPosition) { qreal start = 0.0; qreal end = 1.0; - if (haveHighlightRange && highlightRangeMode != QDeclarativePathView::NoHighlightRange) { + if (haveHighlightRange && highlightRangeMode != QDeclarative1PathView::NoHighlightRange) { start = highlightRangeStart; end = highlightRangeEnd; } @@ -297,27 +298,27 @@ void QDeclarativePathViewPrivate::setHighlightPosition(qreal pos) highlightPosition = pos; qreal pathPos = positionOfIndex(pos); updateItem(highlightItem, pathPos); - if (QDeclarativePathViewAttached *att = attached(highlightItem)) + if (QDeclarative1PathViewAttached *att = attached(highlightItem)) att->setOnPath(pathPos != -1.0); } } -void QDeclarativePathView::pathUpdated() +void QDeclarative1PathView::pathUpdated() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); QList::iterator it = d->items.begin(); while (it != d->items.end()) { QDeclarativeItem *item = *it; - if (QDeclarativePathViewAttached *att = d->attached(item)) + if (QDeclarative1PathViewAttached *att = d->attached(item)) att->m_percent = -1; ++it; } refill(); } -void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) +void QDeclarative1PathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) { - if (QDeclarativePathViewAttached *att = attached(item)) { + if (QDeclarative1PathViewAttached *att = attached(item)) { if (qFuzzyCompare(att->m_percent, percent)) return; att->m_percent = percent; @@ -329,9 +330,9 @@ void QDeclarativePathViewPrivate::updateItem(QDeclarativeItem *item, qreal perce item->setY(qRound(pf.y() - item->height()/2)); } -void QDeclarativePathViewPrivate::regenerate() +void QDeclarative1PathViewPrivate::regenerate() { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (!q->isComponentComplete()) return; @@ -346,7 +347,7 @@ void QDeclarativePathViewPrivate::regenerate() } /*! - \qmlclass PathView QDeclarativePathView + \qmlclass PathView QDeclarative1PathView \ingroup qml-view-elements \since 4.7 \brief The PathView element lays out model-provided items on a path. @@ -410,16 +411,16 @@ void QDeclarativePathViewPrivate::regenerate() \sa Path, {declarative/modelviews/pathview}{PathView example} */ -QDeclarativePathView::QDeclarativePathView(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativePathViewPrivate), parent) +QDeclarative1PathView::QDeclarative1PathView(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1PathViewPrivate), parent) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); d->init(); } -QDeclarativePathView::~QDeclarativePathView() +QDeclarative1PathView::~QDeclarative1PathView() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); d->clear(); if (d->attType) d->attType->release(); @@ -475,15 +476,15 @@ QDeclarativePathView::~QDeclarativePathView() \sa {qmlmodels}{Data Models} */ -QVariant QDeclarativePathView::model() const +QVariant QDeclarative1PathView::model() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->modelVariant; } -void QDeclarativePathView::setModel(const QVariant &model) +void QDeclarative1PathView::setModel(const QVariant &model) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->modelVariant == model) return; @@ -502,8 +503,8 @@ void QDeclarativePathView::setModel(const QVariant &model) d->modelVariant = model; QObject *object = qvariant_cast(model); - QDeclarativeVisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { + QDeclarative1VisualModel *vim = 0; + if (object && (vim = qobject_cast(object))) { if (d->ownModel) { delete d->model; d->ownModel = false; @@ -511,10 +512,10 @@ void QDeclarativePathView::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); + d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); d->ownModel = true; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) dataModel->setModel(model); } d->modelCount = 0; @@ -540,9 +541,9 @@ void QDeclarativePathView::setModel(const QVariant &model) \qmlproperty int PathView::count This property holds the number of items in the model. */ -int QDeclarativePathView::count() const +int QDeclarative1PathView::count() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->model ? d->modelCount : 0; } @@ -551,15 +552,15 @@ int QDeclarativePathView::count() const This property holds the path used to lay out the items. For more information see the \l Path documentation. */ -QDeclarativePath *QDeclarativePathView::path() const +QDeclarative1Path *QDeclarative1PathView::path() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->path; } -void QDeclarativePathView::setPath(QDeclarativePath *path) +void QDeclarative1PathView::setPath(QDeclarative1Path *path) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->path == path) return; if (d->path) @@ -581,15 +582,15 @@ void QDeclarativePathView::setPath(QDeclarativePath *path) \qmlproperty int PathView::currentIndex This property holds the index of the current item. */ -int QDeclarativePathView::currentIndex() const +int QDeclarative1PathView::currentIndex() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->currentIndex; } -void QDeclarativePathView::setCurrentIndex(int idx) +void QDeclarative1PathView::setCurrentIndex(int idx) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->model && d->modelCount) idx = qAbs(idx % d->modelCount); if (d->model && idx != d->currentIndex) { @@ -597,22 +598,22 @@ void QDeclarativePathView::setCurrentIndex(int idx) int itemIndex = (d->currentIndex - d->firstIndex + d->modelCount) % d->modelCount; if (itemIndex < d->items.count()) { if (QDeclarativeItem *item = d->items.at(itemIndex)) { - if (QDeclarativePathViewAttached *att = d->attached(item)) + if (QDeclarative1PathViewAttached *att = d->attached(item)) att->setIsCurrentItem(false); } } } d->currentItem = 0; - d->moveReason = QDeclarativePathViewPrivate::SetIndex; + d->moveReason = QDeclarative1PathViewPrivate::SetIndex; d->currentIndex = idx; if (d->modelCount) { - if (d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) + if (d->haveHighlightRange && d->highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) d->snapToCurrent(); int itemIndex = (idx - d->firstIndex + d->modelCount) % d->modelCount; if (itemIndex < d->items.count()) { d->currentItem = d->items.at(itemIndex); d->currentItem->setFocus(true); - if (QDeclarativePathViewAttached *att = d->attached(d->currentItem)) + if (QDeclarative1PathViewAttached *att = d->attached(d->currentItem)) att->setIsCurrentItem(true); } d->currentItemOffset = d->positionOfIndex(d->currentIndex); @@ -629,10 +630,10 @@ void QDeclarativePathView::setCurrentIndex(int idx) \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativePathView::incrementCurrentIndex() +void QDeclarative1PathView::incrementCurrentIndex() { - Q_D(QDeclarativePathView); - d->moveDirection = QDeclarativePathViewPrivate::Positive; + Q_D(QDeclarative1PathView); + d->moveDirection = QDeclarative1PathViewPrivate::Positive; setCurrentIndex(currentIndex()+1); } @@ -644,14 +645,14 @@ void QDeclarativePathView::incrementCurrentIndex() \bold Note: methods should only be called after the Component has completed. */ -void QDeclarativePathView::decrementCurrentIndex() +void QDeclarative1PathView::decrementCurrentIndex() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->model && d->modelCount) { int idx = currentIndex()-1; if (idx < 0) idx = d->modelCount - 1; - d->moveDirection = QDeclarativePathViewPrivate::Negative; + d->moveDirection = QDeclarative1PathViewPrivate::Negative; setCurrentIndex(idx); } } @@ -662,22 +663,22 @@ void QDeclarativePathView::decrementCurrentIndex() The offset specifies how far along the path the items are from their initial positions. This is a real number that ranges from 0.0 to the count of items in the model. */ -qreal QDeclarativePathView::offset() const +qreal QDeclarative1PathView::offset() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->offset; } -void QDeclarativePathView::setOffset(qreal offset) +void QDeclarative1PathView::setOffset(qreal offset) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); d->setOffset(offset); d->updateCurrent(); } -void QDeclarativePathViewPrivate::setOffset(qreal o) +void QDeclarative1PathViewPrivate::setOffset(qreal o) { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (offset != o) { if (isValid() && q->isComponentComplete()) { offset = qmlMod(o, qreal(modelCount)); @@ -691,7 +692,7 @@ void QDeclarativePathViewPrivate::setOffset(qreal o) } } -void QDeclarativePathViewPrivate::setAdjustedOffset(qreal o) +void QDeclarative1PathViewPrivate::setAdjustedOffset(qreal o) { setOffset(o+offsetAdj); } @@ -720,15 +721,15 @@ void QDeclarativePathViewPrivate::setAdjustedOffset(qreal o) \sa highlightItem, highlightRangeMode */ -QDeclarativeComponent *QDeclarativePathView::highlight() const +QDeclarativeComponent *QDeclarative1PathView::highlight() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->highlightComponent; } -void QDeclarativePathView::setHighlight(QDeclarativeComponent *highlight) +void QDeclarative1PathView::setHighlight(QDeclarativeComponent *highlight) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (highlight != d->highlightComponent) { d->highlightComponent = highlight; d->createHighlight(); @@ -745,9 +746,9 @@ void QDeclarativePathView::setHighlight(QDeclarativeComponent *highlight) \sa highlight */ -QDeclarativeItem *QDeclarativePathView::highlightItem() +QDeclarativeItem *QDeclarative1PathView::highlightItem() { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->highlightItem; } /*! @@ -785,15 +786,15 @@ QDeclarativeItem *QDeclarativePathView::highlightItem() Note that a valid range requires preferredHighlightEnd to be greater than or equal to preferredHighlightBegin. */ -qreal QDeclarativePathView::preferredHighlightBegin() const +qreal QDeclarative1PathView::preferredHighlightBegin() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->highlightRangeStart; } -void QDeclarativePathView::setPreferredHighlightBegin(qreal start) +void QDeclarative1PathView::setPreferredHighlightBegin(qreal start) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->highlightRangeStart == start || start < 0 || start > 1.0) return; d->highlightRangeStart = start; @@ -802,15 +803,15 @@ void QDeclarativePathView::setPreferredHighlightBegin(qreal start) emit preferredHighlightBeginChanged(); } -qreal QDeclarativePathView::preferredHighlightEnd() const +qreal QDeclarative1PathView::preferredHighlightEnd() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->highlightRangeEnd; } -void QDeclarativePathView::setPreferredHighlightEnd(qreal end) +void QDeclarative1PathView::setPreferredHighlightEnd(qreal end) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->highlightRangeEnd == end || end < 0 || end > 1.0) return; d->highlightRangeEnd = end; @@ -819,15 +820,15 @@ void QDeclarativePathView::setPreferredHighlightEnd(qreal end) emit preferredHighlightEndChanged(); } -QDeclarativePathView::HighlightRangeMode QDeclarativePathView::highlightRangeMode() const +QDeclarative1PathView::HighlightRangeMode QDeclarative1PathView::highlightRangeMode() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->highlightRangeMode; } -void QDeclarativePathView::setHighlightRangeMode(HighlightRangeMode mode) +void QDeclarative1PathView::setHighlightRangeMode(HighlightRangeMode mode) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->highlightRangeMode == mode) return; d->highlightRangeMode = mode; @@ -845,15 +846,15 @@ void QDeclarativePathView::setHighlightRangeMode(HighlightRangeMode mode) The default value for the duration is 300ms. */ -int QDeclarativePathView::highlightMoveDuration() const +int QDeclarative1PathView::highlightMoveDuration() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->highlightMoveDuration; } -void QDeclarativePathView::setHighlightMoveDuration(int duration) +void QDeclarative1PathView::setHighlightMoveDuration(int duration) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->highlightMoveDuration == duration) return; d->highlightMoveDuration = duration; @@ -868,15 +869,15 @@ void QDeclarativePathView::setHighlightMoveDuration(int duration) dragMargin is greater than zero, a drag can be initiated by clicking within dragMargin pixels of the path. */ -qreal QDeclarativePathView::dragMargin() const +qreal QDeclarative1PathView::dragMargin() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->dragMargin; } -void QDeclarativePathView::setDragMargin(qreal dragMargin) +void QDeclarative1PathView::setDragMargin(qreal dragMargin) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->dragMargin == dragMargin) return; d->dragMargin = dragMargin; @@ -889,15 +890,15 @@ void QDeclarativePathView::setDragMargin(qreal dragMargin) The default is 100. */ -qreal QDeclarativePathView::flickDeceleration() const +qreal QDeclarative1PathView::flickDeceleration() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->deceleration; } -void QDeclarativePathView::setFlickDeceleration(qreal dec) +void QDeclarative1PathView::setFlickDeceleration(qreal dec) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->deceleration == dec) return; d->deceleration = dec; @@ -912,15 +913,15 @@ void QDeclarativePathView::setFlickDeceleration(qreal dec) This property is useful for temporarily disabling flicking. This allows special interaction with PathView's children. */ -bool QDeclarativePathView::isInteractive() const +bool QDeclarative1PathView::isInteractive() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->interactive; } -void QDeclarativePathView::setInteractive(bool interactive) +void QDeclarative1PathView::setInteractive(bool interactive) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (interactive != d->interactive) { d->interactive = interactive; if (!interactive) @@ -935,9 +936,9 @@ void QDeclarativePathView::setInteractive(bool interactive) This property holds whether the view is currently moving due to the user either dragging or flicking the view. */ -bool QDeclarativePathView::isMoving() const +bool QDeclarative1PathView::isMoving() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->moving; } @@ -947,9 +948,9 @@ bool QDeclarativePathView::isMoving() const This property holds whether the view is currently moving due to the user flicking the view. */ -bool QDeclarativePathView::isFlicking() const +bool QDeclarative1PathView::isFlicking() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->flicking; } @@ -1002,27 +1003,27 @@ bool QDeclarativePathView::isFlicking() const Here is an example delegate: \snippet doc/src/snippets/declarative/pathview/pathview.qml 1 */ -QDeclarativeComponent *QDeclarativePathView::delegate() const +QDeclarativeComponent *QDeclarative1PathView::delegate() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); if (d->model) { - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) return dataModel->delegate(); } return 0; } -void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate) +void QDeclarative1PathView::setDelegate(QDeclarativeComponent *delegate) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (delegate == this->delegate()) return; if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarative1VisualDataModel(qmlContext(this)); d->ownModel = true; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) { + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { int oldCount = dataModel->count(); dataModel->setDelegate(delegate); d->modelCount = dataModel->count(); @@ -1037,15 +1038,15 @@ void QDeclarativePathView::setDelegate(QDeclarativeComponent *delegate) \qmlproperty int PathView::pathItemCount This property holds the number of items visible on the path at any one time. */ -int QDeclarativePathView::pathItemCount() const +int QDeclarative1PathView::pathItemCount() const { - Q_D(const QDeclarativePathView); + Q_D(const QDeclarative1PathView); return d->pathItems; } -void QDeclarativePathView::setPathItemCount(int i) +void QDeclarative1PathView::setPathItemCount(int i) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (i == d->pathItems) return; if (i < 1) @@ -1058,7 +1059,7 @@ void QDeclarativePathView::setPathItemCount(int i) emit pathItemCountChanged(); } -QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const +QPointF QDeclarative1PathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const { //XXX maybe do recursively at increasing resolution. qreal mindist = 1e10; // big number @@ -1081,9 +1082,9 @@ QPointF QDeclarativePathViewPrivate::pointNear(const QPointF &point, qreal *near return nearPoint; } -void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PathView::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->interactive) { d->handleMousePressEvent(event); event->accept(); @@ -1092,9 +1093,9 @@ void QDeclarativePathView::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativePathViewPrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PathViewPrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (!interactive || !items.count()) return; QPointF scenePoint = q->mapToScene(event->pos()); @@ -1126,9 +1127,9 @@ void QDeclarativePathViewPrivate::handleMousePressEvent(QGraphicsSceneMouseEvent tl.clear(); } -void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->interactive) { d->handleMouseMoveEvent(event); if (d->stealMouse) @@ -1139,9 +1140,9 @@ void QDeclarativePathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativePathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (!interactive || !lastPosTime.isValid()) return; @@ -1156,7 +1157,7 @@ void QDeclarativePathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent } if (stealMouse) { - moveReason = QDeclarativePathViewPrivate::Mouse; + moveReason = QDeclarative1PathViewPrivate::Mouse; qreal diff = (newPc - startPc)*modelCount*mappedRange; if (diff) { q->setOffset(offset + diff); @@ -1178,9 +1179,9 @@ void QDeclarativePathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent } } -void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->interactive) { d->handleMouseReleaseEvent(event); event->accept(); @@ -1190,9 +1191,9 @@ void QDeclarativePathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativePathViewPrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *) +void QDeclarative1PathViewPrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *) { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); stealMouse = false; q->setKeepMouseGrab(false); if (!interactive || !lastPosTime.isValid()) @@ -1209,7 +1210,7 @@ void QDeclarativePathViewPrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEve qreal accel = deceleration/10; // + 0.25 to encourage moving at least one item in the flick direction qreal dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0) + 0.25)); - if (haveHighlightRange && highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + if (haveHighlightRange && highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { // round to nearest item. if (velocity > 0.) dist = qRound(dist + offset) - offset; @@ -1226,7 +1227,7 @@ void QDeclarativePathViewPrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEve offsetAdj = 0.0; moveOffset.setValue(offset); tl.accel(moveOffset, velocity, accel, dist); - tl.callback(QDeclarativeTimeLineCallback(&moveOffset, fixOffsetCallback, this)); + tl.callback(QDeclarative1TimeLineCallback(&moveOffset, fixOffsetCallback, this)); if (!flicking) { flicking = true; emit q->flickingChanged(); @@ -1241,9 +1242,9 @@ void QDeclarativePathViewPrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEve q->movementEnding(); } -bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) +bool QDeclarative1PathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); QGraphicsSceneMouseEvent mouseEvent(event->type()); QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); QGraphicsScene *s = scene(); @@ -1289,9 +1290,9 @@ bool QDeclarativePathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) return false; } -bool QDeclarativePathView::sceneEventFilter(QGraphicsItem *i, QEvent *e) +bool QDeclarative1PathView::sceneEventFilter(QGraphicsItem *i, QEvent *e) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (!isVisible() || !d->interactive) return QDeclarativeItem::sceneEventFilter(i, e); @@ -1307,7 +1308,7 @@ bool QDeclarativePathView::sceneEventFilter(QGraphicsItem *i, QEvent *e) return QDeclarativeItem::sceneEventFilter(i, e); } -bool QDeclarativePathView::event(QEvent *event) +bool QDeclarative1PathView::event(QEvent *event) { if (event->type() == QEvent::User) { refill(); @@ -1317,9 +1318,9 @@ bool QDeclarativePathView::event(QEvent *event) return QDeclarativeItem::event(event); } -void QDeclarativePathView::componentComplete() +void QDeclarative1PathView::componentComplete() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); QDeclarativeItem::componentComplete(); d->createHighlight(); // It is possible that a refill has already happended to to Path @@ -1332,9 +1333,9 @@ void QDeclarativePathView::componentComplete() d->updateHighlight(); } -void QDeclarativePathView::refill() +void QDeclarative1PathView::refill() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (!d->isValid() || !isComponentComplete()) return; @@ -1377,7 +1378,7 @@ void QDeclarativePathView::refill() if (d->items.count() < count) { int idx = qRound(d->modelCount - d->offset) % d->modelCount; qreal startPos = 0.0; - if (d->haveHighlightRange && d->highlightRangeMode != QDeclarativePathView::NoHighlightRange) + if (d->haveHighlightRange && d->highlightRangeMode != QDeclarative1PathView::NoHighlightRange) startPos = d->highlightRangeStart; if (d->firstIndex >= 0) { startPos = d->positionOfIndex(d->firstIndex); @@ -1391,7 +1392,7 @@ void QDeclarativePathView::refill() item->setZValue(idx+1); if (d->currentIndex == idx) { item->setFocus(true); - if (QDeclarativePathViewAttached *att = d->attached(item)) + if (QDeclarative1PathViewAttached *att = d->attached(item)) att->setIsCurrentItem(true); currentVisible = true; d->currentItemOffset = pos; @@ -1420,7 +1421,7 @@ void QDeclarativePathView::refill() item->setZValue(idx+1); if (d->currentIndex == idx) { item->setFocus(true); - if (QDeclarativePathViewAttached *att = d->attached(item)) + if (QDeclarative1PathViewAttached *att = d->attached(item)) att->setIsCurrentItem(true); currentVisible = true; d->currentItemOffset = pos; @@ -1442,23 +1443,23 @@ void QDeclarativePathView::refill() if (!currentVisible) d->currentItemOffset = 1.0; - if (d->highlightItem && d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + if (d->highlightItem && d->haveHighlightRange && d->highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { d->updateItem(d->highlightItem, d->highlightRangeStart); - if (QDeclarativePathViewAttached *att = d->attached(d->highlightItem)) + if (QDeclarative1PathViewAttached *att = d->attached(d->highlightItem)) att->setOnPath(true); - } else if (d->highlightItem && d->moveReason != QDeclarativePathViewPrivate::SetIndex) { + } else if (d->highlightItem && d->moveReason != QDeclarative1PathViewPrivate::SetIndex) { d->updateItem(d->highlightItem, d->currentItemOffset); - if (QDeclarativePathViewAttached *att = d->attached(d->highlightItem)) + if (QDeclarative1PathViewAttached *att = d->attached(d->highlightItem)) att->setOnPath(currentVisible); } while (d->itemCache.count()) d->releaseItem(d->itemCache.takeLast()); } -void QDeclarativePathView::itemsInserted(int modelIndex, int count) +void QDeclarative1PathView::itemsInserted(int modelIndex, int count) { //XXX support animated insertion - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (!d->isValid() || !isComponentComplete()) return; @@ -1485,10 +1486,10 @@ void QDeclarativePathView::itemsInserted(int modelIndex, int count) emit countChanged(); } -void QDeclarativePathView::itemsRemoved(int modelIndex, int count) +void QDeclarative1PathView::itemsRemoved(int modelIndex, int count) { //XXX support animated removal - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (!d->model || !d->modelCount || !d->model->isValid() || !d->path || !isComponentComplete()) return; @@ -1501,7 +1502,7 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count) // current item has been removed. d->currentIndex = qMin(modelIndex, d->modelCount-count-1); if (d->currentItem) { - if (QDeclarativePathViewAttached *att = d->attached(d->currentItem)) + if (QDeclarative1PathViewAttached *att = d->attached(d->currentItem)) att->setIsCurrentItem(true); } currentChanged = true; @@ -1530,7 +1531,7 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count) } else { d->regenerate(); d->updateCurrent(); - if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) + if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) d->snapToCurrent(); } if (changedOffset) @@ -1540,9 +1541,9 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count) emit countChanged(); } -void QDeclarativePathView::itemsMoved(int /*from*/, int /*to*/, int /*count*/) +void QDeclarative1PathView::itemsMoved(int /*from*/, int /*to*/, int /*count*/) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (!d->isValid() || !isComponentComplete()) return; @@ -1562,26 +1563,26 @@ void QDeclarativePathView::itemsMoved(int /*from*/, int /*to*/, int /*count*/) d->updateCurrent(); } -void QDeclarativePathView::modelReset() +void QDeclarative1PathView::modelReset() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); d->modelCount = d->model->count(); d->regenerate(); emit countChanged(); } -void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item) +void QDeclarative1PathView::createdItem(int index, QDeclarativeItem *item) { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->requestedIndex != index) { if (!d->attType) { // pre-create one metatype to share with all attached objects - d->attType = new QDeclarativeOpenMetaObjectType(&QDeclarativePathViewAttached::staticMetaObject, qmlEngine(this)); + d->attType = new QDeclarative1OpenMetaObjectType(&QDeclarative1PathViewAttached::staticMetaObject, qmlEngine(this)); foreach(const QString &attr, d->path->attributes()) d->attType->createProperty(attr.toUtf8()); } qPathViewAttachedType = d->attType; - QDeclarativePathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); + QDeclarative1PathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); qPathViewAttachedType = 0; if (att) { att->m_view = this; @@ -1592,20 +1593,20 @@ void QDeclarativePathView::createdItem(int index, QDeclarativeItem *item) } } -void QDeclarativePathView::destroyingItem(QDeclarativeItem *item) +void QDeclarative1PathView::destroyingItem(QDeclarativeItem *item) { Q_UNUSED(item); } -void QDeclarativePathView::ticked() +void QDeclarative1PathView::ticked() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); d->updateCurrent(); } -void QDeclarativePathView::movementEnding() +void QDeclarative1PathView::movementEnding() { - Q_D(QDeclarativePathView); + Q_D(QDeclarative1PathView); if (d->flicking) { d->flicking = false; emit flickingChanged(); @@ -1619,7 +1620,7 @@ void QDeclarativePathView::movementEnding() } // find the item closest to the snap position -int QDeclarativePathViewPrivate::calcCurrentIndex() +int QDeclarative1PathViewPrivate::calcCurrentIndex() { int current = -1; if (modelCount && model && items.count()) { @@ -1633,12 +1634,12 @@ int QDeclarativePathViewPrivate::calcCurrentIndex() return current; } -void QDeclarativePathViewPrivate::updateCurrent() +void QDeclarative1PathViewPrivate::updateCurrent() { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (moveReason != Mouse) return; - if (!modelCount || !haveHighlightRange || highlightRangeMode != QDeclarativePathView::StrictlyEnforceRange) + if (!modelCount || !haveHighlightRange || highlightRangeMode != QDeclarative1PathView::StrictlyEnforceRange) return; int idx = calcCurrentIndex(); @@ -1646,7 +1647,7 @@ void QDeclarativePathViewPrivate::updateCurrent() int itemIndex = (currentIndex - firstIndex + modelCount) % modelCount; if (itemIndex < items.count()) { if (QDeclarativeItem *item = items.at(itemIndex)) { - if (QDeclarativePathViewAttached *att = attached(item)) + if (QDeclarative1PathViewAttached *att = attached(item)) att->setIsCurrentItem(false); } } @@ -1656,23 +1657,23 @@ void QDeclarativePathViewPrivate::updateCurrent() if (itemIndex < items.count()) { currentItem = items.at(itemIndex); currentItem->setFocus(true); - if (QDeclarativePathViewAttached *att = attached(currentItem)) + if (QDeclarative1PathViewAttached *att = attached(currentItem)) att->setIsCurrentItem(true); } emit q->currentIndexChanged(); } } -void QDeclarativePathViewPrivate::fixOffsetCallback(void *d) +void QDeclarative1PathViewPrivate::fixOffsetCallback(void *d) { - ((QDeclarativePathViewPrivate *)d)->fixOffset(); + ((QDeclarative1PathViewPrivate *)d)->fixOffset(); } -void QDeclarativePathViewPrivate::fixOffset() +void QDeclarative1PathViewPrivate::fixOffset() { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (model && items.count()) { - if (haveHighlightRange && highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange) { + if (haveHighlightRange && highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { int curr = calcCurrentIndex(); if (curr != currentIndex) q->setCurrentIndex(curr); @@ -1682,7 +1683,7 @@ void QDeclarativePathViewPrivate::fixOffset() } } -void QDeclarativePathViewPrivate::snapToCurrent() +void QDeclarative1PathViewPrivate::snapToCurrent() { if (!model || modelCount <= 0) return; @@ -1720,10 +1721,12 @@ void QDeclarativePathViewPrivate::snapToCurrent() moveDirection = Shortest; } -QDeclarativePathViewAttached *QDeclarativePathView::qmlAttachedProperties(QObject *obj) +QDeclarative1PathViewAttached *QDeclarative1PathView::qmlAttachedProperties(QObject *obj) { - return new QDeclarativePathViewAttached(obj); + return new QDeclarative1PathViewAttached(obj); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/qtquick1/graphicsitems/qdeclarativepathview_p.h similarity index 86% rename from src/declarative/graphicsitems/qdeclarativepathview_p.h rename to src/qtquick1/graphicsitems/qdeclarativepathview_p.h index f63f6400c7..b4897f9e1d 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepathview_p.h @@ -43,7 +43,7 @@ #define QDECLARATIVEPATHVIEW_H #include "qdeclarativeitem.h" -#include "private/qdeclarativepath_p.h" +#include "QtQuick1/private/qdeclarativepath_p.h" QT_BEGIN_HEADER @@ -51,14 +51,14 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativePathViewPrivate; -class QDeclarativePathViewAttached; -class Q_AUTOTEST_EXPORT QDeclarativePathView : public QDeclarativeItem +class QDeclarative1PathViewPrivate; +class QDeclarative1PathViewAttached; +class Q_AUTOTEST_EXPORT QDeclarative1PathView : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) - Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged) + Q_PROPERTY(QDeclarative1Path *path READ path WRITE setPath NOTIFY pathChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged) @@ -84,14 +84,14 @@ class Q_AUTOTEST_EXPORT QDeclarativePathView : public QDeclarativeItem Q_ENUMS(HighlightRangeMode) public: - QDeclarativePathView(QDeclarativeItem *parent=0); - virtual ~QDeclarativePathView(); + QDeclarative1PathView(QDeclarativeItem *parent=0); + virtual ~QDeclarative1PathView(); QVariant model() const; void setModel(const QVariant &); - QDeclarativePath *path() const; - void setPath(QDeclarativePath *); + QDeclarative1Path *path() const; + void setPath(QDeclarative1Path *); int currentIndex() const; void setCurrentIndex(int idx); @@ -136,7 +136,7 @@ class Q_AUTOTEST_EXPORT QDeclarativePathView : public QDeclarativeItem int pathItemCount() const; void setPathItemCount(int); - static QDeclarativePathViewAttached *qmlAttachedProperties(QObject *); + static QDeclarative1PathViewAttached *qmlAttachedProperties(QObject *); public Q_SLOTS: void incrementCurrentIndex(); @@ -189,25 +189,25 @@ private Q_SLOTS: void pathUpdated(); private: - friend class QDeclarativePathViewAttached; - Q_DISABLE_COPY(QDeclarativePathView) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePathView) + friend class QDeclarative1PathViewAttached; + Q_DISABLE_COPY(QDeclarative1PathView) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PathView) }; -class QDeclarativeOpenMetaObject; -class QDeclarativePathViewAttached : public QObject +class QDeclarative1OpenMetaObject; +class QDeclarative1PathViewAttached : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativePathView *view READ view CONSTANT) + Q_PROPERTY(QDeclarative1PathView *view READ view CONSTANT) Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) Q_PROPERTY(bool onPath READ isOnPath NOTIFY pathChanged) public: - QDeclarativePathViewAttached(QObject *parent); - ~QDeclarativePathViewAttached(); + QDeclarative1PathViewAttached(QObject *parent); + ~QDeclarative1PathViewAttached(); - QDeclarativePathView *view() { return m_view; } + QDeclarative1PathView *view() { return m_view; } bool isCurrentItem() const { return m_isCurrent; } void setIsCurrentItem(bool c) { @@ -234,10 +234,10 @@ class QDeclarativePathViewAttached : public QObject void pathChanged(); private: - friend class QDeclarativePathViewPrivate; - friend class QDeclarativePathView; - QDeclarativePathView *m_view; - QDeclarativeOpenMetaObject *m_metaobject; + friend class QDeclarative1PathViewPrivate; + friend class QDeclarative1PathView; + QDeclarative1PathView *m_view; + QDeclarative1OpenMetaObject *m_metaobject; bool m_onPath : 1; bool m_isCurrent : 1; }; @@ -245,8 +245,8 @@ class QDeclarativePathViewAttached : public QObject QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativePathView) -QML_DECLARE_TYPEINFO(QDeclarativePathView, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarative1PathView) +QML_DECLARE_TYPEINFO(QDeclarative1PathView, QML_HAS_ATTACHED_PROPERTIES) QT_END_HEADER #endif // QDECLARATIVEPATHVIEW_H diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepathview_p_p.h similarity index 80% rename from src/declarative/graphicsitems/qdeclarativepathview_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativepathview_p_p.h index 3a7b712e8c..50965d6842 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepathview_p_p.h @@ -55,38 +55,38 @@ #include "private/qdeclarativepathview_p.h" -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativevisualitemmodel_p.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" +#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" -#include -#include -#include +#include +#include +#include #include QT_BEGIN_NAMESPACE -class QDeclarativeOpenMetaObjectType; -class QDeclarativePathViewAttached; -class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener +class QDeclarative1OpenMetaObjectType; +class QDeclarative1PathViewAttached; +class QDeclarative1PathViewPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener { - Q_DECLARE_PUBLIC(QDeclarativePathView) + Q_DECLARE_PUBLIC(QDeclarative1PathView) public: - QDeclarativePathViewPrivate() + QDeclarative1PathViewPrivate() : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0) , lastElapsed(0), offset(0.0), offsetAdj(0.0), mappedRange(1.0) , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true) , autoHighlight(true), highlightUp(false), layoutScheduled(false) , moving(false), flicking(false) , dragMargin(0), deceleration(100) - , moveOffset(this, &QDeclarativePathViewPrivate::setAdjustedOffset) + , moveOffset(this, &QDeclarative1PathViewPrivate::setAdjustedOffset) , firstIndex(-1), pathItems(-1), requestedIndex(-1) , moveReason(Other), moveDirection(Shortest), attType(0), highlightComponent(0), highlightItem(0) - , moveHighlight(this, &QDeclarativePathViewPrivate::setHighlightPosition) + , moveHighlight(this, &QDeclarative1PathViewPrivate::setHighlightPosition) , highlightPosition(0) , highlightRangeStart(0), highlightRangeEnd(0) - , highlightRangeMode(QDeclarativePathView::StrictlyEnforceRange) + , highlightRangeMode(QDeclarative1PathView::StrictlyEnforceRange) , highlightMoveDuration(300), modelCount(0) { } @@ -96,14 +96,14 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate, public QDecl void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { if ((newGeometry.size() != oldGeometry.size()) && (!highlightItem || item != highlightItem)) { - if (QDeclarativePathViewAttached *att = attached(item)) + if (QDeclarative1PathViewAttached *att = attached(item)) att->m_percent = -1; scheduleLayout(); } } void scheduleLayout() { - Q_Q(QDeclarativePathView); + Q_Q(QDeclarative1PathView); if (!layoutScheduled) { layoutScheduled = true; QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority); @@ -112,7 +112,7 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate, public QDecl QDeclarativeItem *getItem(int modelIndex); void releaseItem(QDeclarativeItem *item); - QDeclarativePathViewAttached *attached(QDeclarativeItem *item); + QDeclarative1PathViewAttached *attached(QDeclarativeItem *item); void clear(); void updateMappedRange(); qreal positionOfIndex(qreal index) const; @@ -138,7 +138,7 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate, public QDecl void snapToCurrent(); QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const; - QDeclarativePath *path; + QDeclarative1Path *path; int currentIndex; QDeclarativeGuard currentItem; qreal currentItemOffset; @@ -162,27 +162,27 @@ class QDeclarativePathViewPrivate : public QDeclarativeItemPrivate, public QDecl QPointF lastPos; qreal dragMargin; qreal deceleration; - QDeclarativeTimeLine tl; - QDeclarativeTimeLineValueProxy moveOffset; + QDeclarative1TimeLine tl; + QDeclarative1TimeLineValueProxy moveOffset; int firstIndex; int pathItems; int requestedIndex; QList items; QList itemCache; - QDeclarativeGuard model; + QDeclarativeGuard model; QVariant modelVariant; enum MovementReason { Other, SetIndex, Mouse }; MovementReason moveReason; enum MovementDirection { Shortest, Negative, Positive }; MovementDirection moveDirection; - QDeclarativeOpenMetaObjectType *attType; + QDeclarative1OpenMetaObjectType *attType; QDeclarativeComponent *highlightComponent; QDeclarativeItem *highlightItem; - QDeclarativeTimeLineValueProxy moveHighlight; + QDeclarative1TimeLineValueProxy moveHighlight; qreal highlightPosition; qreal highlightRangeStart; qreal highlightRangeEnd; - QDeclarativePathView::HighlightRangeMode highlightRangeMode; + QDeclarative1PathView::HighlightRangeMode highlightRangeMode; int highlightMoveDuration; int modelCount; }; diff --git a/src/declarative/graphicsitems/qdeclarativepincharea.cpp b/src/qtquick1/graphicsitems/qdeclarativepincharea.cpp similarity index 90% rename from src/declarative/graphicsitems/qdeclarativepincharea.cpp rename to src/qtquick1/graphicsitems/qdeclarativepincharea.cpp index 0e14ff1792..8efe6e5c8a 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativepincharea.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qdeclarativepincharea_p.h" -#include "qdeclarativepincharea_p_p.h" +#include "QtQuick1/private/qdeclarativepincharea_p.h" +#include "QtQuick1/private/qdeclarativepincharea_p_p.h" #include #include @@ -51,8 +51,10 @@ QT_BEGIN_NAMESPACE + + /*! - \qmlclass PinchEvent QDeclarativePinchEvent + \qmlclass PinchEvent QDeclarative1PinchEvent \ingroup qml-event-elements \brief The PinchEvent object provides information about a pinch event. @@ -146,7 +148,7 @@ QT_BEGIN_NAMESPACE all touch points have been released. */ -QDeclarativePinch::QDeclarativePinch() +QDeclarative1Pinch::QDeclarative1Pinch() : m_target(0), m_minScale(1.0), m_maxScale(1.0) , m_minRotation(0.0), m_maxRotation(0.0) , m_axis(NoDrag), m_xmin(-FLT_MAX), m_xmax(FLT_MAX) @@ -154,13 +156,13 @@ QDeclarativePinch::QDeclarativePinch() { } -QDeclarativePinchAreaPrivate::~QDeclarativePinchAreaPrivate() +QDeclarative1PinchAreaPrivate::~QDeclarative1PinchAreaPrivate() { delete pinch; } /*! - \qmlclass PinchArea QDeclarativePinchArea + \qmlclass PinchArea QDeclarative1PinchArea \brief The PinchArea item enables simple pinch gesture handling. \inherits Item @@ -239,14 +241,14 @@ QDeclarativePinchAreaPrivate::~QDeclarativePinchAreaPrivate() \endlist */ -QDeclarativePinchArea::QDeclarativePinchArea(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativePinchAreaPrivate), parent) +QDeclarative1PinchArea::QDeclarative1PinchArea(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1PinchAreaPrivate), parent) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); d->init(); } -QDeclarativePinchArea::~QDeclarativePinchArea() +QDeclarative1PinchArea::~QDeclarative1PinchArea() { } @@ -256,24 +258,24 @@ QDeclarativePinchArea::~QDeclarativePinchArea() This property defaults to true. */ -bool QDeclarativePinchArea::isEnabled() const +bool QDeclarative1PinchArea::isEnabled() const { - Q_D(const QDeclarativePinchArea); + Q_D(const QDeclarative1PinchArea); return d->absorb; } -void QDeclarativePinchArea::setEnabled(bool a) +void QDeclarative1PinchArea::setEnabled(bool a) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); if (a != d->absorb) { d->absorb = a; emit enabledChanged(); } } -bool QDeclarativePinchArea::event(QEvent *event) +bool QDeclarative1PinchArea::event(QEvent *event) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); if (!d->absorb || !isVisible()) return QDeclarativeItem::event(event); switch (event->type()) { @@ -300,16 +302,16 @@ bool QDeclarativePinchArea::event(QEvent *event) return QDeclarativeItem::event(event); } -void QDeclarativePinchArea::updatePinch() +void QDeclarative1PinchArea::updatePinch() { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); if (d->touchPoints.count() == 0) { if (d->inPinch) { d->stealMouse = false; setKeepMouseGrab(false); d->inPinch = false; QPointF pinchCenter = mapFromScene(d->sceneLastCenter); - QDeclarativePinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation); + QDeclarative1PinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation); pe.setStartCenter(d->pinchStartCenter); pe.setPreviousCenter(pinchCenter); pe.setPreviousAngle(d->pinchLastAngle); @@ -372,7 +374,7 @@ void QDeclarativePinchArea::updatePinch() d->pinchRotation = 0.0; d->lastPoint1 = p1; d->lastPoint2 = p2; - QDeclarativePinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0); + QDeclarative1PinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0); pe.setStartCenter(d->pinchStartCenter); pe.setPreviousCenter(d->pinchStartCenter); pe.setPreviousAngle(d->pinchLastAngle); @@ -409,7 +411,7 @@ void QDeclarativePinchArea::updatePinch() da += 360; d->pinchRotation += da; QPointF pinchCenter = mapFromScene(sceneCenter); - QDeclarativePinchEvent pe(pinchCenter, scale, angle, d->pinchRotation); + QDeclarative1PinchEvent pe(pinchCenter, scale, angle, d->pinchRotation); pe.setStartCenter(d->pinchStartCenter); pe.setPreviousCenter(mapFromScene(d->sceneLastCenter)); pe.setPreviousAngle(d->pinchLastAngle); @@ -430,7 +432,7 @@ void QDeclarativePinchArea::updatePinch() s = qMin(qMax(pinch()->minimumScale(),s), pinch()->maximumScale()); pinch()->target()->setScale(s); QPointF pos = sceneCenter - d->sceneStartCenter + d->pinchStartPos; - if (pinch()->axis() & QDeclarativePinch::XAxis) { + if (pinch()->axis() & QDeclarative1Pinch::XAxis) { qreal x = pos.x(); if (x < pinch()->xmin()) x = pinch()->xmin(); @@ -438,7 +440,7 @@ void QDeclarativePinchArea::updatePinch() x = pinch()->xmax(); pinch()->target()->setX(x); } - if (pinch()->axis() & QDeclarativePinch::YAxis) { + if (pinch()->axis() & QDeclarative1Pinch::YAxis) { qreal y = pos.y(); if (y < pinch()->ymin()) y = pinch()->ymin(); @@ -457,9 +459,9 @@ void QDeclarativePinchArea::updatePinch() } } -void QDeclarativePinchArea::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PinchArea::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); d->stealMouse = false; if (!d->absorb) QDeclarativeItem::mousePressEvent(event); @@ -469,18 +471,18 @@ void QDeclarativePinchArea::mousePressEvent(QGraphicsSceneMouseEvent *event) } } -void QDeclarativePinchArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PinchArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); if (!d->absorb) { QDeclarativeItem::mouseMoveEvent(event); return; } } -void QDeclarativePinchArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1PinchArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); d->stealMouse = false; if (!d->absorb) { QDeclarativeItem::mouseReleaseEvent(event); @@ -492,7 +494,7 @@ void QDeclarativePinchArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } -bool QDeclarativePinchArea::sceneEvent(QEvent *event) +bool QDeclarative1PinchArea::sceneEvent(QEvent *event) { bool rv = QDeclarativeItem::sceneEvent(event); if (event->type() == QEvent::UngrabMouse) { @@ -501,9 +503,9 @@ bool QDeclarativePinchArea::sceneEvent(QEvent *event) return rv; } -bool QDeclarativePinchArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) +bool QDeclarative1PinchArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); QGraphicsSceneMouseEvent mouseEvent(event->type()); QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); @@ -551,9 +553,9 @@ bool QDeclarativePinchArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) return false; } -bool QDeclarativePinchArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) +bool QDeclarative1PinchArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); if (!d->absorb || !isVisible()) return QDeclarativeItem::sceneEventFilter(i, e); switch (e->type()) { @@ -583,25 +585,27 @@ bool QDeclarativePinchArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) return QDeclarativeItem::sceneEventFilter(i, e); } -void QDeclarativePinchArea::geometryChanged(const QRectF &newGeometry, +void QDeclarative1PinchArea::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } -QVariant QDeclarativePinchArea::itemChange(GraphicsItemChange change, +QVariant QDeclarative1PinchArea::itemChange(GraphicsItemChange change, const QVariant &value) { return QDeclarativeItem::itemChange(change, value); } -QDeclarativePinch *QDeclarativePinchArea::pinch() +QDeclarative1Pinch *QDeclarative1PinchArea::pinch() { - Q_D(QDeclarativePinchArea); + Q_D(QDeclarative1PinchArea); if (!d->pinch) - d->pinch = new QDeclarativePinch; + d->pinch = new QDeclarative1Pinch; return d->pinch; } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p.h b/src/qtquick1/graphicsitems/qdeclarativepincharea_p.h similarity index 91% rename from src/declarative/graphicsitems/qdeclarativepincharea_p.h rename to src/qtquick1/graphicsitems/qdeclarativepincharea_p.h index 357c060520..4c1690f1fd 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepincharea_p.h @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_AUTOTEST_EXPORT QDeclarativePinch : public QObject +class Q_AUTOTEST_EXPORT QDeclarative1Pinch : public QObject { Q_OBJECT @@ -68,7 +68,7 @@ class Q_AUTOTEST_EXPORT QDeclarativePinch : public QObject Q_PROPERTY(bool active READ active NOTIFY activeChanged) public: - QDeclarativePinch(); + QDeclarative1Pinch(); QGraphicsObject *target() const { return m_target; } void setTarget(QGraphicsObject *target) { @@ -187,7 +187,7 @@ class Q_AUTOTEST_EXPORT QDeclarativePinch : public QObject bool m_active; }; -class Q_AUTOTEST_EXPORT QDeclarativePinchEvent : public QObject +class Q_AUTOTEST_EXPORT QDeclarative1PinchEvent : public QObject { Q_OBJECT @@ -207,7 +207,7 @@ class Q_AUTOTEST_EXPORT QDeclarativePinchEvent : public QObject Q_PROPERTY(bool accepted READ accepted WRITE setAccepted) public: - QDeclarativePinchEvent(QPointF c, qreal s, qreal a, qreal r) + QDeclarative1PinchEvent(QPointF c, qreal s, qreal a, qreal r) : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r) , m_pointCount(0), m_accepted(true) {} @@ -255,29 +255,29 @@ class Q_AUTOTEST_EXPORT QDeclarativePinchEvent : public QObject }; -class QDeclarativeMouseEvent; -class QDeclarativePinchAreaPrivate; -class Q_AUTOTEST_EXPORT QDeclarativePinchArea : public QDeclarativeItem +class QDeclarative1MouseEvent; +class QDeclarative1PinchAreaPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1PinchArea : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QDeclarativePinch *pinch READ pinch CONSTANT) + Q_PROPERTY(QDeclarative1Pinch *pinch READ pinch CONSTANT) public: - QDeclarativePinchArea(QDeclarativeItem *parent=0); - ~QDeclarativePinchArea(); + QDeclarative1PinchArea(QDeclarativeItem *parent=0); + ~QDeclarative1PinchArea(); bool isEnabled() const; void setEnabled(bool); - QDeclarativePinch *pinch(); + QDeclarative1Pinch *pinch(); Q_SIGNALS: void enabledChanged(); - void pinchStarted(QDeclarativePinchEvent *pinch); - void pinchUpdated(QDeclarativePinchEvent *pinch); - void pinchFinished(QDeclarativePinchEvent *pinch); + void pinchStarted(QDeclarative1PinchEvent *pinch); + void pinchUpdated(QDeclarative1PinchEvent *pinch); + void pinchFinished(QDeclarative1PinchEvent *pinch); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -298,15 +298,15 @@ class Q_AUTOTEST_EXPORT QDeclarativePinchArea : public QDeclarativeItem void handleRelease(); private: - Q_DISABLE_COPY(QDeclarativePinchArea) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativePinchArea) + Q_DISABLE_COPY(QDeclarative1PinchArea) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PinchArea) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativePinch) -QML_DECLARE_TYPE(QDeclarativePinchEvent) -QML_DECLARE_TYPE(QDeclarativePinchArea) +QML_DECLARE_TYPE(QDeclarative1Pinch) +QML_DECLARE_TYPE(QDeclarative1PinchEvent) +QML_DECLARE_TYPE(QDeclarative1PinchArea) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepincharea_p_p.h similarity index 92% rename from src/declarative/graphicsitems/qdeclarativepincharea_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativepincharea_p_p.h index a01859cdf9..963ca6e1bc 100644 --- a/src/declarative/graphicsitems/qdeclarativepincharea_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepincharea_p_p.h @@ -61,12 +61,12 @@ QT_BEGIN_NAMESPACE -class QDeclarativePinch; -class QDeclarativePinchAreaPrivate : public QDeclarativeItemPrivate +class QDeclarative1Pinch; +class QDeclarative1PinchAreaPrivate : public QDeclarativeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativePinchArea) + Q_DECLARE_PUBLIC(QDeclarative1PinchArea) public: - QDeclarativePinchAreaPrivate() + QDeclarative1PinchAreaPrivate() : absorb(true), stealMouse(false), inPinch(false) , pinchRejected(false), pinchActivated(false) , pinch(0), pinchStartDist(0), pinchStartScale(1.0) @@ -75,11 +75,11 @@ class QDeclarativePinchAreaPrivate : public QDeclarativeItemPrivate { } - ~QDeclarativePinchAreaPrivate(); + ~QDeclarative1PinchAreaPrivate(); void init() { - Q_Q(QDeclarativePinchArea); + Q_Q(QDeclarative1PinchArea); q->setAcceptedMouseButtons(Qt::LeftButton); q->setAcceptTouchEvents(true); q->setFiltersChildEvents(true); @@ -90,7 +90,7 @@ class QDeclarativePinchAreaPrivate : public QDeclarativeItemPrivate bool inPinch : 1; bool pinchRejected : 1; bool pinchActivated : 1; - QDeclarativePinch *pinch; + QDeclarative1Pinch *pinch; QPointF sceneStartPoint1; QPointF sceneStartPoint2; QPointF lastPoint1; diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/qtquick1/graphicsitems/qdeclarativepositioners.cpp similarity index 83% rename from src/declarative/graphicsitems/qdeclarativepositioners.cpp rename to src/qtquick1/graphicsitems/qdeclarativepositioners.cpp index 3d9e51032d..0defe40641 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativepositioners.cpp @@ -39,14 +39,14 @@ ** ****************************************************************************/ -#include "private/qdeclarativepositioners_p.h" -#include "private/qdeclarativepositioners_p_p.h" - -#include -#include -#include -#include -#include +#include "QtQuick1/private/qdeclarativepositioners_p.h" +#include "QtQuick1/private/qdeclarativepositioners_p_p.h" + +#include +#include +#include +#include +#include #include #include @@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE + + static const QDeclarativeItemPrivate::ChangeTypes watchedChanges = QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::SiblingOrder @@ -61,13 +63,13 @@ static const QDeclarativeItemPrivate::ChangeTypes watchedChanges | QDeclarativeItemPrivate::Opacity | QDeclarativeItemPrivate::Destroyed; -void QDeclarativeBasePositionerPrivate::watchChanges(QGraphicsObject *other) +void QDeclarative1BasePositionerPrivate::watchChanges(QGraphicsObject *other) { if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) { QDeclarativeItemPrivate *otherPrivate = static_cast(QGraphicsItemPrivate::get(other)); otherPrivate->addItemChangeListener(this, watchedChanges); } else { - Q_Q(QDeclarativeBasePositioner); + Q_Q(QDeclarative1BasePositioner); QObject::connect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged())); QObject::connect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged())); QObject::connect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged())); @@ -75,13 +77,13 @@ void QDeclarativeBasePositionerPrivate::watchChanges(QGraphicsObject *other) } } -void QDeclarativeBasePositionerPrivate::unwatchChanges(QGraphicsObject* other) +void QDeclarative1BasePositionerPrivate::unwatchChanges(QGraphicsObject* other) { if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) { QDeclarativeItemPrivate *otherPrivate = static_cast(QGraphicsItemPrivate::get(other)); otherPrivate->removeItemChangeListener(this, watchedChanges); } else { - Q_Q(QDeclarativeBasePositioner); + Q_Q(QDeclarative1BasePositioner); QObject::disconnect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged())); QObject::disconnect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged())); QObject::disconnect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged())); @@ -89,19 +91,19 @@ void QDeclarativeBasePositionerPrivate::unwatchChanges(QGraphicsObject* other) } } -void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged() +void QDeclarative1BasePositioner::graphicsWidgetGeometryChanged() { prePositioning(); } /*! \internal - \class QDeclarativeBasePositioner - \brief The QDeclarativeBasePositioner class provides a base for QDeclarativeGraphics layouts. + \class QDeclarative1BasePositioner + \brief The QDeclarative1BasePositioner class provides a base for QDeclarative1Graphics layouts. - To create a QDeclarativeGraphics Positioner, simply subclass QDeclarativeBasePositioner and implement + To create a QDeclarative1Graphics Positioner, simply subclass QDeclarative1BasePositioner and implement doLayout(), which is automatically called when the layout might need - updating. In doLayout() use the setX and setY functions from QDeclarativeBasePositioner, and the + updating. In doLayout() use the setX and setY functions from QDeclarative1BasePositioner, and the base class will apply the positions along with the appropriate transitions. The items to position are provided in order as the protected member positionedItems. @@ -110,37 +112,37 @@ void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged() Note that the subclass is responsible for adding the spacing in between items. */ -QDeclarativeBasePositioner::QDeclarativeBasePositioner(PositionerType at, QDeclarativeItem *parent) - : QDeclarativeImplicitSizeItem(*(new QDeclarativeBasePositionerPrivate), parent) +QDeclarative1BasePositioner::QDeclarative1BasePositioner(PositionerType at, QDeclarativeItem *parent) + : QDeclarative1ImplicitSizeItem(*(new QDeclarative1BasePositionerPrivate), parent) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); d->init(at); } -QDeclarativeBasePositioner::QDeclarativeBasePositioner(QDeclarativeBasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent) - : QDeclarativeImplicitSizeItem(dd, parent) +QDeclarative1BasePositioner::QDeclarative1BasePositioner(QDeclarative1BasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent) + : QDeclarative1ImplicitSizeItem(dd, parent) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); d->init(at); } -QDeclarativeBasePositioner::~QDeclarativeBasePositioner() +QDeclarative1BasePositioner::~QDeclarative1BasePositioner() { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); for (int i = 0; i < positionedItems.count(); ++i) d->unwatchChanges(positionedItems.at(i).item); positionedItems.clear(); } -int QDeclarativeBasePositioner::spacing() const +int QDeclarative1BasePositioner::spacing() const { - Q_D(const QDeclarativeBasePositioner); + Q_D(const QDeclarative1BasePositioner); return d->spacing; } -void QDeclarativeBasePositioner::setSpacing(int s) +void QDeclarative1BasePositioner::setSpacing(int s) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); if (s==d->spacing) return; d->spacing = s; @@ -148,30 +150,30 @@ void QDeclarativeBasePositioner::setSpacing(int s) emit spacingChanged(); } -QDeclarativeTransition *QDeclarativeBasePositioner::move() const +QDeclarative1Transition *QDeclarative1BasePositioner::move() const { - Q_D(const QDeclarativeBasePositioner); + Q_D(const QDeclarative1BasePositioner); return d->moveTransition; } -void QDeclarativeBasePositioner::setMove(QDeclarativeTransition *mt) +void QDeclarative1BasePositioner::setMove(QDeclarative1Transition *mt) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); if (mt == d->moveTransition) return; d->moveTransition = mt; emit moveChanged(); } -QDeclarativeTransition *QDeclarativeBasePositioner::add() const +QDeclarative1Transition *QDeclarative1BasePositioner::add() const { - Q_D(const QDeclarativeBasePositioner); + Q_D(const QDeclarative1BasePositioner); return d->addTransition; } -void QDeclarativeBasePositioner::setAdd(QDeclarativeTransition *add) +void QDeclarative1BasePositioner::setAdd(QDeclarative1Transition *add) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); if (add == d->addTransition) return; @@ -179,19 +181,19 @@ void QDeclarativeBasePositioner::setAdd(QDeclarativeTransition *add) emit addChanged(); } -void QDeclarativeBasePositioner::componentComplete() +void QDeclarative1BasePositioner::componentComplete() { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); QDeclarativeItem::componentComplete(); positionedItems.reserve(d->QGraphicsItemPrivate::children.count()); prePositioning(); reportConflictingAnchors(); } -QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change, +QVariant QDeclarative1BasePositioner::itemChange(GraphicsItemChange change, const QVariant &value) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); if (change == ItemChildAddedChange){ QGraphicsItem* item = value.value(); QGraphicsObject* child = 0; @@ -205,7 +207,7 @@ QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change, if(item) child = item->toGraphicsObject(); if (child) { - QDeclarativeBasePositioner::PositionedItem posItem(child); + QDeclarative1BasePositioner::PositionedItem posItem(child); int idx = positionedItems.find(posItem); if (idx >= 0) { d->unwatchChanges(child); @@ -217,9 +219,9 @@ QVariant QDeclarativeBasePositioner::itemChange(GraphicsItemChange change, return QDeclarativeItem::itemChange(change, value); } -void QDeclarativeBasePositioner::prePositioning() +void QDeclarative1BasePositioner::prePositioning() { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); if (!isComponentComplete()) return; @@ -274,45 +276,45 @@ void QDeclarativeBasePositioner::prePositioning() setImplicitWidth(contentSize.width()); } -void QDeclarativeBasePositioner::positionX(int x, const PositionedItem &target) +void QDeclarative1BasePositioner::positionX(int x, const PositionedItem &target) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); if(d->type == Horizontal || d->type == Both){ if (target.isNew) { if (!d->addTransition) target.item->setX(x); else - d->addActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x)); + d->addActions << QDeclarative1Action(target.item, QLatin1String("x"), QVariant(x)); } else if (x != target.item->x()) { if (!d->moveTransition) target.item->setX(x); else - d->moveActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x)); + d->moveActions << QDeclarative1Action(target.item, QLatin1String("x"), QVariant(x)); } } } -void QDeclarativeBasePositioner::positionY(int y, const PositionedItem &target) +void QDeclarative1BasePositioner::positionY(int y, const PositionedItem &target) { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); if(d->type == Vertical || d->type == Both){ if (target.isNew) { if (!d->addTransition) target.item->setY(y); else - d->addActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y)); + d->addActions << QDeclarative1Action(target.item, QLatin1String("y"), QVariant(y)); } else if (y != target.item->y()) { if (!d->moveTransition) target.item->setY(y); else - d->moveActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y)); + d->moveActions << QDeclarative1Action(target.item, QLatin1String("y"), QVariant(y)); } } } -void QDeclarativeBasePositioner::finishApplyTransitions() +void QDeclarative1BasePositioner::finishApplyTransitions() { - Q_D(QDeclarativeBasePositioner); + Q_D(QDeclarative1BasePositioner); // Note that if a transition is not set the transition manager will // apply the changes directly, in the case add/move aren't set d->addTransitionManager.transition(d->addActions, d->addTransition); @@ -322,7 +324,7 @@ void QDeclarativeBasePositioner::finishApplyTransitions() } /*! - \qmlclass Column QDeclarativeColumn + \qmlclass Column QDeclarative1Column \ingroup qml-positioning-elements \since 4.7 \brief The Column item arranges its children vertically. @@ -435,12 +437,12 @@ void QDeclarativeBasePositioner::finishApplyTransitions() \sa Grid::spacing */ -QDeclarativeColumn::QDeclarativeColumn(QDeclarativeItem *parent) -: QDeclarativeBasePositioner(Vertical, parent) +QDeclarative1Column::QDeclarative1Column(QDeclarativeItem *parent) +: QDeclarative1BasePositioner(Vertical, parent) { } -void QDeclarativeColumn::doPositioning(QSizeF *contentSize) +void QDeclarative1Column::doPositioning(QSizeF *contentSize) { int voffset = 0; @@ -461,18 +463,18 @@ void QDeclarativeColumn::doPositioning(QSizeF *contentSize) contentSize->setHeight(voffset - spacing()); } -void QDeclarativeColumn::reportConflictingAnchors() +void QDeclarative1Column::reportConflictingAnchors() { - QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); + QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; + QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; if (anchors) { - QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); - if (usedAnchors & QDeclarativeAnchors::TopAnchor || - usedAnchors & QDeclarativeAnchors::BottomAnchor || - usedAnchors & QDeclarativeAnchors::VCenterAnchor || + QDeclarative1Anchors::Anchors usedAnchors = anchors->usedAnchors(); + if (usedAnchors & QDeclarative1Anchors::TopAnchor || + usedAnchors & QDeclarative1Anchors::BottomAnchor || + usedAnchors & QDeclarative1Anchors::VCenterAnchor || anchors->fill() || anchors->centerIn()) { d->anchorConflict = true; break; @@ -486,7 +488,7 @@ void QDeclarativeColumn::reportConflictingAnchors() } /*! - \qmlclass Row QDeclarativeRow + \qmlclass Row QDeclarative1Row \ingroup qml-positioning-elements \since 4.7 \brief The Row item arranges its children horizontally. @@ -577,8 +579,8 @@ void QDeclarativeColumn::reportConflictingAnchors() \sa Grid::spacing */ -QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent) -: QDeclarativeBasePositioner(Horizontal, parent) +QDeclarative1Row::QDeclarative1Row(QDeclarativeItem *parent) +: QDeclarative1BasePositioner(Horizontal, parent) { } @@ -599,14 +601,14 @@ QDeclarativeRow::QDeclarativeRow(QDeclarativeItem *parent) \sa Grid::layoutDirection, Flow::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example} */ -Qt::LayoutDirection QDeclarativeRow::layoutDirection() const +Qt::LayoutDirection QDeclarative1Row::layoutDirection() const { - return QDeclarativeBasePositionerPrivate::getLayoutDirection(this); + return QDeclarative1BasePositionerPrivate::getLayoutDirection(this); } -void QDeclarativeRow::setLayoutDirection(Qt::LayoutDirection layoutDirection) +void QDeclarative1Row::setLayoutDirection(Qt::LayoutDirection layoutDirection) { - QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); + QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; // For RTL layout the positioning changes when the width changes. @@ -631,14 +633,14 @@ void QDeclarativeRow::setLayoutDirection(Qt::LayoutDirection layoutDirection) \sa Row::layoutDirection, {LayoutMirroring}{LayoutMirroring} */ -Qt::LayoutDirection QDeclarativeRow::effectiveLayoutDirection() const +Qt::LayoutDirection QDeclarative1Row::effectiveLayoutDirection() const { - return QDeclarativeBasePositionerPrivate::getEffectiveLayoutDirection(this); + return QDeclarative1BasePositionerPrivate::getEffectiveLayoutDirection(this); } -void QDeclarativeRow::doPositioning(QSizeF *contentSize) +void QDeclarative1Row::doPositioning(QSizeF *contentSize) { - QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); + QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); int hoffset = 0; QList hoffsets; @@ -683,18 +685,18 @@ void QDeclarativeRow::doPositioning(QSizeF *contentSize) } } -void QDeclarativeRow::reportConflictingAnchors() +void QDeclarative1Row::reportConflictingAnchors() { - QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); + QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; + QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; if (anchors) { - QDeclarativeAnchors::Anchors usedAnchors = anchors->usedAnchors(); - if (usedAnchors & QDeclarativeAnchors::LeftAnchor || - usedAnchors & QDeclarativeAnchors::RightAnchor || - usedAnchors & QDeclarativeAnchors::HCenterAnchor || + QDeclarative1Anchors::Anchors usedAnchors = anchors->usedAnchors(); + if (usedAnchors & QDeclarative1Anchors::LeftAnchor || + usedAnchors & QDeclarative1Anchors::RightAnchor || + usedAnchors & QDeclarative1Anchors::HCenterAnchor || anchors->fill() || anchors->centerIn()) { d->anchorConflict = true; break; @@ -707,7 +709,7 @@ void QDeclarativeRow::reportConflictingAnchors() } /*! - \qmlclass Grid QDeclarativeGrid + \qmlclass Grid QDeclarative1Grid \ingroup qml-positioning-elements \since 4.7 \brief The Grid item positions its children in a grid. @@ -815,8 +817,8 @@ void QDeclarativeRow::reportConflictingAnchors() \sa rows, columns */ -QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) : - QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight) +QDeclarative1Grid::QDeclarative1Grid(QDeclarativeItem *parent) : + QDeclarative1BasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight) { } @@ -838,7 +840,7 @@ QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) : number of rows, some rows will be of zero width. */ -void QDeclarativeGrid::setColumns(const int columns) +void QDeclarative1Grid::setColumns(const int columns) { if (columns == m_columns) return; @@ -847,7 +849,7 @@ void QDeclarativeGrid::setColumns(const int columns) emit columnsChanged(); } -void QDeclarativeGrid::setRows(const int rows) +void QDeclarative1Grid::setRows(const int rows) { if (rows == m_rows) return; @@ -869,12 +871,12 @@ void QDeclarativeGrid::setRows(const int rows) other from top to bottom, then wrapped to the next column. \endlist */ -QDeclarativeGrid::Flow QDeclarativeGrid::flow() const +QDeclarative1Grid::Flow QDeclarative1Grid::flow() const { return m_flow; } -void QDeclarativeGrid::setFlow(Flow flow) +void QDeclarative1Grid::setFlow(Flow flow) { if (m_flow != flow) { m_flow = flow; @@ -902,14 +904,14 @@ void QDeclarativeGrid::setFlow(Flow flow) \sa Flow::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example} */ -Qt::LayoutDirection QDeclarativeGrid::layoutDirection() const +Qt::LayoutDirection QDeclarative1Grid::layoutDirection() const { - return QDeclarativeBasePositionerPrivate::getLayoutDirection(this); + return QDeclarative1BasePositionerPrivate::getLayoutDirection(this); } -void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection) +void QDeclarative1Grid::setLayoutDirection(Qt::LayoutDirection layoutDirection) { - QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); + QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; // For RTL layout the positioning changes when the width changes. @@ -934,14 +936,14 @@ void QDeclarativeGrid::setLayoutDirection(Qt::LayoutDirection layoutDirection) \sa Grid::layoutDirection, {LayoutMirroring}{LayoutMirroring} */ -Qt::LayoutDirection QDeclarativeGrid::effectiveLayoutDirection() const +Qt::LayoutDirection QDeclarative1Grid::effectiveLayoutDirection() const { - return QDeclarativeBasePositionerPrivate::getEffectiveLayoutDirection(this); + return QDeclarative1BasePositionerPrivate::getEffectiveLayoutDirection(this); } -void QDeclarativeGrid::doPositioning(QSizeF *contentSize) +void QDeclarative1Grid::doPositioning(QSizeF *contentSize) { - QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); + QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); int c = m_columns; int r = m_rows; //Is allocating the extra QPODVector too much overhead? @@ -1081,13 +1083,13 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) } } -void QDeclarativeGrid::reportConflictingAnchors() +void QDeclarative1Grid::reportConflictingAnchors() { - QDeclarativeBasePositionerPrivate *d = static_cast(QDeclarativeBasePositionerPrivate::get(this)); + QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; + QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { d->anchorConflict = true; break; @@ -1099,7 +1101,7 @@ void QDeclarativeGrid::reportConflictingAnchors() } /*! - \qmlclass Flow QDeclarativeFlow + \qmlclass Flow QDeclarative1Flow \ingroup qml-positioning-elements \since 4.7 \brief The Flow item arranges its children side by side, wrapping as necessary. @@ -1197,22 +1199,22 @@ void QDeclarativeGrid::reportConflictingAnchors() \sa Grid::spacing */ -class QDeclarativeFlowPrivate : public QDeclarativeBasePositionerPrivate +class QDeclarative1FlowPrivate : public QDeclarative1BasePositionerPrivate { - Q_DECLARE_PUBLIC(QDeclarativeFlow) + Q_DECLARE_PUBLIC(QDeclarative1Flow) public: - QDeclarativeFlowPrivate() - : QDeclarativeBasePositionerPrivate(), flow(QDeclarativeFlow::LeftToRight) + QDeclarative1FlowPrivate() + : QDeclarative1BasePositionerPrivate(), flow(QDeclarative1Flow::LeftToRight) {} - QDeclarativeFlow::Flow flow; + QDeclarative1Flow::Flow flow; }; -QDeclarativeFlow::QDeclarativeFlow(QDeclarativeItem *parent) -: QDeclarativeBasePositioner(*(new QDeclarativeFlowPrivate), Both, parent) +QDeclarative1Flow::QDeclarative1Flow(QDeclarativeItem *parent) +: QDeclarative1BasePositioner(*(new QDeclarative1FlowPrivate), Both, parent) { - Q_D(QDeclarativeFlow); + Q_D(QDeclarative1Flow); // Flow layout requires relayout if its own size changes too. d->addItemChangeListener(d, QDeclarativeItemPrivate::Geometry); } @@ -1232,15 +1234,15 @@ QDeclarativeFlow::QDeclarativeFlow(QDeclarativeItem *parent) then wrapped to the next column. \endlist */ -QDeclarativeFlow::Flow QDeclarativeFlow::flow() const +QDeclarative1Flow::Flow QDeclarative1Flow::flow() const { - Q_D(const QDeclarativeFlow); + Q_D(const QDeclarative1Flow); return d->flow; } -void QDeclarativeFlow::setFlow(Flow flow) +void QDeclarative1Flow::setFlow(Flow flow) { - Q_D(QDeclarativeFlow); + Q_D(QDeclarative1Flow); if (d->flow != flow) { d->flow = flow; prePositioning(); @@ -1268,15 +1270,15 @@ void QDeclarativeFlow::setFlow(Flow flow) \sa Grid::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example} */ -Qt::LayoutDirection QDeclarativeFlow::layoutDirection() const +Qt::LayoutDirection QDeclarative1Flow::layoutDirection() const { - Q_D(const QDeclarativeFlow); + Q_D(const QDeclarative1Flow); return d->layoutDirection; } -void QDeclarativeFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection) +void QDeclarative1Flow::setLayoutDirection(Qt::LayoutDirection layoutDirection) { - Q_D(QDeclarativeFlow); + Q_D(QDeclarative1Flow); if (d->layoutDirection != layoutDirection) { d->layoutDirection = layoutDirection; prePositioning(); @@ -1296,14 +1298,14 @@ void QDeclarativeFlow::setLayoutDirection(Qt::LayoutDirection layoutDirection) \sa Flow::layoutDirection, {LayoutMirroring}{LayoutMirroring} */ -Qt::LayoutDirection QDeclarativeFlow::effectiveLayoutDirection() const +Qt::LayoutDirection QDeclarative1Flow::effectiveLayoutDirection() const { - return QDeclarativeBasePositionerPrivate::getEffectiveLayoutDirection(this); + return QDeclarative1BasePositionerPrivate::getEffectiveLayoutDirection(this); } -void QDeclarativeFlow::doPositioning(QSizeF *contentSize) +void QDeclarative1Flow::doPositioning(QSizeF *contentSize) { - Q_D(QDeclarativeFlow); + Q_D(QDeclarative1Flow); int hoffset = 0; int voffset = 0; @@ -1372,13 +1374,13 @@ void QDeclarativeFlow::doPositioning(QSizeF *contentSize) } } -void QDeclarativeFlow::reportConflictingAnchors() +void QDeclarative1Flow::reportConflictingAnchors() { - Q_D(QDeclarativeFlow); + Q_D(QDeclarative1Flow); for (int ii = 0; ii < positionedItems.count(); ++ii) { const PositionedItem &child = positionedItems.at(ii); if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarativeAnchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; + QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { d->anchorConflict = true; break; @@ -1389,4 +1391,6 @@ void QDeclarativeFlow::reportConflictingAnchors() qmlInfo(this) << "Cannot specify anchors for items inside Flow"; } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/qtquick1/graphicsitems/qdeclarativepositioners_p.h similarity index 78% rename from src/declarative/graphicsitems/qdeclarativepositioners_p.h rename to src/qtquick1/graphicsitems/qdeclarativepositioners_p.h index 3d62a8838f..c5f25228bd 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepositioners_p.h @@ -44,7 +44,7 @@ #include "qdeclarativeimplicitsizeitem_p.h" -#include +#include #include #include @@ -55,31 +55,31 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeBasePositionerPrivate; +class QDeclarative1BasePositionerPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBasePositioner : public QDeclarativeImplicitSizeItem +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1BasePositioner : public QDeclarative1ImplicitSizeItem { Q_OBJECT Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) - Q_PROPERTY(QDeclarativeTransition *move READ move WRITE setMove NOTIFY moveChanged) - Q_PROPERTY(QDeclarativeTransition *add READ add WRITE setAdd NOTIFY addChanged) + Q_PROPERTY(QDeclarative1Transition *move READ move WRITE setMove NOTIFY moveChanged) + Q_PROPERTY(QDeclarative1Transition *add READ add WRITE setAdd NOTIFY addChanged) public: enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 }; - QDeclarativeBasePositioner(PositionerType, QDeclarativeItem *parent); - ~QDeclarativeBasePositioner(); + QDeclarative1BasePositioner(PositionerType, QDeclarativeItem *parent); + ~QDeclarative1BasePositioner(); int spacing() const; void setSpacing(int); - QDeclarativeTransition *move() const; - void setMove(QDeclarativeTransition *); + QDeclarative1Transition *move() const; + void setMove(QDeclarative1Transition *); - QDeclarativeTransition *add() const; - void setAdd(QDeclarativeTransition *); + QDeclarative1Transition *add() const; + void setAdd(QDeclarative1Transition *); protected: - QDeclarativeBasePositioner(QDeclarativeBasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent); + QDeclarative1BasePositioner(QDeclarative1BasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent); virtual void componentComplete(); virtual QVariant itemChange(GraphicsItemChange, const QVariant &); void finishApplyTransitions(); @@ -110,29 +110,29 @@ protected Q_SLOTS: void positionY(int,const PositionedItem &target); private: - Q_DISABLE_COPY(QDeclarativeBasePositioner) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeBasePositioner) + Q_DISABLE_COPY(QDeclarative1BasePositioner) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1BasePositioner) }; -class Q_AUTOTEST_EXPORT QDeclarativeColumn : public QDeclarativeBasePositioner +class Q_AUTOTEST_EXPORT QDeclarative1Column : public QDeclarative1BasePositioner { Q_OBJECT public: - QDeclarativeColumn(QDeclarativeItem *parent=0); + QDeclarative1Column(QDeclarativeItem *parent=0); protected: virtual void doPositioning(QSizeF *contentSize); virtual void reportConflictingAnchors(); private: - Q_DISABLE_COPY(QDeclarativeColumn) + Q_DISABLE_COPY(QDeclarative1Column) }; -class Q_AUTOTEST_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner +class Q_AUTOTEST_EXPORT QDeclarative1Row: public QDeclarative1BasePositioner { Q_OBJECT Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) public: - QDeclarativeRow(QDeclarativeItem *parent=0); + QDeclarative1Row(QDeclarativeItem *parent=0); Qt::LayoutDirection layoutDirection() const; void setLayoutDirection (Qt::LayoutDirection); @@ -146,10 +146,10 @@ class Q_AUTOTEST_EXPORT QDeclarativeRow: public QDeclarativeBasePositioner virtual void doPositioning(QSizeF *contentSize); virtual void reportConflictingAnchors(); private: - Q_DISABLE_COPY(QDeclarativeRow) + Q_DISABLE_COPY(QDeclarative1Row) }; -class Q_AUTOTEST_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner +class Q_AUTOTEST_EXPORT QDeclarative1Grid : public QDeclarative1BasePositioner { Q_OBJECT Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged) @@ -158,7 +158,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) public: - QDeclarativeGrid(QDeclarativeItem *parent=0); + QDeclarative1Grid(QDeclarativeItem *parent=0); int rows() const {return m_rows;} void setRows(const int rows); @@ -190,18 +190,18 @@ class Q_AUTOTEST_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner int m_rows; int m_columns; Flow m_flow; - Q_DISABLE_COPY(QDeclarativeGrid) + Q_DISABLE_COPY(QDeclarative1Grid) }; -class QDeclarativeFlowPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeFlow: public QDeclarativeBasePositioner +class QDeclarative1FlowPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Flow: public QDeclarative1BasePositioner { Q_OBJECT Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) public: - QDeclarativeFlow(QDeclarativeItem *parent=0); + QDeclarative1Flow(QDeclarativeItem *parent=0); Q_ENUMS(Flow) enum Flow { LeftToRight, TopToBottom }; @@ -220,19 +220,19 @@ class Q_AUTOTEST_EXPORT QDeclarativeFlow: public QDeclarativeBasePositioner virtual void doPositioning(QSizeF *contentSize); virtual void reportConflictingAnchors(); protected: - QDeclarativeFlow(QDeclarativeFlowPrivate &dd, QDeclarativeItem *parent); + QDeclarative1Flow(QDeclarative1FlowPrivate &dd, QDeclarativeItem *parent); private: - Q_DISABLE_COPY(QDeclarativeFlow) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlow) + Q_DISABLE_COPY(QDeclarative1Flow) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flow) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeColumn) -QML_DECLARE_TYPE(QDeclarativeRow) -QML_DECLARE_TYPE(QDeclarativeGrid) -QML_DECLARE_TYPE(QDeclarativeFlow) +QML_DECLARE_TYPE(QDeclarative1Column) +QML_DECLARE_TYPE(QDeclarative1Row) +QML_DECLARE_TYPE(QDeclarative1Grid) +QML_DECLARE_TYPE(QDeclarative1Flow) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepositioners_p_p.h similarity index 75% rename from src/declarative/graphicsitems/qdeclarativepositioners_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativepositioners_p_p.h index 752cc02e0e..eb2c9fdc88 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativepositioners_p_p.h @@ -57,9 +57,9 @@ #include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include -#include -#include +#include +#include +#include #include #include @@ -67,32 +67,33 @@ #include QT_BEGIN_NAMESPACE -class QDeclarativeBasePositionerPrivate : public QDeclarativeImplicitSizeItemPrivate, public QDeclarativeItemChangeListener + +class QDeclarative1BasePositionerPrivate : public QDeclarative1ImplicitSizeItemPrivate, public QDeclarativeItemChangeListener { - Q_DECLARE_PUBLIC(QDeclarativeBasePositioner) + Q_DECLARE_PUBLIC(QDeclarative1BasePositioner) public: - QDeclarativeBasePositionerPrivate() - : spacing(0), type(QDeclarativeBasePositioner::None) + QDeclarative1BasePositionerPrivate() + : spacing(0), type(QDeclarative1BasePositioner::None) , moveTransition(0), addTransition(0), queuedPositioning(false) , doingPositioning(false), anchorConflict(false), layoutDirection(Qt::LeftToRight) { } - void init(QDeclarativeBasePositioner::PositionerType at) + void init(QDeclarative1BasePositioner::PositionerType at) { type = at; } int spacing; - QDeclarativeBasePositioner::PositionerType type; - QDeclarativeTransition *moveTransition; - QDeclarativeTransition *addTransition; - QDeclarativeStateOperation::ActionList addActions; - QDeclarativeStateOperation::ActionList moveActions; - QDeclarativeTransitionManager addTransitionManager; - QDeclarativeTransitionManager moveTransitionManager; + QDeclarative1BasePositioner::PositionerType type; + QDeclarative1Transition *moveTransition; + QDeclarative1Transition *addTransition; + QDeclarative1StateOperation::ActionList addActions; + QDeclarative1StateOperation::ActionList moveActions; + QDeclarative1TransitionManager addTransitionManager; + QDeclarative1TransitionManager moveTransitionManager; void watchChanges(QGraphicsObject *other); void unwatchChanges(QGraphicsObject* other); @@ -105,7 +106,7 @@ class QDeclarativeBasePositionerPrivate : public QDeclarativeImplicitSizeItemPri void schedulePositioning() { - Q_Q(QDeclarativeBasePositioner); + Q_Q(QDeclarative1BasePositioner); if(!queuedPositioning){ QTimer::singleShot(0,q,SLOT(prePositioning())); queuedPositioning = true; @@ -113,12 +114,12 @@ class QDeclarativeBasePositionerPrivate : public QDeclarativeImplicitSizeItemPri } void mirrorChange() { - Q_Q(QDeclarativeBasePositioner); - if (type != QDeclarativeBasePositioner::Vertical) + Q_Q(QDeclarative1BasePositioner); + if (type != QDeclarative1BasePositioner::Vertical) q->prePositioning(); } bool isLeftToRight() const { - if (type == QDeclarativeBasePositioner::Vertical) + if (type == QDeclarative1BasePositioner::Vertical) return true; else return effectiveLayoutMirror ? layoutDirection == Qt::RightToLeft : layoutDirection == Qt::LeftToRight; @@ -134,7 +135,7 @@ class QDeclarativeBasePositionerPrivate : public QDeclarativeImplicitSizeItemPri void itemGeometryChanged(QDeclarativeItem *, const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_Q(QDeclarativeBasePositioner); + Q_Q(QDeclarative1BasePositioner); if (newGeometry.size() != oldGeometry.size()) q->prePositioning(); } @@ -145,22 +146,22 @@ class QDeclarativeBasePositionerPrivate : public QDeclarativeImplicitSizeItemPri } virtual void itemOpacityChanged(QDeclarativeItem *) { - Q_Q(QDeclarativeBasePositioner); + Q_Q(QDeclarative1BasePositioner); q->prePositioning(); } void itemDestroyed(QDeclarativeItem *item) { - Q_Q(QDeclarativeBasePositioner); - q->positionedItems.removeOne(QDeclarativeBasePositioner::PositionedItem(item)); + Q_Q(QDeclarative1BasePositioner); + q->positionedItems.removeOne(QDeclarative1BasePositioner::PositionedItem(item)); } - static Qt::LayoutDirection getLayoutDirection(const QDeclarativeBasePositioner *positioner) + static Qt::LayoutDirection getLayoutDirection(const QDeclarative1BasePositioner *positioner) { return positioner->d_func()->layoutDirection; } - static Qt::LayoutDirection getEffectiveLayoutDirection(const QDeclarativeBasePositioner *positioner) + static Qt::LayoutDirection getEffectiveLayoutDirection(const QDeclarative1BasePositioner *positioner) { if (positioner->d_func()->effectiveLayoutMirror) return positioner->d_func()->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp similarity index 88% rename from src/declarative/graphicsitems/qdeclarativerectangle.cpp rename to src/qtquick1/graphicsitems/qdeclarativerectangle.cpp index 18f11f3e38..d0bb5d143d 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "private/qdeclarativerectangle_p.h" -#include "private/qdeclarativerectangle_p_p.h" +#include "QtQuick1/private/qdeclarativerectangle_p.h" +#include "QtQuick1/private/qdeclarativerectangle_p_p.h" #include #include @@ -48,10 +48,12 @@ QT_BEGIN_NAMESPACE + + /*! \internal - \class QDeclarativePen - \brief The QDeclarativePen class provides a pen used for drawing rectangle borders on a QDeclarativeView. + \class QDeclarative1Pen + \brief The QDeclarative1Pen class provides a pen used for drawing rectangle borders on a QDeclarative1View. By default, the pen is invalid and nothing is drawn. You must either set a color (then the default width is 1) or a width (then the default color is black). @@ -67,14 +69,14 @@ QT_BEGIN_NAMESPACE \endqml */ -void QDeclarativePen::setColor(const QColor &c) +void QDeclarative1Pen::setColor(const QColor &c) { _color = c; _valid = (_color.alpha() && _width >= 1) ? true : false; emit penChanged(); } -void QDeclarativePen::setWidth(int w) +void QDeclarative1Pen::setWidth(int w) { if (_width == w && _valid) return; @@ -86,7 +88,7 @@ void QDeclarativePen::setWidth(int w) /*! - \qmlclass GradientStop QDeclarativeGradientStop + \qmlclass GradientStop QDeclarative1GradientStop \ingroup qml-basic-visual-elements \since 4.7 \brief The GradientStop item defines the color at a position in a Gradient. @@ -106,14 +108,14 @@ void QDeclarativePen::setWidth(int w) \sa Gradient */ -void QDeclarativeGradientStop::updateGradient() +void QDeclarative1GradientStop::updateGradient() { - if (QDeclarativeGradient *grad = qobject_cast(parent())) + if (QDeclarative1Gradient *grad = qobject_cast(parent())) grad->doUpdate(); } /*! - \qmlclass Gradient QDeclarativeGradient + \qmlclass Gradient QDeclarative1Gradient \ingroup qml-basic-visual-elements \since 4.7 \brief The Gradient item defines a gradient fill. @@ -172,12 +174,12 @@ void QDeclarativeGradientStop::updateGradient() To set the gradient stops, define them as children of the Gradient element. */ -const QGradient *QDeclarativeGradient::gradient() const +const QGradient *QDeclarative1Gradient::gradient() const { if (!m_gradient && !m_stops.isEmpty()) { m_gradient = new QLinearGradient(0,0,0,1.0); for (int i = 0; i < m_stops.count(); ++i) { - const QDeclarativeGradientStop *stop = m_stops.at(i); + const QDeclarative1GradientStop *stop = m_stops.at(i); m_gradient->setCoordinateMode(QGradient::ObjectBoundingMode); m_gradient->setColorAt(stop->position(), stop->color()); } @@ -186,7 +188,7 @@ const QGradient *QDeclarativeGradient::gradient() const return m_gradient; } -void QDeclarativeGradient::doUpdate() +void QDeclarative1Gradient::doUpdate() { delete m_gradient; m_gradient = 0; @@ -195,7 +197,7 @@ void QDeclarativeGradient::doUpdate() /*! - \qmlclass Rectangle QDeclarativeRectangle + \qmlclass Rectangle QDeclarative1Rectangle \ingroup qml-basic-visual-elements \since 4.7 \brief The Rectangle item provides a filled rectangle with an optional border. @@ -239,16 +241,16 @@ void QDeclarativeGradient::doUpdate() \sa Image */ -int QDeclarativeRectanglePrivate::doUpdateSlotIdx = -1; +int QDeclarative1RectanglePrivate::doUpdateSlotIdx = -1; -QDeclarativeRectangle::QDeclarativeRectangle(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativeRectanglePrivate), parent) +QDeclarative1Rectangle::QDeclarative1Rectangle(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1RectanglePrivate), parent) { } -void QDeclarativeRectangle::doUpdate() +void QDeclarative1Rectangle::doUpdate() { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); d->rectImage = QPixmap(); const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; d->setPaintMargin((pw+1)/2); @@ -282,9 +284,9 @@ void QDeclarativeRectangle::doUpdate() Here, the innermost rectangle's border is clipped on the bottom and right edges by its parent. To avoid this, the border width can be set to two instead of one. */ -QDeclarativePen *QDeclarativeRectangle::border() +QDeclarative1Pen *QDeclarative1Rectangle::border() { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); return d->getPen(); } @@ -307,22 +309,22 @@ QDeclarativePen *QDeclarativeRectangle::border() \sa Gradient, color */ -QDeclarativeGradient *QDeclarativeRectangle::gradient() const +QDeclarative1Gradient *QDeclarative1Rectangle::gradient() const { - Q_D(const QDeclarativeRectangle); + Q_D(const QDeclarative1Rectangle); return d->gradient; } -void QDeclarativeRectangle::setGradient(QDeclarativeGradient *gradient) +void QDeclarative1Rectangle::setGradient(QDeclarative1Gradient *gradient) { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); if (d->gradient == gradient) return; static int updatedSignalIdx = -1; if (updatedSignalIdx < 0) - updatedSignalIdx = QDeclarativeGradient::staticMetaObject.indexOfSignal("updated()"); + updatedSignalIdx = QDeclarative1Gradient::staticMetaObject.indexOfSignal("updated()"); if (d->doUpdateSlotIdx < 0) - d->doUpdateSlotIdx = QDeclarativeRectangle::staticMetaObject.indexOfSlot("doUpdate()"); + d->doUpdateSlotIdx = QDeclarative1Rectangle::staticMetaObject.indexOfSlot("doUpdate()"); if (d->gradient) QMetaObject::disconnect(d->gradient, updatedSignalIdx, this, d->doUpdateSlotIdx); d->gradient = gradient; @@ -340,15 +342,15 @@ void QDeclarativeRectangle::setGradient(QDeclarativeGradient *gradient) painted as a normal rectangle. The same radius is used by all 4 corners; there is currently no way to specify different radii for different corners. */ -qreal QDeclarativeRectangle::radius() const +qreal QDeclarative1Rectangle::radius() const { - Q_D(const QDeclarativeRectangle); + Q_D(const QDeclarative1Rectangle); return d->radius; } -void QDeclarativeRectangle::setRadius(qreal radius) +void QDeclarative1Rectangle::setRadius(qreal radius) { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); if (d->radius == radius) return; @@ -378,15 +380,15 @@ void QDeclarativeRectangle::setRadius(qreal radius) \sa gradient */ -QColor QDeclarativeRectangle::color() const +QColor QDeclarative1Rectangle::color() const { - Q_D(const QDeclarativeRectangle); + Q_D(const QDeclarative1Rectangle); return d->color; } -void QDeclarativeRectangle::setColor(const QColor &c) +void QDeclarative1Rectangle::setColor(const QColor &c) { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); if (d->color == c) return; @@ -396,9 +398,9 @@ void QDeclarativeRectangle::setColor(const QColor &c) emit colorChanged(); } -void QDeclarativeRectangle::generateRoundedRect() +void QDeclarative1Rectangle::generateRoundedRect() { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); if (d->rectImage.isNull()) { const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; const int radius = qCeil(d->radius); //ensure odd numbered width/height so we get 1-pixel center @@ -432,9 +434,9 @@ void QDeclarativeRectangle::generateRoundedRect() } } -void QDeclarativeRectangle::generateBorderedRect() +void QDeclarative1Rectangle::generateBorderedRect() { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); if (d->rectImage.isNull()) { const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; @@ -470,9 +472,9 @@ void QDeclarativeRectangle::generateBorderedRect() } } -void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) +void QDeclarative1Rectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); if (width() <= 0 || height() <= 0) return; if (d->radius > 0 || (d->pen && d->pen->isValid()) @@ -489,9 +491,9 @@ void QDeclarativeRectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, } } -void QDeclarativeRectangle::drawRect(QPainter &p) +void QDeclarative1Rectangle::drawRect(QPainter &p) { - Q_D(QDeclarativeRectangle); + Q_D(QDeclarative1Rectangle); if ((d->gradient && d->gradient->gradient()) || d->radius > width()/2 || d->radius > height()/2 || width() < 3 || height() < 3) { @@ -578,10 +580,12 @@ void QDeclarativeRectangle::drawRect(QPainter &p) On this image, smooth is turned off on the top half and on on the bottom half. */ -QRectF QDeclarativeRectangle::boundingRect() const +QRectF QDeclarative1Rectangle::boundingRect() const { - Q_D(const QDeclarativeRectangle); + Q_D(const QDeclarative1Rectangle); return QRectF(-d->paintmargin, -d->paintmargin, d->width()+d->paintmargin*2, d->height()+d->paintmargin*2); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p.h b/src/qtquick1/graphicsitems/qdeclarativerectangle_p.h similarity index 72% rename from src/declarative/graphicsitems/qdeclarativerectangle_p.h rename to src/qtquick1/graphicsitems/qdeclarativerectangle_p.h index 8a5ab87853..862799faa2 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativerectangle_p.h @@ -46,21 +46,21 @@ #include -#include +#include QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePen : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Pen : public QObject { Q_OBJECT Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged) public: - QDeclarativePen(QObject *parent=0) + QDeclarative1Pen(QObject *parent=0) : QObject(parent), _width(1), _color("#000000"), _valid(false) {} @@ -81,7 +81,7 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePen : public QObject bool _valid; }; -class Q_AUTOTEST_EXPORT QDeclarativeGradientStop : public QObject +class Q_AUTOTEST_EXPORT QDeclarative1GradientStop : public QObject { Q_OBJECT @@ -89,7 +89,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeGradientStop : public QObject Q_PROPERTY(QColor color READ color WRITE setColor) public: - QDeclarativeGradientStop(QObject *parent=0) : QObject(parent) {} + QDeclarative1GradientStop(QObject *parent=0) : QObject(parent) {} qreal position() const { return m_position; } void setPosition(qreal position) { m_position = position; updateGradient(); } @@ -105,18 +105,18 @@ class Q_AUTOTEST_EXPORT QDeclarativeGradientStop : public QObject QColor m_color; }; -class Q_AUTOTEST_EXPORT QDeclarativeGradient : public QObject +class Q_AUTOTEST_EXPORT QDeclarative1Gradient : public QObject { Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty stops READ stops) + Q_PROPERTY(QDeclarativeListProperty stops READ stops) Q_CLASSINFO("DefaultProperty", "stops") public: - QDeclarativeGradient(QObject *parent=0) : QObject(parent), m_gradient(0) {} - ~QDeclarativeGradient() { delete m_gradient; } + QDeclarative1Gradient(QObject *parent=0) : QObject(parent), m_gradient(0) {} + ~QDeclarative1Gradient() { delete m_gradient; } - QDeclarativeListProperty stops() { return QDeclarativeListProperty(this, m_stops); } + QDeclarativeListProperty stops() { return QDeclarativeListProperty(this, m_stops); } const QGradient *gradient() const; @@ -127,30 +127,30 @@ class Q_AUTOTEST_EXPORT QDeclarativeGradient : public QObject void doUpdate(); private: - QList m_stops; + QList m_stops; mutable QGradient *m_gradient; - friend class QDeclarativeGradientStop; + friend class QDeclarative1GradientStop; }; -class QDeclarativeRectanglePrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeRectangle : public QDeclarativeItem +class QDeclarative1RectanglePrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Rectangle : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QDeclarativeGradient *gradient READ gradient WRITE setGradient) - Q_PROPERTY(QDeclarativePen * border READ border CONSTANT) + Q_PROPERTY(QDeclarative1Gradient *gradient READ gradient WRITE setGradient) + Q_PROPERTY(QDeclarative1Pen * border READ border CONSTANT) Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) public: - QDeclarativeRectangle(QDeclarativeItem *parent=0); + QDeclarative1Rectangle(QDeclarativeItem *parent=0); QColor color() const; void setColor(const QColor &); - QDeclarativePen *border(); + QDeclarative1Pen *border(); - QDeclarativeGradient *gradient() const; - void setGradient(QDeclarativeGradient *gradient); + QDeclarative1Gradient *gradient() const; + void setGradient(QDeclarative1Gradient *gradient); qreal radius() const; void setRadius(qreal radius); @@ -172,16 +172,16 @@ private Q_SLOTS: void drawRect(QPainter &painter); private: - Q_DISABLE_COPY(QDeclarativeRectangle) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeRectangle) + Q_DISABLE_COPY(QDeclarative1Rectangle) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Rectangle) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativePen) -QML_DECLARE_TYPE(QDeclarativeGradientStop) -QML_DECLARE_TYPE(QDeclarativeGradient) -QML_DECLARE_TYPE(QDeclarativeRectangle) +QML_DECLARE_TYPE(QDeclarative1Pen) +QML_DECLARE_TYPE(QDeclarative1GradientStop) +QML_DECLARE_TYPE(QDeclarative1Gradient) +QML_DECLARE_TYPE(QDeclarative1Rectangle) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h b/src/qtquick1/graphicsitems/qdeclarativerectangle_p_p.h similarity index 81% rename from src/declarative/graphicsitems/qdeclarativerectangle_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativerectangle_p_p.h index 209fd8ae05..4437f6be75 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativerectangle_p_p.h @@ -57,41 +57,41 @@ QT_BEGIN_NAMESPACE -class QDeclarativeGradient; -class QDeclarativeRectangle; -class QDeclarativeRectanglePrivate : public QDeclarativeItemPrivate +class QDeclarative1Gradient; +class QDeclarative1Rectangle; +class QDeclarative1RectanglePrivate : public QDeclarativeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeRectangle) + Q_DECLARE_PUBLIC(QDeclarative1Rectangle) public: - QDeclarativeRectanglePrivate() : + QDeclarative1RectanglePrivate() : color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0) { QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; } - ~QDeclarativeRectanglePrivate() + ~QDeclarative1RectanglePrivate() { delete pen; } QColor color; - QDeclarativeGradient *gradient; - QDeclarativePen *pen; + QDeclarative1Gradient *gradient; + QDeclarative1Pen *pen; qreal radius; qreal paintmargin; QPixmap rectImage; static int doUpdateSlotIdx; - QDeclarativePen *getPen() { + QDeclarative1Pen *getPen() { if (!pen) { - Q_Q(QDeclarativeRectangle); - pen = new QDeclarativePen; + Q_Q(QDeclarative1Rectangle); + pen = new QDeclarative1Pen; static int penChangedSignalIdx = -1; if (penChangedSignalIdx < 0) - penChangedSignalIdx = QDeclarativePen::staticMetaObject.indexOfSignal("penChanged()"); + penChangedSignalIdx = QDeclarative1Pen::staticMetaObject.indexOfSignal("penChanged()"); if (doUpdateSlotIdx < 0) - doUpdateSlotIdx = QDeclarativeRectangle::staticMetaObject.indexOfSlot("doUpdate()"); + doUpdateSlotIdx = QDeclarative1Rectangle::staticMetaObject.indexOfSlot("doUpdate()"); QMetaObject::connect(pen, penChangedSignalIdx, q, doUpdateSlotIdx); } return pen; @@ -99,7 +99,7 @@ class QDeclarativeRectanglePrivate : public QDeclarativeItemPrivate void setPaintMargin(qreal margin) { - Q_Q(QDeclarativeRectangle); + Q_Q(QDeclarative1Rectangle); if (margin == paintmargin) return; q->prepareGeometryChange(); diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/qtquick1/graphicsitems/qdeclarativerepeater.cpp similarity index 83% rename from src/declarative/graphicsitems/qdeclarativerepeater.cpp rename to src/qtquick1/graphicsitems/qdeclarativerepeater.cpp index 813c255300..cebff875e8 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativerepeater.cpp @@ -39,29 +39,29 @@ ** ****************************************************************************/ -#include "private/qdeclarativerepeater_p.h" -#include "private/qdeclarativerepeater_p_p.h" +#include "QtQuick1/private/qdeclarativerepeater_p.h" +#include "QtQuick1/private/qdeclarativerepeater_p_p.h" -#include "private/qdeclarativevisualitemmodel_p.h" -#include -#include - -#include +#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" +#include +#include QT_BEGIN_NAMESPACE -QDeclarativeRepeaterPrivate::QDeclarativeRepeaterPrivate() + + +QDeclarative1RepeaterPrivate::QDeclarative1RepeaterPrivate() : model(0), ownModel(false) { } -QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() +QDeclarative1RepeaterPrivate::~QDeclarative1RepeaterPrivate() { if (ownModel) delete model; } /*! - \qmlclass Repeater QDeclarativeRepeater + \qmlclass Repeater QDeclarative1Repeater \ingroup qml-utility-elements \since 4.7 \inherits Item @@ -147,12 +147,12 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() in these cases it will be deleted shortly after the handler is called. */ -QDeclarativeRepeater::QDeclarativeRepeater(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativeRepeaterPrivate), parent) +QDeclarative1Repeater::QDeclarative1Repeater(QDeclarativeItem *parent) + : QDeclarativeItem(*(new QDeclarative1RepeaterPrivate), parent) { } -QDeclarativeRepeater::~QDeclarativeRepeater() +QDeclarative1Repeater::~QDeclarative1Repeater() { } @@ -174,15 +174,15 @@ QDeclarativeRepeater::~QDeclarativeRepeater() \sa {qmlmodels}{Data Models} */ -QVariant QDeclarativeRepeater::model() const +QVariant QDeclarative1Repeater::model() const { - Q_D(const QDeclarativeRepeater); + Q_D(const QDeclarative1Repeater); return d->dataSource; } -void QDeclarativeRepeater::setModel(const QVariant &model) +void QDeclarative1Repeater::setModel(const QVariant &model) { - Q_D(QDeclarativeRepeater); + Q_D(QDeclarative1Repeater); if (d->dataSource == model) return; @@ -199,8 +199,8 @@ void QDeclarativeRepeater::setModel(const QVariant &model) } d->dataSource = model; QObject *object = qvariant_cast(model); - QDeclarativeVisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { + QDeclarative1VisualModel *vim = 0; + if (object && (vim = qobject_cast(object))) { if (d->ownModel) { delete d->model; d->ownModel = false; @@ -208,10 +208,10 @@ void QDeclarativeRepeater::setModel(const QVariant &model) d->model = vim; } else { if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this), this); + d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); d->ownModel = true; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) dataModel->setModel(model); } if (d->model) { @@ -262,29 +262,29 @@ void QDeclarativeRepeater::setModel(const QVariant &model) \sa {QML Data Models} */ -QDeclarativeComponent *QDeclarativeRepeater::delegate() const +QDeclarativeComponent *QDeclarative1Repeater::delegate() const { - Q_D(const QDeclarativeRepeater); + Q_D(const QDeclarative1Repeater); if (d->model) { - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) return dataModel->delegate(); } return 0; } -void QDeclarativeRepeater::setDelegate(QDeclarativeComponent *delegate) +void QDeclarative1Repeater::setDelegate(QDeclarativeComponent *delegate) { - Q_D(QDeclarativeRepeater); - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) + Q_D(QDeclarative1Repeater); + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) if (delegate == dataModel->delegate()) return; if (!d->ownModel) { - d->model = new QDeclarativeVisualDataModel(qmlContext(this)); + d->model = new QDeclarative1VisualDataModel(qmlContext(this)); d->ownModel = true; } - if (QDeclarativeVisualDataModel *dataModel = qobject_cast(d->model)) { + if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { dataModel->setDelegate(delegate); regenerate(); emit delegateChanged(); @@ -296,9 +296,9 @@ void QDeclarativeRepeater::setDelegate(QDeclarativeComponent *delegate) This property holds the number of items in the repeater. */ -int QDeclarativeRepeater::count() const +int QDeclarative1Repeater::count() const { - Q_D(const QDeclarativeRepeater); + Q_D(const QDeclarative1Repeater); if (d->model) return d->model->count(); return 0; @@ -311,22 +311,22 @@ int QDeclarativeRepeater::count() const Returns the \l Item that has been created at the given \a index, or \c null if no item exists at \a index. */ -QDeclarativeItem *QDeclarativeRepeater::itemAt(int index) const +QDeclarativeItem *QDeclarative1Repeater::itemAt(int index) const { - Q_D(const QDeclarativeRepeater); + Q_D(const QDeclarative1Repeater); if (index >= 0 && index < d->deletables.count()) return d->deletables[index]; return 0; } -void QDeclarativeRepeater::componentComplete() +void QDeclarative1Repeater::componentComplete() { QDeclarativeItem::componentComplete(); regenerate(); } -QVariant QDeclarativeRepeater::itemChange(GraphicsItemChange change, +QVariant QDeclarative1Repeater::itemChange(GraphicsItemChange change, const QVariant &value) { QVariant rv = QDeclarativeItem::itemChange(change, value); @@ -337,9 +337,9 @@ QVariant QDeclarativeRepeater::itemChange(GraphicsItemChange change, return rv; } -void QDeclarativeRepeater::clear() +void QDeclarative1Repeater::clear() { - Q_D(QDeclarativeRepeater); + Q_D(QDeclarative1Repeater); bool complete = isComponentComplete(); if (d->model) { @@ -353,9 +353,9 @@ void QDeclarativeRepeater::clear() d->deletables.clear(); } -void QDeclarativeRepeater::regenerate() +void QDeclarative1Repeater::regenerate() { - Q_D(QDeclarativeRepeater); + Q_D(QDeclarative1Repeater); if (!isComponentComplete()) return; @@ -376,9 +376,9 @@ void QDeclarativeRepeater::regenerate() } } -void QDeclarativeRepeater::itemsInserted(int index, int count) +void QDeclarative1Repeater::itemsInserted(int index, int count) { - Q_D(QDeclarativeRepeater); + Q_D(QDeclarative1Repeater); if (!isComponentComplete()) return; for (int i = 0; i < count; ++i) { @@ -398,9 +398,9 @@ void QDeclarativeRepeater::itemsInserted(int index, int count) emit countChanged(); } -void QDeclarativeRepeater::itemsRemoved(int index, int count) +void QDeclarative1Repeater::itemsRemoved(int index, int count) { - Q_D(QDeclarativeRepeater); + Q_D(QDeclarative1Repeater); if (!isComponentComplete() || count <= 0) return; while (count--) { @@ -414,9 +414,9 @@ void QDeclarativeRepeater::itemsRemoved(int index, int count) emit countChanged(); } -void QDeclarativeRepeater::itemsMoved(int from, int to, int count) +void QDeclarative1Repeater::itemsMoved(int from, int to, int count) { - Q_D(QDeclarativeRepeater); + Q_D(QDeclarative1Repeater); if (!isComponentComplete() || count <= 0) return; if (from + count > d->deletables.count()) { @@ -436,7 +436,7 @@ void QDeclarativeRepeater::itemsMoved(int from, int to, int count) } } -void QDeclarativeRepeater::modelReset() +void QDeclarative1Repeater::modelReset() { if (!isComponentComplete()) return; @@ -444,4 +444,6 @@ void QDeclarativeRepeater::modelReset() emit countChanged(); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativerepeater_p.h b/src/qtquick1/graphicsitems/qdeclarativerepeater_p.h similarity index 91% rename from src/declarative/graphicsitems/qdeclarativerepeater_p.h rename to src/qtquick1/graphicsitems/qdeclarativerepeater_p.h index f6a2179c26..6176cd1d14 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativerepeater_p.h @@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeRepeaterPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeRepeater : public QDeclarativeItem +class QDeclarative1RepeaterPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Repeater : public QDeclarativeItem { Q_OBJECT @@ -61,8 +61,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeRepeater : public QDeclarativeItem Q_CLASSINFO("DefaultProperty", "delegate") public: - QDeclarativeRepeater(QDeclarativeItem *parent=0); - virtual ~QDeclarativeRepeater(); + QDeclarative1Repeater(QDeclarativeItem *parent=0); + virtual ~QDeclarative1Repeater(); QVariant model() const; void setModel(const QVariant &); @@ -97,13 +97,13 @@ private Q_SLOTS: void modelReset(); private: - Q_DISABLE_COPY(QDeclarativeRepeater) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeRepeater) + Q_DISABLE_COPY(QDeclarative1Repeater) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Repeater) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeRepeater) +QML_DECLARE_TYPE(QDeclarative1Repeater) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativerepeater_p_p.h b/src/qtquick1/graphicsitems/qdeclarativerepeater_p_p.h similarity index 90% rename from src/declarative/graphicsitems/qdeclarativerepeater_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativerepeater_p_p.h index ce1edc8ccf..e806bd4cb5 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativerepeater_p_p.h @@ -62,16 +62,16 @@ QT_BEGIN_NAMESPACE class QDeclarativeContext; -class QDeclarativeVisualModel; -class QDeclarativeRepeaterPrivate : public QDeclarativeItemPrivate +class QDeclarative1VisualModel; +class QDeclarative1RepeaterPrivate : public QDeclarativeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeRepeater) + Q_DECLARE_PUBLIC(QDeclarative1Repeater) public: - QDeclarativeRepeaterPrivate(); - ~QDeclarativeRepeaterPrivate(); + QDeclarative1RepeaterPrivate(); + ~QDeclarative1RepeaterPrivate(); - QDeclarativeVisualModel *model; + QDeclarative1VisualModel *model; QVariant dataSource; bool ownModel; diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp b/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp similarity index 68% rename from src/declarative/graphicsitems/qdeclarativescalegrid.cpp rename to src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp index 996e6a22a7..83a94ec9de 100644 --- a/src/declarative/graphicsitems/qdeclarativescalegrid.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp @@ -39,34 +39,36 @@ ** ****************************************************************************/ -#include "private/qdeclarativescalegrid_p_p.h" +#include "QtQuick1/private/qdeclarativescalegrid_p_p.h" -#include +#include #include #include QT_BEGIN_NAMESPACE + + /*! \internal - \class QDeclarativeScaleGrid - \brief The QDeclarativeScaleGrid class allows you to specify a 3x3 grid to use in scaling an image. + \class QDeclarative1ScaleGrid + \brief The QDeclarative1ScaleGrid class allows you to specify a 3x3 grid to use in scaling an image. */ -QDeclarativeScaleGrid::QDeclarativeScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0) +QDeclarative1ScaleGrid::QDeclarative1ScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0) { } -QDeclarativeScaleGrid::~QDeclarativeScaleGrid() +QDeclarative1ScaleGrid::~QDeclarative1ScaleGrid() { } -bool QDeclarativeScaleGrid::isNull() const +bool QDeclarative1ScaleGrid::isNull() const { return !_left && !_top && !_right && !_bottom; } -void QDeclarativeScaleGrid::setLeft(int pos) +void QDeclarative1ScaleGrid::setLeft(int pos) { if (_left != pos) { _left = pos; @@ -74,7 +76,7 @@ void QDeclarativeScaleGrid::setLeft(int pos) } } -void QDeclarativeScaleGrid::setTop(int pos) +void QDeclarative1ScaleGrid::setTop(int pos) { if (_top != pos) { _top = pos; @@ -82,7 +84,7 @@ void QDeclarativeScaleGrid::setTop(int pos) } } -void QDeclarativeScaleGrid::setRight(int pos) +void QDeclarative1ScaleGrid::setRight(int pos) { if (_right != pos) { _right = pos; @@ -90,7 +92,7 @@ void QDeclarativeScaleGrid::setRight(int pos) } } -void QDeclarativeScaleGrid::setBottom(int pos) +void QDeclarative1ScaleGrid::setBottom(int pos) { if (_bottom != pos) { _bottom = pos; @@ -98,18 +100,18 @@ void QDeclarativeScaleGrid::setBottom(int pos) } } -QDeclarativeGridScaledImage::QDeclarativeGridScaledImage() +QDeclarative1GridScaledImage::QDeclarative1GridScaledImage() : _l(-1), _r(-1), _t(-1), _b(-1), - _h(QDeclarativeBorderImage::Stretch), _v(QDeclarativeBorderImage::Stretch) + _h(QDeclarative1BorderImage::Stretch), _v(QDeclarative1BorderImage::Stretch) { } -QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(const QDeclarativeGridScaledImage &o) +QDeclarative1GridScaledImage::QDeclarative1GridScaledImage(const QDeclarative1GridScaledImage &o) : _l(o._l), _r(o._r), _t(o._t), _b(o._b), _h(o._h), _v(o._v), _pix(o._pix) { } -QDeclarativeGridScaledImage &QDeclarativeGridScaledImage::operator=(const QDeclarativeGridScaledImage &o) +QDeclarative1GridScaledImage &QDeclarative1GridScaledImage::operator=(const QDeclarative1GridScaledImage &o) { _l = o._l; _r = o._r; @@ -121,8 +123,8 @@ QDeclarativeGridScaledImage &QDeclarativeGridScaledImage::operator=(const QDecla return *this; } -QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(QIODevice *data) -: _l(-1), _r(-1), _t(-1), _b(-1), _h(QDeclarativeBorderImage::Stretch), _v(QDeclarativeBorderImage::Stretch) +QDeclarative1GridScaledImage::QDeclarative1GridScaledImage(QIODevice *data) +: _l(-1), _r(-1), _t(-1), _b(-1), _h(QDeclarative1BorderImage::Stretch), _v(QDeclarative1BorderImage::Stretch) { int l = -1; int r = -1; @@ -167,47 +169,49 @@ QDeclarativeGridScaledImage::QDeclarativeGridScaledImage(QIODevice *data) _pix = imgFile; } -QDeclarativeBorderImage::TileMode QDeclarativeGridScaledImage::stringToRule(const QString &s) +QDeclarative1BorderImage::TileMode QDeclarative1GridScaledImage::stringToRule(const QString &s) { if (s == QLatin1String("Stretch")) - return QDeclarativeBorderImage::Stretch; + return QDeclarative1BorderImage::Stretch; if (s == QLatin1String("Repeat")) - return QDeclarativeBorderImage::Repeat; + return QDeclarative1BorderImage::Repeat; if (s == QLatin1String("Round")) - return QDeclarativeBorderImage::Round; + return QDeclarative1BorderImage::Round; - qWarning("QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch."); - return QDeclarativeBorderImage::Stretch; + qWarning("QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); + return QDeclarative1BorderImage::Stretch; } -bool QDeclarativeGridScaledImage::isValid() const +bool QDeclarative1GridScaledImage::isValid() const { return _l >= 0; } -int QDeclarativeGridScaledImage::gridLeft() const +int QDeclarative1GridScaledImage::gridLeft() const { return _l; } -int QDeclarativeGridScaledImage::gridRight() const +int QDeclarative1GridScaledImage::gridRight() const { return _r; } -int QDeclarativeGridScaledImage::gridTop() const +int QDeclarative1GridScaledImage::gridTop() const { return _t; } -int QDeclarativeGridScaledImage::gridBottom() const +int QDeclarative1GridScaledImage::gridBottom() const { return _b; } -QString QDeclarativeGridScaledImage::pixmapUrl() const +QString QDeclarative1GridScaledImage::pixmapUrl() const { return _pix; } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h b/src/qtquick1/graphicsitems/qdeclarativescalegrid_p_p.h similarity index 74% rename from src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativescalegrid_p_p.h index ffb8540222..5a1c298a74 100644 --- a/src/declarative/graphicsitems/qdeclarativescalegrid_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativescalegrid_p_p.h @@ -42,14 +42,14 @@ #ifndef QDECLARATIVESCALEGRID_H #define QDECLARATIVESCALEGRID_H -#include +#include #include #include -#include -#include -#include +#include +#include +#include QT_BEGIN_HEADER @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeScaleGrid : public QObject +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1ScaleGrid : public QObject { Q_OBJECT Q_ENUMS(TileRule) @@ -68,8 +68,8 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeScaleGrid : public QObject Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY borderChanged) public: - QDeclarativeScaleGrid(QObject *parent=0); - ~QDeclarativeScaleGrid(); + QDeclarative1ScaleGrid(QObject *parent=0); + ~QDeclarative1ScaleGrid(); bool isNull() const; @@ -95,39 +95,39 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeScaleGrid : public QObject int _bottom; }; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeGridScaledImage +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1GridScaledImage { public: - QDeclarativeGridScaledImage(); - QDeclarativeGridScaledImage(const QDeclarativeGridScaledImage &); - QDeclarativeGridScaledImage(QIODevice*); - QDeclarativeGridScaledImage &operator=(const QDeclarativeGridScaledImage &); + QDeclarative1GridScaledImage(); + QDeclarative1GridScaledImage(const QDeclarative1GridScaledImage &); + QDeclarative1GridScaledImage(QIODevice*); + QDeclarative1GridScaledImage &operator=(const QDeclarative1GridScaledImage &); bool isValid() const; int gridLeft() const; int gridRight() const; int gridTop() const; int gridBottom() const; - QDeclarativeBorderImage::TileMode horizontalTileRule() const { return _h; } - QDeclarativeBorderImage::TileMode verticalTileRule() const { return _v; } + QDeclarative1BorderImage::TileMode horizontalTileRule() const { return _h; } + QDeclarative1BorderImage::TileMode verticalTileRule() const { return _v; } QString pixmapUrl() const; private: - static QDeclarativeBorderImage::TileMode stringToRule(const QString &); + static QDeclarative1BorderImage::TileMode stringToRule(const QString &); private: int _l; int _r; int _t; int _b; - QDeclarativeBorderImage::TileMode _h; - QDeclarativeBorderImage::TileMode _v; + QDeclarative1BorderImage::TileMode _h; + QDeclarative1BorderImage::TileMode _v; QString _pix; }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeScaleGrid) +QML_DECLARE_TYPE(QDeclarative1ScaleGrid) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/qtquick1/graphicsitems/qdeclarativetext.cpp similarity index 80% rename from src/declarative/graphicsitems/qdeclarativetext.cpp rename to src/qtquick1/graphicsitems/qdeclarativetext.cpp index 96bd792c01..8a497c271e 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetext.cpp @@ -39,11 +39,11 @@ ** ****************************************************************************/ -#include "private/qdeclarativetext_p.h" -#include "private/qdeclarativetext_p_p.h" -#include -#include -#include +#include "QtQuick1/private/qdeclarativetext_p.h" +#include "QtQuick1/private/qdeclarativetext_p_p.h" +#include "QtQuick1/private/qdeclarativestyledtext_p.h" +#include +#include "QtQuick1/private/qdeclarativepixmapcache_p.h" #include #include @@ -57,14 +57,16 @@ QT_BEGIN_NAMESPACE + + extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; -class QTextDocumentWithImageResources : public QTextDocument { +class QTextDocumentWithImageResources_1 : public QTextDocument { Q_OBJECT public: - QTextDocumentWithImageResources(QDeclarativeText *parent); - virtual ~QTextDocumentWithImageResources(); + QTextDocumentWithImageResources_1(QDeclarative1Text *parent); + virtual ~QTextDocumentWithImageResources_1(); void setText(const QString &); int resourcesLoading() const { return outstanding; } @@ -76,51 +78,34 @@ private slots: void requestFinished(); private: - QHash m_resources; + QHash m_resources; int outstanding; static QSet errors; }; -DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE); - -QString QDeclarativeTextPrivate::elideChar = QString(0x2026); - -QDeclarativeTextPrivate::QDeclarativeTextPrivate() -: color((QRgb)0), style(QDeclarativeText::Normal), hAlign(QDeclarativeText::AlignLeft), - vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone), - format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap), lineHeight(1), - lineHeightMode(QDeclarativeText::ProportionalHeight), lineCount(1), truncated(false), maximumLineCount(INT_MAX), - maximumLineCountValid(false), imageCacheDirty(true), updateOnComponentComplete(true), richText(false), singleline(false), - cacheAllTextAsImage(true), internalWidthUpdate(false), requireImplicitWidth(false), hAlignImplicit(true), - rightToLeftText(false), layoutTextElided(false), naturalWidth(0), doc(0) -{ - cacheAllTextAsImage = enableImageCache(); - QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton; - QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; -} -QTextDocumentWithImageResources::QTextDocumentWithImageResources(QDeclarativeText *parent) +QTextDocumentWithImageResources_1::QTextDocumentWithImageResources_1(QDeclarative1Text *parent) : QTextDocument(parent), outstanding(0) { } -QTextDocumentWithImageResources::~QTextDocumentWithImageResources() +QTextDocumentWithImageResources_1::~QTextDocumentWithImageResources_1() { if (!m_resources.isEmpty()) qDeleteAll(m_resources); } -QVariant QTextDocumentWithImageResources::loadResource(int type, const QUrl &name) +QVariant QTextDocumentWithImageResources_1::loadResource(int type, const QUrl &name) { QDeclarativeContext *context = qmlContext(parent()); QUrl url = context->resolvedUrl(name); if (type == QTextDocument::ImageResource) { - QHash::Iterator iter = m_resources.find(url); + QHash::Iterator iter = m_resources.find(url); if (iter == m_resources.end()) { - QDeclarativePixmap *p = new QDeclarativePixmap(context->engine(), url); + QDeclarative1Pixmap *p = new QDeclarative1Pixmap(context->engine(), url); iter = m_resources.insert(name, p); if (p->isLoading()) { @@ -129,7 +114,7 @@ QVariant QTextDocumentWithImageResources::loadResource(int type, const QUrl &nam } } - QDeclarativePixmap *p = *iter; + QDeclarative1Pixmap *p = *iter; if (p->isReady()) { return p->pixmap(); } else if (p->isError()) { @@ -143,23 +128,23 @@ QVariant QTextDocumentWithImageResources::loadResource(int type, const QUrl &nam return QTextDocument::loadResource(type,url); // The *resolved* URL } -void QTextDocumentWithImageResources::requestFinished() +void QTextDocumentWithImageResources_1::requestFinished() { outstanding--; if (outstanding == 0) { - QDeclarativeText *textItem = static_cast(parent()); + QDeclarative1Text *textItem = static_cast(parent()); QString text = textItem->text(); #ifndef QT_NO_TEXTHTMLPARSER setHtml(text); #else setPlainText(text); #endif - QDeclarativeTextPrivate *d = QDeclarativeTextPrivate::get(textItem); + QDeclarative1TextPrivate *d = QDeclarative1TextPrivate::get(textItem); d->updateLayout(); } } -void QTextDocumentWithImageResources::setText(const QString &text) +void QTextDocumentWithImageResources_1::setText(const QString &text) { if (!m_resources.isEmpty()) { qDeleteAll(m_resources); @@ -174,27 +159,45 @@ void QTextDocumentWithImageResources::setText(const QString &text) #endif } -QSet QTextDocumentWithImageResources::errors; +QSet QTextDocumentWithImageResources_1::errors; -QDeclarativeTextPrivate::~QDeclarativeTextPrivate() +QDeclarative1TextPrivate::~QDeclarative1TextPrivate() { } -qreal QDeclarativeTextPrivate::implicitWidth() const +DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE); + +QString QDeclarative1TextPrivate::elideChar = QString(0x2026); + +QDeclarative1TextPrivate::QDeclarative1TextPrivate() +: color((QRgb)0), style(QDeclarative1Text::Normal), hAlign(QDeclarative1Text::AlignLeft), + vAlign(QDeclarative1Text::AlignTop), elideMode(QDeclarative1Text::ElideNone), + format(QDeclarative1Text::AutoText), wrapMode(QDeclarative1Text::NoWrap), lineHeight(1), + lineHeightMode(QDeclarative1Text::ProportionalHeight), lineCount(1), truncated(false), maximumLineCount(INT_MAX), + maximumLineCountValid(false), imageCacheDirty(true), updateOnComponentComplete(true), richText(false), singleline(false), + cacheAllTextAsImage(true), internalWidthUpdate(false), requireImplicitWidth(false), hAlignImplicit(true), + rightToLeftText(false), layoutTextElided(false), naturalWidth(0), doc(0) +{ + cacheAllTextAsImage = enableImageCache(); + QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton; + QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; +} + +qreal QDeclarative1TextPrivate::implicitWidth() const { if (!requireImplicitWidth) { // We don't calculate implicitWidth unless it is required. // We need to force a size update now to ensure implicitWidth is calculated - QDeclarativeTextPrivate *me = const_cast(this); + QDeclarative1TextPrivate *me = const_cast(this); me->requireImplicitWidth = true; me->updateSize(); } return mImplicitWidth; } -void QDeclarativeTextPrivate::updateLayout() +void QDeclarative1TextPrivate::updateLayout() { - Q_Q(QDeclarativeText); + Q_Q(QDeclarative1Text); if (!q->isComponentComplete()) { updateOnComponentComplete = true; return; @@ -205,11 +208,11 @@ void QDeclarativeTextPrivate::updateLayout() if (!richText) { layout.clearLayout(); layout.setFont(font); - if (format != QDeclarativeText::StyledText) { + if (format != QDeclarative1Text::StyledText) { QString tmp = text; tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); singleline = !tmp.contains(QChar::LineSeparator); - if (singleline && !maximumLineCountValid && elideMode != QDeclarativeText::ElideNone && q->widthValid()) { + if (singleline && !maximumLineCountValid && elideMode != QDeclarative1Text::ElideNone && q->widthValid()) { QFontMetrics fm(font); tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); if (tmp != text) { @@ -223,16 +226,16 @@ void QDeclarativeTextPrivate::updateLayout() layout.setText(tmp); } else { singleline = false; - QDeclarativeStyledText::parse(text, layout); + QDeclarative1StyledText::parse(text, layout); } } updateSize(); } -void QDeclarativeTextPrivate::updateSize() +void QDeclarative1TextPrivate::updateSize() { - Q_Q(QDeclarativeText); + Q_Q(QDeclarative1Text); if (!q->isComponentComplete()) { updateOnComponentComplete = true; @@ -274,12 +277,12 @@ void QDeclarativeTextPrivate::updateSize() ensureDoc(); doc->setDefaultFont(font); - QDeclarativeText::HAlignment horizontalAlignment = q->effectiveHAlign(); + QDeclarative1Text::HAlignment horizontalAlignment = q->effectiveHAlign(); if (rightToLeftText) { - if (horizontalAlignment == QDeclarativeText::AlignLeft) - horizontalAlignment = QDeclarativeText::AlignRight; - else if (horizontalAlignment == QDeclarativeText::AlignRight) - horizontalAlignment = QDeclarativeText::AlignLeft; + if (horizontalAlignment == QDeclarative1Text::AlignLeft) + horizontalAlignment = QDeclarative1Text::AlignRight; + else if (horizontalAlignment == QDeclarative1Text::AlignRight) + horizontalAlignment = QDeclarative1Text::AlignLeft; } QTextOption option; option.setAlignment((Qt::Alignment)int(horizontalAlignment | vAlign)); @@ -289,7 +292,7 @@ void QDeclarativeTextPrivate::updateSize() doc->setTextWidth(-1); naturalWidth = doc->idealWidth(); } - if (wrapMode != QDeclarativeText::NoWrap && q->widthValid()) + if (wrapMode != QDeclarative1Text::NoWrap && q->widthValid()) doc->setTextWidth(q->width()); else doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) @@ -304,9 +307,9 @@ void QDeclarativeTextPrivate::updateSize() int yoff = 0; if (q->heightValid()) { - if (vAlign == QDeclarativeText::AlignBottom) + if (vAlign == QDeclarative1Text::AlignBottom) yoff = dy; - else if (vAlign == QDeclarativeText::AlignVCenter) + else if (vAlign == QDeclarative1Text::AlignVCenter) yoff = dy/2; } q->setBaselineOffset(fm.ascent() + yoff); @@ -327,16 +330,16 @@ void QDeclarativeTextPrivate::updateSize() } /*! - Lays out the QDeclarativeTextPrivate::layout QTextLayout in the constraints of the QDeclarativeText. + Lays out the QDeclarative1TextPrivate::layout QTextLayout in the constraints of the QDeclarative1Text. Returns the size of the final text. This can be used to position the text vertically (the text is already absolutely positioned horizontally). */ -QRect QDeclarativeTextPrivate::setupTextLayout() +QRect QDeclarative1TextPrivate::setupTextLayout() { // ### text layout handling should be profiled and optimized as needed // what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine); - Q_Q(QDeclarativeText); + Q_Q(QDeclarative1Text); layout.setCacheEnabled(true); qreal lineWidth = 0; @@ -401,7 +404,7 @@ QRect QDeclarativeTextPrivate::setupTextLayout() if (--linesLeft == 0) { if (visibleTextLength < text.length()) { truncate = true; - if (elideMode==QDeclarativeText::ElideRight && q->widthValid()) { + if (elideMode==QDeclarative1Text::ElideRight && q->widthValid()) { qreal elideWidth = fm.width(elideChar); // Need to correct for alignment line.setLineWidth(lineWidth-elideWidth); @@ -447,7 +450,7 @@ QRect QDeclarativeTextPrivate::setupTextLayout() br = br.united(QRectF(elidePos, QSizeF(fm.width(elideChar), fm.ascent()))); } br = br.united(line.naturalTextRect()); - height += (lineHeightMode == QDeclarativeText::FixedHeight) ? lineHeight : line.height() * lineHeight; + height += (lineHeightMode == QDeclarative1Text::FixedHeight) ? lineHeight : line.height() * lineHeight; } br.setHeight(height); @@ -464,10 +467,10 @@ QRect QDeclarativeTextPrivate::setupTextLayout() } /*! - Returns a painted version of the QDeclarativeTextPrivate::layout QTextLayout. + Returns a painted version of the QDeclarative1TextPrivate::layout QTextLayout. If \a drawStyle is true, the style color overrides all colors in the document. */ -QPixmap QDeclarativeTextPrivate::textLayoutImage(bool drawStyle) +QPixmap QDeclarative1TextPrivate::textLayoutImage(bool drawStyle) { //do layout QSize size = layedOutTextRect.size(); @@ -489,10 +492,10 @@ QPixmap QDeclarativeTextPrivate::textLayoutImage(bool drawStyle) } /*! - Paints the QDeclarativeTextPrivate::layout QTextLayout into \a painter at \a pos. If + Paints the QDeclarative1TextPrivate::layout QTextLayout into \a painter at \a pos. If \a drawStyle is true, the style color overrides all colors in the document. */ -void QDeclarativeTextPrivate::drawTextLayout(QPainter *painter, const QPointF &pos, bool drawStyle) +void QDeclarative1TextPrivate::drawTextLayout(QPainter *painter, const QPointF &pos, bool drawStyle) { if (drawStyle) painter->setPen(styleColor); @@ -505,10 +508,10 @@ void QDeclarativeTextPrivate::drawTextLayout(QPainter *painter, const QPointF &p } /*! - Returns a painted version of the QDeclarativeTextPrivate::doc QTextDocument. + Returns a painted version of the QDeclarative1TextPrivate::doc QTextDocument. If \a drawStyle is true, the style color overrides all colors in the document. */ -QPixmap QDeclarativeTextPrivate::textDocumentImage(bool drawStyle) +QPixmap QDeclarative1TextPrivate::textDocumentImage(bool drawStyle) { QSize size = doc->size().toSize(); @@ -544,11 +547,11 @@ QPixmap QDeclarativeTextPrivate::textDocumentImage(bool drawStyle) /*! Mark the image cache as dirty. */ -void QDeclarativeTextPrivate::invalidateImageCache() +void QDeclarative1TextPrivate::invalidateImageCache() { - Q_Q(QDeclarativeText); + Q_Q(QDeclarative1Text); - if(cacheAllTextAsImage || style != QDeclarativeText::Normal){//If actually using the image cache + if(cacheAllTextAsImage || style != QDeclarative1Text::Normal){//If actually using the image cache if (imageCacheDirty) return; @@ -562,7 +565,7 @@ void QDeclarativeTextPrivate::invalidateImageCache() /*! Tests if the image cache is dirty, and repaints it if it is. */ -void QDeclarativeTextPrivate::checkImageCache() +void QDeclarative1TextPrivate::checkImageCache() { if (!imageCacheDirty) return; @@ -578,22 +581,22 @@ void QDeclarativeTextPrivate::checkImageCache() if (richText) { textImage = textDocumentImage(false); - if (style != QDeclarativeText::Normal) + if (style != QDeclarative1Text::Normal) styledImage = textDocumentImage(true); //### should use styleColor } else { textImage = textLayoutImage(false); - if (style != QDeclarativeText::Normal) + if (style != QDeclarative1Text::Normal) styledImage = textLayoutImage(true); //### should use styleColor } switch (style) { - case QDeclarativeText::Outline: + case QDeclarative1Text::Outline: imageCache = drawOutline(textImage, styledImage); break; - case QDeclarativeText::Sunken: + case QDeclarative1Text::Sunken: imageCache = drawOutline(textImage, styledImage, -1); break; - case QDeclarativeText::Raised: + case QDeclarative1Text::Raised: imageCache = drawOutline(textImage, styledImage, 1); break; default: @@ -607,13 +610,13 @@ void QDeclarativeTextPrivate::checkImageCache() } /*! - Ensures the QDeclarativeTextPrivate::doc variable is set to a valid text document + Ensures the QDeclarative1TextPrivate::doc variable is set to a valid text document */ -void QDeclarativeTextPrivate::ensureDoc() +void QDeclarative1TextPrivate::ensureDoc() { if (!doc) { - Q_Q(QDeclarativeText); - doc = new QTextDocumentWithImageResources(q); + Q_Q(QDeclarative1Text); + doc = new QTextDocumentWithImageResources_1(q); doc->setDocumentMargin(0); } } @@ -621,7 +624,7 @@ void QDeclarativeTextPrivate::ensureDoc() /*! Draw \a styleSource as an outline around \a source and return the new image. */ -QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource) +QPixmap QDeclarative1TextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource) { QPixmap img = QPixmap(styleSource.width() + 2, styleSource.height() + 2); img.fill(Qt::transparent); @@ -648,7 +651,7 @@ QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixma /*! Draw \a styleSource below \a source at \a yOffset and return the new image. */ -QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource, int yOffset) +QPixmap QDeclarative1TextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource, int yOffset) { QPixmap img = QPixmap(styleSource.width() + 2, styleSource.height() + 2); img.fill(Qt::transparent); @@ -664,7 +667,7 @@ QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixma } /*! - \qmlclass Text QDeclarativeText + \qmlclass Text QDeclarative1Text \ingroup qml-basic-visual-elements \since 4.7 \brief The Text item allows you to add formatted text to a scene. @@ -706,12 +709,12 @@ QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixma \sa {declarative/text/fonts}{Fonts example} */ -QDeclarativeText::QDeclarativeText(QDeclarativeItem *parent) - : QDeclarativeImplicitSizeItem(*(new QDeclarativeTextPrivate), parent) +QDeclarative1Text::QDeclarative1Text(QDeclarativeItem *parent) + : QDeclarative1ImplicitSizeItem(*(new QDeclarative1TextPrivate), parent) { } -QDeclarativeText::~QDeclarativeText() +QDeclarative1Text::~QDeclarative1Text() { } @@ -858,15 +861,15 @@ QDeclarativeText::~QDeclarativeText() Text { text: "Hello"; font.capitalization: Font.AllLowercase } \endqml */ -QFont QDeclarativeText::font() const +QFont QDeclarative1Text::font() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->sourceFont; } -void QDeclarativeText::setFont(const QFont &font) +void QDeclarative1Text::setFont(const QFont &font) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (d->sourceFont == font) return; @@ -893,15 +896,15 @@ void QDeclarativeText::setFont(const QFont &font) The item will try to automatically determine whether the text should be treated as rich text. This determination is made using Qt::mightBeRichText(). */ -QString QDeclarativeText::text() const +QString QDeclarative1Text::text() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->text; } -void QDeclarativeText::setText(const QString &n) +void QDeclarative1Text::setText(const QString &n) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (d->text == n) return; @@ -943,15 +946,15 @@ void QDeclarativeText::setText(const QString &n) } \endqml */ -QColor QDeclarativeText::color() const +QColor QDeclarative1Text::color() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->color; } -void QDeclarativeText::setColor(const QColor &color) +void QDeclarative1Text::setColor(const QColor &color) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (d->color == color) return; @@ -984,15 +987,15 @@ void QDeclarativeText::setColor(const QColor &color) \image declarative-textstyle.png */ -QDeclarativeText::TextStyle QDeclarativeText::style() const +QDeclarative1Text::TextStyle QDeclarative1Text::style() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->style; } -void QDeclarativeText::setStyle(QDeclarativeText::TextStyle style) +void QDeclarative1Text::setStyle(QDeclarative1Text::TextStyle style) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (d->style == style) return; @@ -1019,15 +1022,15 @@ void QDeclarativeText::setStyle(QDeclarativeText::TextStyle style) \sa style */ -QColor QDeclarativeText::styleColor() const +QColor QDeclarative1Text::styleColor() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->styleColor; } -void QDeclarativeText::setStyleColor(const QColor &color) +void QDeclarative1Text::setStyleColor(const QColor &color) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (d->styleColor == color) return; @@ -1061,40 +1064,40 @@ void QDeclarativeText::setStyleColor(const QColor &color) \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment of Text, use the read-only property \c effectiveHorizontalAlignment. */ -QDeclarativeText::HAlignment QDeclarativeText::hAlign() const +QDeclarative1Text::HAlignment QDeclarative1Text::hAlign() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->hAlign; } -void QDeclarativeText::setHAlign(HAlignment align) +void QDeclarative1Text::setHAlign(HAlignment align) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror; d->hAlignImplicit = false; if (d->setHAlign(align, forceAlign) && isComponentComplete()) d->updateLayout(); } -void QDeclarativeText::resetHAlign() +void QDeclarative1Text::resetHAlign() { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); d->hAlignImplicit = true; if (d->determineHorizontalAlignment() && isComponentComplete()) d->updateLayout(); } -QDeclarativeText::HAlignment QDeclarativeText::effectiveHAlign() const +QDeclarative1Text::HAlignment QDeclarative1Text::effectiveHAlign() const { - Q_D(const QDeclarativeText); - QDeclarativeText::HAlignment effectiveAlignment = d->hAlign; + Q_D(const QDeclarative1Text); + QDeclarative1Text::HAlignment effectiveAlignment = d->hAlign; if (!d->hAlignImplicit && d->effectiveLayoutMirror) { switch (d->hAlign) { - case QDeclarativeText::AlignLeft: - effectiveAlignment = QDeclarativeText::AlignRight; + case QDeclarative1Text::AlignLeft: + effectiveAlignment = QDeclarative1Text::AlignRight; break; - case QDeclarativeText::AlignRight: - effectiveAlignment = QDeclarativeText::AlignLeft; + case QDeclarative1Text::AlignRight: + effectiveAlignment = QDeclarative1Text::AlignLeft; break; default: break; @@ -1103,11 +1106,11 @@ QDeclarativeText::HAlignment QDeclarativeText::effectiveHAlign() const return effectiveAlignment; } -bool QDeclarativeTextPrivate::setHAlign(QDeclarativeText::HAlignment alignment, bool forceAlign) +bool QDeclarative1TextPrivate::setHAlign(QDeclarative1Text::HAlignment alignment, bool forceAlign) { - Q_Q(QDeclarativeText); + Q_Q(QDeclarative1Text); if (hAlign != alignment || forceAlign) { - QDeclarativeText::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); + QDeclarative1Text::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); hAlign = alignment; emit q->horizontalAlignmentChanged(hAlign); @@ -1118,41 +1121,41 @@ bool QDeclarativeTextPrivate::setHAlign(QDeclarativeText::HAlignment alignment, return false; } -bool QDeclarativeTextPrivate::determineHorizontalAlignment() +bool QDeclarative1TextPrivate::determineHorizontalAlignment() { - Q_Q(QDeclarativeText); + Q_Q(QDeclarative1Text); if (hAlignImplicit && q->isComponentComplete()) { bool alignToRight = text.isEmpty() ? QApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText; - return setHAlign(alignToRight ? QDeclarativeText::AlignRight : QDeclarativeText::AlignLeft); + return setHAlign(alignToRight ? QDeclarative1Text::AlignRight : QDeclarative1Text::AlignLeft); } return false; } -void QDeclarativeTextPrivate::mirrorChange() +void QDeclarative1TextPrivate::mirrorChange() { - Q_Q(QDeclarativeText); + Q_Q(QDeclarative1Text); if (q->isComponentComplete()) { - if (!hAlignImplicit && (hAlign == QDeclarativeText::AlignRight || hAlign == QDeclarativeText::AlignLeft)) { + if (!hAlignImplicit && (hAlign == QDeclarative1Text::AlignRight || hAlign == QDeclarative1Text::AlignLeft)) { updateLayout(); emit q->effectiveHorizontalAlignmentChanged(); } } } -QTextDocument *QDeclarativeTextPrivate::textDocument() +QTextDocument *QDeclarative1TextPrivate::textDocument() { return doc; } -QDeclarativeText::VAlignment QDeclarativeText::vAlign() const +QDeclarative1Text::VAlignment QDeclarative1Text::vAlign() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->vAlign; } -void QDeclarativeText::setVAlign(VAlignment align) +void QDeclarative1Text::setVAlign(VAlignment align) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (d->vAlign == align) return; @@ -1175,15 +1178,15 @@ void QDeclarativeText::setVAlign(VAlignment align) \o Text.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word. \endlist */ -QDeclarativeText::WrapMode QDeclarativeText::wrapMode() const +QDeclarative1Text::WrapMode QDeclarative1Text::wrapMode() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->wrapMode; } -void QDeclarativeText::setWrapMode(WrapMode mode) +void QDeclarative1Text::setWrapMode(WrapMode mode) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (mode == d->wrapMode) return; @@ -1203,9 +1206,9 @@ void QDeclarativeText::setWrapMode(WrapMode mode) \sa maximumLineCount */ -int QDeclarativeText::lineCount() const +int QDeclarative1Text::lineCount() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->lineCount; } @@ -1220,9 +1223,9 @@ int QDeclarativeText::lineCount() const \sa maximumLineCount, elide */ -bool QDeclarativeText::truncated() const +bool QDeclarative1Text::truncated() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->truncated; } @@ -1238,15 +1241,15 @@ bool QDeclarativeText::truncated() const \sa lineCount, elide */ -int QDeclarativeText::maximumLineCount() const +int QDeclarative1Text::maximumLineCount() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->maximumLineCount; } -void QDeclarativeText::setMaximumLineCount(int lines) +void QDeclarative1Text::setMaximumLineCount(int lines) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); d->maximumLineCountValid = lines==INT_MAX ? false : true; if (d->maximumLineCount != lines) { @@ -1256,9 +1259,9 @@ void QDeclarativeText::setMaximumLineCount(int lines) } } -void QDeclarativeText::resetMaximumLineCount() +void QDeclarative1Text::resetMaximumLineCount() { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); setMaximumLineCount(INT_MAX); d->elidePos = QPointF(); if (d->truncated != false) { @@ -1322,15 +1325,15 @@ Column { \o \image declarative-textformat.png \endtable */ -QDeclarativeText::TextFormat QDeclarativeText::textFormat() const +QDeclarative1Text::TextFormat QDeclarative1Text::textFormat() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->format; } -void QDeclarativeText::setTextFormat(TextFormat format) +void QDeclarative1Text::setTextFormat(TextFormat format) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (format == d->format) return; d->format = format; @@ -1372,15 +1375,15 @@ void QDeclarativeText::setTextFormat(TextFormat format) Multi-length strings are ordered from longest to shortest, separated by the Unicode "String Terminator" character \c U009C (write this in QML with \c{"\u009C"} or \c{"\x9C"}). */ -QDeclarativeText::TextElideMode QDeclarativeText::elideMode() const +QDeclarative1Text::TextElideMode QDeclarative1Text::elideMode() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->elideMode; } -void QDeclarativeText::setElideMode(QDeclarativeText::TextElideMode mode) +void QDeclarative1Text::setElideMode(QDeclarative1Text::TextElideMode mode) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (mode == d->elideMode) return; @@ -1391,9 +1394,9 @@ void QDeclarativeText::setElideMode(QDeclarativeText::TextElideMode mode) } /*! \internal */ -QRectF QDeclarativeText::boundingRect() const +QRectF QDeclarative1Text::boundingRect() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); QRect rect = d->layedOutTextRect; if (d->style != Normal) @@ -1417,14 +1420,14 @@ QRectF QDeclarativeText::boundingRect() const } /*! \internal */ -void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +void QDeclarative1Text::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if ((!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width()) - && (d->wrapMode != QDeclarativeText::NoWrap - || d->elideMode != QDeclarativeText::ElideNone - || d->hAlign != QDeclarativeText::AlignLeft)) { - if ((d->singleline || d->maximumLineCountValid) && d->elideMode != QDeclarativeText::ElideNone && widthValid()) { + && (d->wrapMode != QDeclarative1Text::NoWrap + || d->elideMode != QDeclarative1Text::ElideNone + || d->hAlign != QDeclarative1Text::AlignLeft)) { + if ((d->singleline || d->maximumLineCountValid) && d->elideMode != QDeclarative1Text::ElideNone && widthValid()) { // We need to re-elide d->updateLayout(); } else { @@ -1442,9 +1445,9 @@ void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF & Returns the width of the text, including width past the width which is covered due to insufficient wrapping if WrapMode is set. */ -qreal QDeclarativeText::paintedWidth() const +qreal QDeclarative1Text::paintedWidth() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->paintedSize.width(); } @@ -1454,9 +1457,9 @@ qreal QDeclarativeText::paintedWidth() const Returns the height of the text, including height past the height which is covered due to there being more text than fits in the set height. */ -qreal QDeclarativeText::paintedHeight() const +qreal QDeclarative1Text::paintedHeight() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->paintedSize.height(); } @@ -1470,15 +1473,15 @@ qreal QDeclarativeText::paintedHeight() const The default value is a multiplier of 1.0. The line height must be a positive value. */ -qreal QDeclarativeText::lineHeight() const +qreal QDeclarative1Text::lineHeight() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->lineHeight; } -void QDeclarativeText::setLineHeight(qreal lineHeight) +void QDeclarative1Text::setLineHeight(qreal lineHeight) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if ((d->lineHeight == lineHeight) || (lineHeight < 0.0)) return; @@ -1500,15 +1503,15 @@ void QDeclarativeText::setLineHeight(qreal lineHeight) \o Text.FixedHeight - this sets the line height to a fixed line height (in pixels). \endlist */ -QDeclarativeText::LineHeightMode QDeclarativeText::lineHeightMode() const +QDeclarative1Text::LineHeightMode QDeclarative1Text::lineHeightMode() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->lineHeightMode; } -void QDeclarativeText::setLineHeightMode(LineHeightMode mode) +void QDeclarative1Text::setLineHeightMode(LineHeightMode mode) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (mode == d->lineHeightMode) return; @@ -1521,16 +1524,16 @@ void QDeclarativeText::setLineHeightMode(LineHeightMode mode) /*! Returns the number of resources (images) that are being loaded asynchronously. */ -int QDeclarativeText::resourcesLoading() const +int QDeclarative1Text::resourcesLoading() const { - Q_D(const QDeclarativeText); + Q_D(const QDeclarative1Text); return d->doc ? d->doc->resourcesLoading() : 0; } /*! \internal */ -void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) +void QDeclarative1Text::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (d->cacheAllTextAsImage || d->style != Normal) { d->checkImageCache(); @@ -1583,9 +1586,9 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid } /*! \internal */ -void QDeclarativeText::componentComplete() +void QDeclarative1Text::componentComplete() { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); QDeclarativeItem::componentComplete(); if (d->updateOnComponentComplete) { d->updateOnComponentComplete = false; @@ -1602,9 +1605,9 @@ void QDeclarativeText::componentComplete() } /*! \internal */ -void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1Text::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); if (!d->richText || !d->doc || d->doc->documentLayout()->anchorAt(event->pos()).isEmpty()) { event->setAccepted(false); @@ -1621,9 +1624,9 @@ void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event) } /*! \internal */ -void QDeclarativeText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeText); + Q_D(QDeclarative1Text); // ### confirm the link, and send a signal out if (d->richText && d->doc && d->activeLink == d->doc->documentLayout()->anchorAt(event->pos())) @@ -1635,6 +1638,8 @@ void QDeclarativeText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) QDeclarativeItem::mouseReleaseEvent(event); } + + QT_END_NAMESPACE #include "qdeclarativetext.moc" diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/qtquick1/graphicsitems/qdeclarativetext_p.h similarity index 95% rename from src/declarative/graphicsitems/qdeclarativetext_p.h rename to src/qtquick1/graphicsitems/qdeclarativetext_p.h index b711582535..93261fbb24 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetext_p.h @@ -45,15 +45,15 @@ #include #include "qdeclarativeimplicitsizeitem_p.h" -#include +#include QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeTextPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeImplicitSizeItem +class QDeclarative1TextPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Text : public QDeclarative1ImplicitSizeItem { Q_OBJECT Q_ENUMS(HAlignment) @@ -85,8 +85,8 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeImplici Q_PROPERTY(LineHeightMode lineHeightMode READ lineHeightMode WRITE setLineHeightMode NOTIFY lineHeightModeChanged REVISION 1) public: - QDeclarativeText(QDeclarativeItem *parent=0); - ~QDeclarativeText(); + QDeclarative1Text(QDeclarativeItem *parent=0); + ~QDeclarative1Text(); enum HAlignment { AlignLeft = Qt::AlignLeft, AlignRight = Qt::AlignRight, @@ -200,13 +200,13 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeImplici const QRectF &oldGeometry); private: - Q_DISABLE_COPY(QDeclarativeText) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeText) + Q_DISABLE_COPY(QDeclarative1Text) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Text) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeText) +QML_DECLARE_TYPE(QDeclarative1Text) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/qtquick1/graphicsitems/qdeclarativetext_p_p.h similarity index 80% rename from src/declarative/graphicsitems/qdeclarativetext_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativetext_p_p.h index dd12fb7ad9..b6862d8e85 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetext_p_p.h @@ -55,29 +55,29 @@ #include "qdeclarativeitem.h" #include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include "private/qdeclarativetextlayout_p.h" +#include "QtQuick1/private/qdeclarativetextlayout_p.h" -#include +#include #include QT_BEGIN_NAMESPACE class QTextLayout; -class QTextDocumentWithImageResources; +class QTextDocumentWithImageResources_1; -class Q_AUTOTEST_EXPORT QDeclarativeTextPrivate : public QDeclarativeImplicitSizeItemPrivate +class Q_AUTOTEST_EXPORT QDeclarative1TextPrivate : public QDeclarative1ImplicitSizeItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeText) + Q_DECLARE_PUBLIC(QDeclarative1Text) public: - QDeclarativeTextPrivate(); + QDeclarative1TextPrivate(); - ~QDeclarativeTextPrivate(); + ~QDeclarative1TextPrivate(); void updateSize(); void updateLayout(); bool determineHorizontalAlignment(); - bool setHAlign(QDeclarativeText::HAlignment, bool forceAlign = false); + bool setHAlign(QDeclarative1Text::HAlignment, bool forceAlign = false); void mirrorChange(); QTextDocument *textDocument(); @@ -85,16 +85,16 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextPrivate : public QDeclarativeImplicitSiz QFont font; QFont sourceFont; QColor color; - QDeclarativeText::TextStyle style; + QDeclarative1Text::TextStyle style; QColor styleColor; QString activeLink; - QDeclarativeText::HAlignment hAlign; - QDeclarativeText::VAlignment vAlign; - QDeclarativeText::TextElideMode elideMode; - QDeclarativeText::TextFormat format; - QDeclarativeText::WrapMode wrapMode; + QDeclarative1Text::HAlignment hAlign; + QDeclarative1Text::VAlignment vAlign; + QDeclarative1Text::TextElideMode elideMode; + QDeclarative1Text::TextFormat format; + QDeclarative1Text::WrapMode wrapMode; qreal lineHeight; - QDeclarativeText::LineHeightMode lineHeightMode; + QDeclarative1Text::LineHeightMode lineHeightMode; int lineCount; bool truncated; int maximumLineCount; @@ -124,17 +124,17 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextPrivate : public QDeclarativeImplicitSiz virtual qreal implicitWidth() const; void ensureDoc(); QPixmap textDocumentImage(bool drawStyle); - QTextDocumentWithImageResources *doc; + QTextDocumentWithImageResources_1 *doc; QRect setupTextLayout(); QPixmap textLayoutImage(bool drawStyle); void drawTextLayout(QPainter *p, const QPointF &pos, bool drawStyle); - QDeclarativeTextLayout layout; + QDeclarative1TextLayout layout; static QPixmap drawOutline(const QPixmap &source, const QPixmap &styleSource); static QPixmap drawOutline(const QPixmap &source, const QPixmap &styleSource, int yOffset); - static inline QDeclarativeTextPrivate *get(QDeclarativeText *t) { + static inline QDeclarative1TextPrivate *get(QDeclarative1Text *t) { return t->d_func(); } }; diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp similarity index 81% rename from src/declarative/graphicsitems/qdeclarativetextedit.cpp rename to src/qtquick1/graphicsitems/qdeclarativetextedit.cpp index b32e02dcae..1645bfd390 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp @@ -61,8 +61,10 @@ QT_BEGIN_NAMESPACE + + /*! - \qmlclass TextEdit QDeclarativeTextEdit + \qmlclass TextEdit QDeclarative1TextEdit \ingroup qml-basic-visual-elements \since 4.7 \brief The TextEdit item displays multiple lines of editable formatted text. @@ -113,16 +115,16 @@ TextEdit { The link must be in rich text or HTML format and the \a link string provides access to the particular link. */ -QDeclarativeTextEdit::QDeclarativeTextEdit(QDeclarativeItem *parent) -: QDeclarativeImplicitSizePaintedItem(*(new QDeclarativeTextEditPrivate), parent) +QDeclarative1TextEdit::QDeclarative1TextEdit(QDeclarativeItem *parent) +: QDeclarative1ImplicitSizePaintedItem(*(new QDeclarative1TextEditPrivate), parent) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->init(); } -QString QDeclarativeTextEdit::text() const +QString QDeclarative1TextEdit::text() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); #ifndef QT_NO_TEXTHTMLPARSER if (d->richText) @@ -245,10 +247,10 @@ QString QDeclarativeTextEdit::text() const automatically determine whether the text should be treated as rich text. This determination is made using Qt::mightBeRichText(). */ -void QDeclarativeTextEdit::setText(const QString &text) +void QDeclarative1TextEdit::setText(const QString &text) { - Q_D(QDeclarativeTextEdit); - if (QDeclarativeTextEdit::text() == text) + Q_D(QDeclarative1TextEdit); + if (QDeclarative1TextEdit::text() == text) return; d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text)); @@ -303,15 +305,15 @@ Column { \o \image declarative-textformat.png \endtable */ -QDeclarativeTextEdit::TextFormat QDeclarativeTextEdit::textFormat() const +QDeclarative1TextEdit::TextFormat QDeclarative1TextEdit::textFormat() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->format; } -void QDeclarativeTextEdit::setTextFormat(TextFormat format) +void QDeclarative1TextEdit::setTextFormat(TextFormat format) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (format == d->format) return; bool wasRich = d->richText; @@ -333,15 +335,15 @@ void QDeclarativeTextEdit::setTextFormat(TextFormat format) emit textFormatChanged(d->format); } -QFont QDeclarativeTextEdit::font() const +QFont QDeclarative1TextEdit::font() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->sourceFont; } -void QDeclarativeTextEdit::setFont(const QFont &font) +void QDeclarative1TextEdit::setFont(const QFont &font) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->sourceFont == font) return; @@ -382,15 +384,15 @@ void QDeclarativeTextEdit::setFont(const QFont &font) TextEdit { color: "steelblue" } \endqml */ -QColor QDeclarativeTextEdit::color() const +QColor QDeclarative1TextEdit::color() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->color; } -void QDeclarativeTextEdit::setColor(const QColor &color) +void QDeclarative1TextEdit::setColor(const QColor &color) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->color == color) return; @@ -408,15 +410,15 @@ void QDeclarativeTextEdit::setColor(const QColor &color) The text highlight color, used behind selections. */ -QColor QDeclarativeTextEdit::selectionColor() const +QColor QDeclarative1TextEdit::selectionColor() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->selectionColor; } -void QDeclarativeTextEdit::setSelectionColor(const QColor &color) +void QDeclarative1TextEdit::setSelectionColor(const QColor &color) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->selectionColor == color) return; @@ -434,15 +436,15 @@ void QDeclarativeTextEdit::setSelectionColor(const QColor &color) The selected text color, used in selections. */ -QColor QDeclarativeTextEdit::selectedTextColor() const +QColor QDeclarative1TextEdit::selectedTextColor() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->selectedTextColor; } -void QDeclarativeTextEdit::setSelectedTextColor(const QColor &color) +void QDeclarative1TextEdit::setSelectedTextColor(const QColor &color) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->selectedTextColor == color) return; @@ -485,15 +487,15 @@ void QDeclarativeTextEdit::setSelectedTextColor(const QColor &color) \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment of TextEdit, use the read-only property \c effectiveHorizontalAlignment. */ -QDeclarativeTextEdit::HAlignment QDeclarativeTextEdit::hAlign() const +QDeclarative1TextEdit::HAlignment QDeclarative1TextEdit::hAlign() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->hAlign; } -void QDeclarativeTextEdit::setHAlign(HAlignment align) +void QDeclarative1TextEdit::setHAlign(HAlignment align) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror; d->hAlignImplicit = false; if (d->setHAlign(align, forceAlign) && isComponentComplete()) { @@ -502,9 +504,9 @@ void QDeclarativeTextEdit::setHAlign(HAlignment align) } } -void QDeclarativeTextEdit::resetHAlign() +void QDeclarative1TextEdit::resetHAlign() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->hAlignImplicit = true; if (d->determineHorizontalAlignment() && isComponentComplete()) { d->updateDefaultTextOption(); @@ -512,17 +514,17 @@ void QDeclarativeTextEdit::resetHAlign() } } -QDeclarativeTextEdit::HAlignment QDeclarativeTextEdit::effectiveHAlign() const +QDeclarative1TextEdit::HAlignment QDeclarative1TextEdit::effectiveHAlign() const { - Q_D(const QDeclarativeTextEdit); - QDeclarativeTextEdit::HAlignment effectiveAlignment = d->hAlign; + Q_D(const QDeclarative1TextEdit); + QDeclarative1TextEdit::HAlignment effectiveAlignment = d->hAlign; if (!d->hAlignImplicit && d->effectiveLayoutMirror) { switch (d->hAlign) { - case QDeclarativeTextEdit::AlignLeft: - effectiveAlignment = QDeclarativeTextEdit::AlignRight; + case QDeclarative1TextEdit::AlignLeft: + effectiveAlignment = QDeclarative1TextEdit::AlignRight; break; - case QDeclarativeTextEdit::AlignRight: - effectiveAlignment = QDeclarativeTextEdit::AlignLeft; + case QDeclarative1TextEdit::AlignRight: + effectiveAlignment = QDeclarative1TextEdit::AlignLeft; break; default: break; @@ -531,11 +533,11 @@ QDeclarativeTextEdit::HAlignment QDeclarativeTextEdit::effectiveHAlign() const return effectiveAlignment; } -bool QDeclarativeTextEditPrivate::setHAlign(QDeclarativeTextEdit::HAlignment alignment, bool forceAlign) +bool QDeclarative1TextEditPrivate::setHAlign(QDeclarative1TextEdit::HAlignment alignment, bool forceAlign) { - Q_Q(QDeclarativeTextEdit); + Q_Q(QDeclarative1TextEdit); if (hAlign != alignment || forceAlign) { - QDeclarativeTextEdit::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); + QDeclarative1TextEdit::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); hAlign = alignment; emit q->horizontalAlignmentChanged(alignment); if (oldEffectiveHAlign != q->effectiveHAlign()) @@ -545,21 +547,21 @@ bool QDeclarativeTextEditPrivate::setHAlign(QDeclarativeTextEdit::HAlignment ali return false; } -bool QDeclarativeTextEditPrivate::determineHorizontalAlignment() +bool QDeclarative1TextEditPrivate::determineHorizontalAlignment() { - Q_Q(QDeclarativeTextEdit); + Q_Q(QDeclarative1TextEdit); if (hAlignImplicit && q->isComponentComplete()) { bool alignToRight = text.isEmpty() ? QApplication::keyboardInputDirection() == Qt::RightToLeft : rightToLeftText; - return setHAlign(alignToRight ? QDeclarativeTextEdit::AlignRight : QDeclarativeTextEdit::AlignLeft); + return setHAlign(alignToRight ? QDeclarative1TextEdit::AlignRight : QDeclarative1TextEdit::AlignLeft); } return false; } -void QDeclarativeTextEditPrivate::mirrorChange() +void QDeclarative1TextEditPrivate::mirrorChange() { - Q_Q(QDeclarativeTextEdit); + Q_Q(QDeclarative1TextEdit); if (q->isComponentComplete()) { - if (!hAlignImplicit && (hAlign == QDeclarativeTextEdit::AlignRight || hAlign == QDeclarativeTextEdit::AlignLeft)) { + if (!hAlignImplicit && (hAlign == QDeclarative1TextEdit::AlignRight || hAlign == QDeclarative1TextEdit::AlignLeft)) { updateDefaultTextOption(); q->updateSize(); emit q->effectiveHorizontalAlignmentChanged(); @@ -567,15 +569,15 @@ void QDeclarativeTextEditPrivate::mirrorChange() } } -QDeclarativeTextEdit::VAlignment QDeclarativeTextEdit::vAlign() const +QDeclarative1TextEdit::VAlignment QDeclarative1TextEdit::vAlign() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->vAlign; } -void QDeclarativeTextEdit::setVAlign(QDeclarativeTextEdit::VAlignment alignment) +void QDeclarative1TextEdit::setVAlign(QDeclarative1TextEdit::VAlignment alignment) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (alignment == d->vAlign) return; d->vAlign = alignment; @@ -600,15 +602,15 @@ void QDeclarativeTextEdit::setVAlign(QDeclarativeTextEdit::VAlignment alignment) The default is TextEdit.NoWrap. If you set a width, consider using TextEdit.Wrap. */ -QDeclarativeTextEdit::WrapMode QDeclarativeTextEdit::wrapMode() const +QDeclarative1TextEdit::WrapMode QDeclarative1TextEdit::wrapMode() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->wrapMode; } -void QDeclarativeTextEdit::setWrapMode(WrapMode mode) +void QDeclarative1TextEdit::setWrapMode(WrapMode mode) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (mode == d->wrapMode) return; d->wrapMode = mode; @@ -623,9 +625,9 @@ void QDeclarativeTextEdit::setWrapMode(WrapMode mode) Returns the total number of lines in the textEdit item. */ -int QDeclarativeTextEdit::lineCount() const +int QDeclarative1TextEdit::lineCount() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->lineCount; } @@ -635,9 +637,9 @@ int QDeclarativeTextEdit::lineCount() const Returns the width of the text, including the width past the width which is covered due to insufficient wrapping if \l wrapMode is set. */ -qreal QDeclarativeTextEdit::paintedWidth() const +qreal QDeclarative1TextEdit::paintedWidth() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->paintedSize.width(); } @@ -647,9 +649,9 @@ qreal QDeclarativeTextEdit::paintedWidth() const Returns the height of the text, including the height past the height that is covered if the text does not fit within the set height. */ -qreal QDeclarativeTextEdit::paintedHeight() const +qreal QDeclarative1TextEdit::paintedHeight() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->paintedSize.height(); } @@ -660,9 +662,9 @@ qreal QDeclarativeTextEdit::paintedHeight() const and height properties correspond to the cursor that would describe that position. */ -QRectF QDeclarativeTextEdit::positionToRectangle(int pos) const +QRectF QDeclarative1TextEdit::positionToRectangle(int pos) const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); QTextCursor c(d->document); c.setPosition(pos); return d->control->cursorRect(c); @@ -677,9 +679,9 @@ QRectF QDeclarativeTextEdit::positionToRectangle(int pos) const Position 0 is before the first character, position 1 is after the first character but before the second, and so on until position \l {text}.length, which is after all characters. */ -int QDeclarativeTextEdit::positionAt(int x, int y) const +int QDeclarative1TextEdit::positionAt(int x, int y) const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); int r = d->document->documentLayout()->hitTest(QPoint(x,y-d->yoff), Qt::FuzzyHit); QTextCursor cursor = d->control->textCursor(); if (r > cursor.position()) { @@ -700,10 +702,10 @@ int QDeclarativeTextEdit::positionAt(int x, int y) const return r; } -void QDeclarativeTextEdit::moveCursorSelection(int pos) +void QDeclarative1TextEdit::moveCursorSelection(int pos) { //Note that this is the same as setCursorPosition but with the KeepAnchor flag set - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); QTextCursor cursor = d->control->textCursor(); if (cursor.position() == pos) return; @@ -749,9 +751,9 @@ void QDeclarativeTextEdit::moveCursorSelection(int pos) The same sequence with TextEdit.SelectWords will extend the selection start to a word boundary before or on position 5 and extend the selection end to a word boundary on or past position 9. */ -void QDeclarativeTextEdit::moveCursorSelection(int pos, SelectionMode mode) +void QDeclarative1TextEdit::moveCursorSelection(int pos, SelectionMode mode) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); QTextCursor cursor = d->control->textCursor(); if (cursor.position() == pos) return; @@ -805,15 +807,15 @@ void QDeclarativeTextEdit::moveCursorSelection(int pos, SelectionMode mode) This property is set and unset when the text edit gets active focus, but it can also be set directly (useful, for example, if a KeyProxy might forward keys to it). */ -bool QDeclarativeTextEdit::isCursorVisible() const +bool QDeclarative1TextEdit::isCursorVisible() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->cursorVisible; } -void QDeclarativeTextEdit::setCursorVisible(bool on) +void QDeclarative1TextEdit::setCursorVisible(bool on) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->cursorVisible == on) return; d->cursorVisible = on; @@ -828,15 +830,15 @@ void QDeclarativeTextEdit::setCursorVisible(bool on) \qmlproperty int TextEdit::cursorPosition The position of the cursor in the TextEdit. */ -int QDeclarativeTextEdit::cursorPosition() const +int QDeclarative1TextEdit::cursorPosition() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->control->textCursor().position(); } -void QDeclarativeTextEdit::setCursorPosition(int pos) +void QDeclarative1TextEdit::setCursorPosition(int pos) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (pos < 0 || pos > d->text.length()) return; QTextCursor cursor = d->control->textCursor(); @@ -859,15 +861,15 @@ void QDeclarativeTextEdit::setCursorPosition(int pos) Note that the root item of the delegate component must be a QDeclarativeItem or QDeclarativeItem derived item. */ -QDeclarativeComponent* QDeclarativeTextEdit::cursorDelegate() const +QDeclarativeComponent* QDeclarative1TextEdit::cursorDelegate() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->cursorComponent; } -void QDeclarativeTextEdit::setCursorDelegate(QDeclarativeComponent* c) +void QDeclarative1TextEdit::setCursorDelegate(QDeclarativeComponent* c) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if(d->cursorComponent){ if(d->cursor){ d->control->setCursorWidth(-1); @@ -888,9 +890,9 @@ void QDeclarativeTextEdit::setCursorDelegate(QDeclarativeComponent* c) emit cursorDelegateChanged(); } -void QDeclarativeTextEdit::loadCursorDelegate() +void QDeclarative1TextEdit::loadCursorDelegate() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if(d->cursorComponent->isLoading()) return; d->cursor = qobject_cast(d->cursorComponent->create(qmlContext(this))); @@ -916,9 +918,9 @@ void QDeclarativeTextEdit::loadCursorDelegate() \sa selectionEnd, cursorPosition, selectedText */ -int QDeclarativeTextEdit::selectionStart() const +int QDeclarative1TextEdit::selectionStart() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->control->textCursor().selectionStart(); } @@ -932,9 +934,9 @@ int QDeclarativeTextEdit::selectionStart() const \sa selectionStart, cursorPosition, selectedText */ -int QDeclarativeTextEdit::selectionEnd() const +int QDeclarative1TextEdit::selectionEnd() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->control->textCursor().selectionEnd(); } @@ -952,9 +954,9 @@ int QDeclarativeTextEdit::selectionEnd() const myTextEdit.selectionEnd); \endcode */ -QString QDeclarativeTextEdit::selectedText() const +QString QDeclarative1TextEdit::selectedText() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->control->textCursor().selectedText(); } @@ -964,15 +966,15 @@ QString QDeclarativeTextEdit::selectedText() const Whether the TextEdit should gain active focus on a mouse press. By default this is set to true. */ -bool QDeclarativeTextEdit::focusOnPress() const +bool QDeclarative1TextEdit::focusOnPress() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->focusOnPress; } -void QDeclarativeTextEdit::setFocusOnPress(bool on) +void QDeclarative1TextEdit::setFocusOnPress(bool on) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->focusOnPress == on) return; d->focusOnPress = on; @@ -985,15 +987,15 @@ void QDeclarativeTextEdit::setFocusOnPress(bool on) Whether the TextEdit should keep the selection visible when it loses active focus to another item in the scene. By default this is set to true; */ -bool QDeclarativeTextEdit::persistentSelection() const +bool QDeclarative1TextEdit::persistentSelection() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->persistentSelection; } -void QDeclarativeTextEdit::setPersistentSelection(bool on) +void QDeclarative1TextEdit::setPersistentSelection(bool on) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->persistentSelection == on) return; d->persistentSelection = on; @@ -1005,15 +1007,15 @@ void QDeclarativeTextEdit::setPersistentSelection(bool on) The margin, in pixels, around the text in the TextEdit. */ -qreal QDeclarativeTextEdit::textMargin() const +qreal QDeclarative1TextEdit::textMargin() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->textMargin; } -void QDeclarativeTextEdit::setTextMargin(qreal margin) +void QDeclarative1TextEdit::setTextMargin(qreal margin) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->textMargin == margin) return; d->textMargin = margin; @@ -1021,22 +1023,22 @@ void QDeclarativeTextEdit::setTextMargin(qreal margin) emit textMarginChanged(d->textMargin); } -void QDeclarativeTextEdit::geometryChanged(const QRectF &newGeometry, +void QDeclarative1TextEdit::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { if (newGeometry.width() != oldGeometry.width()) updateSize(); - QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry); + QDeclarative1PaintedItem::geometryChanged(newGeometry, oldGeometry); } /*! Ensures any delayed caching or data loading the class needs to performed is complete. */ -void QDeclarativeTextEdit::componentComplete() +void QDeclarative1TextEdit::componentComplete() { - Q_D(QDeclarativeTextEdit); - QDeclarativePaintedItem::componentComplete(); + Q_D(QDeclarative1TextEdit); + QDeclarative1PaintedItem::componentComplete(); if (d->dirty) { d->determineHorizontalAlignment(); d->updateDefaultTextOption(); @@ -1055,15 +1057,15 @@ void QDeclarativeTextEdit::componentComplete() not be an appropriate interaction (eg. may conflict with how the text needs to behave inside a Flickable. */ -bool QDeclarativeTextEdit::selectByMouse() const +bool QDeclarative1TextEdit::selectByMouse() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->selectByMouse; } -void QDeclarativeTextEdit::setSelectByMouse(bool on) +void QDeclarative1TextEdit::setSelectByMouse(bool on) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->selectByMouse != on) { d->selectByMouse = on; setKeepMouseGrab(on); @@ -1090,15 +1092,15 @@ void QDeclarativeTextEdit::setSelectByMouse(bool on) This property only applies when \l selectByMouse is true. */ -QDeclarativeTextEdit::SelectionMode QDeclarativeTextEdit::mouseSelectionMode() const +QDeclarative1TextEdit::SelectionMode QDeclarative1TextEdit::mouseSelectionMode() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->mouseSelectionMode; } -void QDeclarativeTextEdit::setMouseSelectionMode(SelectionMode mode) +void QDeclarative1TextEdit::setMouseSelectionMode(SelectionMode mode) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->mouseSelectionMode != mode) { d->mouseSelectionMode = mode; d->control->setWordSelectionEnabled(mode == SelectWords); @@ -1114,9 +1116,9 @@ void QDeclarativeTextEdit::setMouseSelectionMode(SelectionMode mode) By default this property is false. */ -void QDeclarativeTextEdit::setReadOnly(bool r) +void QDeclarative1TextEdit::setReadOnly(bool r) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (r == isReadOnly()) return; @@ -1134,9 +1136,9 @@ void QDeclarativeTextEdit::setReadOnly(bool r) emit readOnlyChanged(r); } -bool QDeclarativeTextEdit::isReadOnly() const +bool QDeclarative1TextEdit::isReadOnly() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return !(d->control->textInteractionFlags() & Qt::TextEditable); } @@ -1144,9 +1146,9 @@ bool QDeclarativeTextEdit::isReadOnly() const Sets how the text edit should interact with user input to the given \a flags. */ -void QDeclarativeTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) +void QDeclarative1TextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->setTextInteractionFlags(flags); } @@ -1154,9 +1156,9 @@ void QDeclarativeTextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flag Returns the flags specifying how the text edit should interact with user input. */ -Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const +Qt::TextInteractionFlags QDeclarative1TextEdit::textInteractionFlags() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->control->textInteractionFlags(); } @@ -1166,9 +1168,9 @@ Qt::TextInteractionFlags QDeclarativeTextEdit::textInteractionFlags() const The rectangle where the text cursor is rendered within the text edit. Read-only. */ -QRect QDeclarativeTextEdit::cursorRectangle() const +QRect QDeclarative1TextEdit::cursorRectangle() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->control->cursorRect().toRect().translated(0,d->yoff); } @@ -1177,47 +1179,47 @@ QRect QDeclarativeTextEdit::cursorRectangle() const \overload Handles the given \a event. */ -bool QDeclarativeTextEdit::event(QEvent *event) +bool QDeclarative1TextEdit::event(QEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (event->type() == QEvent::ShortcutOverride) { d->control->processEvent(event, QPointF(0, -d->yoff)); return event->isAccepted(); } - return QDeclarativePaintedItem::event(event); + return QDeclarative1PaintedItem::event(event); } /*! \overload Handles the given key \a event. */ -void QDeclarativeTextEdit::keyPressEvent(QKeyEvent *event) +void QDeclarative1TextEdit::keyPressEvent(QKeyEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); keyPressPreHandler(event); if (!event->isAccepted()) d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) - QDeclarativePaintedItem::keyPressEvent(event); + QDeclarative1PaintedItem::keyPressEvent(event); } /*! \overload Handles the given key \a event. */ -void QDeclarativeTextEdit::keyReleaseEvent(QKeyEvent *event) +void QDeclarative1TextEdit::keyReleaseEvent(QKeyEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); keyReleasePreHandler(event); if (!event->isAccepted()) d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) - QDeclarativePaintedItem::keyReleaseEvent(event); + QDeclarative1PaintedItem::keyReleaseEvent(event); } -void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus) +void QDeclarative1TextEditPrivate::focusChanged(bool hasFocus) { - Q_Q(QDeclarativeTextEdit); + Q_Q(QDeclarative1TextEdit); q->setCursorVisible(hasFocus && scene && scene->hasFocus()); QDeclarativeItemPrivate::focusChanged(hasFocus); } @@ -1228,9 +1230,9 @@ void QDeclarativeTextEditPrivate::focusChanged(bool hasFocus) Removes active text selection. */ -void QDeclarativeTextEdit::deselect() +void QDeclarative1TextEdit::deselect() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); QTextCursor c = d->control->textCursor(); c.clearSelection(); d->control->setTextCursor(c); @@ -1241,9 +1243,9 @@ void QDeclarativeTextEdit::deselect() Causes all text to be selected. */ -void QDeclarativeTextEdit::selectAll() +void QDeclarative1TextEdit::selectAll() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->selectAll(); } @@ -1252,9 +1254,9 @@ void QDeclarativeTextEdit::selectAll() Causes the word closest to the current cursor position to be selected. */ -void QDeclarativeTextEdit::selectWord() +void QDeclarative1TextEdit::selectWord() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); QTextCursor c = d->control->textCursor(); c.select(QTextCursor::WordUnderCursor); d->control->setTextCursor(c); @@ -1273,9 +1275,9 @@ void QDeclarativeTextEdit::selectWord() \sa selectionStart, selectionEnd */ -void QDeclarativeTextEdit::select(int start, int end) +void QDeclarative1TextEdit::select(int start, int end) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (start < 0 || end < 0 || start > d->text.length() || end > d->text.length()) return; QTextCursor cursor = d->control->textCursor(); @@ -1295,9 +1297,9 @@ void QDeclarativeTextEdit::select(int start, int end) Returns true if the natural reading direction of the editor text found between positions \a start and \a end is right to left. */ -bool QDeclarativeTextEdit::isRightToLeft(int start, int end) +bool QDeclarative1TextEdit::isRightToLeft(int start, int end) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (start > end) { qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start."; return false; @@ -1312,9 +1314,9 @@ bool QDeclarativeTextEdit::isRightToLeft(int start, int end) Moves the currently selected text to the system clipboard. */ -void QDeclarativeTextEdit::cut() +void QDeclarative1TextEdit::cut() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->cut(); } @@ -1323,9 +1325,9 @@ void QDeclarativeTextEdit::cut() Copies the currently selected text to the system clipboard. */ -void QDeclarativeTextEdit::copy() +void QDeclarative1TextEdit::copy() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->copy(); } @@ -1334,9 +1336,9 @@ void QDeclarativeTextEdit::copy() Replaces the currently selected text by the contents of the system clipboard. */ -void QDeclarativeTextEdit::paste() +void QDeclarative1TextEdit::paste() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->paste(); } #endif // QT_NO_CLIPBOARD @@ -1345,9 +1347,9 @@ void QDeclarativeTextEdit::paste() \overload Handles the given mouse \a event. */ -void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (d->focusOnPress){ bool hadActiveFocus = hasActiveFocus(); forceActiveFocus(); @@ -1365,16 +1367,16 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) - QDeclarativePaintedItem::mousePressEvent(event); + QDeclarative1PaintedItem::mousePressEvent(event); } /*! \overload Handles the given mouse \a event. */ -void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->processEvent(event, QPointF(0, -d->yoff)); if (!d->showInputPanelOnFocus) { // input panel on click if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) { @@ -1388,20 +1390,20 @@ void QDeclarativeTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) d->clickCausedFocus = false; if (!event->isAccepted()) - QDeclarativePaintedItem::mouseReleaseEvent(event); + QDeclarative1PaintedItem::mouseReleaseEvent(event); } /*! \overload Handles the given mouse \a event. */ -void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) - QDeclarativePaintedItem::mouseDoubleClickEvent(event); + QDeclarative1PaintedItem::mouseDoubleClickEvent(event); } @@ -1409,21 +1411,21 @@ void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event \overload Handles the given mouse \a event. */ -void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->control->processEvent(event, QPointF(0, -d->yoff)); if (!event->isAccepted()) - QDeclarativePaintedItem::mouseMoveEvent(event); + QDeclarative1PaintedItem::mouseMoveEvent(event); } /*! \overload Handles the given input method \a event. */ -void QDeclarativeTextEdit::inputMethodEvent(QInputMethodEvent *event) +void QDeclarative1TextEdit::inputMethodEvent(QInputMethodEvent *event) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); const bool wasComposing = isInputMethodComposing(); d->control->processEvent(event, QPointF(0, -d->yoff)); if (wasComposing != isInputMethodComposing()) @@ -1434,9 +1436,9 @@ void QDeclarativeTextEdit::inputMethodEvent(QInputMethodEvent *event) \overload Returns the value of the given \a property. */ -QVariant QDeclarativeTextEdit::inputMethodQuery(Qt::InputMethodQuery property) const +QVariant QDeclarative1TextEdit::inputMethodQuery(Qt::InputMethodQuery property) const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->control->inputMethodQuery(property); } @@ -1444,9 +1446,9 @@ QVariant QDeclarativeTextEdit::inputMethodQuery(Qt::InputMethodQuery property) c Draws the contents of the text edit using the given \a painter within the given \a bounds. */ -void QDeclarativeTextEdit::drawContents(QPainter *painter, const QRect &bounds) +void QDeclarative1TextEdit::drawContents(QPainter *painter, const QRect &bounds) { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); painter->setRenderHint(QPainter::TextAntialiasing, true); painter->translate(0,d->yoff); @@ -1456,9 +1458,9 @@ void QDeclarativeTextEdit::drawContents(QPainter *painter, const QRect &bounds) painter->translate(0,-d->yoff); } -void QDeclarativeTextEdit::updateImgCache(const QRectF &rf) +void QDeclarative1TextEdit::updateImgCache(const QRectF &rf) { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); QRect r; if (!rf.isValid()) { r = QRect(0,0,INT_MAX,INT_MAX); @@ -1497,9 +1499,9 @@ void QDeclarativeTextEdit::updateImgCache(const QRectF &rf) Returns true if the TextEdit is writable and the content of the clipboard is suitable for pasting into the TextEdit. */ -bool QDeclarativeTextEdit::canPaste() const +bool QDeclarative1TextEdit::canPaste() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); return d->canPaste; } @@ -1516,17 +1518,17 @@ bool QDeclarativeTextEdit::canPaste() const to determine when to disable events handlers that may interfere with the correct operation of an input method. */ -bool QDeclarativeTextEdit::isInputMethodComposing() const +bool QDeclarative1TextEdit::isInputMethodComposing() const { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); if (QTextLayout *layout = d->control->textCursor().block().layout()) return layout->preeditAreaText().length() > 0; return false; } -void QDeclarativeTextEditPrivate::init() +void QDeclarative1TextEditPrivate::init() { - Q_Q(QDeclarativeTextEdit); + Q_Q(QDeclarative1TextEdit); q->setSmooth(smooth); q->setAcceptedMouseButtons(Qt::LeftButton); @@ -1535,7 +1537,7 @@ void QDeclarativeTextEditPrivate::init() control = new QTextControl(q); control->setIgnoreUnusedNavigationEvents(true); - control->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable); + control->setTextInteractionFlags(Qt::TextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable)); control->setDragEnabled(false); // QTextControl follows the default text color @@ -1570,9 +1572,9 @@ void QDeclarativeTextEditPrivate::init() updateDefaultTextOption(); } -void QDeclarativeTextEdit::q_textChanged() +void QDeclarative1TextEdit::q_textChanged() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); d->text = text(); d->rightToLeftText = d->document->begin().layout()->engine()->isRightToLeft(); d->determineHorizontalAlignment(); @@ -1582,9 +1584,9 @@ void QDeclarativeTextEdit::q_textChanged() emit textChanged(d->text); } -void QDeclarativeTextEdit::moveCursorDelegate() +void QDeclarative1TextEdit::moveCursorDelegate() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); updateMicroFocus(); emit cursorRectangleChanged(); if(!d->cursor) @@ -1594,9 +1596,9 @@ void QDeclarativeTextEdit::moveCursorDelegate() d->cursor->setY(cursorRect.y()); } -void QDeclarativeTextEditPrivate::updateSelection() +void QDeclarative1TextEditPrivate::updateSelection() { - Q_Q(QDeclarativeTextEdit); + Q_Q(QDeclarative1TextEdit); QTextCursor cursor = control->textCursor(); bool startChange = (lastSelectionStart != cursor.selectionStart()); bool endChange = (lastSelectionEnd != cursor.selectionEnd()); @@ -1611,9 +1613,9 @@ void QDeclarativeTextEditPrivate::updateSelection() q->selectionEndChanged(); } -void QDeclarativeTextEdit::updateSelectionMarkers() +void QDeclarative1TextEdit::updateSelectionMarkers() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if(d->lastSelectionStart != d->control->textCursor().selectionStart()){ d->lastSelectionStart = d->control->textCursor().selectionStart(); emit selectionStartChanged(); @@ -1624,10 +1626,10 @@ void QDeclarativeTextEdit::updateSelectionMarkers() } } -QRectF QDeclarativeTextEdit::boundingRect() const +QRectF QDeclarative1TextEdit::boundingRect() const { - Q_D(const QDeclarativeTextEdit); - QRectF r = QDeclarativePaintedItem::boundingRect(); + Q_D(const QDeclarative1TextEdit); + QRectF r = QDeclarative1PaintedItem::boundingRect(); int cursorWidth = 1; if(d->cursor) cursorWidth = d->cursor->width(); @@ -1640,23 +1642,23 @@ QRectF QDeclarativeTextEdit::boundingRect() const return r.translated(0,d->yoff); } -qreal QDeclarativeTextEditPrivate::implicitWidth() const +qreal QDeclarative1TextEditPrivate::implicitWidth() const { - Q_Q(const QDeclarativeTextEdit); + Q_Q(const QDeclarative1TextEdit); if (!requireImplicitWidth) { // We don't calculate implicitWidth unless it is required. // We need to force a size update now to ensure implicitWidth is calculated - const_cast(this)->requireImplicitWidth = true; - const_cast(q)->updateSize(); + const_cast(this)->requireImplicitWidth = true; + const_cast(q)->updateSize(); } return mImplicitWidth; } //### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't // need to do all the calculations each time -void QDeclarativeTextEdit::updateSize() +void QDeclarative1TextEdit::updateSize() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); if (isComponentComplete()) { qreal naturalWidth = d->mImplicitWidth; // ### assumes that if the width is set, the text will fill to edges @@ -1719,9 +1721,9 @@ void QDeclarativeTextEdit::updateSize() emit update(); } -void QDeclarativeTextEdit::updateTotalLines() +void QDeclarative1TextEdit::updateTotalLines() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); int subLines = 0; @@ -1739,18 +1741,18 @@ void QDeclarativeTextEdit::updateTotalLines() } } -void QDeclarativeTextEditPrivate::updateDefaultTextOption() +void QDeclarative1TextEditPrivate::updateDefaultTextOption() { - Q_Q(QDeclarativeTextEdit); + Q_Q(QDeclarative1TextEdit); QTextOption opt = document->defaultTextOption(); int oldAlignment = opt.alignment(); - QDeclarativeTextEdit::HAlignment horizontalAlignment = q->effectiveHAlign(); + QDeclarative1TextEdit::HAlignment horizontalAlignment = q->effectiveHAlign(); if (rightToLeftText) { - if (horizontalAlignment == QDeclarativeTextEdit::AlignLeft) - horizontalAlignment = QDeclarativeTextEdit::AlignRight; - else if (horizontalAlignment == QDeclarativeTextEdit::AlignRight) - horizontalAlignment = QDeclarativeTextEdit::AlignLeft; + if (horizontalAlignment == QDeclarative1TextEdit::AlignLeft) + horizontalAlignment = QDeclarative1TextEdit::AlignRight; + else if (horizontalAlignment == QDeclarative1TextEdit::AlignRight) + horizontalAlignment = QDeclarative1TextEdit::AlignLeft; } opt.setAlignment((Qt::Alignment)(int)(horizontalAlignment | vAlign)); @@ -1802,7 +1804,7 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption() } \endcode */ -void QDeclarativeTextEdit::openSoftwareInputPanel() +void QDeclarative1TextEdit::openSoftwareInputPanel() { QEvent event(QEvent::RequestSoftwareInputPanel); if (qApp) { @@ -1853,7 +1855,7 @@ void QDeclarativeTextEdit::openSoftwareInputPanel() } \endcode */ -void QDeclarativeTextEdit::closeSoftwareInputPanel() +void QDeclarative1TextEdit::closeSoftwareInputPanel() { QEvent event(QEvent::CloseSoftwareInputPanel); if (qApp) { @@ -1865,24 +1867,26 @@ void QDeclarativeTextEdit::closeSoftwareInputPanel() } } -void QDeclarativeTextEdit::focusInEvent(QFocusEvent *event) +void QDeclarative1TextEdit::focusInEvent(QFocusEvent *event) { - Q_D(const QDeclarativeTextEdit); + Q_D(const QDeclarative1TextEdit); if (d->showInputPanelOnFocus) { if (d->focusOnPress && !isReadOnly()) { openSoftwareInputPanel(); } } - QDeclarativePaintedItem::focusInEvent(event); + QDeclarative1PaintedItem::focusInEvent(event); } -void QDeclarativeTextEdit::q_canPasteChanged() +void QDeclarative1TextEdit::q_canPasteChanged() { - Q_D(QDeclarativeTextEdit); + Q_D(QDeclarative1TextEdit); bool old = d->canPaste; d->canPaste = d->control->canPaste(); if(old!=d->canPaste) emit canPasteChanged(); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/qtquick1/graphicsitems/qdeclarativetextedit_p.h similarity index 97% rename from src/declarative/graphicsitems/qdeclarativetextedit_p.h rename to src/qtquick1/graphicsitems/qdeclarativetextedit_p.h index f9a6c73a39..712d2f079f 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetextedit_p.h @@ -57,8 +57,8 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeTextEditPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativeImplicitSizePaintedItem +class QDeclarative1TextEditPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1TextEdit : public QDeclarative1ImplicitSizePaintedItem { Q_OBJECT Q_ENUMS(VAlignment) @@ -98,7 +98,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativeImplicitSizePa Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged REVISION 1) public: - QDeclarativeTextEdit(QDeclarativeItem *parent=0); + QDeclarative1TextEdit(QDeclarativeItem *parent=0); enum HAlignment { AlignLeft = Qt::AlignLeft, @@ -294,13 +294,13 @@ private Q_SLOTS: void drawContents(QPainter *, const QRect &); private: - Q_DISABLE_COPY(QDeclarativeTextEdit) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeTextEdit) + Q_DISABLE_COPY(QDeclarative1TextEdit) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1TextEdit) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeTextEdit) +QML_DECLARE_TYPE(QDeclarative1TextEdit) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/qtquick1/graphicsitems/qdeclarativetextedit_p_p.h similarity index 81% rename from src/declarative/graphicsitems/qdeclarativetextedit_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativetextedit_p_p.h index 731d956602..b370d5aeaa 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetextedit_p_p.h @@ -56,24 +56,25 @@ #include "qdeclarativeitem.h" #include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include +#include QT_BEGIN_NAMESPACE + class QTextLayout; class QTextDocument; class QTextControl; -class QDeclarativeTextEditPrivate : public QDeclarativeImplicitSizePaintedItemPrivate +class QDeclarative1TextEditPrivate : public QDeclarative1ImplicitSizePaintedItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeTextEdit) + Q_DECLARE_PUBLIC(QDeclarative1TextEdit) public: - QDeclarativeTextEditPrivate() - : color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop), + QDeclarative1TextEditPrivate() + : color("black"), hAlign(QDeclarative1TextEdit::AlignLeft), vAlign(QDeclarative1TextEdit::AlignTop), imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true), showInputPanelOnFocus(true), clickCausedFocus(false), persistentSelection(true), requireImplicitWidth(false), hAlignImplicit(true), rightToLeftText(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), - cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0), wrapMode(QDeclarativeTextEdit::NoWrap), - mouseSelectionMode(QDeclarativeTextEdit::SelectCharacters), selectByMouse(false), canPaste(false), + cursorComponent(0), cursor(0), format(QDeclarative1TextEdit::AutoText), document(0), wrapMode(QDeclarative1TextEdit::NoWrap), + mouseSelectionMode(QDeclarative1TextEdit::SelectCharacters), selectByMouse(false), canPaste(false), yoff(0) { #ifdef Q_OS_SYMBIAN @@ -89,7 +90,7 @@ class QDeclarativeTextEditPrivate : public QDeclarativeImplicitSizePaintedItemPr void relayoutDocument(); void updateSelection(); bool determineHorizontalAlignment(); - bool setHAlign(QDeclarativeTextEdit::HAlignment, bool forceAlign = false); + bool setHAlign(QDeclarative1TextEdit::HAlignment, bool forceAlign = false); void mirrorChange(); qreal implicitWidth() const; void focusChanged(bool); @@ -104,8 +105,8 @@ class QDeclarativeTextEditPrivate : public QDeclarativeImplicitSizePaintedItemPr QColor styleColor; QPixmap imgCache; QPixmap imgStyleCache; - QDeclarativeTextEdit::HAlignment hAlign; - QDeclarativeTextEdit::VAlignment vAlign; + QDeclarative1TextEdit::HAlignment hAlign; + QDeclarative1TextEdit::VAlignment vAlign; bool imgDirty : 1; bool dirty : 1; bool richText : 1; @@ -122,11 +123,11 @@ class QDeclarativeTextEditPrivate : public QDeclarativeImplicitSizePaintedItemPr int lastSelectionEnd; QDeclarativeComponent* cursorComponent; QDeclarativeItem* cursor; - QDeclarativeTextEdit::TextFormat format; + QDeclarative1TextEdit::TextFormat format; QTextDocument *document; QTextControl *control; - QDeclarativeTextEdit::WrapMode wrapMode; - QDeclarativeTextEdit::SelectionMode mouseSelectionMode; + QDeclarative1TextEdit::WrapMode wrapMode; + QDeclarative1TextEdit::SelectionMode mouseSelectionMode; int lineCount; bool selectByMouse; bool canPaste; diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp similarity index 82% rename from src/declarative/graphicsitems/qdeclarativetextinput.cpp rename to src/qtquick1/graphicsitems/qdeclarativetextinput.cpp index b456d07c02..53be1d3dfa 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp @@ -58,8 +58,10 @@ QT_BEGIN_NAMESPACE + + /*! - \qmlclass TextInput QDeclarativeTextInput + \qmlclass TextInput QDeclarative1TextInput \ingroup qml-basic-visual-elements \since 4.7 \brief The TextInput item displays an editable line of text. @@ -77,14 +79,14 @@ QT_BEGIN_NAMESPACE \sa TextEdit, Text, {declarative/text/textselection}{Text Selection example} */ -QDeclarativeTextInput::QDeclarativeTextInput(QDeclarativeItem* parent) - : QDeclarativeImplicitSizePaintedItem(*(new QDeclarativeTextInputPrivate), parent) +QDeclarative1TextInput::QDeclarative1TextInput(QDeclarativeItem* parent) + : QDeclarative1ImplicitSizePaintedItem(*(new QDeclarative1TextInputPrivate), parent) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->init(); } -QDeclarativeTextInput::~QDeclarativeTextInput() +QDeclarative1TextInput::~QDeclarative1TextInput() { } @@ -94,15 +96,15 @@ QDeclarativeTextInput::~QDeclarativeTextInput() The text in the TextInput. */ -QString QDeclarativeTextInput::text() const +QString QDeclarative1TextInput::text() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->text(); } -void QDeclarativeTextInput::setText(const QString &s) +void QDeclarative1TextInput::setText(const QString &s) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if(s == text()) return; d->control->setText(s); @@ -213,15 +215,15 @@ void QDeclarativeTextInput::setText(const QString &s) \endqml */ -QFont QDeclarativeTextInput::font() const +QFont QDeclarative1TextInput::font() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->sourceFont; } -void QDeclarativeTextInput::setFont(const QFont &font) +void QDeclarative1TextInput::setFont(const QFont &font) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->sourceFont == font) return; @@ -250,15 +252,15 @@ void QDeclarativeTextInput::setFont(const QFont &font) The text color. */ -QColor QDeclarativeTextInput::color() const +QColor QDeclarative1TextInput::color() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->color; } -void QDeclarativeTextInput::setColor(const QColor &c) +void QDeclarative1TextInput::setColor(const QColor &c) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (c != d->color) { d->color = c; clearCache(); @@ -273,15 +275,15 @@ void QDeclarativeTextInput::setColor(const QColor &c) The text highlight color, used behind selections. */ -QColor QDeclarativeTextInput::selectionColor() const +QColor QDeclarative1TextInput::selectionColor() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->selectionColor; } -void QDeclarativeTextInput::setSelectionColor(const QColor &color) +void QDeclarative1TextInput::setSelectionColor(const QColor &color) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->selectionColor == color) return; @@ -301,15 +303,15 @@ void QDeclarativeTextInput::setSelectionColor(const QColor &color) The highlighted text color, used in selections. */ -QColor QDeclarativeTextInput::selectedTextColor() const +QColor QDeclarative1TextInput::selectedTextColor() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->selectedTextColor; } -void QDeclarativeTextInput::setSelectedTextColor(const QColor &color) +void QDeclarative1TextInput::setSelectedTextColor(const QColor &color) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->selectedTextColor == color) return; @@ -347,15 +349,15 @@ void QDeclarativeTextInput::setSelectedTextColor(const QColor &color) \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment of TextInput, use the read-only property \c effectiveHorizontalAlignment. */ -QDeclarativeTextInput::HAlignment QDeclarativeTextInput::hAlign() const +QDeclarative1TextInput::HAlignment QDeclarative1TextInput::hAlign() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->hAlign; } -void QDeclarativeTextInput::setHAlign(HAlignment align) +void QDeclarative1TextInput::setHAlign(HAlignment align) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror; d->hAlignImplicit = false; if (d->setHAlign(align, forceAlign) && isComponentComplete()) { @@ -363,26 +365,26 @@ void QDeclarativeTextInput::setHAlign(HAlignment align) } } -void QDeclarativeTextInput::resetHAlign() +void QDeclarative1TextInput::resetHAlign() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->hAlignImplicit = true; if (d->determineHorizontalAlignment() && isComponentComplete()) { updateCursorRectangle(); } } -QDeclarativeTextInput::HAlignment QDeclarativeTextInput::effectiveHAlign() const +QDeclarative1TextInput::HAlignment QDeclarative1TextInput::effectiveHAlign() const { - Q_D(const QDeclarativeTextInput); - QDeclarativeTextInput::HAlignment effectiveAlignment = d->hAlign; + Q_D(const QDeclarative1TextInput); + QDeclarative1TextInput::HAlignment effectiveAlignment = d->hAlign; if (!d->hAlignImplicit && d->effectiveLayoutMirror) { switch (d->hAlign) { - case QDeclarativeTextInput::AlignLeft: - effectiveAlignment = QDeclarativeTextInput::AlignRight; + case QDeclarative1TextInput::AlignLeft: + effectiveAlignment = QDeclarative1TextInput::AlignRight; break; - case QDeclarativeTextInput::AlignRight: - effectiveAlignment = QDeclarativeTextInput::AlignLeft; + case QDeclarative1TextInput::AlignRight: + effectiveAlignment = QDeclarative1TextInput::AlignLeft; break; default: break; @@ -391,11 +393,11 @@ QDeclarativeTextInput::HAlignment QDeclarativeTextInput::effectiveHAlign() const return effectiveAlignment; } -bool QDeclarativeTextInputPrivate::setHAlign(QDeclarativeTextInput::HAlignment alignment, bool forceAlign) +bool QDeclarative1TextInputPrivate::setHAlign(QDeclarative1TextInput::HAlignment alignment, bool forceAlign) { - Q_Q(QDeclarativeTextInput); - if ((hAlign != alignment || forceAlign) && alignment <= QDeclarativeTextInput::AlignHCenter) { // justify not supported - QDeclarativeTextInput::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); + Q_Q(QDeclarative1TextInput); + if ((hAlign != alignment || forceAlign) && alignment <= QDeclarative1TextInput::AlignHCenter) { // justify not supported + QDeclarative1TextInput::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); hAlign = alignment; emit q->horizontalAlignmentChanged(alignment); if (oldEffectiveHAlign != q->effectiveHAlign()) @@ -405,22 +407,22 @@ bool QDeclarativeTextInputPrivate::setHAlign(QDeclarativeTextInput::HAlignment a return false; } -bool QDeclarativeTextInputPrivate::determineHorizontalAlignment() +bool QDeclarative1TextInputPrivate::determineHorizontalAlignment() { if (hAlignImplicit) { // if no explicit alignment has been set, follow the natural layout direction of the text QString text = control->text(); bool isRightToLeft = text.isEmpty() ? QApplication::keyboardInputDirection() == Qt::RightToLeft : text.isRightToLeft(); - return setHAlign(isRightToLeft ? QDeclarativeTextInput::AlignRight : QDeclarativeTextInput::AlignLeft); + return setHAlign(isRightToLeft ? QDeclarative1TextInput::AlignRight : QDeclarative1TextInput::AlignLeft); } return false; } -void QDeclarativeTextInputPrivate::mirrorChange() +void QDeclarative1TextInputPrivate::mirrorChange() { - Q_Q(QDeclarativeTextInput); + Q_Q(QDeclarative1TextInput); if (q->isComponentComplete()) { - if (!hAlignImplicit && (hAlign == QDeclarativeTextInput::AlignRight || hAlign == QDeclarativeTextInput::AlignLeft)) { + if (!hAlignImplicit && (hAlign == QDeclarative1TextInput::AlignRight || hAlign == QDeclarative1TextInput::AlignLeft)) { q->updateCursorRectangle(); emit q->effectiveHorizontalAlignmentChanged(); } @@ -437,15 +439,15 @@ void QDeclarativeTextInputPrivate::mirrorChange() work. */ -bool QDeclarativeTextInput::isReadOnly() const +bool QDeclarative1TextInput::isReadOnly() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->isReadOnly(); } -void QDeclarativeTextInput::setReadOnly(bool ro) +void QDeclarative1TextInput::setReadOnly(bool ro) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->control->isReadOnly() == ro) return; @@ -463,15 +465,15 @@ void QDeclarativeTextInput::setReadOnly(bool ro) By default, this property contains a value of 32767. */ -int QDeclarativeTextInput::maxLength() const +int QDeclarative1TextInput::maxLength() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->maxLength(); } -void QDeclarativeTextInput::setMaxLength(int ml) +void QDeclarative1TextInput::setMaxLength(int ml) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->control->maxLength() == ml) return; @@ -506,15 +508,15 @@ void QDeclarativeTextInput::setMaxLength(int ml) In the above snippet the cursor will still become visible when the TextInput gains active focus. */ -bool QDeclarativeTextInput::isCursorVisible() const +bool QDeclarative1TextInput::isCursorVisible() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->cursorVisible; } -void QDeclarativeTextInput::setCursorVisible(bool on) +void QDeclarative1TextInput::setCursorVisible(bool on) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->cursorVisible == on) return; d->cursorVisible = on; @@ -531,14 +533,14 @@ void QDeclarativeTextInput::setCursorVisible(bool on) \qmlproperty int TextInput::cursorPosition The position of the cursor in the TextInput. */ -int QDeclarativeTextInput::cursorPosition() const +int QDeclarative1TextInput::cursorPosition() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->cursor(); } -void QDeclarativeTextInput::setCursorPosition(int cp) +void QDeclarative1TextInput::setCursorPosition(int cp) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (cp < 0 || cp > d->control->text().length()) return; d->control->moveCursor(cp); @@ -548,9 +550,9 @@ void QDeclarativeTextInput::setCursorPosition(int cp) Returns a Rect which encompasses the cursor, but which may be larger than is required. Ignores custom cursor delegates. */ -QRect QDeclarativeTextInput::cursorRectangle() const +QRect QDeclarative1TextInput::cursorRectangle() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); QRect r = d->control->cursorRect(); // Scroll and make consistent with TextEdit // QLineControl inexplicably adds 1 to the height and horizontal padding @@ -571,9 +573,9 @@ QRect QDeclarativeTextInput::cursorRectangle() const \sa selectionEnd, cursorPosition, selectedText, select() */ -int QDeclarativeTextInput::selectionStart() const +int QDeclarative1TextInput::selectionStart() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->lastSelectionStart; } @@ -589,9 +591,9 @@ int QDeclarativeTextInput::selectionStart() const \sa selectionStart, cursorPosition, selectedText, select() */ -int QDeclarativeTextInput::selectionEnd() const +int QDeclarative1TextInput::selectionEnd() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->lastSelectionEnd; } @@ -608,9 +610,9 @@ int QDeclarativeTextInput::selectionEnd() const \sa selectionStart, selectionEnd */ -void QDeclarativeTextInput::select(int start, int end) +void QDeclarative1TextInput::select(int start, int end) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (start < 0 || end < 0 || start > d->control->text().length() || end > d->control->text().length()) return; d->control->setSelection(start, end-start); @@ -630,9 +632,9 @@ void QDeclarativeTextInput::select(int start, int end) myTextInput.selectionEnd); \endjs */ -QString QDeclarativeTextInput::selectedText() const +QString QDeclarative1TextInput::selectedText() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->selectedText(); } @@ -642,15 +644,15 @@ QString QDeclarativeTextInput::selectedText() const Whether the TextInput should gain active focus on a mouse press. By default this is set to true. */ -bool QDeclarativeTextInput::focusOnPress() const +bool QDeclarative1TextInput::focusOnPress() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->focusOnPress; } -void QDeclarativeTextInput::setFocusOnPress(bool b) +void QDeclarative1TextInput::setFocusOnPress(bool b) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->focusOnPress == b) return; @@ -665,15 +667,15 @@ void QDeclarativeTextInput::setFocusOnPress(bool b) Whether the TextInput should scroll when the text is longer than the width. By default this is set to true. */ -bool QDeclarativeTextInput::autoScroll() const +bool QDeclarative1TextInput::autoScroll() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->autoScroll; } -void QDeclarativeTextInput::setAutoScroll(bool b) +void QDeclarative1TextInput::setAutoScroll(bool b) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->autoScroll == b) return; @@ -788,16 +790,16 @@ void QDeclarativeTextInput::setAutoScroll(bool b) \sa acceptableInput, inputMask */ #ifndef QT_NO_VALIDATOR -QValidator* QDeclarativeTextInput::validator() const +QValidator* QDeclarative1TextInput::validator() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); //###const cast isn't good, but needed for property system? return const_cast(d->control->validator()); } -void QDeclarativeTextInput::setValidator(QValidator* v) +void QDeclarative1TextInput::setValidator(QValidator* v) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->control->validator() == v) return; @@ -820,15 +822,15 @@ void QDeclarativeTextInput::setValidator(QValidator* v) \sa acceptableInput, validator */ -QString QDeclarativeTextInput::inputMask() const +QString QDeclarative1TextInput::inputMask() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->inputMask(); } -void QDeclarativeTextInput::setInputMask(const QString &im) +void QDeclarative1TextInput::setInputMask(const QString &im) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->control->inputMask() == im) return; @@ -844,9 +846,9 @@ void QDeclarativeTextInput::setInputMask(const QString &im) if the current text is acceptable to the validator or input mask as a final string (not as an intermediate string). */ -bool QDeclarativeTextInput::hasAcceptableInput() const +bool QDeclarative1TextInput::hasAcceptableInput() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->hasAcceptableInput(); } @@ -859,17 +861,19 @@ bool QDeclarativeTextInput::hasAcceptableInput() const state. */ -void QDeclarativeTextInputPrivate::updateInputMethodHints() +void QDeclarative1TextInputPrivate::updateInputMethodHints() { - Q_Q(QDeclarativeTextInput); + Q_Q(QDeclarative1TextInput); Qt::InputMethodHints hints = inputMethodHints; uint echo = control->echoMode(); - if (echo == QDeclarativeTextInput::Password || echo == QDeclarativeTextInput::NoEcho) + if (echo == QDeclarative1TextInput::Password || echo == QDeclarative1TextInput::NoEcho) hints |= Qt::ImhHiddenText; - else if (echo == QDeclarativeTextInput::PasswordEchoOnEdit) + else if (echo == QDeclarative1TextInput::PasswordEchoOnEdit) hints &= ~Qt::ImhHiddenText; - if (echo != QDeclarativeTextInput::Normal) - hints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + if (echo != QDeclarative1TextInput::Normal) { + hints |= Qt::ImhNoAutoUppercase; + hints |= Qt::ImhNoPredictiveText; + } q->setInputMethodHints(hints); } @@ -884,15 +888,15 @@ void QDeclarativeTextInputPrivate::updateInputMethodHints() \o TextInput.PasswordEchoOnEdit - Displays all but the current character as asterixes. \endlist */ -QDeclarativeTextInput::EchoMode QDeclarativeTextInput::echoMode() const +QDeclarative1TextInput::EchoMode QDeclarative1TextInput::echoMode() const { - Q_D(const QDeclarativeTextInput); - return (QDeclarativeTextInput::EchoMode)d->control->echoMode(); + Q_D(const QDeclarative1TextInput); + return (QDeclarative1TextInput::EchoMode)d->control->echoMode(); } -void QDeclarativeTextInput::setEchoMode(QDeclarativeTextInput::EchoMode echo) +void QDeclarative1TextInput::setEchoMode(QDeclarative1TextInput::EchoMode echo) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (echoMode() == echo) return; d->control->setEchoMode((uint)echo); @@ -901,15 +905,15 @@ void QDeclarativeTextInput::setEchoMode(QDeclarativeTextInput::EchoMode echo) emit echoModeChanged(echoMode()); } -Qt::InputMethodHints QDeclarativeTextInput::imHints() const +Qt::InputMethodHints QDeclarative1TextInput::imHints() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->inputMethodHints; } -void QDeclarativeTextInput::setIMHints(Qt::InputMethodHints hints) +void QDeclarative1TextInput::setIMHints(Qt::InputMethodHints hints) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->inputMethodHints == hints) return; d->inputMethodHints = hints; @@ -929,15 +933,15 @@ void QDeclarativeTextInput::setIMHints(Qt::InputMethodHints hints) Note that the root item of the delegate component must be a QDeclarativeItem or QDeclarativeItem derived item. */ -QDeclarativeComponent* QDeclarativeTextInput::cursorDelegate() const +QDeclarativeComponent* QDeclarative1TextInput::cursorDelegate() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->cursorComponent; } -void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c) +void QDeclarative1TextInput::setCursorDelegate(QDeclarativeComponent* c) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->cursorComponent == c) return; @@ -952,22 +956,22 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c) emit cursorDelegateChanged(); } -void QDeclarativeTextInputPrivate::startCreatingCursor() +void QDeclarative1TextInputPrivate::startCreatingCursor() { - Q_Q(QDeclarativeTextInput); + Q_Q(QDeclarative1TextInput); if(cursorComponent->isReady()){ q->createCursor(); }else if(cursorComponent->isLoading()){ q->connect(cursorComponent, SIGNAL(statusChanged(int)), q, SLOT(createCursor())); }else {//isError - qmlInfo(q, cursorComponent->errors()) << QDeclarativeTextInput::tr("Could not load cursor delegate"); + qmlInfo(q, cursorComponent->errors()) << QDeclarative1TextInput::tr("Could not load cursor delegate"); } } -void QDeclarativeTextInput::createCursor() +void QDeclarative1TextInput::createCursor() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if(d->cursorComponent->isError()){ qmlInfo(this, d->cursorComponent->errors()) << tr("Could not load cursor delegate"); return; @@ -999,9 +1003,9 @@ void QDeclarativeTextInput::createCursor() This is similar to setting the cursorPosition, and then querying the cursor rectangle, but the cursorPosition is not changed. */ -QRectF QDeclarativeTextInput::positionToRectangle(int pos) const +QRectF QDeclarative1TextInput::positionToRectangle(int pos) const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); if (pos > d->control->cursorPosition()) pos += d->control->preeditAreaText().length(); return QRectF(d->control->cursorToX(pos)-d->hscroll, @@ -1010,7 +1014,7 @@ QRectF QDeclarativeTextInput::positionToRectangle(int pos) const cursorRectangle().height()); } -int QDeclarativeTextInput::positionAt(int x) const +int QDeclarative1TextInput::positionAt(int x) const { return positionAt(x, CursorBetweenCharacters); } @@ -1034,9 +1038,9 @@ int QDeclarativeTextInput::positionAt(int x) const \o TextInput.CursorOnCharacter - Returns the position before the character that is nearest x. \endlist */ -int QDeclarativeTextInput::positionAt(int x, CursorPosition position) const +int QDeclarative1TextInput::positionAt(int x, CursorPosition position) const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); int pos = d->control->xToPos(x + d->hscroll, QTextLine::CursorPosition(position)); const int cursor = d->control->cursor(); if (pos > cursor) { @@ -1048,21 +1052,21 @@ int QDeclarativeTextInput::positionAt(int x, CursorPosition position) const return pos; } -void QDeclarativeTextInputPrivate::focusChanged(bool hasFocus) +void QDeclarative1TextInputPrivate::focusChanged(bool hasFocus) { - Q_Q(QDeclarativeTextInput); + Q_Q(QDeclarative1TextInput); focused = hasFocus; q->setCursorVisible(hasFocus && scene && scene->hasFocus()); - if(q->echoMode() == QDeclarativeTextInput::PasswordEchoOnEdit && !hasFocus) + if(q->echoMode() == QDeclarative1TextInput::PasswordEchoOnEdit && !hasFocus) control->updatePasswordEchoEditing(false);//QLineControl sets it on key events, but doesn't deal with focus events if (!hasFocus) control->deselect(); QDeclarativeItemPrivate::focusChanged(hasFocus); } -void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev) +void QDeclarative1TextInput::keyPressEvent(QKeyEvent* ev) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); keyPressPreHandler(ev); if (ev->isAccepted()) return; @@ -1084,12 +1088,12 @@ void QDeclarativeTextInput::keyPressEvent(QKeyEvent* ev) d->control->processKeyEvent(ev); } if (!ev->isAccepted()) - QDeclarativePaintedItem::keyPressEvent(ev); + QDeclarative1PaintedItem::keyPressEvent(ev); } -void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev) +void QDeclarative1TextInput::inputMethodEvent(QInputMethodEvent *ev) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); ev->ignore(); const bool wasComposing = d->control->preeditAreaText().length() > 0; inputMethodPreHandler(ev); @@ -1101,7 +1105,7 @@ void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev) } } if (!ev->isAccepted()) - QDeclarativePaintedItem::inputMethodEvent(ev); + QDeclarative1PaintedItem::inputMethodEvent(ev); if (wasComposing != (d->control->preeditAreaText().length() > 0)) emit inputMethodComposingChanged(); @@ -1111,9 +1115,9 @@ void QDeclarativeTextInput::inputMethodEvent(QInputMethodEvent *ev) \overload Handles the given mouse \a event. */ -void QDeclarativeTextInput::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextInput::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonDblClick)) return; if (d->selectByMouse) { @@ -1121,13 +1125,13 @@ void QDeclarativeTextInput::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even d->control->selectWordAtPos(cursor); event->setAccepted(true); } else { - QDeclarativePaintedItem::mouseDoubleClickEvent(event); + QDeclarative1PaintedItem::mouseDoubleClickEvent(event); } } -void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonPress)) return; if(d->focusOnPress){ @@ -1155,9 +1159,9 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) event->setAccepted(true); } -void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->sendMouseEventToInputContext(event, QEvent::MouseMove)) return; if (d->selectPressed) { @@ -1166,7 +1170,7 @@ void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) moveCursorSelection(d->xToPos(event->pos().x()), d->mouseSelectionMode); event->setAccepted(true); } else { - QDeclarativePaintedItem::mouseMoveEvent(event); + QDeclarative1PaintedItem::mouseMoveEvent(event); } } @@ -1174,9 +1178,9 @@ void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) \overload Handles the given mouse \a event. */ -void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void QDeclarative1TextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonRelease)) return; if (d->selectPressed) { @@ -1195,10 +1199,10 @@ void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) d->clickCausedFocus = false; d->control->processEvent(event); if (!event->isAccepted()) - QDeclarativePaintedItem::mouseReleaseEvent(event); + QDeclarative1PaintedItem::mouseReleaseEvent(event); } -bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext( +bool QDeclarative1TextInputPrivate::sendMouseEventToInputContext( QGraphicsSceneMouseEvent *event, QEvent::Type eventType) { #if !defined QT_NO_IM @@ -1236,9 +1240,9 @@ bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext( return false; } -bool QDeclarativeTextInput::sceneEvent(QEvent *event) +bool QDeclarative1TextInput::sceneEvent(QEvent *event) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); bool rv = QDeclarativeItem::sceneEvent(event); if (event->type() == QEvent::UngrabMouse) { d->selectPressed = false; @@ -1247,9 +1251,9 @@ bool QDeclarativeTextInput::sceneEvent(QEvent *event) return rv; } -bool QDeclarativeTextInput::event(QEvent* ev) +bool QDeclarative1TextInput::event(QEvent* ev) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); //Anything we don't deal with ourselves, pass to the control bool handled = false; switch(ev->type()){ @@ -1265,35 +1269,35 @@ bool QDeclarativeTextInput::event(QEvent* ev) handled = d->control->processEvent(ev); } if(!handled) - handled = QDeclarativePaintedItem::event(ev); + handled = QDeclarative1PaintedItem::event(ev); return handled; } -void QDeclarativeTextInput::geometryChanged(const QRectF &newGeometry, +void QDeclarative1TextInput::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (newGeometry.width() != oldGeometry.width()) { updateSize(); updateCursorRectangle(); } - QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry); + QDeclarative1PaintedItem::geometryChanged(newGeometry, oldGeometry); } -int QDeclarativeTextInputPrivate::calculateTextWidth() +int QDeclarative1TextInputPrivate::calculateTextWidth() { return qRound(control->naturalTextWidth()); } -void QDeclarativeTextInputPrivate::updateHorizontalScroll() +void QDeclarative1TextInputPrivate::updateHorizontalScroll() { - Q_Q(QDeclarativeTextInput); + Q_Q(QDeclarative1TextInput); const int preeditLength = control->preeditAreaText().length(); int cix = qRound(control->cursorToX(control->cursor() + preeditLength)); QRect br(q->boundingRect().toRect()); int widthUsed = calculateTextWidth(); - QDeclarativeTextInput::HAlignment effectiveHAlign = q->effectiveHAlign(); + QDeclarative1TextInput::HAlignment effectiveHAlign = q->effectiveHAlign(); if (autoScroll) { if (widthUsed <= br.width()) { // text fits in br; use hscroll for alignment @@ -1330,10 +1334,10 @@ void QDeclarativeTextInputPrivate::updateHorizontalScroll() } } else { switch (effectiveHAlign) { - case QDeclarativeTextInput::AlignRight: + case QDeclarative1TextInput::AlignRight: hscroll = q->width() - widthUsed; break; - case QDeclarativeTextInput::AlignHCenter: + case QDeclarative1TextInput::AlignHCenter: hscroll = (q->width() - widthUsed) / 2; break; default: @@ -1344,9 +1348,9 @@ void QDeclarativeTextInputPrivate::updateHorizontalScroll() } } -void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r) +void QDeclarative1TextInput::drawContents(QPainter *p, const QRect &r) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); p->setRenderHint(QPainter::TextAntialiasing, true); p->save(); p->setPen(QPen(d->color)); @@ -1372,9 +1376,9 @@ void QDeclarativeTextInput::drawContents(QPainter *p, const QRect &r) \overload Returns the value of the given \a property. */ -QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property) const +QVariant QDeclarative1TextInput::inputMethodQuery(Qt::InputMethodQuery property) const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); switch(property) { case Qt::ImMicroFocus: return cursorRectangle(); @@ -1409,9 +1413,9 @@ QVariant QDeclarativeTextInput::inputMethodQuery(Qt::InputMethodQuery property) Removes active text selection. */ -void QDeclarativeTextInput::deselect() +void QDeclarative1TextInput::deselect() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->control->deselect(); } @@ -1420,9 +1424,9 @@ void QDeclarativeTextInput::deselect() Causes all text to be selected. */ -void QDeclarativeTextInput::selectAll() +void QDeclarative1TextInput::selectAll() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->control->setSelection(0, d->control->text().length()); } @@ -1432,9 +1436,9 @@ void QDeclarativeTextInput::selectAll() Returns true if the natural reading direction of the editor text found between positions \a start and \a end is right to left. */ -bool QDeclarativeTextInput::isRightToLeft(int start, int end) +bool QDeclarative1TextInput::isRightToLeft(int start, int end) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (start > end) { qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start."; return false; @@ -1449,9 +1453,9 @@ bool QDeclarativeTextInput::isRightToLeft(int start, int end) Moves the currently selected text to the system clipboard. */ -void QDeclarativeTextInput::cut() +void QDeclarative1TextInput::cut() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->control->copy(); d->control->del(); } @@ -1461,9 +1465,9 @@ void QDeclarativeTextInput::cut() Copies the currently selected text to the system clipboard. */ -void QDeclarativeTextInput::copy() +void QDeclarative1TextInput::copy() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->control->copy(); } @@ -1472,9 +1476,9 @@ void QDeclarativeTextInput::copy() Replaces the currently selected text by the contents of the system clipboard. */ -void QDeclarativeTextInput::paste() +void QDeclarative1TextInput::paste() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if(!d->control->isReadOnly()) d->control->paste(); } @@ -1485,9 +1489,9 @@ void QDeclarativeTextInput::paste() Causes the word closest to the current cursor position to be selected. */ -void QDeclarativeTextInput::selectWord() +void QDeclarative1TextInput::selectWord() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->control->selectWordAtPos(d->control->cursor()); } @@ -1515,15 +1519,15 @@ void QDeclarativeTextInput::selectWord() the first character is used. If the string is empty, the value is ignored and the property is not set. */ -QString QDeclarativeTextInput::passwordCharacter() const +QString QDeclarative1TextInput::passwordCharacter() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return QString(d->control->passwordCharacter()); } -void QDeclarativeTextInput::setPasswordCharacter(const QString &str) +void QDeclarative1TextInput::setPasswordCharacter(const QString &str) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if(str.length() < 1) return; d->control->setPasswordCharacter(str.constData()[0]); @@ -1544,9 +1548,9 @@ void QDeclarativeTextInput::setPasswordCharacter(const QString &str) this property holds the text visible to the user, while the \l text property holds the actual entered text. */ -QString QDeclarativeTextInput::displayText() const +QString QDeclarative1TextInput::displayText() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->displayText(); } @@ -1560,15 +1564,15 @@ QString QDeclarativeTextInput::displayText() const not be an appropriate interaction (eg. may conflict with how the text needs to behave inside a Flickable. */ -bool QDeclarativeTextInput::selectByMouse() const +bool QDeclarative1TextInput::selectByMouse() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->selectByMouse; } -void QDeclarativeTextInput::setSelectByMouse(bool on) +void QDeclarative1TextInput::setSelectByMouse(bool on) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->selectByMouse != on) { d->selectByMouse = on; emit selectByMouseChanged(on); @@ -1589,15 +1593,15 @@ void QDeclarativeTextInput::setSelectByMouse(bool on) This property only applies when \l selectByMouse is true. */ -QDeclarativeTextInput::SelectionMode QDeclarativeTextInput::mouseSelectionMode() const +QDeclarative1TextInput::SelectionMode QDeclarative1TextInput::mouseSelectionMode() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->mouseSelectionMode; } -void QDeclarativeTextInput::setMouseSelectionMode(SelectionMode mode) +void QDeclarative1TextInput::setMouseSelectionMode(SelectionMode mode) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (d->mouseSelectionMode != mode) { d->mouseSelectionMode = mode; emit mouseSelectionModeChanged(mode); @@ -1611,15 +1615,15 @@ void QDeclarativeTextInput::setMouseSelectionMode(SelectionMode mode) Returns true if the TextInput is writable and the content of the clipboard is suitable for pasting into the TextEdit. */ -bool QDeclarativeTextInput::canPaste() const +bool QDeclarative1TextInput::canPaste() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->canPaste; } -void QDeclarativeTextInput::moveCursorSelection(int position) +void QDeclarative1TextInput::moveCursorSelection(int position) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->control->moveCursor(position, true); } @@ -1661,9 +1665,9 @@ void QDeclarativeTextInput::moveCursorSelection(int position) The same sequence with TextInput.SelectWords will extend the selection start to a word boundary before or on position 5 and extend the selection end to a word boundary on or past position 9. */ -void QDeclarativeTextInput::moveCursorSelection(int pos, SelectionMode mode) +void QDeclarative1TextInput::moveCursorSelection(int pos, SelectionMode mode) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if (mode == SelectCharacters) { d->control->moveCursor(pos, true); @@ -1756,7 +1760,7 @@ void QDeclarativeTextInput::moveCursorSelection(int pos, SelectionMode mode) } \endqml */ -void QDeclarativeTextInput::openSoftwareInputPanel() +void QDeclarative1TextInput::openSoftwareInputPanel() { QEvent event(QEvent::RequestSoftwareInputPanel); if (qApp) { @@ -1807,7 +1811,7 @@ void QDeclarativeTextInput::openSoftwareInputPanel() } \endqml */ -void QDeclarativeTextInput::closeSoftwareInputPanel() +void QDeclarative1TextInput::closeSoftwareInputPanel() { QEvent event(QEvent::CloseSoftwareInputPanel); if (qApp) { @@ -1820,15 +1824,15 @@ void QDeclarativeTextInput::closeSoftwareInputPanel() } } -void QDeclarativeTextInput::focusInEvent(QFocusEvent *event) +void QDeclarative1TextInput::focusInEvent(QFocusEvent *event) { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); if (d->showInputPanelOnFocus) { if (d->focusOnPress && !isReadOnly()) { openSoftwareInputPanel(); } } - QDeclarativePaintedItem::focusInEvent(event); + QDeclarative1PaintedItem::focusInEvent(event); } /*! @@ -1844,15 +1848,15 @@ void QDeclarativeTextInput::focusInEvent(QFocusEvent *event) used to determine when to disable events handlers that may interfere with the correct operation of an input method. */ -bool QDeclarativeTextInput::isInputMethodComposing() const +bool QDeclarative1TextInput::isInputMethodComposing() const { - Q_D(const QDeclarativeTextInput); + Q_D(const QDeclarative1TextInput); return d->control->preeditAreaText().length() > 0; } -void QDeclarativeTextInputPrivate::init() +void QDeclarative1TextInputPrivate::init() { - Q_Q(QDeclarativeTextInput); + Q_Q(QDeclarative1TextInput); control->setParent(q);//Now mandatory due to accessibility changes control->setCursorWidth(1); control->setPasswordCharacter(QLatin1Char('*')); @@ -1891,9 +1895,9 @@ void QDeclarativeTextInputPrivate::init() determineHorizontalAlignment(); } -void QDeclarativeTextInput::cursorPosChanged() +void QDeclarative1TextInput::cursorPosChanged() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); updateCursorRectangle(); emit cursorPositionChanged(); d->control->resetCursorBlinkTimer(); @@ -1910,9 +1914,9 @@ void QDeclarativeTextInput::cursorPosChanged() } } -void QDeclarativeTextInput::updateCursorRectangle() +void QDeclarative1TextInput::updateCursorRectangle() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); d->updateHorizontalScroll(); updateRect();//TODO: Only update rect between pos's updateMicroFocus(); @@ -1921,9 +1925,9 @@ void QDeclarativeTextInput::updateCursorRectangle() d->cursorItem->setX(d->control->cursorToX() - d->hscroll); } -void QDeclarativeTextInput::selectionChanged() +void QDeclarative1TextInput::selectionChanged() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); updateRect();//TODO: Only update rect in selection emit selectedTextChanged(); @@ -1941,9 +1945,9 @@ void QDeclarativeTextInput::selectionChanged() } } -void QDeclarativeTextInput::q_textChanged() +void QDeclarative1TextInput::q_textChanged() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); updateSize(); d->determineHorizontalAlignment(); d->updateHorizontalScroll(); @@ -1956,9 +1960,9 @@ void QDeclarativeTextInput::q_textChanged() } } -void QDeclarativeTextInput::updateRect(const QRect &r) +void QDeclarative1TextInput::updateRect(const QRect &r) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); if(r == QRect()) clearCache(); else @@ -1966,10 +1970,10 @@ void QDeclarativeTextInput::updateRect(const QRect &r) update(); } -QRectF QDeclarativeTextInput::boundingRect() const +QRectF QDeclarative1TextInput::boundingRect() const { - Q_D(const QDeclarativeTextInput); - QRectF r = QDeclarativePaintedItem::boundingRect(); + Q_D(const QDeclarative1TextInput); + QRectF r = QDeclarative1PaintedItem::boundingRect(); int cursorWidth = d->cursorItem ? d->cursorItem->width() : d->control->cursorWidth(); @@ -1979,9 +1983,9 @@ QRectF QDeclarativeTextInput::boundingRect() const return r; } -void QDeclarativeTextInput::updateSize(bool needsRedraw) +void QDeclarative1TextInput::updateSize(bool needsRedraw) { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); int w = width(); int h = height(); setImplicitHeight(d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text. @@ -1993,9 +1997,9 @@ void QDeclarativeTextInput::updateSize(bool needsRedraw) } } -void QDeclarativeTextInput::q_canPasteChanged() +void QDeclarative1TextInput::q_canPasteChanged() { - Q_D(QDeclarativeTextInput); + Q_D(QDeclarative1TextInput); bool old = d->canPaste; #ifndef QT_NO_CLIPBOARD d->canPaste = !d->control->isReadOnly() && QApplication::clipboard()->text().length() != 0; @@ -2004,6 +2008,8 @@ void QDeclarativeTextInput::q_canPasteChanged() emit canPasteChanged(); } + + QT_END_NAMESPACE #endif // QT_NO_LINEEDIT diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/qtquick1/graphicsitems/qdeclarativetextinput_p.h similarity index 97% rename from src/declarative/graphicsitems/qdeclarativetextinput_p.h rename to src/qtquick1/graphicsitems/qdeclarativetextinput_p.h index 8b7fff9cfb..562d1bf08a 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetextinput_p.h @@ -56,9 +56,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeTextInputPrivate; class QValidator; -class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativeImplicitSizePaintedItem +class QDeclarative1TextInputPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1TextInput : public QDeclarative1ImplicitSizePaintedItem { Q_OBJECT Q_ENUMS(HAlignment) @@ -100,8 +100,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInput : public QDeclarativeImplicitSizeP Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged REVISION 1) public: - QDeclarativeTextInput(QDeclarativeItem* parent=0); - ~QDeclarativeTextInput(); + QDeclarative1TextInput(QDeclarativeItem* parent=0); + ~QDeclarative1TextInput(); enum EchoMode {//To match QLineEdit::EchoMode Normal, @@ -286,12 +286,12 @@ private Q_SLOTS: void q_canPasteChanged(); private: - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeTextInput) + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1TextInput) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeTextInput) +QML_DECLARE_TYPE(QDeclarative1TextInput) #ifndef QT_NO_VALIDATOR QML_DECLARE_TYPE(QValidator) QML_DECLARE_TYPE(QIntValidator) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/qtquick1/graphicsitems/qdeclarativetextinput_p_p.h similarity index 82% rename from src/declarative/graphicsitems/qdeclarativetextinput_p_p.h rename to src/qtquick1/graphicsitems/qdeclarativetextinput_p_p.h index 947ddc7bfa..4132db65f3 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetextinput_p_p.h @@ -46,7 +46,7 @@ #include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include +#include #include @@ -66,14 +66,14 @@ QT_BEGIN_NAMESPACE -class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplicitSizePaintedItemPrivate +class Q_AUTOTEST_EXPORT QDeclarative1TextInputPrivate : public QDeclarative1ImplicitSizePaintedItemPrivate { - Q_DECLARE_PUBLIC(QDeclarativeTextInput) + Q_DECLARE_PUBLIC(QDeclarative1TextInput) public: - QDeclarativeTextInputPrivate() : control(new QLineControl), - color((QRgb)0), style(QDeclarativeText::Normal), - styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft), - mouseSelectionMode(QDeclarativeTextInput::SelectCharacters), inputMethodHints(Qt::ImhNone), + QDeclarative1TextInputPrivate() : control(new QLineControl), + color((QRgb)0), style(QDeclarative1Text::Normal), + styleColor((QRgb)0), hAlign(QDeclarative1TextInput::AlignLeft), + mouseSelectionMode(QDeclarative1TextInput::SelectCharacters), inputMethodHints(Qt::ImhNone), hscroll(0), oldScroll(0), oldValidity(false), focused(false), focusOnPress(true), showInputPanelOnFocus(true), clickCausedFocus(false), cursorVisible(false), autoScroll(true), selectByMouse(false), canPaste(false), hAlignImplicit(true), @@ -86,13 +86,13 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplic #endif } - ~QDeclarativeTextInputPrivate() + ~QDeclarative1TextInputPrivate() { } int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const { - Q_Q(const QDeclarativeTextInput); + Q_Q(const QDeclarative1TextInput); QRect cr = q->boundingRect().toRect(); x-= cr.x() - hscroll; return control->xToPos(x, betweenOrOn); @@ -103,7 +103,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplic void focusChanged(bool hasFocus); void updateHorizontalScroll(); bool determineHorizontalAlignment(); - bool setHAlign(QDeclarativeTextInput::HAlignment, bool forceAlign = false); + bool setHAlign(QDeclarative1TextInput::HAlignment, bool forceAlign = false); void mirrorChange(); int calculateTextWidth(); bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType); @@ -116,10 +116,10 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplic QColor color; QColor selectionColor; QColor selectedTextColor; - QDeclarativeText::TextStyle style; + QDeclarative1Text::TextStyle style; QColor styleColor; - QDeclarativeTextInput::HAlignment hAlign; - QDeclarativeTextInput::SelectionMode mouseSelectionMode; + QDeclarative1TextInput::HAlignment hAlign; + QDeclarative1TextInput::SelectionMode mouseSelectionMode; Qt::InputMethodHints inputMethodHints; QPointer cursorComponent; QPointer cursorItem; @@ -143,7 +143,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextInputPrivate : public QDeclarativeImplic bool hAlignImplicit:1; bool selectPressed:1; - static inline QDeclarativeTextInputPrivate *get(QDeclarativeTextInput *t) { + static inline QDeclarative1TextInputPrivate *get(QDeclarative1TextInput *t) { return t->d_func(); } }; diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp b/src/qtquick1/graphicsitems/qdeclarativetextlayout.cpp similarity index 91% rename from src/declarative/graphicsitems/qdeclarativetextlayout.cpp rename to src/qtquick1/graphicsitems/qdeclarativetextlayout.cpp index e7bcf1f460..454b611783 100644 --- a/src/declarative/graphicsitems/qdeclarativetextlayout.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetextlayout.cpp @@ -48,10 +48,18 @@ QT_BEGIN_NAMESPACE -class QDeclarativeTextLayoutPrivate +// Defined in qpainter.cpp +extern Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray, + const QFixedPoint *positions, int glyphCount, + QFontEngine *fontEngine, const QFont &font, + const QTextCharFormat &charFormat); + + + +class QDeclarative1TextLayoutPrivate { public: - QDeclarativeTextLayoutPrivate() + QDeclarative1TextLayoutPrivate() : cached(false) {} QPointF position; @@ -161,13 +169,13 @@ class DrawTextItemRecorder: public QPaintEngine return User; } - void begin(QDeclarativeTextLayoutPrivate *t) { + void begin(QDeclarative1TextLayoutPrivate *t) { m_inertText = t; m_dirtyPen = false; } private: - QDeclarativeTextLayoutPrivate *m_inertText; + QDeclarative1TextLayoutPrivate *m_inertText; bool m_dirtyPen; bool m_useBackendOptimizations; @@ -189,7 +197,7 @@ class DrawTextItemDevice: public QPaintDevice delete m_paintEngine; } - void begin(QDeclarativeTextLayoutPrivate *t) { + void begin(QDeclarative1TextLayoutPrivate *t) { m_paintEngine->begin(t); } @@ -245,36 +253,36 @@ struct InertTextPainter { Q_GLOBAL_STATIC(InertTextPainter, inertTextPainter); /*! -\class QDeclarativeTextLayout -\brief The QDeclarativeTextLayout class is a version of QStaticText that works with QTextLayouts. +\class QDeclarative1TextLayout +\brief The QDeclarative1TextLayout class is a version of QStaticText that works with QTextLayouts. \internal This class is basically a copy of the QStaticText code, but it is adapted to source its text from QTextLayout. -It is also considerably faster to create a QDeclarativeTextLayout than a QStaticText because it uses +It is also considerably faster to create a QDeclarative1TextLayout than a QStaticText because it uses a single, shared QPainter instance. QStaticText by comparison creates a new QPainter per instance. -As a consequence this means that QDeclarativeTextLayout is not re-enterant. Adding a lock around +As a consequence this means that QDeclarative1TextLayout is not re-enterant. Adding a lock around the shared painter solves this, and only introduces a minor performance penalty, but is unnecessary -for QDeclarativeTextLayout's current use (QDeclarativeText is already tied to the GUI thread). +for QDeclarative1TextLayout's current use (QDeclarative1Text is already tied to the GUI thread). */ -QDeclarativeTextLayout::QDeclarativeTextLayout() +QDeclarative1TextLayout::QDeclarative1TextLayout() : d(0) { } -QDeclarativeTextLayout::QDeclarativeTextLayout(const QString &text) +QDeclarative1TextLayout::QDeclarative1TextLayout(const QString &text) : QTextLayout(text), d(0) { } -QDeclarativeTextLayout::~QDeclarativeTextLayout() +QDeclarative1TextLayout::~QDeclarative1TextLayout() { if (d) delete d; } -void QDeclarativeTextLayout::beginLayout() +void QDeclarative1TextLayout::beginLayout() { if (d && d->cached) { d->cached = false; @@ -287,7 +295,7 @@ void QDeclarativeTextLayout::beginLayout() QTextLayout::beginLayout(); } -void QDeclarativeTextLayout::clearLayout() +void QDeclarative1TextLayout::clearLayout() { if (d && d->cached) { d->cached = false; @@ -300,12 +308,12 @@ void QDeclarativeTextLayout::clearLayout() QTextLayout::clearLayout(); } -void QDeclarativeTextLayout::prepare() +void QDeclarative1TextLayout::prepare() { if (!d || !d->cached) { if (!d) - d = new QDeclarativeTextLayoutPrivate; + d = new QDeclarative1TextLayoutPrivate; InertTextPainter *itp = inertTextPainter(); itp->device.begin(d); @@ -327,13 +335,7 @@ void QDeclarativeTextLayout::prepare() } } -// Defined in qpainter.cpp -extern Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray, - const QFixedPoint *positions, int glyphCount, - QFontEngine *fontEngine, const QFont &font, - const QTextCharFormat &charFormat); - -void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p) +void QDeclarative1TextLayout::draw(QPainter *painter, const QPointF &p) { QPainterPrivate *priv = QPainterPrivate::get(painter); @@ -387,5 +389,7 @@ void QDeclarativeTextLayout::draw(QPainter *painter, const QPointF &p) painter->setPen(oldPen); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetextlayout_p.h b/src/qtquick1/graphicsitems/qdeclarativetextlayout_p.h similarity index 89% rename from src/declarative/graphicsitems/qdeclarativetextlayout_p.h rename to src/qtquick1/graphicsitems/qdeclarativetextlayout_p.h index d83ce7e4ce..bfedbec958 100644 --- a/src/declarative/graphicsitems/qdeclarativetextlayout_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetextlayout_p.h @@ -50,13 +50,13 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeTextLayoutPrivate; -class QDeclarativeTextLayout : public QTextLayout +class QDeclarative1TextLayoutPrivate; +class QDeclarative1TextLayout : public QTextLayout { public: - QDeclarativeTextLayout(); - QDeclarativeTextLayout(const QString &); - ~QDeclarativeTextLayout(); + QDeclarative1TextLayout(); + QDeclarative1TextLayout(const QString &); + ~QDeclarative1TextLayout(); void beginLayout(); void clearLayout(); @@ -65,7 +65,7 @@ class QDeclarativeTextLayout : public QTextLayout void draw(QPainter *, const QPointF & = QPointF()); private: - QDeclarativeTextLayoutPrivate *d; + QDeclarative1TextLayoutPrivate *d; }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/qtquick1/graphicsitems/qdeclarativetranslate.cpp similarity index 74% rename from src/declarative/graphicsitems/qdeclarativetranslate.cpp rename to src/qtquick1/graphicsitems/qdeclarativetranslate.cpp index 186a56aef6..66173efc6c 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativetranslate.cpp @@ -46,46 +46,48 @@ QT_BEGIN_NAMESPACE -class QDeclarativeTranslatePrivate : public QGraphicsTransformPrivate + + +class QDeclarative1TranslatePrivate : public QGraphicsTransformPrivate { public: - QDeclarativeTranslatePrivate() + QDeclarative1TranslatePrivate() : x(0), y(0) {} qreal x; qreal y; }; /*! - Constructs an empty QDeclarativeTranslate object with the given \a parent. + Constructs an empty QDeclarative1Translate object with the given \a parent. */ -QDeclarativeTranslate::QDeclarativeTranslate(QObject *parent) - : QGraphicsTransform(*new QDeclarativeTranslatePrivate, parent) +QDeclarative1Translate::QDeclarative1Translate(QObject *parent) + : QGraphicsTransform(*new QDeclarative1TranslatePrivate, parent) { } /*! Destroys the graphics scale. */ -QDeclarativeTranslate::~QDeclarativeTranslate() +QDeclarative1Translate::~QDeclarative1Translate() { } /*! - \property QDeclarativeTranslate::x + \property QDeclarative1Translate::x \brief the horizontal translation. The translation can be any real number; the default value is 0.0. \sa y */ -qreal QDeclarativeTranslate::x() const +qreal QDeclarative1Translate::x() const { - Q_D(const QDeclarativeTranslate); + Q_D(const QDeclarative1Translate); return d->x; } -void QDeclarativeTranslate::setX(qreal x) +void QDeclarative1Translate::setX(qreal x) { - Q_D(QDeclarativeTranslate); + Q_D(QDeclarative1Translate); if (d->x == x) return; d->x = x; @@ -94,21 +96,21 @@ void QDeclarativeTranslate::setX(qreal x) } /*! - \property QDeclarativeTranslate::y + \property QDeclarative1Translate::y \brief the vertical translation. The translation can be any real number; the default value is 0.0. \sa x */ -qreal QDeclarativeTranslate::y() const +qreal QDeclarative1Translate::y() const { - Q_D(const QDeclarativeTranslate); + Q_D(const QDeclarative1Translate); return d->y; } -void QDeclarativeTranslate::setY(qreal y) +void QDeclarative1Translate::setY(qreal y) { - Q_D(QDeclarativeTranslate); + Q_D(QDeclarative1Translate); if (d->y == y) return; d->y = y; @@ -116,10 +118,12 @@ void QDeclarativeTranslate::setY(qreal y) emit yChanged(); } -void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const +void QDeclarative1Translate::applyTo(QMatrix4x4 *matrix) const { - Q_D(const QDeclarativeTranslate); + Q_D(const QDeclarative1Translate); matrix->translate(d->x, d->y, 0); } + + QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetranslate_p.h b/src/qtquick1/graphicsitems/qdeclarativetranslate_p.h similarity index 87% rename from src/declarative/graphicsitems/qdeclarativetranslate_p.h rename to src/qtquick1/graphicsitems/qdeclarativetranslate_p.h index b67ff229a1..be5cd74486 100644 --- a/src/declarative/graphicsitems/qdeclarativetranslate_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativetranslate_p.h @@ -50,9 +50,9 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeTranslatePrivate; +class QDeclarative1TranslatePrivate; -class Q_AUTOTEST_EXPORT QDeclarativeTranslate : public QGraphicsTransform +class Q_AUTOTEST_EXPORT QDeclarative1Translate : public QGraphicsTransform { Q_OBJECT @@ -60,8 +60,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeTranslate : public QGraphicsTransform Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) public: - QDeclarativeTranslate(QObject *parent = 0); - ~QDeclarativeTranslate(); + QDeclarative1Translate(QObject *parent = 0); + ~QDeclarative1Translate(); qreal x() const; void setX(qreal); @@ -76,13 +76,13 @@ class Q_AUTOTEST_EXPORT QDeclarativeTranslate : public QGraphicsTransform void yChanged(); private: - Q_DECLARE_PRIVATE(QDeclarativeTranslate) - Q_DISABLE_COPY(QDeclarativeTranslate) + Q_DECLARE_PRIVATE(QDeclarative1Translate) + Q_DISABLE_COPY(QDeclarative1Translate) }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeTranslate) +QML_DECLARE_TYPE(QDeclarative1Translate) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp similarity index 71% rename from src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp rename to src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp index 26757b57ec..e712ca1888 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -39,68 +39,70 @@ ** ****************************************************************************/ -#include "private/qdeclarativevisualitemmodel_p.h" - -#include "qdeclarativeitem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" + +#include "QtQuick1/qdeclarativeitem.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include #include #include -#include +#include #include #include QT_BEGIN_NAMESPACE -QHash QDeclarativeVisualItemModelAttached::attachedProperties; -class QDeclarativeVisualItemModelPrivate : public QObjectPrivate +QHash QDeclarative1VisualItemModelAttached::attachedProperties; + + +class QDeclarative1VisualItemModelPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QDeclarativeVisualItemModel) + Q_DECLARE_PUBLIC(QDeclarative1VisualItemModel) public: - QDeclarativeVisualItemModelPrivate() : QObjectPrivate() {} + QDeclarative1VisualItemModelPrivate() : QObjectPrivate() {} static void children_append(QDeclarativeListProperty *prop, QDeclarativeItem *item) { QDeclarative_setParent_noEvent(item, prop->object); - static_cast(prop->data)->children.append(Item(item)); - static_cast(prop->data)->itemAppended(); - static_cast(prop->data)->emitChildrenChanged(); + static_cast(prop->data)->children.append(Item(item)); + static_cast(prop->data)->itemAppended(); + static_cast(prop->data)->emitChildrenChanged(); } static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->data)->children.count(); + return static_cast(prop->data)->children.count(); } static QDeclarativeItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->data)->children.at(index).item; + return static_cast(prop->data)->children.at(index).item; } void itemAppended() { - Q_Q(QDeclarativeVisualItemModel); - QDeclarativeVisualItemModelAttached *attached = QDeclarativeVisualItemModelAttached::properties(children.last().item); + Q_Q(QDeclarative1VisualItemModel); + QDeclarative1VisualItemModelAttached *attached = QDeclarative1VisualItemModelAttached::properties(children.last().item); attached->setIndex(children.count()-1); emit q->itemsInserted(children.count()-1, 1); emit q->countChanged(); } void emitChildrenChanged() { - Q_Q(QDeclarativeVisualItemModel); + Q_Q(QDeclarative1VisualItemModel); emit q->childrenChanged(); } @@ -127,7 +129,7 @@ class QDeclarativeVisualItemModelPrivate : public QObjectPrivate /*! - \qmlclass VisualItemModel QDeclarativeVisualItemModel + \qmlclass VisualItemModel QDeclarative1VisualItemModel \ingroup qml-working-with-data \since 4.7 \brief The VisualItemModel allows items to be provided to a view. @@ -163,8 +165,8 @@ class QDeclarativeVisualItemModelPrivate : public QObjectPrivate \sa {declarative/modelviews/visualitemmodel}{VisualItemModel example} */ -QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(QObject *parent) - : QDeclarativeVisualModel(*(new QDeclarativeVisualItemModelPrivate), parent) +QDeclarative1VisualItemModel::QDeclarative1VisualItemModel(QObject *parent) + : QDeclarative1VisualModel(*(new QDeclarative1VisualItemModelPrivate), parent) { } @@ -175,9 +177,9 @@ QDeclarativeVisualItemModel::QDeclarativeVisualItemModel(QObject *parent) It is attached to each instance of the delegate. */ -QDeclarativeListProperty QDeclarativeVisualItemModel::children() +QDeclarativeListProperty QDeclarative1VisualItemModel::children() { - Q_D(QDeclarativeVisualItemModel); + Q_D(QDeclarative1VisualItemModel); return QDeclarativeListProperty(this, d, d->children_append, d->children_count, d->children_at); } @@ -187,28 +189,28 @@ QDeclarativeListProperty QDeclarativeVisualItemModel::children The number of items in the model. This property is readonly. */ -int QDeclarativeVisualItemModel::count() const +int QDeclarative1VisualItemModel::count() const { - Q_D(const QDeclarativeVisualItemModel); + Q_D(const QDeclarative1VisualItemModel); return d->children.count(); } -bool QDeclarativeVisualItemModel::isValid() const +bool QDeclarative1VisualItemModel::isValid() const { return true; } -QDeclarativeItem *QDeclarativeVisualItemModel::item(int index, bool) +QDeclarativeItem *QDeclarative1VisualItemModel::item(int index, bool) { - Q_D(QDeclarativeVisualItemModel); - QDeclarativeVisualItemModelPrivate::Item &item = d->children[index]; + Q_D(QDeclarative1VisualItemModel); + QDeclarative1VisualItemModelPrivate::Item &item = d->children[index]; item.addRef(); return item.item; } -QDeclarativeVisualModel::ReleaseFlags QDeclarativeVisualItemModel::release(QDeclarativeItem *item) +QDeclarative1VisualModel::ReleaseFlags QDeclarative1VisualItemModel::release(QDeclarativeItem *item) { - Q_D(QDeclarativeVisualItemModel); + Q_D(QDeclarative1VisualItemModel); int idx = d->indexOf(item); if (idx >= 0) { if (d->children[idx].deref()) { @@ -220,61 +222,61 @@ QDeclarativeVisualModel::ReleaseFlags QDeclarativeVisualItemModel::release(QDecl return 0; } -bool QDeclarativeVisualItemModel::completePending() const +bool QDeclarative1VisualItemModel::completePending() const { return false; } -void QDeclarativeVisualItemModel::completeItem() +void QDeclarative1VisualItemModel::completeItem() { // Nothing to do } -QString QDeclarativeVisualItemModel::stringValue(int index, const QString &name) +QString QDeclarative1VisualItemModel::stringValue(int index, const QString &name) { - Q_D(QDeclarativeVisualItemModel); + Q_D(QDeclarative1VisualItemModel); if (index < 0 || index >= d->children.count()) return QString(); return QDeclarativeEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString(); } -int QDeclarativeVisualItemModel::indexOf(QDeclarativeItem *item, QObject *) const +int QDeclarative1VisualItemModel::indexOf(QDeclarativeItem *item, QObject *) const { - Q_D(const QDeclarativeVisualItemModel); + Q_D(const QDeclarative1VisualItemModel); return d->indexOf(item); } -QDeclarativeVisualItemModelAttached *QDeclarativeVisualItemModel::qmlAttachedProperties(QObject *obj) +QDeclarative1VisualItemModelAttached *QDeclarative1VisualItemModel::qmlAttachedProperties(QObject *obj) { - return QDeclarativeVisualItemModelAttached::properties(obj); + return QDeclarative1VisualItemModelAttached::properties(obj); } //============================================================================ -class VDMDelegateDataType : public QDeclarativeOpenMetaObjectType +class VDMDelegateDataType : public QDeclarative1OpenMetaObjectType { public: - VDMDelegateDataType(const QMetaObject *base, QDeclarativeEngine *engine) : QDeclarativeOpenMetaObjectType(base, engine) {} + VDMDelegateDataType(const QMetaObject *base, QDeclarativeEngine *engine) : QDeclarative1OpenMetaObjectType(base, engine) {} void propertyCreated(int, QMetaPropertyBuilder &prop) { prop.setWritable(false); } }; -class QDeclarativeVisualDataModelParts; -class QDeclarativeVisualDataModelData; -class QDeclarativeVisualDataModelPrivate : public QObjectPrivate +class QDeclarative1VisualDataModelParts; +class QDeclarative1VisualDataModelData; +class QDeclarative1VisualDataModelPrivate : public QObjectPrivate { public: - QDeclarativeVisualDataModelPrivate(QDeclarativeContext *); + QDeclarative1VisualDataModelPrivate(QDeclarativeContext *); - static QDeclarativeVisualDataModelPrivate *get(QDeclarativeVisualDataModel *m) { - return static_cast(QObjectPrivate::get(m)); + static QDeclarative1VisualDataModelPrivate *get(QDeclarative1VisualDataModel *m) { + return static_cast(QObjectPrivate::get(m)); } QDeclarativeGuard m_listModelInterface; QDeclarativeGuard m_abstractItemModel; - QDeclarativeGuard m_visualItemModel; + QDeclarativeGuard m_visualItemModel; QString m_part; QDeclarativeComponent *m_delegate; @@ -297,7 +299,7 @@ class QDeclarativeVisualDataModelPrivate : public QObjectPrivate m_roleNames.insert("hasModelChildren", -1); } else if (m_listAccessor) { m_roleNames.insert("modelData", 0); - if (m_listAccessor->type() == QDeclarativeListAccessor::Instance) { + if (m_listAccessor->type() == QDeclarative1ListAccessor::Instance) { if (QObject *object = m_listAccessor->at(0).value()) { int count = object->metaObject()->propertyCount(); for (int ii = 1; ii < count; ++ii) { @@ -385,47 +387,47 @@ class QDeclarativeVisualDataModelPrivate : public QObjectPrivate } Cache m_cache; - QHash m_packaged; + QHash m_packaged; - QDeclarativeVisualDataModelParts *m_parts; - friend class QDeclarativeVisualItemParts; + QDeclarative1VisualDataModelParts *m_parts; + friend class QDeclarative1VisualItemParts; VDMDelegateDataType *m_delegateDataType; - friend class QDeclarativeVisualDataModelData; + friend class QDeclarative1VisualDataModelData; bool m_metaDataCreated : 1; bool m_metaDataCacheable : 1; bool m_delegateValidated : 1; bool m_completePending : 1; - QDeclarativeVisualDataModelData *data(QObject *item); + QDeclarative1VisualDataModelData *data(QObject *item); QVariant m_modelVariant; - QDeclarativeListAccessor *m_listAccessor; + QDeclarative1ListAccessor *m_listAccessor; QModelIndex m_root; QList watchedRoles; QList watchedRoleIds; }; -class QDeclarativeVisualDataModelDataMetaObject : public QDeclarativeOpenMetaObject +class QDeclarative1VisualDataModelDataMetaObject : public QDeclarative1OpenMetaObject { public: - QDeclarativeVisualDataModelDataMetaObject(QObject *parent, QDeclarativeOpenMetaObjectType *type) - : QDeclarativeOpenMetaObject(parent, type) {} + QDeclarative1VisualDataModelDataMetaObject(QObject *parent, QDeclarative1OpenMetaObjectType *type) + : QDeclarative1OpenMetaObject(parent, type) {} virtual QVariant initialValue(int); virtual int createProperty(const char *, const char *); private: - friend class QDeclarativeVisualDataModelData; + friend class QDeclarative1VisualDataModelData; }; -class QDeclarativeVisualDataModelData : public QObject +class QDeclarative1VisualDataModelData : public QObject { Q_OBJECT public: - QDeclarativeVisualDataModelData(int index, QDeclarativeVisualDataModel *model); - ~QDeclarativeVisualDataModelData(); + QDeclarative1VisualDataModelData(int index, QDeclarative1VisualDataModel *model); + ~QDeclarative1VisualDataModelData(); Q_PROPERTY(int index READ index NOTIFY indexChanged) int index() const; @@ -433,7 +435,7 @@ Q_OBJECT int propForRole(int) const; int modelDataPropertyId() const { - QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(m_model); + QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(m_model); return model->m_modelDataPropId; } @@ -448,15 +450,15 @@ Q_OBJECT void indexChanged(); private: - friend class QDeclarativeVisualDataModelDataMetaObject; + friend class QDeclarative1VisualDataModelDataMetaObject; int m_index; - QDeclarativeGuard m_model; - QDeclarativeVisualDataModelDataMetaObject *m_meta; + QDeclarativeGuard m_model; + QDeclarative1VisualDataModelDataMetaObject *m_meta; }; -int QDeclarativeVisualDataModelData::propForRole(int id) const +int QDeclarative1VisualDataModelData::propForRole(int id) const { - QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(m_model); + QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(m_model); QHash::const_iterator it = model->m_roleToPropId.find(id); if (it != model->m_roleToPropId.end()) return *it; @@ -464,45 +466,45 @@ int QDeclarativeVisualDataModelData::propForRole(int id) const return -1; } -void QDeclarativeVisualDataModelData::setValue(int id, const QVariant &val) +void QDeclarative1VisualDataModelData::setValue(int id, const QVariant &val) { m_meta->setValue(id, val); } -int QDeclarativeVisualDataModelDataMetaObject::createProperty(const char *name, const char *type) +int QDeclarative1VisualDataModelDataMetaObject::createProperty(const char *name, const char *type) { - QDeclarativeVisualDataModelData *data = - static_cast(object()); + QDeclarative1VisualDataModelData *data = + static_cast(object()); if (!data->m_model) return -1; - QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(data->m_model); + QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(data->m_model); if (data->m_index < 0 || data->m_index >= model->modelCount()) return -1; if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { - if (model->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) { + if (model->m_listAccessor->type() == QDeclarative1ListAccessor::ListProperty) { model->ensureRoles(); if (qstrcmp(name,"modelData") == 0) - return QDeclarativeOpenMetaObject::createProperty(name, type); + return QDeclarative1OpenMetaObject::createProperty(name, type); } } return -1; } -QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId) +QVariant QDeclarative1VisualDataModelDataMetaObject::initialValue(int propId) { - QDeclarativeVisualDataModelData *data = - static_cast(object()); + QDeclarative1VisualDataModelData *data = + static_cast(object()); Q_ASSERT(data->m_model); - QDeclarativeVisualDataModelPrivate *model = QDeclarativeVisualDataModelPrivate::get(data->m_model); + QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(data->m_model); QByteArray propName = name(propId); if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { if (propName == "modelData") { - if (model->m_listAccessor->type() == QDeclarativeListAccessor::Instance) { + if (model->m_listAccessor->type() == QDeclarative1ListAccessor::Instance) { QObject *object = model->m_listAccessor->at(0).value(); return object->metaObject()->property(1).read(object); // the first property after objectName } @@ -542,21 +544,21 @@ QVariant QDeclarativeVisualDataModelDataMetaObject::initialValue(int propId) return QVariant(); } -QDeclarativeVisualDataModelData::QDeclarativeVisualDataModelData(int index, - QDeclarativeVisualDataModel *model) +QDeclarative1VisualDataModelData::QDeclarative1VisualDataModelData(int index, + QDeclarative1VisualDataModel *model) : m_index(index), m_model(model), -m_meta(new QDeclarativeVisualDataModelDataMetaObject(this, QDeclarativeVisualDataModelPrivate::get(model)->m_delegateDataType)) +m_meta(new QDeclarative1VisualDataModelDataMetaObject(this, QDeclarative1VisualDataModelPrivate::get(model)->m_delegateDataType)) { ensureProperties(); } -QDeclarativeVisualDataModelData::~QDeclarativeVisualDataModelData() +QDeclarative1VisualDataModelData::~QDeclarative1VisualDataModelData() { } -void QDeclarativeVisualDataModelData::ensureProperties() +void QDeclarative1VisualDataModelData::ensureProperties() { - QDeclarativeVisualDataModelPrivate *modelPriv = QDeclarativeVisualDataModelPrivate::get(m_model); + QDeclarative1VisualDataModelPrivate *modelPriv = QDeclarative1VisualDataModelPrivate::get(m_model); if (modelPriv->m_metaDataCacheable) { if (!modelPriv->m_metaDataCreated) modelPriv->createMetaData(); @@ -565,13 +567,13 @@ void QDeclarativeVisualDataModelData::ensureProperties() } } -int QDeclarativeVisualDataModelData::index() const +int QDeclarative1VisualDataModelData::index() const { return m_index; } // This is internal only - it should not be set from qml -void QDeclarativeVisualDataModelData::setIndex(int index) +void QDeclarative1VisualDataModelData::setIndex(int index) { m_index = index; emit indexChanged(); @@ -579,60 +581,60 @@ void QDeclarativeVisualDataModelData::setIndex(int index) //--------------------------------------------------------------------------- -class QDeclarativeVisualDataModelPartsMetaObject : public QDeclarativeOpenMetaObject +class QDeclarative1VisualDataModelPartsMetaObject : public QDeclarative1OpenMetaObject { public: - QDeclarativeVisualDataModelPartsMetaObject(QObject *parent) - : QDeclarativeOpenMetaObject(parent) {} + QDeclarative1VisualDataModelPartsMetaObject(QObject *parent) + : QDeclarative1OpenMetaObject(parent) {} virtual void propertyCreated(int, QMetaPropertyBuilder &); virtual QVariant initialValue(int); }; -class QDeclarativeVisualDataModelParts : public QObject +class QDeclarative1VisualDataModelParts : public QObject { Q_OBJECT public: - QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent); + QDeclarative1VisualDataModelParts(QDeclarative1VisualDataModel *parent); private: - friend class QDeclarativeVisualDataModelPartsMetaObject; - QDeclarativeVisualDataModel *model; + friend class QDeclarative1VisualDataModelPartsMetaObject; + QDeclarative1VisualDataModel *model; }; -void QDeclarativeVisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) +void QDeclarative1VisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) { prop.setWritable(false); } -QVariant QDeclarativeVisualDataModelPartsMetaObject::initialValue(int id) +QVariant QDeclarative1VisualDataModelPartsMetaObject::initialValue(int id) { - QDeclarativeVisualDataModel *m = new QDeclarativeVisualDataModel; + QDeclarative1VisualDataModel *m = new QDeclarative1VisualDataModel; m->setParent(object()); m->setPart(QString::fromUtf8(name(id))); - m->setModel(QVariant::fromValue(static_cast(object())->model)); + m->setModel(QVariant::fromValue(static_cast(object())->model)); QVariant var = QVariant::fromValue((QObject *)m); return var; } -QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeVisualDataModel *parent) +QDeclarative1VisualDataModelParts::QDeclarative1VisualDataModelParts(QDeclarative1VisualDataModel *parent) : QObject(parent), model(parent) { - new QDeclarativeVisualDataModelPartsMetaObject(this); + new QDeclarative1VisualDataModelPartsMetaObject(this); } -QDeclarativeVisualDataModelPrivate::QDeclarativeVisualDataModelPrivate(QDeclarativeContext *ctxt) +QDeclarative1VisualDataModelPrivate::QDeclarative1VisualDataModelPrivate(QDeclarativeContext *ctxt) : m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0) , m_context(ctxt), m_modelDataPropId(-1), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false) , m_metaDataCacheable(false), m_delegateValidated(false), m_completePending(false), m_listAccessor(0) { } -QDeclarativeVisualDataModelData *QDeclarativeVisualDataModelPrivate::data(QObject *item) +QDeclarative1VisualDataModelData *QDeclarative1VisualDataModelPrivate::data(QObject *item) { - QDeclarativeVisualDataModelData *dataItem = - item->findChild(); + QDeclarative1VisualDataModelData *dataItem = + item->findChild(); Q_ASSERT(dataItem); return dataItem; } @@ -640,7 +642,7 @@ QDeclarativeVisualDataModelData *QDeclarativeVisualDataModelPrivate::data(QObjec //--------------------------------------------------------------------------- /*! - \qmlclass VisualDataModel QDeclarativeVisualDataModel + \qmlclass VisualDataModel QDeclarative1VisualDataModel \ingroup qml-working-with-data \brief The VisualDataModel encapsulates a model and delegate @@ -658,19 +660,19 @@ QDeclarativeVisualDataModelData *QDeclarativeVisualDataModelPrivate::data(QObjec \snippet doc/src/snippets/declarative/visualdatamodel.qml 0 */ -QDeclarativeVisualDataModel::QDeclarativeVisualDataModel() -: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(0))) +QDeclarative1VisualDataModel::QDeclarative1VisualDataModel() +: QDeclarative1VisualModel(*(new QDeclarative1VisualDataModelPrivate(0))) { } -QDeclarativeVisualDataModel::QDeclarativeVisualDataModel(QDeclarativeContext *ctxt, QObject *parent) -: QDeclarativeVisualModel(*(new QDeclarativeVisualDataModelPrivate(ctxt)), parent) +QDeclarative1VisualDataModel::QDeclarative1VisualDataModel(QDeclarativeContext *ctxt, QObject *parent) +: QDeclarative1VisualModel(*(new QDeclarative1VisualDataModelPrivate(ctxt)), parent) { } -QDeclarativeVisualDataModel::~QDeclarativeVisualDataModel() +QDeclarative1VisualDataModel::~QDeclarative1VisualDataModel() { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (d->m_listAccessor) delete d->m_listAccessor; if (d->m_delegateDataType) @@ -691,15 +693,15 @@ QDeclarativeVisualDataModel::~QDeclarativeVisualDataModel() \sa {qmlmodels}{Data Models} */ -QVariant QDeclarativeVisualDataModel::model() const +QVariant QDeclarative1VisualDataModel::model() const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); return d->m_modelVariant; } -void QDeclarativeVisualDataModel::setModel(const QVariant &model) +void QDeclarative1VisualDataModel::setModel(const QVariant &model) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); delete d->m_listAccessor; d->m_listAccessor = 0; d->m_modelVariant = model; @@ -733,10 +735,10 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) this, SIGNAL(itemsRemoved(int,int))); QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)), this, SIGNAL(itemsMoved(int,int,int))); - QObject::disconnect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarativePackage*)), - this, SLOT(_q_createdPackage(int,QDeclarativePackage*))); - QObject::disconnect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarativePackage*)), - this, SLOT(_q_destroyingPackage(QDeclarativePackage*))); + QObject::disconnect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarative1Package*)), + this, SLOT(_q_createdPackage(int,QDeclarative1Package*))); + QObject::disconnect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarative1Package*)), + this, SLOT(_q_destroyingPackage(QDeclarative1Package*))); d->m_visualItemModel = 0; } @@ -746,7 +748,7 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) d->m_delegateDataType->release(); d->m_metaDataCreated = 0; d->m_metaDataCacheable = false; - d->m_delegateDataType = new VDMDelegateDataType(&QDeclarativeVisualDataModelData::staticMetaObject, d->m_context?d->m_context->engine():qmlEngine(this)); + d->m_delegateDataType = new VDMDelegateDataType(&QDeclarative1VisualDataModelData::staticMetaObject, d->m_context?d->m_context->engine():qmlEngine(this)); QObject *object = qvariant_cast(model); if (object && (d->m_listModelInterface = qobject_cast(object))) { @@ -778,22 +780,22 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) d->m_abstractItemModel->fetchMore(d->m_root); return; } - if ((d->m_visualItemModel = qvariant_cast(model))) { + if ((d->m_visualItemModel = qvariant_cast(model))) { QObject::connect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), this, SIGNAL(itemsInserted(int,int))); QObject::connect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)), this, SIGNAL(itemsRemoved(int,int))); QObject::connect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)), this, SIGNAL(itemsMoved(int,int,int))); - QObject::connect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarativePackage*)), - this, SLOT(_q_createdPackage(int,QDeclarativePackage*))); - QObject::connect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarativePackage*)), - this, SLOT(_q_destroyingPackage(QDeclarativePackage*))); + QObject::connect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarative1Package*)), + this, SLOT(_q_createdPackage(int,QDeclarative1Package*))); + QObject::connect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarative1Package*)), + this, SLOT(_q_destroyingPackage(QDeclarative1Package*))); return; } - d->m_listAccessor = new QDeclarativeListAccessor; + d->m_listAccessor = new QDeclarative1ListAccessor; d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this)); - if (d->m_listAccessor->type() != QDeclarativeListAccessor::ListProperty) + if (d->m_listAccessor->type() != QDeclarative1ListAccessor::ListProperty) d->m_metaDataCacheable = true; if (d->m_delegate && d->modelCount()) { emit itemsInserted(0, d->modelCount()); @@ -808,17 +810,17 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) The index is exposed as an accessible \c index property. Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}. */ -QDeclarativeComponent *QDeclarativeVisualDataModel::delegate() const +QDeclarativeComponent *QDeclarative1VisualDataModel::delegate() const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->delegate(); return d->m_delegate; } -void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate) +void QDeclarative1VisualDataModel::setDelegate(QDeclarativeComponent *delegate) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); bool wasValid = d->m_delegate != 0; d->m_delegate = delegate; d->m_delegateValidated = false; @@ -861,15 +863,15 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate) \sa modelIndex(), parentModelIndex() */ -QVariant QDeclarativeVisualDataModel::rootIndex() const +QVariant QDeclarative1VisualDataModel::rootIndex() const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); return QVariant::fromValue(d->m_root); } -void QDeclarativeVisualDataModel::setRootIndex(const QVariant &root) +void QDeclarative1VisualDataModel::setRootIndex(const QVariant &root) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); QModelIndex modelIndex = qvariant_cast(root); if (d->m_root != modelIndex) { int oldCount = d->modelCount(); @@ -900,9 +902,9 @@ void QDeclarativeVisualDataModel::setRootIndex(const QVariant &root) \sa rootIndex */ -QVariant QDeclarativeVisualDataModel::modelIndex(int idx) const +QVariant QDeclarative1VisualDataModel::modelIndex(int idx) const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); if (d->m_abstractItemModel) return QVariant::fromValue(d->m_abstractItemModel->index(idx, 0, d->m_root)); return QVariant::fromValue(QModelIndex()); @@ -920,29 +922,29 @@ QVariant QDeclarativeVisualDataModel::modelIndex(int idx) const \sa rootIndex */ -QVariant QDeclarativeVisualDataModel::parentModelIndex() const +QVariant QDeclarative1VisualDataModel::parentModelIndex() const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); if (d->m_abstractItemModel) return QVariant::fromValue(d->m_abstractItemModel->parent(d->m_root)); return QVariant::fromValue(QModelIndex()); } -QString QDeclarativeVisualDataModel::part() const +QString QDeclarative1VisualDataModel::part() const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); return d->m_part; } -void QDeclarativeVisualDataModel::setPart(const QString &part) +void QDeclarative1VisualDataModel::setPart(const QString &part) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); d->m_part = part; } -int QDeclarativeVisualDataModel::count() const +int QDeclarative1VisualDataModel::count() const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->count(); if (!d->m_delegate) @@ -950,9 +952,9 @@ int QDeclarativeVisualDataModel::count() const return d->modelCount(); } -QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, bool complete) +QDeclarativeItem *QDeclarative1VisualDataModel::item(int index, bool complete) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->item(index, d->m_part.toUtf8(), complete); return item(index, QByteArray(), complete); @@ -961,9 +963,9 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, bool complete) /* Returns ReleaseStatus flags. */ -QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(QDeclarativeItem *item) +QDeclarative1VisualDataModel::ReleaseFlags QDeclarative1VisualDataModel::release(QDeclarativeItem *item) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->release(item); @@ -971,9 +973,9 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q QObject *obj = item; bool inPackage = false; - QHash::iterator it = d->m_packaged.find(item); + QHash::iterator it = d->m_packaged.find(item); if (it != d->m_packaged.end()) { - QDeclarativePackage *package = *it; + QDeclarative1Package *package = *it; d->m_packaged.erase(it); if (d->m_packaged.contains(item)) stat |= Referenced; @@ -990,7 +992,7 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q d->context->clearContext(); if (inPackage) { - emit destroyingPackage(qobject_cast(obj)); + emit destroyingPackage(qobject_cast(obj)); } else { if (item->scene()) item->scene()->removeItem(item); @@ -1031,17 +1033,17 @@ QDeclarativeVisualDataModel::ReleaseFlags QDeclarativeVisualDataModel::release(Q \sa Package */ -QObject *QDeclarativeVisualDataModel::parts() +QObject *QDeclarative1VisualDataModel::parts() { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (!d->m_parts) - d->m_parts = new QDeclarativeVisualDataModelParts(this); + d->m_parts = new QDeclarative1VisualDataModelParts(this); return d->m_parts; } -QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray &viewId, bool complete) +QDeclarativeItem *QDeclarative1VisualDataModel::item(int index, const QByteArray &viewId, bool complete) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->item(index, viewId, complete); @@ -1053,9 +1055,9 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray QDeclarativeContext *ccontext = d->m_context; if (!ccontext) ccontext = qmlContext(this); QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext); - QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this); + QDeclarative1VisualDataModelData *data = new QDeclarative1VisualDataModelData(index, this); if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor - && d->m_listAccessor->type() == QDeclarativeListAccessor::ListProperty) { + && d->m_listAccessor->type() == QDeclarative1ListAccessor::ListProperty) { ctxt->setContextObject(d->m_listAccessor->at(index).value()); ctxt = new QDeclarativeContext(ctxt, ctxt); } @@ -1073,7 +1075,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray QDeclarative_setParent_noEvent(ctxt, nobj); QDeclarative_setParent_noEvent(data, nobj); d->m_cache.insertItem(index, nobj); - if (QDeclarativePackage *package = qobject_cast(nobj)) + if (QDeclarative1Package *package = qobject_cast(nobj)) emit createdPackage(index, package); } else { delete data; @@ -1083,7 +1085,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray } QDeclarativeItem *item = qobject_cast(nobj); if (!item) { - QDeclarativePackage *package = qobject_cast(nobj); + QDeclarative1Package *package = qobject_cast(nobj); if (package) { QObject *o = package->part(QString::fromUtf8(viewId)); item = qobject_cast(o); @@ -1096,7 +1098,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray d->m_delegate->completeCreate(); d->m_cache.releaseItem(nobj); if (!d->m_delegateValidated) { - qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type."); + qmlInfo(d->m_delegate) << QDeclarative1VisualDataModel::tr("Delegate component must be Item type."); d->m_delegateValidated = true; } } @@ -1106,17 +1108,17 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray return item; } -bool QDeclarativeVisualDataModel::completePending() const +bool QDeclarative1VisualDataModel::completePending() const { - Q_D(const QDeclarativeVisualDataModel); + Q_D(const QDeclarative1VisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->completePending(); return d->m_completePending; } -void QDeclarativeVisualDataModel::completeItem() +void QDeclarative1VisualDataModel::completeItem() { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (d->m_visualItemModel) { d->m_visualItemModel->completeItem(); return; @@ -1126,9 +1128,9 @@ void QDeclarativeVisualDataModel::completeItem() d->m_completePending = false; } -QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name) +QString QDeclarative1VisualDataModel::stringValue(int index, const QString &name) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (d->m_visualItemModel) return d->m_visualItemModel->stringValue(index, name); @@ -1147,7 +1149,7 @@ QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name) if (QObject *nobj = d->m_cache.item(index)) data = d->data(nobj); if (!data) { - data = new QDeclarativeVisualDataModelData(index, this); + data = new QDeclarative1VisualDataModelData(index, this); tempData = true; } @@ -1177,24 +1179,24 @@ QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name) return val; } -int QDeclarativeVisualDataModel::indexOf(QDeclarativeItem *item, QObject *) const +int QDeclarative1VisualDataModel::indexOf(QDeclarativeItem *item, QObject *) const { QVariant val = QDeclarativeEngine::contextForObject(item)->contextProperty(QLatin1String("index")); return val.toInt(); return -1; } -void QDeclarativeVisualDataModel::setWatchedRoles(QList roles) +void QDeclarative1VisualDataModel::setWatchedRoles(QList roles) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); d->watchedRoles = roles; d->watchedRoleIds.clear(); } -void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, +void QDeclarative1VisualDataModel::_q_itemsChanged(int index, int count, const QList &roles) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); bool changed = false; if (!d->watchedRoles.isEmpty() && d->watchedRoleIds.isEmpty()) { foreach (QByteArray r, d->watchedRoles) { @@ -1203,13 +1205,13 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, } } - for (QHash::ConstIterator iter = d->m_cache.begin(); + for (QHash::ConstIterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ++iter) { const int idx = iter.key(); if (idx >= index && idx < index+count) { - QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter; - QDeclarativeVisualDataModelData *data = d->data(objRef.obj); + QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; + QDeclarative1VisualDataModelData *data = d->data(objRef.obj); for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) { int role = roles.at(roleIdx); if (!changed && !d->watchedRoleIds.isEmpty() && d->watchedRoleIds.contains(role)) @@ -1252,24 +1254,24 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, emit itemsChanged(index, count); } -void QDeclarativeVisualDataModel::_q_itemsInserted(int index, int count) +void QDeclarative1VisualDataModel::_q_itemsInserted(int index, int count) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (!count) return; // XXX - highly inefficient - QHash items; - for (QHash::Iterator iter = d->m_cache.begin(); + QHash items; + for (QHash::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { if (iter.key() >= index) { - QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter; + QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; int index = iter.key() + count; iter = d->m_cache.erase(iter); items.insert(index, objRef); - QDeclarativeVisualDataModelData *data = d->data(objRef.obj); + QDeclarative1VisualDataModelData *data = d->data(objRef.obj); data->setIndex(index); } else { ++iter; @@ -1281,27 +1283,27 @@ void QDeclarativeVisualDataModel::_q_itemsInserted(int index, int count) emit countChanged(); } -void QDeclarativeVisualDataModel::_q_itemsRemoved(int index, int count) +void QDeclarative1VisualDataModel::_q_itemsRemoved(int index, int count) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (!count) return; // XXX - highly inefficient - QHash items; - for (QHash::Iterator iter = d->m_cache.begin(); + QHash items; + for (QHash::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { if (iter.key() >= index && iter.key() < index + count) { - QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter; + QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; iter = d->m_cache.erase(iter); items.insertMulti(-1, objRef); //XXX perhaps better to maintain separately - QDeclarativeVisualDataModelData *data = d->data(objRef.obj); + QDeclarative1VisualDataModelData *data = d->data(objRef.obj); data->setIndex(-1); } else if (iter.key() >= index + count) { - QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter; + QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; int index = iter.key() - count; iter = d->m_cache.erase(iter); items.insert(index, objRef); - QDeclarativeVisualDataModelData *data = d->data(objRef.obj); + QDeclarative1VisualDataModelData *data = d->data(objRef.obj); data->setIndex(index); } else { ++iter; @@ -1313,39 +1315,39 @@ void QDeclarativeVisualDataModel::_q_itemsRemoved(int index, int count) emit countChanged(); } -void QDeclarativeVisualDataModel::_q_itemsMoved(int from, int to, int count) +void QDeclarative1VisualDataModel::_q_itemsMoved(int from, int to, int count) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); // XXX - highly inefficient - QHash items; - for (QHash::Iterator iter = d->m_cache.begin(); + QHash items; + for (QHash::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { if (iter.key() >= from && iter.key() < from + count) { - QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter; + QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; int index = iter.key() - from + to; iter = d->m_cache.erase(iter); items.insert(index, objRef); - QDeclarativeVisualDataModelData *data = d->data(objRef.obj); + QDeclarative1VisualDataModelData *data = d->data(objRef.obj); data->setIndex(index); } else { ++iter; } } - for (QHash::Iterator iter = d->m_cache.begin(); + for (QHash::Iterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ) { int diff = from > to ? count : -count; if (iter.key() >= qMin(from,to) && iter.key() < qMax(from+count,to+count)) { - QDeclarativeVisualDataModelPrivate::ObjectRef objRef = *iter; + QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; int index = iter.key() + diff; iter = d->m_cache.erase(iter); items.insert(index, objRef); - QDeclarativeVisualDataModelData *data = d->data(objRef.obj); + QDeclarative1VisualDataModelData *data = d->data(objRef.obj); data->setIndex(index); } else { ++iter; @@ -1356,23 +1358,23 @@ void QDeclarativeVisualDataModel::_q_itemsMoved(int from, int to, int count) emit itemsMoved(from, to, count); } -void QDeclarativeVisualDataModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end) +void QDeclarative1VisualDataModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (parent == d->m_root) _q_itemsInserted(begin, end - begin + 1); } -void QDeclarativeVisualDataModel::_q_rowsRemoved(const QModelIndex &parent, int begin, int end) +void QDeclarative1VisualDataModel::_q_rowsRemoved(const QModelIndex &parent, int begin, int end) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (parent == d->m_root) _q_itemsRemoved(begin, end - begin + 1); } -void QDeclarativeVisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) +void QDeclarative1VisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); const int count = sourceEnd - sourceStart + 1; if (destinationParent == d->m_root && sourceParent == d->m_root) { _q_itemsMoved(sourceStart, sourceStart > destinationRow ? destinationRow : destinationRow-1, count); @@ -1383,22 +1385,22 @@ void QDeclarativeVisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent, } } -void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end) +void QDeclarative1VisualDataModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); if (begin.parent() == d->m_root) _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles); } -void QDeclarativeVisualDataModel::_q_layoutChanged() +void QDeclarative1VisualDataModel::_q_layoutChanged() { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); _q_itemsChanged(0, count(), d->m_roles); } -void QDeclarativeVisualDataModel::_q_modelReset() +void QDeclarative1VisualDataModel::_q_modelReset() { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); d->m_root = QModelIndex(); emit modelReset(); emit rootIndexChanged(); @@ -1406,18 +1408,20 @@ void QDeclarativeVisualDataModel::_q_modelReset() d->m_abstractItemModel->fetchMore(d->m_root); } -void QDeclarativeVisualDataModel::_q_createdPackage(int index, QDeclarativePackage *package) +void QDeclarative1VisualDataModel::_q_createdPackage(int index, QDeclarative1Package *package) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); emit createdItem(index, qobject_cast(package->part(d->m_part))); } -void QDeclarativeVisualDataModel::_q_destroyingPackage(QDeclarativePackage *package) +void QDeclarative1VisualDataModel::_q_destroyingPackage(QDeclarative1Package *package) { - Q_D(QDeclarativeVisualDataModel); + Q_D(QDeclarative1VisualDataModel); emit destroyingItem(qobject_cast(package->part(d->m_part))); } + + QT_END_NAMESPACE QML_DECLARE_TYPE(QListModelInterface) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel_p.h similarity index 75% rename from src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h rename to src/qtquick1/graphicsitems/qdeclarativevisualitemmodel_p.h index e46b6d85cc..e9729d08ce 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h +++ b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel_p.h @@ -42,7 +42,7 @@ #ifndef QDECLARATIVEVISUALDATAMODEL_H #define QDECLARATIVEVISUALDATAMODEL_H -#include +#include #include #include @@ -55,19 +55,19 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QDeclarativeItem; class QDeclarativeComponent; -class QDeclarativePackage; -class QDeclarativeVisualDataModelPrivate; +class QDeclarativeItem; +class QDeclarative1Package; +class QDeclarative1VisualDataModelPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeVisualModel : public QObject +class Q_AUTOTEST_EXPORT QDeclarative1VisualModel : public QObject { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) public: - virtual ~QDeclarativeVisualModel() {} + virtual ~QDeclarative1VisualModel() {} enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 }; Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag) @@ -94,26 +94,26 @@ class Q_AUTOTEST_EXPORT QDeclarativeVisualModel : public QObject void destroyingItem(QDeclarativeItem *item); protected: - QDeclarativeVisualModel(QObjectPrivate &dd, QObject *parent = 0) + QDeclarative1VisualModel(QObjectPrivate &dd, QObject *parent = 0) : QObject(dd, parent) {} private: - Q_DISABLE_COPY(QDeclarativeVisualModel) + Q_DISABLE_COPY(QDeclarative1VisualModel) }; -class QDeclarativeVisualItemModelAttached; -class QDeclarativeVisualItemModelPrivate; -class Q_AUTOTEST_EXPORT QDeclarativeVisualItemModel : public QDeclarativeVisualModel +class QDeclarative1VisualItemModelAttached; +class QDeclarative1VisualItemModelPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1VisualItemModel : public QDeclarative1VisualModel { Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeVisualItemModel) + Q_DECLARE_PRIVATE(QDeclarative1VisualItemModel) Q_PROPERTY(QDeclarativeListProperty children READ children NOTIFY childrenChanged DESIGNABLE false) Q_CLASSINFO("DefaultProperty", "children") public: - QDeclarativeVisualItemModel(QObject *parent=0); - virtual ~QDeclarativeVisualItemModel() {} + QDeclarative1VisualItemModel(QObject *parent=0); + virtual ~QDeclarative1VisualItemModel() {} virtual int count() const; virtual bool isValid() const; @@ -128,20 +128,20 @@ class Q_AUTOTEST_EXPORT QDeclarativeVisualItemModel : public QDeclarativeVisualM QDeclarativeListProperty children(); - static QDeclarativeVisualItemModelAttached *qmlAttachedProperties(QObject *obj); + static QDeclarative1VisualItemModelAttached *qmlAttachedProperties(QObject *obj); Q_SIGNALS: void childrenChanged(); private: - Q_DISABLE_COPY(QDeclarativeVisualItemModel) + Q_DISABLE_COPY(QDeclarative1VisualItemModel) }; -class Q_AUTOTEST_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisualModel +class Q_AUTOTEST_EXPORT QDeclarative1VisualDataModel : public QDeclarative1VisualModel { Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeVisualDataModel) + Q_DECLARE_PRIVATE(QDeclarative1VisualDataModel) Q_PROPERTY(QVariant model READ model WRITE setModel) Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate) @@ -150,9 +150,9 @@ class Q_AUTOTEST_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisualM Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged) Q_CLASSINFO("DefaultProperty", "delegate") public: - QDeclarativeVisualDataModel(); - QDeclarativeVisualDataModel(QDeclarativeContext *, QObject *parent=0); - virtual ~QDeclarativeVisualDataModel(); + QDeclarative1VisualDataModel(); + QDeclarative1VisualDataModel(QDeclarativeContext *, QObject *parent=0); + virtual ~QDeclarative1VisualDataModel(); QVariant model() const; void setModel(const QVariant &); @@ -184,8 +184,8 @@ class Q_AUTOTEST_EXPORT QDeclarativeVisualDataModel : public QDeclarativeVisualM QObject *parts(); Q_SIGNALS: - void createdPackage(int index, QDeclarativePackage *package); - void destroyingPackage(QDeclarativePackage *package); + void createdPackage(int index, QDeclarative1Package *package); + void destroyingPackage(QDeclarative1Package *package); void rootIndexChanged(); private Q_SLOTS: @@ -199,21 +199,21 @@ private Q_SLOTS: void _q_dataChanged(const QModelIndex&,const QModelIndex&); void _q_layoutChanged(); void _q_modelReset(); - void _q_createdPackage(int index, QDeclarativePackage *package); - void _q_destroyingPackage(QDeclarativePackage *package); + void _q_createdPackage(int index, QDeclarative1Package *package); + void _q_destroyingPackage(QDeclarative1Package *package); private: - Q_DISABLE_COPY(QDeclarativeVisualDataModel) + Q_DISABLE_COPY(QDeclarative1VisualDataModel) }; -class QDeclarativeVisualItemModelAttached : public QObject +class QDeclarative1VisualItemModelAttached : public QObject { Q_OBJECT public: - QDeclarativeVisualItemModelAttached(QObject *parent) + QDeclarative1VisualItemModelAttached(QObject *parent) : QObject(parent), m_index(0) {} - ~QDeclarativeVisualItemModelAttached() { + ~QDeclarative1VisualItemModelAttached() { attachedProperties.remove(parent()); } @@ -226,10 +226,10 @@ class QDeclarativeVisualItemModelAttached : public QObject } } - static QDeclarativeVisualItemModelAttached *properties(QObject *obj) { - QDeclarativeVisualItemModelAttached *rv = attachedProperties.value(obj); + static QDeclarative1VisualItemModelAttached *properties(QObject *obj) { + QDeclarative1VisualItemModelAttached *rv = attachedProperties.value(obj); if (!rv) { - rv = new QDeclarativeVisualItemModelAttached(obj); + rv = new QDeclarative1VisualItemModelAttached(obj); attachedProperties.insert(obj, rv); } return rv; @@ -241,16 +241,16 @@ class QDeclarativeVisualItemModelAttached : public QObject public: int m_index; - static QHash attachedProperties; + static QHash attachedProperties; }; QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarativeVisualModel) -QML_DECLARE_TYPE(QDeclarativeVisualItemModel) -QML_DECLARE_TYPEINFO(QDeclarativeVisualItemModel, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarativeVisualDataModel) +QML_DECLARE_TYPE(QDeclarative1VisualModel) +QML_DECLARE_TYPE(QDeclarative1VisualItemModel) +QML_DECLARE_TYPEINFO(QDeclarative1VisualItemModel, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QDeclarative1VisualDataModel) QT_END_HEADER diff --git a/src/qtquick1/qtquick1.cpp b/src/qtquick1/qtquick1.cpp new file mode 100644 index 0000000000..b8c0e109ba --- /dev/null +++ b/src/qtquick1/qtquick1.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "qtquick1_p.h" + +QT_BEGIN_NAMESPACE + +void QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::Module module) +{ + QDeclarativeFastProperties::instance()->add(&QDeclarativeItem::staticMetaObject, + QDeclarativeItem::staticMetaObject.indexOfProperty("parent"), + QDeclarativeItemPrivate::parentProperty); + if (module == QtQuick1) + qmlRegisterBaseTypes("QtQuick", 1, 0); + else if (module == Qt47) + qmlRegisterBaseTypes("Qt", 4, 7); + QDeclarative1UtilModule::defineModule(module); + QDeclarative1ItemModule::defineModule(module); +} + +QT_END_NAMESPACE + diff --git a/src/qtquick1/qtquick1.pro b/src/qtquick1/qtquick1.pro new file mode 100644 index 0000000000..e3dd0298cd --- /dev/null +++ b/src/qtquick1/qtquick1.pro @@ -0,0 +1,42 @@ +load(qt_module) + +TARGET = QtQuick1 +QPRO_PWD = $$PWD + +CONFIG += module +CONFIG += dll warn_on +MODULE_PRI += ../../modules/qt_qtquick1.pri + +QT += testlib-private declarative script testlib declarative-private core-private gui-private script-private network +DEFINES += QT_NO_URL_CAST_FROM_STRING + +load(qt_module_config) + +# Install qtquick1.prf into the Qt mkspecs so that "CONFIG += qtquick1" +# can be used in customer applications to build against QtQuick 1. +feature.path = $$[QT_INSTALL_DATA]/mkspecs/features +feature.files = $$PWD/features/qtquick1.prf +INSTALLS += feature + +symbian { + DEFINES += QT_MAKEDLL + CONFIG += epocallowdlldata + contains(QT_EDITION, OpenSource) { + TARGET.CAPABILITY = LocalServices NetworkServices ReadUserData UserEnvironment WriteUserData + } else { + TARGET.CAPABILITY = All -Tcb + } +} + +#INCLUDEPATH += $$PWD/QtQuick1 +#INCLUDEPATH += $$PWD + +include(util/util.pri) +include(graphicsitems/graphicsitems.pri) + +HEADERS += qtquick1_p.h +SOURCES += qtquick1.cpp + +DEFINES += QT_NO_OPENTYPE +INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/harfbuzz/src + diff --git a/src/qtquick1/qtquick1_p.h b/src/qtquick1/qtquick1_p.h new file mode 100644 index 0000000000..36dfd1ad05 --- /dev/null +++ b/src/qtquick1/qtquick1_p.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTQUICK1_H +#define QTQUICK1_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class Q_DECLARATIVE_EXPORT QDeclarativeQtQuick1Module +{ +public: + enum Module { QtQuick1, Qt47 }; + static void defineModule(Module module); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QTQUICK1_H diff --git a/src/qtquick1/util/qdeclarativeanimation.cpp b/src/qtquick1/util/qdeclarativeanimation.cpp new file mode 100644 index 0000000000..3b05429c84 --- /dev/null +++ b/src/qtquick1/util/qdeclarativeanimation.cpp @@ -0,0 +1,2956 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativeanimation_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" + +#include "QtQuick1/private/qdeclarativebehavior_p.h" +#include "QtQuick1/private/qdeclarativestateoperations_p.h" +#include "QtDeclarative/private/qdeclarativecontext_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + + +/*! + \qmlclass Animation QDeclarative1AbstractAnimation + \ingroup qml-animation-transition + \since 4.7 + \brief The Animation element is the base of all QML animations. + + The Animation element cannot be used directly in a QML file. It exists + to provide a set of common properties and methods, available across all the + other animation types that inherit from it. Attempting to use the Animation + element directly will result in an error. +*/ + +QDeclarative1AbstractAnimation::QDeclarative1AbstractAnimation(QObject *parent) +: QObject(*(new QDeclarative1AbstractAnimationPrivate), parent) +{ +} + +QDeclarative1AbstractAnimation::~QDeclarative1AbstractAnimation() +{ +} + +QDeclarative1AbstractAnimation::QDeclarative1AbstractAnimation(QDeclarative1AbstractAnimationPrivate &dd, QObject *parent) +: QObject(dd, parent) +{ +} + +/*! + \qmlproperty bool Animation::running + This property holds whether the animation is currently running. + + The \c running property can be set to declaratively control whether or not + an animation is running. The following example will animate a rectangle + whenever the \l MouseArea is pressed. + + \code + Rectangle { + width: 100; height: 100 + NumberAnimation on x { + running: myMouse.pressed + from: 0; to: 100 + } + MouseArea { id: myMouse } + } + \endcode + + Likewise, the \c running property can be read to determine if the animation + is running. In the following example the text element will indicate whether + or not the animation is running. + + \code + NumberAnimation { id: myAnimation } + Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" } + \endcode + + Animations can also be started and stopped imperatively from JavaScript + using the \c start() and \c stop() methods. + + By default, animations are not running. Though, when the animations are assigned to properties, + as property value sources using the \e on syntax, they are set to running by default. +*/ +bool QDeclarative1AbstractAnimation::isRunning() const +{ + Q_D(const QDeclarative1AbstractAnimation); + return d->running; +} + +// the behavior calls this function +void QDeclarative1AbstractAnimation::notifyRunningChanged(bool running) +{ + Q_D(QDeclarative1AbstractAnimation); + if (d->disableUserControl && d->running != running) { + d->running = running; + emit runningChanged(running); + } +} + +//commence is called to start an animation when it is used as a +//simple animation, and not as part of a transition +void QDeclarative1AbstractAnimationPrivate::commence() +{ + Q_Q(QDeclarative1AbstractAnimation); + + QDeclarative1StateActions actions; + QDeclarativeProperties properties; + q->transition(actions, properties, QDeclarative1AbstractAnimation::Forward); + + q->qtAnimation()->start(); + if (q->qtAnimation()->state() != QAbstractAnimation::Running) { + running = false; + emit q->completed(); + } +} + +QDeclarativeProperty QDeclarative1AbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) +{ + QDeclarativeProperty prop(obj, str, qmlContext(infoObj)); + if (!prop.isValid()) { + qmlInfo(infoObj) << QDeclarative1AbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); + return QDeclarativeProperty(); + } else if (!prop.isWritable()) { + qmlInfo(infoObj) << QDeclarative1AbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); + return QDeclarativeProperty(); + } + return prop; +} + +void QDeclarative1AbstractAnimation::setRunning(bool r) +{ + Q_D(QDeclarative1AbstractAnimation); + if (!d->componentComplete) { + d->running = r; + if (r == false) + d->avoidPropertyValueSourceStart = true; + else if (!d->registered) { + d->registered = true; + QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this)); + engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()")); + } + return; + } + + if (d->running == r) + return; + + if (d->group || d->disableUserControl) { + qmlInfo(this) << "setRunning() cannot be used on non-root animation nodes."; + return; + } + + d->running = r; + if (d->running) { + bool supressStart = false; + if (d->alwaysRunToEnd && d->loopCount != 1 + && qtAnimation()->state() == QAbstractAnimation::Running) { + //we've restarted before the final loop finished; restore proper loop count + if (d->loopCount == -1) + qtAnimation()->setLoopCount(d->loopCount); + else + qtAnimation()->setLoopCount(qtAnimation()->currentLoop() + d->loopCount); + supressStart = true; //we want the animation to continue, rather than restart + } + + if (!d->connectedTimeLine) { + QObject::connect(qtAnimation(), SIGNAL(finished()), + this, SLOT(timelineComplete())); + d->connectedTimeLine = true; + } + if (!supressStart) + d->commence(); + emit started(); + } else { + if (d->alwaysRunToEnd) { + if (d->loopCount != 1) + qtAnimation()->setLoopCount(qtAnimation()->currentLoop()+1); //finish the current loop + } else + qtAnimation()->stop(); + + emit completed(); + } + + emit runningChanged(d->running); +} + +/*! + \qmlproperty bool Animation::paused + This property holds whether the animation is currently paused. + + The \c paused property can be set to declaratively control whether or not + an animation is paused. + + Animations can also be paused and resumed imperatively from JavaScript + using the \c pause() and \c resume() methods. + + By default, animations are not paused. +*/ +bool QDeclarative1AbstractAnimation::isPaused() const +{ + Q_D(const QDeclarative1AbstractAnimation); + return d->paused; +} + +void QDeclarative1AbstractAnimation::setPaused(bool p) +{ + Q_D(QDeclarative1AbstractAnimation); + if (d->paused == p) + return; + + if (d->group || d->disableUserControl) { + qmlInfo(this) << "setPaused() cannot be used on non-root animation nodes."; + return; + } + + d->paused = p; + if (d->paused) + qtAnimation()->pause(); + else + qtAnimation()->resume(); + + emit pausedChanged(d->paused); +} + +void QDeclarative1AbstractAnimation::classBegin() +{ + Q_D(QDeclarative1AbstractAnimation); + d->componentComplete = false; +} + +void QDeclarative1AbstractAnimation::componentComplete() +{ + Q_D(QDeclarative1AbstractAnimation); + d->componentComplete = true; +} + +void QDeclarative1AbstractAnimation::componentFinalized() +{ + Q_D(QDeclarative1AbstractAnimation); + if (d->running) { + d->running = false; + setRunning(true); + } +} + +/*! + \qmlproperty bool Animation::alwaysRunToEnd + This property holds whether the animation should run to completion when it is stopped. + + If this true the animation will complete its current iteration when it + is stopped - either by setting the \c running property to false, or by + calling the \c stop() method. The \c complete() method is not effected + by this value. + + This behavior is most useful when the \c repeat property is set, as the + animation will finish playing normally but not restart. + + By default, the alwaysRunToEnd property is not set. + + \note alwaysRunToEnd has no effect on animations in a Transition. +*/ +bool QDeclarative1AbstractAnimation::alwaysRunToEnd() const +{ + Q_D(const QDeclarative1AbstractAnimation); + return d->alwaysRunToEnd; +} + +void QDeclarative1AbstractAnimation::setAlwaysRunToEnd(bool f) +{ + Q_D(QDeclarative1AbstractAnimation); + if (d->alwaysRunToEnd == f) + return; + + d->alwaysRunToEnd = f; + emit alwaysRunToEndChanged(f); +} + +/*! + \qmlproperty int Animation::loops + This property holds the number of times the animation should play. + + By default, \c loops is 1: the animation will play through once and then stop. + + If set to Animation.Infinite, the animation will continuously repeat until it is explicitly + stopped - either by setting the \c running property to false, or by calling + the \c stop() method. + + In the following example, the rectangle will spin indefinitely. + + \code + Rectangle { + width: 100; height: 100; color: "green" + RotationAnimation on rotation { + loops: Animation.Infinite + from: 0 + to: 360 + } + } + \endcode +*/ +int QDeclarative1AbstractAnimation::loops() const +{ + Q_D(const QDeclarative1AbstractAnimation); + return d->loopCount; +} + +void QDeclarative1AbstractAnimation::setLoops(int loops) +{ + Q_D(QDeclarative1AbstractAnimation); + if (loops < 0) + loops = -1; + + if (loops == d->loopCount) + return; + + d->loopCount = loops; + qtAnimation()->setLoopCount(loops); + emit loopCountChanged(loops); +} + + +int QDeclarative1AbstractAnimation::currentTime() +{ + return qtAnimation()->currentLoopTime(); +} + +void QDeclarative1AbstractAnimation::setCurrentTime(int time) +{ + qtAnimation()->setCurrentTime(time); +} + +QDeclarative1AnimationGroup *QDeclarative1AbstractAnimation::group() const +{ + Q_D(const QDeclarative1AbstractAnimation); + return d->group; +} + +void QDeclarative1AbstractAnimation::setGroup(QDeclarative1AnimationGroup *g) +{ + Q_D(QDeclarative1AbstractAnimation); + if (d->group == g) + return; + if (d->group) + static_cast(d->group->d_func())->animations.removeAll(this); + + d->group = g; + + if (d->group && !static_cast(d->group->d_func())->animations.contains(this)) + static_cast(d->group->d_func())->animations.append(this); + + //if (g) //if removed from a group, then the group should no longer be the parent + setParent(g); +} + +/*! + \qmlmethod Animation::start() + \brief Starts the animation. + + If the animation is already running, calling this method has no effect. The + \c running property will be true following a call to \c start(). +*/ +void QDeclarative1AbstractAnimation::start() +{ + setRunning(true); +} + +/*! + \qmlmethod Animation::pause() + \brief Pauses the animation. + + If the animation is already paused, calling this method has no effect. The + \c paused property will be true following a call to \c pause(). +*/ +void QDeclarative1AbstractAnimation::pause() +{ + setPaused(true); +} + +/*! + \qmlmethod Animation::resume() + \brief Resumes a paused animation. + + If the animation is not paused, calling this method has no effect. The + \c paused property will be false following a call to \c resume(). +*/ +void QDeclarative1AbstractAnimation::resume() +{ + setPaused(false); +} + +/*! + \qmlmethod Animation::stop() + \brief Stops the animation. + + If the animation is not running, calling this method has no effect. The + \c running property will be false following a call to \c stop(). + + Normally \c stop() stops the animation immediately, and the animation has + no further influence on property values. In this example animation + \code + Rectangle { + NumberAnimation on x { from: 0; to: 100; duration: 500 } + } + \endcode + was stopped at time 250ms, the \c x property will have a value of 50. + + However, if the \c alwaysRunToEnd property is set, the animation will + continue running until it completes and then stop. The \c running property + will still become false immediately. +*/ +void QDeclarative1AbstractAnimation::stop() +{ + setRunning(false); +} + +/*! + \qmlmethod Animation::restart() + \brief Restarts the animation. + + This is a convenience method, and is equivalent to calling \c stop() and + then \c start(). +*/ +void QDeclarative1AbstractAnimation::restart() +{ + stop(); + start(); +} + +/*! + \qmlmethod Animation::complete() + \brief Stops the animation, jumping to the final property values. + + If the animation is not running, calling this method has no effect. The + \c running property will be false following a call to \c complete(). + + Unlike \c stop(), \c complete() immediately fast-forwards the animation to + its end. In the following example, + \code + Rectangle { + NumberAnimation on x { from: 0; to: 100; duration: 500 } + } + \endcode + calling \c stop() at time 250ms will result in the \c x property having + a value of 50, while calling \c complete() will set the \c x property to + 100, exactly as though the animation had played the whole way through. +*/ +void QDeclarative1AbstractAnimation::complete() +{ + if (isRunning()) { + qtAnimation()->setCurrentTime(qtAnimation()->duration()); + } +} + +void QDeclarative1AbstractAnimation::setTarget(const QDeclarativeProperty &p) +{ + Q_D(QDeclarative1AbstractAnimation); + d->defaultProperty = p; + + if (!d->avoidPropertyValueSourceStart) + setRunning(true); +} + +/* + we rely on setTarget only being called when used as a value source + so this function allows us to do the same thing as setTarget without + that assumption +*/ +void QDeclarative1AbstractAnimation::setDefaultTarget(const QDeclarativeProperty &p) +{ + Q_D(QDeclarative1AbstractAnimation); + d->defaultProperty = p; +} + +/* + don't allow start/stop/pause/resume to be manually invoked, + because something else (like a Behavior) already has control + over the animation. +*/ +void QDeclarative1AbstractAnimation::setDisableUserControl() +{ + Q_D(QDeclarative1AbstractAnimation); + d->disableUserControl = true; +} + +void QDeclarative1AbstractAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_UNUSED(actions); + Q_UNUSED(modified); + Q_UNUSED(direction); +} + +void QDeclarative1AbstractAnimation::timelineComplete() +{ + Q_D(QDeclarative1AbstractAnimation); + setRunning(false); + if (d->alwaysRunToEnd && d->loopCount != 1) { + //restore the proper loopCount for the next run + qtAnimation()->setLoopCount(d->loopCount); + } +} + +/*! + \qmlclass PauseAnimation QDeclarative1PauseAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The PauseAnimation element provides a pause for an animation. + + When used in a SequentialAnimation, PauseAnimation is a step when + nothing happens, for a specified duration. + + A 500ms animation sequence, with a 100ms pause between two animations: + \code + SequentialAnimation { + NumberAnimation { ... duration: 200 } + PauseAnimation { duration: 100 } + NumberAnimation { ... duration: 200 } + } + \endcode + + \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ +QDeclarative1PauseAnimation::QDeclarative1PauseAnimation(QObject *parent) +: QDeclarative1AbstractAnimation(*(new QDeclarative1PauseAnimationPrivate), parent) +{ + Q_D(QDeclarative1PauseAnimation); + d->init(); +} + +QDeclarative1PauseAnimation::~QDeclarative1PauseAnimation() +{ +} + +void QDeclarative1PauseAnimationPrivate::init() +{ + Q_Q(QDeclarative1PauseAnimation); + pa = new QPauseAnimation; + QDeclarative_setParent_noEvent(pa, q); +} + +/*! + \qmlproperty int PauseAnimation::duration + This property holds the duration of the pause in milliseconds + + The default value is 250. +*/ +int QDeclarative1PauseAnimation::duration() const +{ + Q_D(const QDeclarative1PauseAnimation); + return d->pa->duration(); +} + +void QDeclarative1PauseAnimation::setDuration(int duration) +{ + if (duration < 0) { + qmlInfo(this) << tr("Cannot set a duration of < 0"); + return; + } + + Q_D(QDeclarative1PauseAnimation); + if (d->pa->duration() == duration) + return; + d->pa->setDuration(duration); + emit durationChanged(duration); +} + +QAbstractAnimation *QDeclarative1PauseAnimation::qtAnimation() +{ + Q_D(QDeclarative1PauseAnimation); + return d->pa; +} + +/*! + \qmlclass ColorAnimation QDeclarative1ColorAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits PropertyAnimation + \brief The ColorAnimation element animates changes in color values. + + ColorAnimation is a specialized PropertyAnimation that defines an + animation to be applied when a color value changes. + + Here is a ColorAnimation applied to the \c color property of a \l Rectangle + as a property value source. It animates the \c color property's value from + its current value to a value of "red", over 1000 milliseconds: + + \snippet doc/src/snippets/declarative/coloranimation.qml 0 + + Like any other animation element, a ColorAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + For convenience, when a ColorAnimation is used in a \l Transition, it will + animate any \c color properties that have been modified during the state + change. If a \l{PropertyAnimation::}{property} or + \l{PropertyAnimation::}{properties} are explicitly set for the animation, + then those are used instead. + + \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ +QDeclarative1ColorAnimation::QDeclarative1ColorAnimation(QObject *parent) +: QDeclarative1PropertyAnimation(parent) +{ + Q_D(QDeclarative1PropertyAnimation); + d->interpolatorType = QMetaType::QColor; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + d->defaultToInterpolatorType = true; +} + +QDeclarative1ColorAnimation::~QDeclarative1ColorAnimation() +{ +} + +/*! + \qmlproperty color ColorAnimation::from + This property holds the color value at which the animation should begin. + + For example, the following animation is not applied until a color value + has reached "#c0c0c0": + + \qml + Item { + states: [ + // States are defined here... + ] + + transition: Transition { + NumberAnimation { from: "#c0c0c0"; duration: 2000 } + } + } + \endqml + + If the ColorAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the starting state of the + \l Transition, or the current value of the property at the moment the + \l Behavior is triggered. + + \sa {QML Animation and Transitions} +*/ +QColor QDeclarative1ColorAnimation::from() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->from.value(); +} + +void QDeclarative1ColorAnimation::setFrom(const QColor &f) +{ + QDeclarative1PropertyAnimation::setFrom(f); +} + +/*! + \qmlproperty color ColorAnimation::to + + This property holds the color value at which the animation should end. + + If the ColorAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the end state of the + \l Transition, or the value of the property change that triggered the + \l Behavior. + + \sa {QML Animation and Transitions} +*/ +QColor QDeclarative1ColorAnimation::to() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->to.value(); +} + +void QDeclarative1ColorAnimation::setTo(const QColor &t) +{ + QDeclarative1PropertyAnimation::setTo(t); +} + + + +/*! + \qmlclass ScriptAction QDeclarative1ScriptAction + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The ScriptAction element allows scripts to be run during an animation. + + ScriptAction can be used to run a script at a specific point in an animation. + + \qml + SequentialAnimation { + NumberAnimation { + // ... + } + ScriptAction { script: doSomething(); } + NumberAnimation { + // ... + } + } + \endqml + + When used as part of a Transition, you can also target a specific + StateChangeScript to run using the \c scriptName property. + + \snippet doc/src/snippets/declarative/states/statechangescript.qml state and transition + + \sa StateChangeScript +*/ +QDeclarative1ScriptAction::QDeclarative1ScriptAction(QObject *parent) + :QDeclarative1AbstractAnimation(*(new QDeclarative1ScriptActionPrivate), parent) +{ + Q_D(QDeclarative1ScriptAction); + d->init(); +} + +QDeclarative1ScriptAction::~QDeclarative1ScriptAction() +{ +} + +void QDeclarative1ScriptActionPrivate::init() +{ + Q_Q(QDeclarative1ScriptAction); + rsa = new QActionAnimation_1(&proxy); + QDeclarative_setParent_noEvent(rsa, q); +} + +/*! + \qmlproperty script ScriptAction::script + This property holds the script to run. +*/ +QDeclarativeScriptString QDeclarative1ScriptAction::script() const +{ + Q_D(const QDeclarative1ScriptAction); + return d->script; +} + +void QDeclarative1ScriptAction::setScript(const QDeclarativeScriptString &script) +{ + Q_D(QDeclarative1ScriptAction); + d->script = script; +} + +/*! + \qmlproperty string ScriptAction::scriptName + This property holds the the name of the StateChangeScript to run. + + This property is only valid when ScriptAction is used as part of a transition. + If both script and scriptName are set, scriptName will be used. + + \note When using scriptName in a reversible transition, the script will only + be run when the transition is being run forwards. +*/ +QString QDeclarative1ScriptAction::stateChangeScriptName() const +{ + Q_D(const QDeclarative1ScriptAction); + return d->name; +} + +void QDeclarative1ScriptAction::setStateChangeScriptName(const QString &name) +{ + Q_D(QDeclarative1ScriptAction); + d->name = name; +} + +void QDeclarative1ScriptActionPrivate::execute() +{ + Q_Q(QDeclarative1ScriptAction); + if (hasRunScriptScript && reversing) + return; + + QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script; + + const QString &str = scriptStr.script(); + if (!str.isEmpty()) { + QDeclarativeExpression expr(scriptStr.context(), scriptStr.scopeObject(), str); + QDeclarativeData *ddata = QDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); + expr.evaluate(); + if (expr.hasError()) + qmlInfo(q) << expr.error(); + } +} + +void QDeclarative1ScriptAction::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1ScriptAction); + Q_UNUSED(modified); + + d->hasRunScriptScript = false; + d->reversing = (direction == Backward); + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarative1Action &action = actions[ii]; + + if (action.event && action.event->typeName() == QLatin1String("StateChangeScript") + && static_cast(action.event)->name() == d->name) { + d->runScriptScript = static_cast(action.event)->script(); + d->hasRunScriptScript = true; + action.actionDone = true; + break; //only match one (names should be unique) + } + } +} + +QAbstractAnimation *QDeclarative1ScriptAction::qtAnimation() +{ + Q_D(QDeclarative1ScriptAction); + return d->rsa; +} + + + +/*! + \qmlclass PropertyAction QDeclarative1PropertyAction + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The PropertyAction element allows immediate property changes during animation. + + PropertyAction is used to specify an immediate property change during an + animation. The property change is not animated. + + It is useful for setting non-animated property values during an animation. + + For example, here is a SequentialAnimation that sets the image's + \l {Image::}{smooth} property to \c true, animates the width of the image, + then sets \l {Image::}{smooth} back to \c false: + + \snippet doc/src/snippets/declarative/propertyaction.qml standalone + + PropertyAction is also useful for setting the exact point at which a property + change should occur during a \l Transition. For example, if PropertyChanges + was used in a \l State to rotate an item around a particular + \l {Item::}{transformOrigin}, it might be implemented like this: + + \snippet doc/src/snippets/declarative/propertyaction.qml transition + + However, with this code, the \c transformOrigin is not set until \e after + the animation, as a \l State is taken to define the values at the \e end of + a transition. The animation would rotate at the default \c transformOrigin, + then jump to \c Item.BottomRight. To fix this, insert a PropertyAction + before the RotationAnimation begins: + + \snippet doc/src/snippets/declarative/propertyaction-sequential.qml sequential + + This immediately sets the \c transformOrigin property to the value defined + in the end state of the \l Transition (i.e. the value defined in the + PropertyAction object) so that the rotation animation begins with the + correct transform origin. + + \sa {QML Animation and Transitions}, QtDeclarative +*/ +QDeclarative1PropertyAction::QDeclarative1PropertyAction(QObject *parent) +: QDeclarative1AbstractAnimation(*(new QDeclarative1PropertyActionPrivate), parent) +{ + Q_D(QDeclarative1PropertyAction); + d->init(); +} + +QDeclarative1PropertyAction::~QDeclarative1PropertyAction() +{ +} + +void QDeclarative1PropertyActionPrivate::init() +{ + Q_Q(QDeclarative1PropertyAction); + spa = new QActionAnimation_1; + QDeclarative_setParent_noEvent(spa, q); +} + +QObject *QDeclarative1PropertyAction::target() const +{ + Q_D(const QDeclarative1PropertyAction); + return d->target; +} + +void QDeclarative1PropertyAction::setTarget(QObject *o) +{ + Q_D(QDeclarative1PropertyAction); + if (d->target == o) + return; + d->target = o; + emit targetChanged(); +} + +QString QDeclarative1PropertyAction::property() const +{ + Q_D(const QDeclarative1PropertyAction); + return d->propertyName; +} + +void QDeclarative1PropertyAction::setProperty(const QString &n) +{ + Q_D(QDeclarative1PropertyAction); + if (d->propertyName == n) + return; + d->propertyName = n; + emit propertyChanged(); +} + +/*! + \qmlproperty Object PropertyAction::target + \qmlproperty list PropertyAction::targets + \qmlproperty string PropertyAction::property + \qmlproperty string PropertyAction::properties + + These properties determine the items and their properties that are + affected by this action. + + The details of how these properties are interpreted in different situations + is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation + documentation. + + \sa exclude +*/ +QString QDeclarative1PropertyAction::properties() const +{ + Q_D(const QDeclarative1PropertyAction); + return d->properties; +} + +void QDeclarative1PropertyAction::setProperties(const QString &p) +{ + Q_D(QDeclarative1PropertyAction); + if (d->properties == p) + return; + d->properties = p; + emit propertiesChanged(p); +} + +QDeclarativeListProperty QDeclarative1PropertyAction::targets() +{ + Q_D(QDeclarative1PropertyAction); + return QDeclarativeListProperty(this, d->targets); +} + +/*! + \qmlproperty list PropertyAction::exclude + This property holds the objects that should not be affected by this action. + + \sa targets +*/ +QDeclarativeListProperty QDeclarative1PropertyAction::exclude() +{ + Q_D(QDeclarative1PropertyAction); + return QDeclarativeListProperty(this, d->exclude); +} + +/*! + \qmlproperty any PropertyAction::value + This property holds the value to be set on the property. + + If the PropertyAction is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the end state of the + \l Transition, or the value of the property change that triggered the + \l Behavior. +*/ +QVariant QDeclarative1PropertyAction::value() const +{ + Q_D(const QDeclarative1PropertyAction); + return d->value; +} + +void QDeclarative1PropertyAction::setValue(const QVariant &v) +{ + Q_D(QDeclarative1PropertyAction); + if (d->value.isNull || d->value != v) { + d->value = v; + emit valueChanged(v); + } +} + +QAbstractAnimation *QDeclarative1PropertyAction::qtAnimation() +{ + Q_D(QDeclarative1PropertyAction); + return d->spa; +} + +void QDeclarative1PropertyAction::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1PropertyAction); + Q_UNUSED(direction); + + struct QDeclarative1SetPropertyAnimationAction : public QAbstractAnimationAction + { + QDeclarative1StateActions actions; + virtual void doAction() + { + for (int ii = 0; ii < actions.count(); ++ii) { + const QDeclarative1Action &action = actions.at(ii); + QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + } + } + }; + + QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); + for (int ii = 0; ii < props.count(); ++ii) + props[ii] = props.at(ii).trimmed(); + if (!d->propertyName.isEmpty()) + props << d->propertyName; + + QList targets = d->targets; + if (d->target) + targets.append(d->target); + + bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); + + if (d->defaultProperty.isValid() && !hasSelectors) { + props << d->defaultProperty.name(); + targets << d->defaultProperty.object(); + } + + QDeclarative1SetPropertyAnimationAction *data = new QDeclarative1SetPropertyAnimationAction; + + bool hasExplicit = false; + //an explicit animation has been specified + if (d->value.isValid()) { + for (int i = 0; i < props.count(); ++i) { + for (int j = 0; j < targets.count(); ++j) { + QDeclarative1Action myAction; + myAction.property = d->createProperty(targets.at(j), props.at(i), this); + if (myAction.property.isValid()) { + myAction.toValue = d->value; + QDeclarative1PropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); + data->actions << myAction; + hasExplicit = true; + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarative1Action &action = actions[ii]; + if (action.property.object() == myAction.property.object() && + myAction.property.name() == action.property.name()) { + modified << action.property; + break; //### any chance there could be multiples? + } + } + } + } + } + } + + if (!hasExplicit) + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarative1Action &action = actions[ii]; + + QObject *obj = action.property.object(); + QString propertyName = action.property.name(); + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) { + QDeclarative1Action myAction = action; + + if (d->value.isValid()) + myAction.toValue = d->value; + QDeclarative1PropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); + + modified << action.property; + data->actions << myAction; + action.fromValue = myAction.toValue; + } + } + + if (data->actions.count()) { + d->spa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped); + } else { + delete data; + } +} + +/*! + \qmlclass NumberAnimation QDeclarative1NumberAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits PropertyAnimation + \brief The NumberAnimation element animates changes in qreal-type values. + + NumberAnimation is a specialized PropertyAnimation that defines an + animation to be applied when a numerical value changes. + + Here is a NumberAnimation applied to the \c x property of a \l Rectangle + as a property value source. It animates the \c x value from its current + value to a value of 50, over 1000 milliseconds: + + \snippet doc/src/snippets/declarative/numberanimation.qml 0 + + Like any other animation element, a NumberAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + Note that NumberAnimation may not animate smoothly if there are irregular + changes in the number value that it is tracking. If this is the case, use + SmoothedAnimation instead. + + \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ +QDeclarative1NumberAnimation::QDeclarative1NumberAnimation(QObject *parent) +: QDeclarative1PropertyAnimation(parent) +{ + init(); +} + +QDeclarative1NumberAnimation::QDeclarative1NumberAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent) +: QDeclarative1PropertyAnimation(dd, parent) +{ + init(); +} + +QDeclarative1NumberAnimation::~QDeclarative1NumberAnimation() +{ +} + +void QDeclarative1NumberAnimation::init() +{ + Q_D(QDeclarative1PropertyAnimation); + d->interpolatorType = QMetaType::QReal; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); +} + +/*! + \qmlproperty real NumberAnimation::from + This property holds the starting value for the animation. + + For example, the following animation is not applied until the \c x value + has reached 100: + + \qml + Item { + states: [ + // ... + ] + + transition: Transition { + NumberAnimation { properties: "x"; from: 100; duration: 200 } + } + } + \endqml + + If the NumberAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the starting state of the + \l Transition, or the current value of the property at the moment the + \l Behavior is triggered. + + \sa {QML Animation and Transitions} +*/ + +qreal QDeclarative1NumberAnimation::from() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->from.toReal(); +} + +void QDeclarative1NumberAnimation::setFrom(qreal f) +{ + QDeclarative1PropertyAnimation::setFrom(f); +} + +/*! + \qmlproperty real NumberAnimation::to + This property holds the end value for the animation. + + If the NumberAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the end state of the + \l Transition, or the value of the property change that triggered the + \l Behavior. + + \sa {QML Animation and Transitions} +*/ +qreal QDeclarative1NumberAnimation::to() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->to.toReal(); +} + +void QDeclarative1NumberAnimation::setTo(qreal t) +{ + QDeclarative1PropertyAnimation::setTo(t); +} + + + +/*! + \qmlclass Vector3dAnimation QDeclarative1Vector3dAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits PropertyAnimation + \brief The Vector3dAnimation element animates changes in QVector3d values. + + Vector3dAnimation is a specialized PropertyAnimation that defines an + animation to be applied when a Vector3d value changes. + + Like any other animation element, a Vector3dAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ +QDeclarative1Vector3dAnimation::QDeclarative1Vector3dAnimation(QObject *parent) +: QDeclarative1PropertyAnimation(parent) +{ + Q_D(QDeclarative1PropertyAnimation); + d->interpolatorType = QMetaType::QVector3D; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + d->defaultToInterpolatorType = true; +} + +QDeclarative1Vector3dAnimation::~QDeclarative1Vector3dAnimation() +{ +} + +/*! + \qmlproperty real Vector3dAnimation::from + This property holds the starting value for the animation. + + If the Vector3dAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the starting state of the + \l Transition, or the current value of the property at the moment the + \l Behavior is triggered. + + \sa {QML Animation and Transitions} +*/ +QVector3D QDeclarative1Vector3dAnimation::from() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->from.value(); +} + +void QDeclarative1Vector3dAnimation::setFrom(QVector3D f) +{ + QDeclarative1PropertyAnimation::setFrom(f); +} + +/*! + \qmlproperty real Vector3dAnimation::to + This property holds the end value for the animation. + + If the Vector3dAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the end state of the + \l Transition, or the value of the property change that triggered the + \l Behavior. + + \sa {QML Animation and Transitions} +*/ +QVector3D QDeclarative1Vector3dAnimation::to() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->to.value(); +} + +void QDeclarative1Vector3dAnimation::setTo(QVector3D t) +{ + QDeclarative1PropertyAnimation::setTo(t); +} + + + +/*! + \qmlclass RotationAnimation QDeclarative1RotationAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits PropertyAnimation + \brief The RotationAnimation element animates changes in rotation values. + + RotationAnimation is a specialized PropertyAnimation that gives control + over the direction of rotation during an animation. + + By default, it rotates in the direction + of the numerical change; a rotation from 0 to 240 will rotate 240 degrees + clockwise, while a rotation from 240 to 0 will rotate 240 degrees + counterclockwise. The \l direction property can be set to specify the + direction in which the rotation should occur. + + In the following example we use RotationAnimation to animate the rotation + between states via the shortest path: + + \snippet doc/src/snippets/declarative/rotationanimation.qml 0 + + Notice the RotationAnimation did not need to set a \l target + value. As a convenience, when used in a transition, RotationAnimation will rotate all + properties named "rotation" or "angle". You can override this by providing + your own properties via \l {PropertyAnimation::properties}{properties} or + \l {PropertyAnimation::property}{property}. + + Also, note the \l Rectangle will be rotated around its default + \l {Item::}{transformOrigin} (which is \c Item.Center). To use a different + transform origin, set the origin in the PropertyChanges object and apply + the change at the start of the animation using PropertyAction. See the + PropertyAction documentation for more details. + + Like any other animation element, a RotationAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ +QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff > 180.0){ + newt -= 360.0; + diff -= 360.0; + } + while(diff < -180.0){ + newt += 360.0; + diff += 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff < 0.0){ + newt += 360.0; + diff += 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff > 0.0){ + newt -= 360.0; + diff -= 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QDeclarative1RotationAnimation::QDeclarative1RotationAnimation(QObject *parent) +: QDeclarative1PropertyAnimation(*(new QDeclarative1RotationAnimationPrivate), parent) +{ + Q_D(QDeclarative1RotationAnimation); + d->interpolatorType = QMetaType::QReal; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + d->defaultProperties = QLatin1String("rotation,angle"); +} + +QDeclarative1RotationAnimation::~QDeclarative1RotationAnimation() +{ +} + +/*! + \qmlproperty real RotationAnimation::from + This property holds the starting value for the animation. + + For example, the following animation is not applied until the \c angle value + has reached 100: + + \qml + Item { + states: [ + // ... + ] + + transition: Transition { + RotationAnimation { properties: "angle"; from: 100; duration: 2000 } + } + } + \endqml + + If the RotationAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the starting state of the + \l Transition, or the current value of the property at the moment the + \l Behavior is triggered. + + \sa {QML Animation and Transitions} +*/ +qreal QDeclarative1RotationAnimation::from() const +{ + Q_D(const QDeclarative1RotationAnimation); + return d->from.toReal(); +} + +void QDeclarative1RotationAnimation::setFrom(qreal f) +{ + QDeclarative1PropertyAnimation::setFrom(f); +} + +/*! + \qmlproperty real RotationAnimation::to + This property holds the end value for the animation.. + + If the RotationAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the end state of the + \l Transition, or the value of the property change that triggered the + \l Behavior. + + \sa {QML Animation and Transitions} +*/ +qreal QDeclarative1RotationAnimation::to() const +{ + Q_D(const QDeclarative1RotationAnimation); + return d->to.toReal(); +} + +void QDeclarative1RotationAnimation::setTo(qreal t) +{ + QDeclarative1PropertyAnimation::setTo(t); +} + +/*! + \qmlproperty enumeration RotationAnimation::direction + This property holds the direction of the rotation. + + Possible values are: + + \list + \o RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers. + A rotation from 10 to 350 will rotate 340 degrees clockwise. + \o RotationAnimation.Clockwise - Rotate clockwise between the two values + \o RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values + \o RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path. + A rotation from 10 to 350 will rotate 20 degrees counterclockwise. + \endlist +*/ +QDeclarative1RotationAnimation::RotationDirection QDeclarative1RotationAnimation::direction() const +{ + Q_D(const QDeclarative1RotationAnimation); + return d->direction; +} + +void QDeclarative1RotationAnimation::setDirection(QDeclarative1RotationAnimation::RotationDirection direction) +{ + Q_D(QDeclarative1RotationAnimation); + if (d->direction == direction) + return; + + d->direction = direction; + switch(d->direction) { + case Clockwise: + d->interpolator = reinterpret_cast(&_q_interpolateClockwiseRotation); + break; + case Counterclockwise: + d->interpolator = reinterpret_cast(&_q_interpolateCounterclockwiseRotation); + break; + case Shortest: + d->interpolator = reinterpret_cast(&_q_interpolateShortestRotation); + break; + default: + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + break; + } + + emit directionChanged(); +} + + + +QDeclarative1AnimationGroup::QDeclarative1AnimationGroup(QObject *parent) +: QDeclarative1AbstractAnimation(*(new QDeclarative1AnimationGroupPrivate), parent) +{ +} + +QDeclarative1AnimationGroup::QDeclarative1AnimationGroup(QDeclarative1AnimationGroupPrivate &dd, QObject *parent) + : QDeclarative1AbstractAnimation(dd, parent) +{ +} + +void QDeclarative1AnimationGroupPrivate::append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *a) +{ + QDeclarative1AnimationGroup *q = qobject_cast(list->object); + if (q) { + a->setGroup(q); + // This is an optimization for the parenting that already occurs via addAnimation + QDeclarative_setParent_noEvent(a->qtAnimation(), q->d_func()->ag); + q->d_func()->ag->addAnimation(a->qtAnimation()); + } +} + +void QDeclarative1AnimationGroupPrivate::clear_animation(QDeclarativeListProperty *list) +{ + QDeclarative1AnimationGroup *q = qobject_cast(list->object); + if (q) { + while (q->d_func()->animations.count()) { + QDeclarative1AbstractAnimation *firstAnim = q->d_func()->animations.at(0); + QDeclarative_setParent_noEvent(firstAnim->qtAnimation(), 0); + q->d_func()->ag->removeAnimation(firstAnim->qtAnimation()); + firstAnim->setGroup(0); + } + } +} + +QDeclarative1AnimationGroup::~QDeclarative1AnimationGroup() +{ +} + +QDeclarativeListProperty QDeclarative1AnimationGroup::animations() +{ + Q_D(QDeclarative1AnimationGroup); + QDeclarativeListProperty list(this, d->animations); + list.append = &QDeclarative1AnimationGroupPrivate::append_animation; + list.clear = &QDeclarative1AnimationGroupPrivate::clear_animation; + return list; +} + +/*! + \qmlclass SequentialAnimation QDeclarative1SequentialAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The SequentialAnimation element allows animations to be run sequentially. + + The SequentialAnimation and ParallelAnimation elements allow multiple + animations to be run together. Animations defined in a SequentialAnimation + are run one after the other, while animations defined in a ParallelAnimation + are run at the same time. + + The following example runs two number animations in a sequence. The \l Rectangle + animates to a \c x position of 50, then to a \c y position of 50. + + \snippet doc/src/snippets/declarative/sequentialanimation.qml 0 + + Animations defined within a \l Transition are automatically run in parallel, + so SequentialAnimation can be used to enclose the animations in a \l Transition + if this is the preferred behavior. + + Like any other animation element, a SequentialAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \note Once an animation has been grouped into a SequentialAnimation or + ParallelAnimation, it cannot be individually started and stopped; the + SequentialAnimation or ParallelAnimation must be started and stopped as a group. + + \sa ParallelAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ + +QDeclarative1SequentialAnimation::QDeclarative1SequentialAnimation(QObject *parent) : + QDeclarative1AnimationGroup(parent) +{ + Q_D(QDeclarative1AnimationGroup); + d->ag = new QSequentialAnimationGroup; + QDeclarative_setParent_noEvent(d->ag, this); +} + +QDeclarative1SequentialAnimation::~QDeclarative1SequentialAnimation() +{ +} + +QAbstractAnimation *QDeclarative1SequentialAnimation::qtAnimation() +{ + Q_D(QDeclarative1AnimationGroup); + return d->ag; +} + +void QDeclarative1SequentialAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1AnimationGroup); + + int inc = 1; + int from = 0; + if (direction == Backward) { + inc = -1; + from = d->animations.count() - 1; + } + + bool valid = d->defaultProperty.isValid(); + for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) { + if (valid) + d->animations.at(ii)->setDefaultTarget(d->defaultProperty); + d->animations.at(ii)->transition(actions, modified, direction); + } +} + + + +/*! + \qmlclass ParallelAnimation QDeclarative1ParallelAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The ParallelAnimation element allows animations to be run in parallel. + + The SequentialAnimation and ParallelAnimation elements allow multiple + animations to be run together. Animations defined in a SequentialAnimation + are run one after the other, while animations defined in a ParallelAnimation + are run at the same time. + + The following animation runs two number animations in parallel. The \l Rectangle + moves to (50,50) by animating its \c x and \c y properties at the same time. + + \snippet doc/src/snippets/declarative/parallelanimation.qml 0 + + Like any other animation element, a ParallelAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \note Once an animation has been grouped into a SequentialAnimation or + ParallelAnimation, it cannot be individually started and stopped; the + SequentialAnimation or ParallelAnimation must be started and stopped as a group. + + \sa SequentialAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ +QDeclarative1ParallelAnimation::QDeclarative1ParallelAnimation(QObject *parent) : + QDeclarative1AnimationGroup(parent) +{ + Q_D(QDeclarative1AnimationGroup); + d->ag = new QParallelAnimationGroup; + QDeclarative_setParent_noEvent(d->ag, this); +} + +QDeclarative1ParallelAnimation::~QDeclarative1ParallelAnimation() +{ +} + +QAbstractAnimation *QDeclarative1ParallelAnimation::qtAnimation() +{ + Q_D(QDeclarative1AnimationGroup); + return d->ag; +} + +void QDeclarative1ParallelAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1AnimationGroup); + bool valid = d->defaultProperty.isValid(); + for (int ii = 0; ii < d->animations.count(); ++ii) { + if (valid) + d->animations.at(ii)->setDefaultTarget(d->defaultProperty); + d->animations.at(ii)->transition(actions, modified, direction); + } +} + + + +//convert a variant from string type to another animatable type +void QDeclarative1PropertyAnimationPrivate::convertVariant(QVariant &variant, int type) +{ + if (variant.userType() != QVariant::String) { + variant.convert((QVariant::Type)type); + return; + } + + switch (type) { + case QVariant::Rect: { + variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()).toRect()); + break; + } + case QVariant::RectF: { + variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString())); + break; + } + case QVariant::Point: { + variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()).toPoint()); + break; + } + case QVariant::PointF: { + variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString())); + break; + } + case QVariant::Size: { + variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()).toSize()); + break; + } + case QVariant::SizeF: { + variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString())); + break; + } + case QVariant::Color: { + variant.setValue(QDeclarativeStringConverters::colorFromString(variant.toString())); + break; + } + case QVariant::Vector3D: { + variant.setValue(QDeclarativeStringConverters::vector3DFromString(variant.toString())); + break; + } + default: + if (QDeclarativeValueTypeFactory::isValueType((uint)type)) { + variant.convert((QVariant::Type)type); + } else { + QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type); + if (converter) + variant = converter(variant.toString()); + } + break; + } +} + +/*! + \qmlclass PropertyAnimation QDeclarative1PropertyAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The PropertyAnimation element animates changes in property values. + + PropertyAnimation provides a way to animate changes to a property's value. + + It can be used to define animations in a number of ways: + + \list + \o In a \l Transition + + For example, to animate any objects that have changed their \c x or \c y properties + as a result of a state change, using an \c InOutQuad easing curve: + + \snippet doc/src/snippets/declarative/propertyanimation.qml transition + + + \o In a \l Behavior + + For example, to animate all changes to a rectangle's \c x property: + + \snippet doc/src/snippets/declarative/propertyanimation.qml behavior + + + \o As a property value source + + For example, to repeatedly animate the rectangle's \c x property: + + \snippet doc/src/snippets/declarative/propertyanimation.qml propertyvaluesource + + + \o In a signal handler + + For example, to fade out \c theObject when clicked: + \qml + MouseArea { + anchors.fill: theObject + onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } + } + \endqml + + \o Standalone + + For example, to animate \c rect's \c width property over 500ms, from its current width to 30: + + \snippet doc/src/snippets/declarative/propertyanimation.qml standalone + + \endlist + + Depending on how the animation is used, the set of properties normally used will be + different. For more information see the individual property documentation, as well + as the \l{QML Animation and Transitions} introduction. + + Note that PropertyAnimation inherits the abstract \l Animation element. + This includes additional properties and methods for controlling the animation. + + \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ + +QDeclarative1PropertyAnimation::QDeclarative1PropertyAnimation(QObject *parent) +: QDeclarative1AbstractAnimation(*(new QDeclarative1PropertyAnimationPrivate), parent) +{ + Q_D(QDeclarative1PropertyAnimation); + d->init(); +} + +QDeclarative1PropertyAnimation::QDeclarative1PropertyAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent) +: QDeclarative1AbstractAnimation(dd, parent) +{ + Q_D(QDeclarative1PropertyAnimation); + d->init(); +} + +QDeclarative1PropertyAnimation::~QDeclarative1PropertyAnimation() +{ +} + +void QDeclarative1PropertyAnimationPrivate::init() +{ + Q_Q(QDeclarative1PropertyAnimation); + va = new QDeclarative1BulkValueAnimator; + QDeclarative_setParent_noEvent(va, q); +} + +/*! + \qmlproperty int PropertyAnimation::duration + This property holds the duration of the animation, in milliseconds. + + The default value is 250. +*/ +int QDeclarative1PropertyAnimation::duration() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->va->duration(); +} + +void QDeclarative1PropertyAnimation::setDuration(int duration) +{ + if (duration < 0) { + qmlInfo(this) << tr("Cannot set a duration of < 0"); + return; + } + + Q_D(QDeclarative1PropertyAnimation); + if (d->va->duration() == duration) + return; + d->va->setDuration(duration); + emit durationChanged(duration); +} + +/*! + \qmlproperty real PropertyAnimation::from + This property holds the starting value for the animation. + + If the PropertyAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the starting state of the + \l Transition, or the current value of the property at the moment the + \l Behavior is triggered. + + \sa {QML Animation and Transitions} +*/ +QVariant QDeclarative1PropertyAnimation::from() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->from; +} + +void QDeclarative1PropertyAnimation::setFrom(const QVariant &f) +{ + Q_D(QDeclarative1PropertyAnimation); + if (d->fromIsDefined && f == d->from) + return; + d->from = f; + d->fromIsDefined = f.isValid(); + emit fromChanged(f); +} + +/*! + \qmlproperty real PropertyAnimation::to + This property holds the end value for the animation. + + If the PropertyAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the end state of the + \l Transition, or the value of the property change that triggered the + \l Behavior. + + \sa {QML Animation and Transitions} +*/ +QVariant QDeclarative1PropertyAnimation::to() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->to; +} + +void QDeclarative1PropertyAnimation::setTo(const QVariant &t) +{ + Q_D(QDeclarative1PropertyAnimation); + if (d->toIsDefined && t == d->to) + return; + d->to = t; + d->toIsDefined = t.isValid(); + emit toChanged(t); +} + +/*! + \qmlproperty enumeration PropertyAnimation::easing.type + \qmlproperty real PropertyAnimation::easing.amplitude + \qmlproperty real PropertyAnimation::easing.overshoot + \qmlproperty real PropertyAnimation::easing.period + \brief the easing curve used for the animation. + + To specify an easing curve you need to specify at least the type. For some curves you can also specify + amplitude, period and/or overshoot (more details provided after the table). The default easing curve is + \c Easing.Linear. + + \qml + PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 } + \endqml + + Available types are: + + \table + \row + \o \c Easing.Linear + \o Easing curve for a linear (t) function: velocity is constant. + \o \inlineimage qeasingcurve-linear.png + \row + \o \c Easing.InQuad + \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-inquad.png + \row + \o \c Easing.OutQuad + \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity. + \o \inlineimage qeasingcurve-outquad.png + \row + \o \c Easing.InOutQuad + \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutquad.png + \row + \o \c Easing.OutInQuad + \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinquad.png + \row + \o \c Easing.InCubic + \o Easing curve for a cubic (t^3) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-incubic.png + \row + \o \c Easing.OutCubic + \o Easing curve for a cubic (t^3) function: decelerating from zero velocity. + \o \inlineimage qeasingcurve-outcubic.png + \row + \o \c Easing.InOutCubic + \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutcubic.png + \row + \o \c Easing.OutInCubic + \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outincubic.png + \row + \o \c Easing.InQuart + \o Easing curve for a quartic (t^4) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-inquart.png + \row + \o \c Easing.OutQuart + \o Easing curve for a quartic (t^4) function: decelerating from zero velocity. + \o \inlineimage qeasingcurve-outquart.png + \row + \o \c Easing.InOutQuart + \o Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutquart.png + \row + \o \c Easing.OutInQuart + \o Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinquart.png + \row + \o \c Easing.InQuint + \o Easing curve for a quintic (t^5) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-inquint.png + \row + \o \c Easing.OutQuint + \o Easing curve for a quintic (t^5) function: decelerating from zero velocity. + \o \inlineimage qeasingcurve-outquint.png + \row + \o \c Easing.InOutQuint + \o Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutquint.png + \row + \o \c Easing.OutInQuint + \o Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinquint.png + \row + \o \c Easing.InSine + \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-insine.png + \row + \o \c Easing.OutSine + \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity. + \o \inlineimage qeasingcurve-outsine.png + \row + \o \c Easing.InOutSine + \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutsine.png + \row + \o \c Easing.OutInSine + \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinsine.png + \row + \o \c Easing.InExpo + \o Easing curve for an exponential (2^t) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-inexpo.png + \row + \o \c Easing.OutExpo + \o Easing curve for an exponential (2^t) function: decelerating from zero velocity. + \o \inlineimage qeasingcurve-outexpo.png + \row + \o \c Easing.InOutExpo + \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutexpo.png + \row + \o \c Easing.OutInExpo + \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinexpo.png + \row + \o \c Easing.InCirc + \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-incirc.png + \row + \o \c Easing.OutCirc + \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity. + \o \inlineimage qeasingcurve-outcirc.png + \row + \o \c Easing.InOutCirc + \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutcirc.png + \row + \o \c Easing.OutInCirc + \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outincirc.png + \row + \o \c Easing.InElastic + \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity. + \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. + \o \inlineimage qeasingcurve-inelastic.png + \row + \o \c Easing.OutElastic + \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity. + \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. + \o \inlineimage qeasingcurve-outelastic.png + \row + \o \c Easing.InOutElastic + \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutelastic.png + \row + \o \c Easing.OutInElastic + \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinelastic.png + \row + \o \c Easing.InBack + \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. + \o \inlineimage qeasingcurve-inback.png + \row + \o \c Easing.OutBack + \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity. + \o \inlineimage qeasingcurve-outback.png + \row + \o \c Easing.InOutBack + \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutback.png + \row + \o \c Easing.OutInBack + \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinback.png + \row + \o \c Easing.InBounce + \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity. + \o \inlineimage qeasingcurve-inbounce.png + \row + \o \c Easing.OutBounce + \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity. + \o \inlineimage qeasingcurve-outbounce.png + \row + \o \c Easing.InOutBounce + \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration. + \o \inlineimage qeasingcurve-inoutbounce.png + \row + \o \c Easing.OutInBounce + \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration. + \o \inlineimage qeasingcurve-outinbounce.png + \endtable + + \c easing.amplitude is only applicable for bounce and elastic curves (curves of type + \c Easing.InBounce, \c Easing.OutBounce, \c Easing.InOutBounce, \c Easing.OutInBounce, \c Easing.InElastic, + \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic). + + \c easing.overshoot is only applicable if \c easing.type is: \c Easing.InBack, \c Easing.OutBack, + \c Easing.InOutBack or \c Easing.OutInBack. + + \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic, + \c Easing.InOutElastic or \c Easing.OutInElastic. + + See the \l {declarative/animation/easing}{easing} example for a demonstration of + the different easing settings. +*/ +QEasingCurve QDeclarative1PropertyAnimation::easing() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->va->easingCurve(); +} + +void QDeclarative1PropertyAnimation::setEasing(const QEasingCurve &e) +{ + Q_D(QDeclarative1PropertyAnimation); + if (d->va->easingCurve() == e) + return; + + d->va->setEasingCurve(e); + emit easingChanged(e); +} + +QObject *QDeclarative1PropertyAnimation::target() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->target; +} + +void QDeclarative1PropertyAnimation::setTarget(QObject *o) +{ + Q_D(QDeclarative1PropertyAnimation); + if (d->target == o) + return; + d->target = o; + emit targetChanged(); +} + +QString QDeclarative1PropertyAnimation::property() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->propertyName; +} + +void QDeclarative1PropertyAnimation::setProperty(const QString &n) +{ + Q_D(QDeclarative1PropertyAnimation); + if (d->propertyName == n) + return; + d->propertyName = n; + emit propertyChanged(); +} + +QString QDeclarative1PropertyAnimation::properties() const +{ + Q_D(const QDeclarative1PropertyAnimation); + return d->properties; +} + +void QDeclarative1PropertyAnimation::setProperties(const QString &prop) +{ + Q_D(QDeclarative1PropertyAnimation); + if (d->properties == prop) + return; + + d->properties = prop; + emit propertiesChanged(prop); +} + +/*! + \qmlproperty string PropertyAnimation::properties + \qmlproperty list PropertyAnimation::targets + \qmlproperty string PropertyAnimation::property + \qmlproperty Object PropertyAnimation::target + + These properties are used as a set to determine which properties should be animated. + The singular and plural forms are functionally identical, e.g. + \qml + NumberAnimation { target: theItem; property: "x"; to: 500 } + \endqml + has the same meaning as + \qml + NumberAnimation { targets: theItem; properties: "x"; to: 500 } + \endqml + The singular forms are slightly optimized, so if you do have only a single target/property + to animate you should try to use them. + + The \c targets property allows multiple targets to be set. For example, this animates the + \c x property of both \c itemA and \c itemB: + + \qml + NumberAnimation { targets: [itemA, itemB]; properties: "x"; to: 500 } + \endqml + + In many cases these properties do not need to be explicitly specified, as they can be + inferred from the animation framework: + + \table 80% + \row + \o Value Source / Behavior + \o When an animation is used as a value source or in a Behavior, the default target and property + name to be animated can both be inferred. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property + Behavior on y { NumberAnimation {} } //animate theRect's y property + } + \endqml + \row + \o Transition + \o When used in a transition, a property animation is assumed to match \e all targets + but \e no properties. In practice, that means you need to specify at least the properties + in order for the animation to do anything. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + Item { id: uselessItem } + states: State { + name: "state1" + PropertyChanges { target: theRect; x: 200; y: 200; z: 4 } + PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 } + } + transitions: Transition { + //animate both theRect's and uselessItem's x and y to their final values + NumberAnimation { properties: "x,y" } + + //animate theRect's z to its final value + NumberAnimation { target: theRect; property: "z" } + } + } + \endqml + \row + \o Standalone + \o When an animation is used standalone, both the target and property need to be + explicitly specified. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + //need to explicitly specify target and property + NumberAnimation { id: theAnim; target: theRect; property: "x"; to: 500 } + MouseArea { + anchors.fill: parent + onClicked: theAnim.start() + } + } + \endqml + \endtable + + As seen in the above example, properties is specified as a comma-separated string of property names to animate. + + \sa exclude, {QML Animation and Transitions} +*/ +QDeclarativeListProperty QDeclarative1PropertyAnimation::targets() +{ + Q_D(QDeclarative1PropertyAnimation); + return QDeclarativeListProperty(this, d->targets); +} + +/*! + \qmlproperty list PropertyAnimation::exclude + This property holds the items not to be affected by this animation. + \sa PropertyAnimation::targets +*/ +QDeclarativeListProperty QDeclarative1PropertyAnimation::exclude() +{ + Q_D(QDeclarative1PropertyAnimation); + return QDeclarativeListProperty(this, d->exclude); +} + +QAbstractAnimation *QDeclarative1PropertyAnimation::qtAnimation() +{ + Q_D(QDeclarative1PropertyAnimation); + return d->va; +} + +void QDeclarative1AnimationPropertyUpdater::setValue(qreal v) +{ + bool deleted = false; + wasDeleted = &deleted; + if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 + v = 1 - v; + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarative1Action &action = actions[ii]; + + if (v == 1.) + QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + else { + if (!fromSourced && !fromDefined) { + action.fromValue = action.property.read(); + if (interpolatorType) + QDeclarative1PropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); + } + if (!interpolatorType) { + int propType = action.property.propertyType(); + if (!prevInterpolatorType || prevInterpolatorType != propType) { + prevInterpolatorType = propType; + interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); + } + } + if (interpolator) + QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + } + if (deleted) + return; + } + wasDeleted = 0; + fromSourced = true; +} + +void QDeclarative1PropertyAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1PropertyAnimation); + + QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); + for (int ii = 0; ii < props.count(); ++ii) + props[ii] = props.at(ii).trimmed(); + if (!d->propertyName.isEmpty()) + props << d->propertyName; + + QList targets = d->targets; + if (d->target) + targets.append(d->target); + + bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); + bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false; + + if (d->defaultProperty.isValid() && !hasSelectors) { + props << d->defaultProperty.name(); + targets << d->defaultProperty.object(); + } + + if (props.isEmpty() && !d->defaultProperties.isEmpty()) { + props << d->defaultProperties.split(QLatin1Char(',')); + } + + QDeclarative1AnimationPropertyUpdater *data = new QDeclarative1AnimationPropertyUpdater; + data->interpolatorType = d->interpolatorType; + data->interpolator = d->interpolator; + data->reverse = direction == Backward ? true : false; + data->fromSourced = false; + data->fromDefined = d->fromIsDefined; + + bool hasExplicit = false; + //an explicit animation has been specified + if (d->toIsDefined) { + for (int i = 0; i < props.count(); ++i) { + for (int j = 0; j < targets.count(); ++j) { + QDeclarative1Action myAction; + myAction.property = d->createProperty(targets.at(j), props.at(i), this); + if (myAction.property.isValid()) { + if (d->fromIsDefined) { + myAction.fromValue = d->from; + d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + } + myAction.toValue = d->to; + d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + data->actions << myAction; + hasExplicit = true; + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarative1Action &action = actions[ii]; + if (action.property.object() == myAction.property.object() && + myAction.property.name() == action.property.name()) { + modified << action.property; + break; //### any chance there could be multiples? + } + } + } + } + } + } + + if (!hasExplicit) + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarative1Action &action = actions[ii]; + + QObject *obj = action.property.object(); + QString propertyName = action.property.name(); + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName)) + || (useType && action.property.propertyType() == d->interpolatorType))) { + QDeclarative1Action myAction = action; + + if (d->fromIsDefined) + myAction.fromValue = d->from; + else + myAction.fromValue = QVariant(); + if (d->toIsDefined) + myAction.toValue = d->to; + + d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + + modified << action.property; + + data->actions << myAction; + action.fromValue = myAction.toValue; + } + } + + if (data->actions.count()) { + if (!d->rangeIsSet) { + d->va->setStartValue(qreal(0)); + d->va->setEndValue(qreal(1)); + d->rangeIsSet = true; + } + d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); + d->va->setFromSourcedValue(&data->fromSourced); + d->actions = &data->actions; + } else { + delete data; + d->va->setFromSourcedValue(0); //clear previous data + d->va->setAnimValue(0, QAbstractAnimation::DeleteWhenStopped); //clear previous data + d->actions = 0; + } +} + +/*! + \qmlclass ParentAnimation QDeclarative1ParentAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The ParentAnimation element animates changes in parent values. + + ParentAnimation is used to animate a parent change for an \l Item. + + For example, the following ParentChange changes \c blueRect to become + a child of \c redRect when it is clicked. The inclusion of the + ParentAnimation, which defines a NumberAnimation to be applied during + the transition, ensures the item animates smoothly as it moves to + its new parent: + + \snippet doc/src/snippets/declarative/parentanimation.qml 0 + + A ParentAnimation can contain any number of animations. These animations will + be run in parallel; to run them sequentially, define them within a + SequentialAnimation. + + In some cases, such as when reparenting between items with clipping enabled, it is useful + to animate the parent change via another item that does not have clipping + enabled. Such an item can be set using the \l via property. + + For convenience, when a ParentAnimation is used in a \l Transition, it will + animate any ParentChange that has occurred during the state change. + This can be overridden by setting a specific target item using the + \l target property. + + Like any other animation element, a ParentAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ +QDeclarative1ParentAnimation::QDeclarative1ParentAnimation(QObject *parent) + : QDeclarative1AnimationGroup(*(new QDeclarative1ParentAnimationPrivate), parent) +{ + Q_D(QDeclarative1ParentAnimation); + d->topLevelGroup = new QSequentialAnimationGroup; + QDeclarative_setParent_noEvent(d->topLevelGroup, this); + + d->startAction = new QActionAnimation_1; + QDeclarative_setParent_noEvent(d->startAction, d->topLevelGroup); + d->topLevelGroup->addAnimation(d->startAction); + + d->ag = new QParallelAnimationGroup; + QDeclarative_setParent_noEvent(d->ag, d->topLevelGroup); + d->topLevelGroup->addAnimation(d->ag); + + d->endAction = new QActionAnimation_1; + QDeclarative_setParent_noEvent(d->endAction, d->topLevelGroup); + d->topLevelGroup->addAnimation(d->endAction); +} + +QDeclarative1ParentAnimation::~QDeclarative1ParentAnimation() +{ +} + +/*! + \qmlproperty Item ParentAnimation::target + The item to reparent. + + When used in a transition, if no target is specified, all + ParentChange occurrences are animated by the ParentAnimation. +*/ +QDeclarativeItem *QDeclarative1ParentAnimation::target() const +{ + Q_D(const QDeclarative1ParentAnimation); + return d->target; +} + +void QDeclarative1ParentAnimation::setTarget(QDeclarativeItem *target) +{ + Q_D(QDeclarative1ParentAnimation); + if (target == d->target) + return; + + d->target = target; + emit targetChanged(); +} + +/*! + \qmlproperty Item ParentAnimation::newParent + The new parent to animate to. + + If the ParentAnimation is defined within a \l Transition or \l Behavior, + this value defaults to the value defined in the end state of the + \l Transition, or the value of the property change that triggered the + \l Behavior. +*/ +QDeclarativeItem *QDeclarative1ParentAnimation::newParent() const +{ + Q_D(const QDeclarative1ParentAnimation); + return d->newParent; +} + +void QDeclarative1ParentAnimation::setNewParent(QDeclarativeItem *newParent) +{ + Q_D(QDeclarative1ParentAnimation); + if (newParent == d->newParent) + return; + + d->newParent = newParent; + emit newParentChanged(); +} + +/*! + \qmlproperty Item ParentAnimation::via + The item to reparent via. This provides a way to do an unclipped animation + when both the old parent and new parent are clipped. + + \qml + ParentAnimation { + target: myItem + via: topLevelItem + // ... + } + \endqml +*/ +QDeclarativeItem *QDeclarative1ParentAnimation::via() const +{ + Q_D(const QDeclarative1ParentAnimation); + return d->via; +} + +void QDeclarative1ParentAnimation::setVia(QDeclarativeItem *via) +{ + Q_D(QDeclarative1ParentAnimation); + if (via == d->via) + return; + + d->via = via; + emit viaChanged(); +} + +//### mirrors same-named function in QDeclarativeItem +QPointF QDeclarative1ParentAnimationPrivate::computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const +{ + switch(origin) { + default: + case QDeclarativeItem::TopLeft: + return QPointF(0, 0); + case QDeclarativeItem::Top: + return QPointF(width / 2., 0); + case QDeclarativeItem::TopRight: + return QPointF(width, 0); + case QDeclarativeItem::Left: + return QPointF(0, height / 2.); + case QDeclarativeItem::Center: + return QPointF(width / 2., height / 2.); + case QDeclarativeItem::Right: + return QPointF(width, height / 2.); + case QDeclarativeItem::BottomLeft: + return QPointF(0, height); + case QDeclarativeItem::Bottom: + return QPointF(width / 2., height); + case QDeclarativeItem::BottomRight: + return QPointF(width, height); + } +} + +void QDeclarative1ParentAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1ParentAnimation); + + struct QDeclarative1ParentAnimationData : public QAbstractAnimationAction + { + QDeclarative1ParentAnimationData() {} + ~QDeclarative1ParentAnimationData() { qDeleteAll(pc); } + + QDeclarative1StateActions actions; + //### reverse should probably apply on a per-action basis + bool reverse; + QList pc; + virtual void doAction() + { + for (int ii = 0; ii < actions.count(); ++ii) { + const QDeclarative1Action &action = actions.at(ii); + if (reverse) + action.event->reverse(); + else + action.event->execute(); + } + } + }; + + QDeclarative1ParentAnimationData *data = new QDeclarative1ParentAnimationData; + QDeclarative1ParentAnimationData *viaData = new QDeclarative1ParentAnimationData; + + bool hasExplicit = false; + if (d->target && d->newParent) { + data->reverse = false; + QDeclarative1Action myAction; + QDeclarative1ParentChange *pc = new QDeclarative1ParentChange; + pc->setObject(d->target); + pc->setParent(d->newParent); + myAction.event = pc; + data->pc << pc; + data->actions << myAction; + hasExplicit = true; + if (d->via) { + viaData->reverse = false; + QDeclarative1Action myVAction; + QDeclarative1ParentChange *vpc = new QDeclarative1ParentChange; + vpc->setObject(d->target); + vpc->setParent(d->via); + myVAction.event = vpc; + viaData->pc << vpc; + viaData->actions << myVAction; + } + //### once actions have concept of modified, + // loop to match appropriate ParentChanges and mark as modified + } + + if (!hasExplicit) + for (int i = 0; i < actions.size(); ++i) { + QDeclarative1Action &action = actions[i]; + if (action.event && action.event->typeName() == QLatin1String("ParentChange") + && (!d->target || static_cast(action.event)->object() == d->target)) { + + QDeclarative1ParentChange *pc = static_cast(action.event); + QDeclarative1Action myAction = action; + data->reverse = action.reverseEvent; + + //### this logic differs from PropertyAnimation + // (probably a result of modified vs. done) + if (d->newParent) { + QDeclarative1ParentChange *epc = new QDeclarative1ParentChange; + epc->setObject(static_cast(action.event)->object()); + epc->setParent(d->newParent); + myAction.event = epc; + data->pc << epc; + data->actions << myAction; + pc = epc; + } else { + action.actionDone = true; + data->actions << myAction; + } + + if (d->via) { + viaData->reverse = false; + QDeclarative1Action myAction; + QDeclarative1ParentChange *vpc = new QDeclarative1ParentChange; + vpc->setObject(pc->object()); + vpc->setParent(d->via); + myAction.event = vpc; + viaData->pc << vpc; + viaData->actions << myAction; + QDeclarative1Action dummyAction; + QDeclarative1Action &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarative1Action &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarative1Action &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarative1Action &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeItem *target = pc->object(); + QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); + + //### this mirrors the logic in QDeclarative1ParentChange. + bool ok; + const QTransform &transform = targetParent->itemTransform(d->via, &ok); + if (transform.type() >= QTransform::TxShear || !ok) { + qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under complex transform"); + ok = false; + } + + qreal scale = 1; + qreal rotation = 0; + bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0); + if (ok && !isRotate) { + if (transform.m11() == transform.m22()) + scale = transform.m11(); + else { + qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under non-uniform scale"); + ok = false; + } + } else if (ok && isRotate) { + if (transform.m11() == transform.m22()) + scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); + else { + qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under non-uniform scale"); + ok = false; + } + + if (scale != 0) + rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; + else { + qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under scale of 0"); + ok = false; + } + } + + const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal())); + qreal x = point.x(); + qreal y = point.y(); + if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { + qreal w = target->width(); + qreal h = target->height(); + if (pc->widthIsSet() && i < actions.size() - 1) + w = actions[++i].toValue.toReal(); + if (pc->heightIsSet() && i < actions.size() - 1) + h = actions[++i].toValue.toReal(); + const QPointF &transformOrigin + = d->computeTransformOrigin(target->transformOrigin(), w,h); + qreal tempxt = transformOrigin.x(); + qreal tempyt = transformOrigin.y(); + QTransform t; + t.translate(-tempxt, -tempyt); + t.rotate(rotation); + t.scale(scale, scale); + t.translate(tempxt, tempyt); + const QPointF &offset = t.map(QPointF(0,0)); + x += offset.x(); + y += offset.y(); + } + + if (ok) { + //qDebug() << x << y << rotation << scale; + xAction.toValue = x; + yAction.toValue = y; + sAction.toValue = sAction.toValue.toReal() * scale; + rAction.toValue = rAction.toValue.toReal() + rotation; + } + } + } + } + + if (data->actions.count()) { + if (direction == QDeclarative1AbstractAnimation::Forward) { + d->startAction->setAnimAction(d->via ? viaData : data, QActionAnimation_1::DeleteWhenStopped); + d->endAction->setAnimAction(d->via ? data : 0, QActionAnimation_1::DeleteWhenStopped); + } else { + d->endAction->setAnimAction(d->via ? viaData : data, QActionAnimation_1::DeleteWhenStopped); + d->startAction->setAnimAction(d->via ? data : 0, QActionAnimation_1::DeleteWhenStopped); + } + if (!d->via) + delete viaData; + } else { + delete data; + delete viaData; + } + + //take care of any child animations + bool valid = d->defaultProperty.isValid(); + for (int ii = 0; ii < d->animations.count(); ++ii) { + if (valid) + d->animations.at(ii)->setDefaultTarget(d->defaultProperty); + d->animations.at(ii)->transition(actions, modified, direction); + } + +} + +QAbstractAnimation *QDeclarative1ParentAnimation::qtAnimation() +{ + Q_D(QDeclarative1ParentAnimation); + return d->topLevelGroup; +} + +/*! + \qmlclass AnchorAnimation QDeclarative1AnchorAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits Animation + \brief The AnchorAnimation element animates changes in anchor values. + + AnchorAnimation is used to animate an anchor change. + + In the following snippet we animate the addition of a right anchor to a \l Rectangle: + + \snippet doc/src/snippets/declarative/anchoranimation.qml 0 + + For convenience, when an AnchorAnimation is used in a \l Transition, it will + animate any AnchorChanges that have occurred during the state change. + This can be overridden by setting a specific target item using the + \l target property. + + Like any other animation element, an AnchorAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \sa {QML Animation and Transitions}, AnchorChanges +*/ + +QDeclarative1AnchorAnimation::QDeclarative1AnchorAnimation(QObject *parent) +: QDeclarative1AbstractAnimation(*(new QDeclarative1AnchorAnimationPrivate), parent) +{ + Q_D(QDeclarative1AnchorAnimation); + d->va = new QDeclarative1BulkValueAnimator; + QDeclarative_setParent_noEvent(d->va, this); +} + +QDeclarative1AnchorAnimation::~QDeclarative1AnchorAnimation() +{ +} + +QAbstractAnimation *QDeclarative1AnchorAnimation::qtAnimation() +{ + Q_D(QDeclarative1AnchorAnimation); + return d->va; +} + +/*! + \qmlproperty list AnchorAnimation::targets + The items to reanchor. + + If no targets are specified all AnchorChanges will be + animated by the AnchorAnimation. +*/ +QDeclarativeListProperty QDeclarative1AnchorAnimation::targets() +{ + Q_D(QDeclarative1AnchorAnimation); + return QDeclarativeListProperty(this, d->targets); +} + +/*! + \qmlproperty int AnchorAnimation::duration + This property holds the duration of the animation, in milliseconds. + + The default value is 250. +*/ +int QDeclarative1AnchorAnimation::duration() const +{ + Q_D(const QDeclarative1AnchorAnimation); + return d->va->duration(); +} + +void QDeclarative1AnchorAnimation::setDuration(int duration) +{ + if (duration < 0) { + qmlInfo(this) << tr("Cannot set a duration of < 0"); + return; + } + + Q_D(QDeclarative1AnchorAnimation); + if (d->va->duration() == duration) + return; + d->va->setDuration(duration); + emit durationChanged(duration); +} + +/*! + \qmlproperty enumeration AnchorAnimation::easing.type + \qmlproperty real AnchorAnimation::easing.amplitude + \qmlproperty real AnchorAnimation::easing.overshoot + \qmlproperty real AnchorAnimation::easing.period + \brief the easing curve used for the animation. + + To specify an easing curve you need to specify at least the type. For some curves you can also specify + amplitude, period and/or overshoot. The default easing curve is + Linear. + + \qml + AnchorAnimation { easing.type: Easing.InOutQuad } + \endqml + + See the \l{PropertyAnimation::easing.type} documentation for information + about the different types of easing curves. +*/ + +QEasingCurve QDeclarative1AnchorAnimation::easing() const +{ + Q_D(const QDeclarative1AnchorAnimation); + return d->va->easingCurve(); +} + +void QDeclarative1AnchorAnimation::setEasing(const QEasingCurve &e) +{ + Q_D(QDeclarative1AnchorAnimation); + if (d->va->easingCurve() == e) + return; + + d->va->setEasingCurve(e); + emit easingChanged(e); +} + +void QDeclarative1AnchorAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_UNUSED(modified); + Q_D(QDeclarative1AnchorAnimation); + QDeclarative1AnimationPropertyUpdater *data = new QDeclarative1AnimationPropertyUpdater; + data->interpolatorType = QMetaType::QReal; + data->interpolator = d->interpolator; + + data->reverse = direction == Backward ? true : false; + data->fromSourced = false; + data->fromDefined = false; + + for (int ii = 0; ii < actions.count(); ++ii) { + QDeclarative1Action &action = actions[ii]; + if (action.event && action.event->typeName() == QLatin1String("AnchorChanges") + && (d->targets.isEmpty() || d->targets.contains(static_cast(action.event)->object()))) { + data->actions << static_cast(action.event)->additionalActions(); + } + } + + if (data->actions.count()) { + if (!d->rangeIsSet) { + d->va->setStartValue(qreal(0)); + d->va->setEndValue(qreal(1)); + d->rangeIsSet = true; + } + d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); + d->va->setFromSourcedValue(&data->fromSourced); + } else { + delete data; + } +} + +QDeclarative1ScriptActionPrivate::QDeclarative1ScriptActionPrivate() + : QDeclarative1AbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {} + + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeanimation_p.h b/src/qtquick1/util/qdeclarativeanimation_p.h new file mode 100644 index 0000000000..decb9a339a --- /dev/null +++ b/src/qtquick1/util/qdeclarativeanimation_p.h @@ -0,0 +1,528 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEANIMATION_H +#define QDECLARATIVEANIMATION_H + +#include "QtQuick1/private/qdeclarativetransition_p.h" +#include "QtQuick1/private/qdeclarativestate_p.h" +#include + +#include +#include +#include + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeItem; +class QDeclarative1AbstractAnimationPrivate; +class QDeclarative1AnimationGroup; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1AbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1AbstractAnimation) + + Q_INTERFACES(QDeclarativeParserStatus) + Q_INTERFACES(QDeclarativePropertyValueSource) + Q_ENUMS(Loops) + Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) + Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) + Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged) + Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged) + Q_CLASSINFO("DefaultMethod", "start()") + +public: + QDeclarative1AbstractAnimation(QObject *parent=0); + virtual ~QDeclarative1AbstractAnimation(); + + enum Loops { Infinite = -2 }; + + bool isRunning() const; + void setRunning(bool); + bool isPaused() const; + void setPaused(bool); + bool alwaysRunToEnd() const; + void setAlwaysRunToEnd(bool); + + int loops() const; + void setLoops(int); + + int currentTime(); + void setCurrentTime(int); + + QDeclarative1AnimationGroup *group() const; + void setGroup(QDeclarative1AnimationGroup *); + + void setDefaultTarget(const QDeclarativeProperty &); + void setDisableUserControl(); + + void classBegin(); + void componentComplete(); + +Q_SIGNALS: + void started(); + void completed(); + void runningChanged(bool); + void pausedChanged(bool); + void alwaysRunToEndChanged(bool); + void loopCountChanged(int); + +public Q_SLOTS: + void restart(); + void start(); + void pause(); + void resume(); + void stop(); + void complete(); + +protected: + QDeclarative1AbstractAnimation(QDeclarative1AbstractAnimationPrivate &dd, QObject *parent); + +public: + enum TransitionDirection { Forward, Backward }; + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation() = 0; + +private Q_SLOTS: + void timelineComplete(); + void componentFinalized(); +private: + virtual void setTarget(const QDeclarativeProperty &); + void notifyRunningChanged(bool running); + friend class QDeclarative1Behavior; + + +}; + +class QDeclarative1PauseAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1PauseAnimation : public QDeclarative1AbstractAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1PauseAnimation) + + Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) + +public: + QDeclarative1PauseAnimation(QObject *parent=0); + virtual ~QDeclarative1PauseAnimation(); + + int duration() const; + void setDuration(int); + +Q_SIGNALS: + void durationChanged(int); + +protected: + virtual QAbstractAnimation *qtAnimation(); +}; + +class QDeclarative1ScriptActionPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1ScriptAction : public QDeclarative1AbstractAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1ScriptAction) + + Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) + Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName) + +public: + QDeclarative1ScriptAction(QObject *parent=0); + virtual ~QDeclarative1ScriptAction(); + + QDeclarativeScriptString script() const; + void setScript(const QDeclarativeScriptString &); + + QString stateChangeScriptName() const; + void setStateChangeScriptName(const QString &); + +protected: + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation(); +}; + +class QDeclarative1PropertyActionPrivate; +class QDeclarative1PropertyAction : public QDeclarative1AbstractAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1PropertyAction) + + Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) + Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) + Q_PROPERTY(QDeclarativeListProperty targets READ targets) + Q_PROPERTY(QDeclarativeListProperty exclude READ exclude) + Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) + +public: + QDeclarative1PropertyAction(QObject *parent=0); + virtual ~QDeclarative1PropertyAction(); + + QObject *target() const; + void setTarget(QObject *); + + QString property() const; + void setProperty(const QString &); + + QString properties() const; + void setProperties(const QString &); + + QDeclarativeListProperty targets(); + QDeclarativeListProperty exclude(); + + QVariant value() const; + void setValue(const QVariant &); + +Q_SIGNALS: + void valueChanged(const QVariant &); + void propertiesChanged(const QString &); + void targetChanged(); + void propertyChanged(); + +protected: + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation(); +}; + +class QDeclarative1PropertyAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1PropertyAnimation : public QDeclarative1AbstractAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) + + Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) + Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) + Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) + Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) + Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) + Q_PROPERTY(QDeclarativeListProperty targets READ targets) + Q_PROPERTY(QDeclarativeListProperty exclude READ exclude) + +public: + QDeclarative1PropertyAnimation(QObject *parent=0); + virtual ~QDeclarative1PropertyAnimation(); + + virtual int duration() const; + virtual void setDuration(int); + + QVariant from() const; + void setFrom(const QVariant &); + + QVariant to() const; + void setTo(const QVariant &); + + QEasingCurve easing() const; + void setEasing(const QEasingCurve &); + + QObject *target() const; + void setTarget(QObject *); + + QString property() const; + void setProperty(const QString &); + + QString properties() const; + void setProperties(const QString &); + + QDeclarativeListProperty targets(); + QDeclarativeListProperty exclude(); + +protected: + QDeclarative1PropertyAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent); + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation(); + +Q_SIGNALS: + void durationChanged(int); + void fromChanged(QVariant); + void toChanged(QVariant); + void easingChanged(const QEasingCurve &); + void propertiesChanged(const QString &); + void targetChanged(); + void propertyChanged(); +}; + +class Q_AUTOTEST_EXPORT QDeclarative1ColorAnimation : public QDeclarative1PropertyAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) + Q_PROPERTY(QColor from READ from WRITE setFrom) + Q_PROPERTY(QColor to READ to WRITE setTo) + +public: + QDeclarative1ColorAnimation(QObject *parent=0); + virtual ~QDeclarative1ColorAnimation(); + + QColor from() const; + void setFrom(const QColor &); + + QColor to() const; + void setTo(const QColor &); +}; + +class Q_AUTOTEST_EXPORT QDeclarative1NumberAnimation : public QDeclarative1PropertyAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) + + Q_PROPERTY(qreal from READ from WRITE setFrom) + Q_PROPERTY(qreal to READ to WRITE setTo) + +public: + QDeclarative1NumberAnimation(QObject *parent=0); + virtual ~QDeclarative1NumberAnimation(); + + qreal from() const; + void setFrom(qreal); + + qreal to() const; + void setTo(qreal); + +protected: + QDeclarative1NumberAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent); + +private: + void init(); +}; + +class Q_AUTOTEST_EXPORT QDeclarative1Vector3dAnimation : public QDeclarative1PropertyAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) + + Q_PROPERTY(QVector3D from READ from WRITE setFrom) + Q_PROPERTY(QVector3D to READ to WRITE setTo) + +public: + QDeclarative1Vector3dAnimation(QObject *parent=0); + virtual ~QDeclarative1Vector3dAnimation(); + + QVector3D from() const; + void setFrom(QVector3D); + + QVector3D to() const; + void setTo(QVector3D); +}; + +class QDeclarative1RotationAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1RotationAnimation : public QDeclarative1PropertyAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1RotationAnimation) + Q_ENUMS(RotationDirection) + + Q_PROPERTY(qreal from READ from WRITE setFrom) + Q_PROPERTY(qreal to READ to WRITE setTo) + Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) + +public: + QDeclarative1RotationAnimation(QObject *parent=0); + virtual ~QDeclarative1RotationAnimation(); + + qreal from() const; + void setFrom(qreal); + + qreal to() const; + void setTo(qreal); + + enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise }; + RotationDirection direction() const; + void setDirection(RotationDirection direction); + +Q_SIGNALS: + void directionChanged(); +}; + +class QDeclarative1AnimationGroupPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1AnimationGroup : public QDeclarative1AbstractAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup) + + Q_CLASSINFO("DefaultProperty", "animations") + Q_PROPERTY(QDeclarativeListProperty animations READ animations) + +public: + QDeclarative1AnimationGroup(QObject *parent); + virtual ~QDeclarative1AnimationGroup(); + + QDeclarativeListProperty animations(); + friend class QDeclarative1AbstractAnimation; + +protected: + QDeclarative1AnimationGroup(QDeclarative1AnimationGroupPrivate &dd, QObject *parent); +}; + +class QDeclarative1SequentialAnimation : public QDeclarative1AnimationGroup +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup) + +public: + QDeclarative1SequentialAnimation(QObject *parent=0); + virtual ~QDeclarative1SequentialAnimation(); + +protected: + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation(); +}; + +class QDeclarative1ParallelAnimation : public QDeclarative1AnimationGroup +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup) + +public: + QDeclarative1ParallelAnimation(QObject *parent=0); + virtual ~QDeclarative1ParallelAnimation(); + +protected: + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation(); +}; + +class QDeclarative1ParentAnimationPrivate; +class QDeclarative1ParentAnimation : public QDeclarative1AnimationGroup +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1ParentAnimation) + + Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged) + Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia NOTIFY viaChanged) + +public: + QDeclarative1ParentAnimation(QObject *parent=0); + virtual ~QDeclarative1ParentAnimation(); + + QDeclarativeItem *target() const; + void setTarget(QDeclarativeItem *); + + QDeclarativeItem *newParent() const; + void setNewParent(QDeclarativeItem *); + + QDeclarativeItem *via() const; + void setVia(QDeclarativeItem *); + +Q_SIGNALS: + void targetChanged(); + void newParentChanged(); + void viaChanged(); + +protected: + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation(); +}; + +class QDeclarative1AnchorAnimationPrivate; +class QDeclarative1AnchorAnimation : public QDeclarative1AbstractAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1AnchorAnimation) + Q_PROPERTY(QDeclarativeListProperty targets READ targets) + Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) + Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) + +public: + QDeclarative1AnchorAnimation(QObject *parent=0); + virtual ~QDeclarative1AnchorAnimation(); + + QDeclarativeListProperty targets(); + + int duration() const; + void setDuration(int); + + QEasingCurve easing() const; + void setEasing(const QEasingCurve &); + +Q_SIGNALS: + void durationChanged(int); + void easingChanged(const QEasingCurve&); + +protected: + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + virtual QAbstractAnimation *qtAnimation(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1AbstractAnimation) +QML_DECLARE_TYPE(QDeclarative1PauseAnimation) +QML_DECLARE_TYPE(QDeclarative1ScriptAction) +QML_DECLARE_TYPE(QDeclarative1PropertyAction) +QML_DECLARE_TYPE(QDeclarative1PropertyAnimation) +QML_DECLARE_TYPE(QDeclarative1ColorAnimation) +QML_DECLARE_TYPE(QDeclarative1NumberAnimation) +QML_DECLARE_TYPE(QDeclarative1SequentialAnimation) +QML_DECLARE_TYPE(QDeclarative1ParallelAnimation) +QML_DECLARE_TYPE(QDeclarative1Vector3dAnimation) +QML_DECLARE_TYPE(QDeclarative1RotationAnimation) +QML_DECLARE_TYPE(QDeclarative1ParentAnimation) +QML_DECLARE_TYPE(QDeclarative1AnchorAnimation) + +QT_END_HEADER + +#endif // QDECLARATIVEANIMATION_H diff --git a/src/qtquick1/util/qdeclarativeanimation_p_p.h b/src/qtquick1/util/qdeclarativeanimation_p_p.h new file mode 100644 index 0000000000..e528a927ef --- /dev/null +++ b/src/qtquick1/util/qdeclarativeanimation_p_p.h @@ -0,0 +1,397 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEANIMATION_P_H +#define QDECLARATIVEANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtQuick1/private/qdeclarativeanimation_p.h" + +#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h" +#include "QtQuick1/private/qdeclarativetimeline_p_p.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +//interface for classes that provide animation actions for QActionAnimation_1 +class QAbstractAnimationAction +{ +public: + virtual ~QAbstractAnimationAction() {} + virtual void doAction() = 0; +}; + +//templated animation action +//allows us to specify an action that calls a function of a class. +//(so that class doesn't have to inherit QDeclarative1AbstractAnimationAction) +template +class QAnimationActionProxy_1 : public QAbstractAnimationAction +{ +public: + QAnimationActionProxy_1(T *p) : m_p(p) {} + virtual void doAction() { (m_p->*method)(); } + +private: + T *m_p; +}; + +//performs an action of type QAbstractAnimationAction +class Q_AUTOTEST_EXPORT QActionAnimation_1 : public QAbstractAnimation +{ + Q_OBJECT +public: + QActionAnimation_1(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped) {} + QActionAnimation_1(QAbstractAnimationAction *action, QObject *parent = 0) + : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped) {} + ~QActionAnimation_1() { if (policy == DeleteWhenStopped) { delete animAction; animAction = 0; } } + virtual int duration() const { return 0; } + void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p) + { + if (state() == Running) + stop(); + if (policy == DeleteWhenStopped) + delete animAction; + animAction = action; + policy = p; + } +protected: + virtual void updateCurrentTime(int) {} + + virtual void updateState(State newState, State /*oldState*/) + { + if (newState == Running) { + if (animAction) { + animAction->doAction(); + if (state() == Stopped && policy == DeleteWhenStopped) { + delete animAction; + animAction = 0; + } + } + } + } + +private: + QAbstractAnimationAction *animAction; + DeletionPolicy policy; +}; + +class QDeclarative1BulkValueUpdater +{ +public: + virtual ~QDeclarative1BulkValueUpdater() {} + virtual void setValue(qreal value) = 0; +}; + +//animates QDeclarative1BulkValueUpdater (assumes start and end values will be reals or compatible) +class Q_AUTOTEST_EXPORT QDeclarative1BulkValueAnimator : public QVariantAnimation +{ + Q_OBJECT +public: + QDeclarative1BulkValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {} + ~QDeclarative1BulkValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } } + void setAnimValue(QDeclarative1BulkValueUpdater *value, DeletionPolicy p) + { + if (state() == Running) + stop(); + if (policy == DeleteWhenStopped) + delete animValue; + animValue = value; + policy = p; + } + void setFromSourcedValue(bool *value) + { + fromSourced = value; + } +protected: + virtual void updateCurrentValue(const QVariant &value) + { + if (state() == QAbstractAnimation::Stopped) + return; + + if (animValue) + animValue->setValue(value.toReal()); + } + virtual void updateState(State newState, State oldState) + { + QVariantAnimation::updateState(newState, oldState); + if (newState == Running) { + //check for new from every loop + if (fromSourced) + *fromSourced = false; + } + } + +private: + QDeclarative1BulkValueUpdater *animValue; + bool *fromSourced; + DeletionPolicy policy; +}; + +//an animation that just gives a tick +template +class QTickAnimationProxy_1 : public QAbstractAnimation +{ + //Q_OBJECT //doesn't work with templating +public: + QTickAnimationProxy_1(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {} + virtual int duration() const { return -1; } +protected: + virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); } + +private: + T *m_p; +}; + +class QDeclarative1AbstractAnimationPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1AbstractAnimation) +public: + QDeclarative1AbstractAnimationPrivate() + : running(false), paused(false), alwaysRunToEnd(false), + connectedTimeLine(false), componentComplete(true), + avoidPropertyValueSourceStart(false), disableUserControl(false), + registered(false), loopCount(1), group(0) {} + + bool running:1; + bool paused:1; + bool alwaysRunToEnd:1; + bool connectedTimeLine:1; + bool componentComplete:1; + bool avoidPropertyValueSourceStart:1; + bool disableUserControl:1; + bool registered:1; + + int loopCount; + + void commence(); + + QDeclarativeProperty defaultProperty; + + QDeclarative1AnimationGroup *group; + + static QDeclarativeProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); +}; + +class QDeclarative1PauseAnimationPrivate : public QDeclarative1AbstractAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1PauseAnimation) +public: + QDeclarative1PauseAnimationPrivate() + : QDeclarative1AbstractAnimationPrivate(), pa(0) {} + + void init(); + + QPauseAnimation *pa; +}; + +class QDeclarative1ScriptActionPrivate : public QDeclarative1AbstractAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1ScriptAction) +public: + QDeclarative1ScriptActionPrivate(); + + void init(); + + QDeclarativeScriptString script; + QString name; + QDeclarativeScriptString runScriptScript; + bool hasRunScriptScript; + bool reversing; + + void execute(); + + QAnimationActionProxy_1 proxy; + QActionAnimation_1 *rsa; +}; + +class QDeclarative1PropertyActionPrivate : public QDeclarative1AbstractAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1PropertyAction) +public: + QDeclarative1PropertyActionPrivate() + : QDeclarative1AbstractAnimationPrivate(), target(0), spa(0) {} + + void init(); + + QObject *target; + QString propertyName; + QString properties; + QList targets; + QList exclude; + + QDeclarativeNullableValue value; + + QActionAnimation_1 *spa; +}; + +class QDeclarative1AnimationGroupPrivate : public QDeclarative1AbstractAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1AnimationGroup) +public: + QDeclarative1AnimationGroupPrivate() + : QDeclarative1AbstractAnimationPrivate(), ag(0) {} + + static void append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *role); + static void clear_animation(QDeclarativeListProperty *list); + QList animations; + QAnimationGroup *ag; +}; + +class QDeclarative1PropertyAnimationPrivate : public QDeclarative1AbstractAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1PropertyAnimation) +public: + QDeclarative1PropertyAnimationPrivate() + : QDeclarative1AbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false), + rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), actions(0) {} + + void init(); + + QVariant from; + QVariant to; + + QObject *target; + QString propertyName; + QString properties; + QList targets; + QList exclude; + QString defaultProperties; + + bool fromSourced; + bool fromIsDefined:1; + bool toIsDefined:1; + bool rangeIsSet:1; + bool defaultToInterpolatorType:1; + int interpolatorType; + QVariantAnimation::Interpolator interpolator; + + QDeclarative1BulkValueAnimator *va; + + // for animations that don't use the QDeclarative1BulkValueAnimator + QDeclarative1StateActions *actions; + + static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); + static void convertVariant(QVariant &variant, int type); +}; + +class QDeclarative1RotationAnimationPrivate : public QDeclarative1PropertyAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1RotationAnimation) +public: + QDeclarative1RotationAnimationPrivate() : direction(QDeclarative1RotationAnimation::Numerical) {} + + QDeclarative1RotationAnimation::RotationDirection direction; +}; + +class QDeclarative1ParentAnimationPrivate : public QDeclarative1AnimationGroupPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1ParentAnimation) +public: + QDeclarative1ParentAnimationPrivate() + : QDeclarative1AnimationGroupPrivate(), target(0), newParent(0), + via(0), topLevelGroup(0), startAction(0), endAction(0) {} + + QDeclarativeItem *target; + QDeclarativeItem *newParent; + QDeclarativeItem *via; + + QSequentialAnimationGroup *topLevelGroup; + QActionAnimation_1 *startAction; + QActionAnimation_1 *endAction; + + QPointF computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const; +}; + +class QDeclarative1AnchorAnimationPrivate : public QDeclarative1AbstractAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1AnchorAnimation) +public: + QDeclarative1AnchorAnimationPrivate() : rangeIsSet(false), va(0), + interpolator(QVariantAnimationPrivate::getInterpolator(QMetaType::QReal)) {} + + bool rangeIsSet; + QDeclarative1BulkValueAnimator *va; + QVariantAnimation::Interpolator interpolator; + QList targets; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1AnimationPropertyUpdater : public QDeclarative1BulkValueUpdater +{ +public: + QDeclarative1StateActions actions; + int interpolatorType; //for Number/ColorAnimation + int prevInterpolatorType; //for generic + QVariantAnimation::Interpolator interpolator; + bool reverse; + bool fromSourced; + bool fromDefined; + bool *wasDeleted; + QDeclarative1AnimationPropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {} + ~QDeclarative1AnimationPropertyUpdater() { if (wasDeleted) *wasDeleted = true; } + void setValue(qreal v); +}; + +QT_END_NAMESPACE + +#endif // QDECLARATIVEANIMATION_P_H diff --git a/src/qtquick1/util/qdeclarativeapplication.cpp b/src/qtquick1/util/qdeclarativeapplication.cpp new file mode 100644 index 0000000000..3cc572f27b --- /dev/null +++ b/src/qtquick1/util/qdeclarativeapplication.cpp @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativeapplication_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + + + +class QDeclarative1ApplicationPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1Application) +public: + QDeclarative1ApplicationPrivate() : active(QApplication::activeWindow() != 0), + layoutDirection(QApplication::layoutDirection()) {} + bool active; + Qt::LayoutDirection layoutDirection; +}; + +/* + This object and its properties are documented as part of the Qt object, + in qdeclarativengine.cpp +*/ + +QDeclarative1Application::QDeclarative1Application(QObject *parent) : QObject(*new QDeclarative1ApplicationPrivate(), parent) +{ + if (qApp) + qApp->installEventFilter(this); +} + +QDeclarative1Application::~QDeclarative1Application() +{ +} + +bool QDeclarative1Application::active() const +{ + Q_D(const QDeclarative1Application); + return d->active; +} + +Qt::LayoutDirection QDeclarative1Application::layoutDirection() const +{ + Q_D(const QDeclarative1Application); + return d->layoutDirection; +} + +bool QDeclarative1Application::eventFilter(QObject *obj, QEvent *event) +{ + Q_UNUSED(obj) + Q_D(QDeclarative1Application); + if (event->type() == QEvent::ApplicationActivate + || event->type() == QEvent::ApplicationDeactivate) { + bool active = d->active; + if (event->type() == QEvent::ApplicationActivate) + active = true; + else if (event->type() == QEvent::ApplicationDeactivate) + active = false; + + if (d->active != active) { + d->active = active; + emit activeChanged(); + } + } + if (event->type() == QEvent::LayoutDirectionChange) { + Qt::LayoutDirection direction = QApplication::layoutDirection(); + if (d->layoutDirection != direction) { + d->layoutDirection = direction; + emit layoutDirectionChanged(); + } + } + return false; +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeapplication_p.h b/src/qtquick1/util/qdeclarativeapplication_p.h new file mode 100644 index 0000000000..4a588c2940 --- /dev/null +++ b/src/qtquick1/util/qdeclarativeapplication_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEAPPLICATION_P_H +#define QDECLARATIVEAPPLICATION_P_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1ApplicationPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Application : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool active READ active NOTIFY activeChanged) + Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged) + +public: + explicit QDeclarative1Application(QObject *parent = 0); + virtual ~QDeclarative1Application(); + bool active() const; + Qt::LayoutDirection layoutDirection() const; + +protected: + bool eventFilter(QObject *obj, QEvent *event); + +Q_SIGNALS: + void activeChanged(); + void layoutDirectionChanged(); + +private: + Q_DISABLE_COPY(QDeclarative1Application) + Q_DECLARE_PRIVATE(QDeclarative1Application) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1Application) + +QT_END_HEADER + +#endif // QDECLARATIVEAPPLICATION_P_H diff --git a/src/qtquick1/util/qdeclarativebehavior.cpp b/src/qtquick1/util/qdeclarativebehavior.cpp new file mode 100644 index 0000000000..203f141721 --- /dev/null +++ b/src/qtquick1/util/qdeclarativebehavior.cpp @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativebehavior_p.h" + +#include "QtQuick1/private/qdeclarativeanimation_p.h" +#include "QtQuick1/private/qdeclarativetransition_p.h" + +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + + +class QDeclarative1BehaviorPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1Behavior) +public: + QDeclarative1BehaviorPrivate() : animation(0), enabled(true), finalized(false) + , blockRunningChanged(false) {} + + QDeclarativeProperty property; + QVariant currentValue; + QVariant targetValue; + QDeclarativeGuard animation; + bool enabled; + bool finalized; + bool blockRunningChanged; +}; + +/*! + \qmlclass Behavior QDeclarative1Behavior + \ingroup qml-animation-transition + \since 4.7 + \brief The Behavior element allows you to specify a default animation for a property change. + + A Behavior defines the default animation to be applied whenever a + particular property value changes. + + For example, the following Behavior defines a NumberAnimation to be run + whenever the \l Rectangle's \c width value changes. When the MouseArea + is clicked, the \c width is changed, triggering the behavior's animation: + + \snippet doc/src/snippets/declarative/behavior.qml 0 + + Note that a property cannot have more than one assigned Behavior. To provide + multiple animations within a Behavior, use ParallelAnimation or + SequentialAnimation. + + If a \l{QML States}{state change} has a \l Transition that matches the same property as a + Behavior, the \l Transition animation overrides the Behavior for that + state change. For general advice on using Behaviors to animate state changes, see + \l{Using QML Behaviors with States}. + + \sa {QML Animation and Transitions}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative +*/ + + +QDeclarative1Behavior::QDeclarative1Behavior(QObject *parent) + : QObject(*(new QDeclarative1BehaviorPrivate), parent) +{ +} + +QDeclarative1Behavior::~QDeclarative1Behavior() +{ +} + +/*! + \qmlproperty Animation Behavior::animation + \default + + This property holds the animation to run when the behavior is triggered. +*/ + +QDeclarative1AbstractAnimation *QDeclarative1Behavior::animation() +{ + Q_D(QDeclarative1Behavior); + return d->animation; +} + +void QDeclarative1Behavior::setAnimation(QDeclarative1AbstractAnimation *animation) +{ + Q_D(QDeclarative1Behavior); + if (d->animation) { + qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior."); + return; + } + + d->animation = animation; + if (d->animation) { + d->animation->setDefaultTarget(d->property); + d->animation->setDisableUserControl(); + connect(d->animation->qtAnimation(), + SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)), + this, + SLOT(qtAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + } +} + + +void QDeclarative1Behavior::qtAnimationStateChanged(QAbstractAnimation::State newState,QAbstractAnimation::State) +{ + Q_D(QDeclarative1Behavior); + if (!d->blockRunningChanged) + d->animation->notifyRunningChanged(newState == QAbstractAnimation::Running); +} + + +/*! + \qmlproperty bool Behavior::enabled + + This property holds whether the behavior will be triggered when the tracked + property changes value. + + By default a Behavior is enabled. +*/ + +bool QDeclarative1Behavior::enabled() const +{ + Q_D(const QDeclarative1Behavior); + return d->enabled; +} + +void QDeclarative1Behavior::setEnabled(bool enabled) +{ + Q_D(QDeclarative1Behavior); + if (d->enabled == enabled) + return; + d->enabled = enabled; + emit enabledChanged(); +} + +void QDeclarative1Behavior::write(const QVariant &value) +{ + Q_D(QDeclarative1Behavior); + qmlExecuteDeferred(this); + if (!d->animation || !d->enabled || !d->finalized) { + QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + d->targetValue = value; + return; + } + + if (d->animation->isRunning() && value == d->targetValue) + return; + + d->currentValue = d->property.read(); + d->targetValue = value; + + if (d->animation->qtAnimation()->duration() != -1 + && d->animation->qtAnimation()->state() != QAbstractAnimation::Stopped) { + d->blockRunningChanged = true; + d->animation->qtAnimation()->stop(); + } + + QDeclarative1StateOperation::ActionList actions; + QDeclarative1Action action; + action.property = d->property; + action.fromValue = d->currentValue; + action.toValue = value; + actions << action; + + QList after; + d->animation->transition(actions, after, QDeclarative1AbstractAnimation::Forward); + d->animation->qtAnimation()->start(); + d->blockRunningChanged = false; + if (!after.contains(d->property)) + QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); +} + +void QDeclarative1Behavior::setTarget(const QDeclarativeProperty &property) +{ + Q_D(QDeclarative1Behavior); + d->property = property; + d->currentValue = property.read(); + if (d->animation) + d->animation->setDefaultTarget(property); + + QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this)); + engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()")); +} + +void QDeclarative1Behavior::componentFinalized() +{ + Q_D(QDeclarative1Behavior); + d->finalized = true; +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativebehavior_p.h b/src/qtquick1/util/qdeclarativebehavior_p.h new file mode 100644 index 0000000000..76792bc438 --- /dev/null +++ b/src/qtquick1/util/qdeclarativebehavior_p.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEBEHAVIOR_H +#define QDECLARATIVEBEHAVIOR_H + +#include "QtQuick1/private/qdeclarativestate_p.h" + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1AbstractAnimation; +class QDeclarative1BehaviorPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Behavior : public QObject, public QDeclarativePropertyValueInterceptor +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1Behavior) + + Q_INTERFACES(QDeclarativePropertyValueInterceptor) + Q_CLASSINFO("DefaultProperty", "animation") + Q_PROPERTY(QDeclarative1AbstractAnimation *animation READ animation WRITE setAnimation) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_CLASSINFO("DeferredPropertyNames", "animation") + +public: + QDeclarative1Behavior(QObject *parent=0); + ~QDeclarative1Behavior(); + + virtual void setTarget(const QDeclarativeProperty &); + virtual void write(const QVariant &value); + + QDeclarative1AbstractAnimation *animation(); + void setAnimation(QDeclarative1AbstractAnimation *); + + bool enabled() const; + void setEnabled(bool enabled); + +Q_SIGNALS: + void enabledChanged(); + +private Q_SLOTS: + void componentFinalized(); + void qtAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1Behavior) + +QT_END_HEADER + +#endif // QDECLARATIVEBEHAVIOR_H diff --git a/src/qtquick1/util/qdeclarativebind.cpp b/src/qtquick1/util/qdeclarativebind.cpp new file mode 100644 index 0000000000..bf0802b1d1 --- /dev/null +++ b/src/qtquick1/util/qdeclarativebind.cpp @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativebind_p.h" + +#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + + +class QDeclarative1BindPrivate : public QObjectPrivate +{ +public: + QDeclarative1BindPrivate() : when(true), componentComplete(true), obj(0) {} + + bool when : 1; + bool componentComplete : 1; + QObject *obj; + QString prop; + QDeclarativeNullableValue value; +}; + + +/*! + \qmlclass Binding QDeclarative1Bind + \ingroup qml-working-with-data + \since 4.7 + \brief The Binding element allows arbitrary property bindings to be created. + + Sometimes it is necessary to bind to a property of an object that wasn't + directly instantiated by QML - generally a property of a class exported + to QML by C++. In these cases, regular property binding doesn't work. Binding + allows you to bind any value to any property. + + For example, imagine a C++ application that maps an "app.enteredText" + property into QML. You could use Binding to update the enteredText property + like this. + \code + TextEdit { id: myTextField; text: "Please type here..." } + Binding { target: app; property: "enteredText"; value: myTextField.text } + \endcode + Whenever the text in the TextEdit is updated, the C++ property will be + updated also. + + If the binding target or binding property is changed, the bound value is + immediately pushed onto the new target. + + \sa QtDeclarative +*/ +QDeclarative1Bind::QDeclarative1Bind(QObject *parent) + : QObject(*(new QDeclarative1BindPrivate), parent) +{ +} + +QDeclarative1Bind::~QDeclarative1Bind() +{ +} + +/*! + \qmlproperty bool Binding::when + + This property holds when the binding is active. + This should be set to an expression that evaluates to true when you want the binding to be active. + + \code + Binding { + target: contactName; property: 'text' + value: name; when: list.ListView.isCurrentItem + } + \endcode +*/ +bool QDeclarative1Bind::when() const +{ + Q_D(const QDeclarative1Bind); + return d->when; +} + +void QDeclarative1Bind::setWhen(bool v) +{ + Q_D(QDeclarative1Bind); + d->when = v; + eval(); +} + +/*! + \qmlproperty Object Binding::target + + The object to be updated. +*/ +QObject *QDeclarative1Bind::object() +{ + Q_D(const QDeclarative1Bind); + return d->obj; +} + +void QDeclarative1Bind::setObject(QObject *obj) +{ + Q_D(QDeclarative1Bind); + d->obj = obj; + eval(); +} + +/*! + \qmlproperty string Binding::property + + The property to be updated. +*/ +QString QDeclarative1Bind::property() const +{ + Q_D(const QDeclarative1Bind); + return d->prop; +} + +void QDeclarative1Bind::setProperty(const QString &p) +{ + Q_D(QDeclarative1Bind); + d->prop = p; + eval(); +} + +/*! + \qmlproperty any Binding::value + + The value to be set on the target object and property. This can be a + constant (which isn't very useful), or a bound expression. +*/ +QVariant QDeclarative1Bind::value() const +{ + Q_D(const QDeclarative1Bind); + return d->value.value; +} + +void QDeclarative1Bind::setValue(const QVariant &v) +{ + Q_D(QDeclarative1Bind); + d->value.value = v; + d->value.isNull = false; + eval(); +} + +void QDeclarative1Bind::classBegin() +{ + Q_D(QDeclarative1Bind); + d->componentComplete = false; +} + +void QDeclarative1Bind::componentComplete() +{ + Q_D(QDeclarative1Bind); + d->componentComplete = true; + eval(); +} + +void QDeclarative1Bind::eval() +{ + Q_D(QDeclarative1Bind); + if (!d->obj || d->value.isNull || !d->when || !d->componentComplete) + return; + + QDeclarativeProperty prop(d->obj, d->prop); + prop.write(d->value.value); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativebind_p.h b/src/qtquick1/util/qdeclarativebind_p.h new file mode 100644 index 0000000000..d8296455c7 --- /dev/null +++ b/src/qtquick1/util/qdeclarativebind_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEBIND_H +#define QDECLARATIVEBIND_H + +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1BindPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Bind : public QObject, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1Bind) + Q_INTERFACES(QDeclarativeParserStatus) + Q_PROPERTY(QObject *target READ object WRITE setObject) + Q_PROPERTY(QString property READ property WRITE setProperty) + Q_PROPERTY(QVariant value READ value WRITE setValue) + Q_PROPERTY(bool when READ when WRITE setWhen) + +public: + QDeclarative1Bind(QObject *parent=0); + ~QDeclarative1Bind(); + + bool when() const; + void setWhen(bool); + + QObject *object(); + void setObject(QObject *); + + QString property() const; + void setProperty(const QString &); + + QVariant value() const; + void setValue(const QVariant &); + +protected: + virtual void classBegin(); + virtual void componentComplete(); + +private: + void eval(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1Bind) + +QT_END_HEADER + +#endif diff --git a/src/qtquick1/util/qdeclarativeconnections.cpp b/src/qtquick1/util/qdeclarativeconnections.cpp new file mode 100644 index 0000000000..d1d92356ac --- /dev/null +++ b/src/qtquick1/util/qdeclarativeconnections.cpp @@ -0,0 +1,293 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativeconnections_p.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + + +class QDeclarative1ConnectionsPrivate : public QObjectPrivate +{ +public: + QDeclarative1ConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} + + QList boundsignals; + QObject *target; + + bool targetSet; + bool ignoreUnknownSignals; + bool componentcomplete; + + QByteArray data; +}; + +/*! + \qmlclass Connections QDeclarative1Connections + \ingroup qml-utility-elements + \since 4.7 + \brief A Connections element describes generalized connections to signals. + + A Connections object creates a connection to a QML signal. + + When connecting to signals in QML, the usual way is to create an + "on" handler that reacts when a signal is received, like this: + + \qml + MouseArea { + onClicked: { foo(parameters) } + } + \endqml + + However, it is not possible to connect to a signal in this way in some + cases, such as when: + + \list + \i Multiple connections to the same signal are required + \i Creating connections outside the scope of the signal sender + \i Connecting to targets not defined in QML + \endlist + + When any of these are needed, the Connections element can be used instead. + + For example, the above code can be changed to use a Connections object, + like this: + + \qml + MouseArea { + Connections { + onClicked: foo(parameters) + } + } + \endqml + + More generally, the Connections object can be a child of some object other than + the sender of the signal: + + \qml + MouseArea { + id: area + } + // ... + \endqml + \qml + Connections { + target: area + onClicked: foo(parameters) + } + \endqml + + \sa QtDeclarative +*/ +QDeclarative1Connections::QDeclarative1Connections(QObject *parent) : + QObject(*(new QDeclarative1ConnectionsPrivate), parent) +{ +} + +QDeclarative1Connections::~QDeclarative1Connections() +{ +} + +/*! + \qmlproperty Object Connections::target + This property holds the object that sends the signal. + + If this property is not set, the \c target defaults to the parent of the Connection. + + If set to null, no connection is made and any signal handlers are ignored + until the target is not null. +*/ +QObject *QDeclarative1Connections::target() const +{ + Q_D(const QDeclarative1Connections); + return d->targetSet ? d->target : parent(); +} + +void QDeclarative1Connections::setTarget(QObject *obj) +{ + Q_D(QDeclarative1Connections); + d->targetSet = true; // even if setting to 0, it is *set* + if (d->target == obj) + return; + foreach (QDeclarativeBoundSignal *s, d->boundsignals) { + // It is possible that target is being changed due to one of our signal + // handlers -> use deleteLater(). + if (s->isEvaluating()) + s->deleteLater(); + else + delete s; + } + d->boundsignals.clear(); + d->target = obj; + connectSignals(); + emit targetChanged(); +} + +/*! + \qmlproperty bool Connections::ignoreUnknownSignals + + Normally, a connection to a non-existent signal produces runtime errors. + + If this property is set to \c true, such errors are ignored. + This is useful if you intend to connect to different types of objects, handling + a different set of signals for each object. +*/ +bool QDeclarative1Connections::ignoreUnknownSignals() const +{ + Q_D(const QDeclarative1Connections); + return d->ignoreUnknownSignals; +} + +void QDeclarative1Connections::setIgnoreUnknownSignals(bool ignore) +{ + Q_D(QDeclarative1Connections); + d->ignoreUnknownSignals = ignore; +} + + + +QByteArray +QDeclarative1ConnectionsParser::compile(const QList &props) +{ + QByteArray rv; + QDataStream ds(&rv, QIODevice::WriteOnly); + + for(int ii = 0; ii < props.count(); ++ii) + { + QString propName = QString::fromUtf8(props.at(ii).name()); + if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) { + error(props.at(ii), QDeclarative1Connections::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); + return QByteArray(); + } + + QList values = props.at(ii).assignedValues(); + + for (int i = 0; i < values.count(); ++i) { + const QVariant &value = values.at(i); + + if (value.userType() == qMetaTypeId()) { + error(props.at(ii), QDeclarative1Connections::tr("Connections: nested objects not allowed")); + return QByteArray(); + } else if (value.userType() == qMetaTypeId()) { + error(props.at(ii), QDeclarative1Connections::tr("Connections: syntax error")); + return QByteArray(); + } else { + QDeclarativeParser::Variant v = qvariant_cast(value); + if (v.isScript()) { + ds << propName; + ds << v.asScript(); + } else { + error(props.at(ii), QDeclarative1Connections::tr("Connections: script expected")); + return QByteArray(); + } + } + } + } + + return rv; +} + +void QDeclarative1ConnectionsParser::setCustomData(QObject *object, + const QByteArray &data) +{ + QDeclarative1ConnectionsPrivate *p = + static_cast(QObjectPrivate::get(object)); + p->data = data; +} + + +void QDeclarative1Connections::connectSignals() +{ + Q_D(QDeclarative1Connections); + if (!d->componentcomplete || (d->targetSet && !target())) + return; + + QDataStream ds(d->data); + while (!ds.atEnd()) { + QString propName; + ds >> propName; + QString script; + ds >> script; + QDeclarativeProperty prop(target(), propName); + if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) { + QDeclarativeBoundSignal *signal = + new QDeclarativeBoundSignal(target(), prop.method(), this); + QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(this), 0, script); + QDeclarativeData *ddata = QDeclarativeData::get(this); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); + signal->setExpression(expression); + d->boundsignals += signal; + } else { + if (!d->ignoreUnknownSignals) + qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); + } + } +} + +void QDeclarative1Connections::classBegin() +{ + Q_D(QDeclarative1Connections); + d->componentcomplete=false; +} + +void QDeclarative1Connections::componentComplete() +{ + Q_D(QDeclarative1Connections); + d->componentcomplete=true; + connectSignals(); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeconnections_p.h b/src/qtquick1/util/qdeclarativeconnections_p.h new file mode 100644 index 0000000000..6d6112bf98 --- /dev/null +++ b/src/qtquick1/util/qdeclarativeconnections_p.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVECONNECTIONS_H +#define QDECLARATIVECONNECTIONS_H + +#include +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeBoundSignal; +class QDeclarativeContext; +class QDeclarative1ConnectionsPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1Connections : public QObject, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1Connections) + + Q_INTERFACES(QDeclarativeParserStatus) + Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals) + +public: + QDeclarative1Connections(QObject *parent=0); + ~QDeclarative1Connections(); + + QObject *target() const; + void setTarget(QObject *); + + bool ignoreUnknownSignals() const; + void setIgnoreUnknownSignals(bool ignore); + +Q_SIGNALS: + void targetChanged(); + +private: + void connectSignals(); + void classBegin(); + void componentComplete(); +}; + +class QDeclarative1ConnectionsParser : public QDeclarativeCustomParser +{ +public: + virtual QByteArray compile(const QList &); + virtual void setCustomData(QObject *, const QByteArray &); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1Connections) + +QT_END_HEADER + +#endif diff --git a/src/qtquick1/util/qdeclarativefontloader.cpp b/src/qtquick1/util/qdeclarativefontloader.cpp new file mode 100644 index 0000000000..38f7fc6121 --- /dev/null +++ b/src/qtquick1/util/qdeclarativefontloader.cpp @@ -0,0 +1,342 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativefontloader_p.h" + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + + +#define FONTLOADER_MAXIMUM_REDIRECT_RECURSION 16 + +class QDeclarative1FontObject : public QObject +{ +Q_OBJECT + +public: + QDeclarative1FontObject(int _id); + + void download(const QUrl &url, QNetworkAccessManager *manager); + +Q_SIGNALS: + void fontDownloaded(const QString&, QDeclarative1FontLoader::Status); + +private Q_SLOTS: + void replyFinished(); + +public: + int id; + +private: + QNetworkReply *reply; + int redirectCount; + + Q_DISABLE_COPY(QDeclarative1FontObject) +}; + +QDeclarative1FontObject::QDeclarative1FontObject(int _id = -1) + : QObject(0), id(_id), reply(0), redirectCount(0) {} + + +void QDeclarative1FontObject::download(const QUrl &url, QNetworkAccessManager *manager) +{ + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + reply = manager->get(req); + QObject::connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); +} + +void QDeclarative1FontObject::replyFinished() +{ + if (reply) { + redirectCount++; + if (redirectCount < FONTLOADER_MAXIMUM_REDIRECT_RECURSION) { + QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = reply->url().resolved(redirect.toUrl()); + QNetworkAccessManager *manager = reply->manager(); + reply->deleteLater(); + reply = 0; + download(url, manager); + return; + } + } + redirectCount = 0; + + if (!reply->error()) { + id = QFontDatabase::addApplicationFontFromData(reply->readAll()); + if (id != -1) + emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QDeclarative1FontLoader::Ready); + else + emit fontDownloaded(QString(), QDeclarative1FontLoader::Error); + } else { + emit fontDownloaded(QString(), QDeclarative1FontLoader::Error); + } + reply->deleteLater(); + reply = 0; + } +} + + +class QDeclarative1FontLoaderPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1FontLoader) + +public: + QDeclarative1FontLoaderPrivate() : status(QDeclarative1FontLoader::Null) {} + + QUrl url; + QString name; + QDeclarative1FontLoader::Status status; + static QHash fonts; +}; + +QHash QDeclarative1FontLoaderPrivate::fonts; + +/*! + \qmlclass FontLoader QDeclarative1FontLoader + \ingroup qml-utility-elements + \since 4.7 + \brief The FontLoader element allows fonts to be loaded by name or URL. + + The FontLoader element is used to load fonts by name or URL. + + The \l status indicates when the font has been loaded, which is useful + for fonts loaded from remote sources. + + For example: + \qml + import QtQuick 1.0 + + Column { + FontLoader { id: fixedFont; name: "Courier" } + FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" } + + Text { text: "Fixed-size font"; font.family: fixedFont.name } + Text { text: "Fancy font"; font.family: webFont.name } + } + \endqml + + \sa {declarative/text/fonts}{Fonts example} +*/ +QDeclarative1FontLoader::QDeclarative1FontLoader(QObject *parent) + : QObject(*(new QDeclarative1FontLoaderPrivate), parent) +{ +} + +QDeclarative1FontLoader::~QDeclarative1FontLoader() +{ +} + +/*! + \qmlproperty url FontLoader::source + The url of the font to load. +*/ +QUrl QDeclarative1FontLoader::source() const +{ + Q_D(const QDeclarative1FontLoader); + return d->url; +} + +void QDeclarative1FontLoader::setSource(const QUrl &url) +{ + Q_D(QDeclarative1FontLoader); + if (url == d->url) + return; + d->url = qmlContext(this)->resolvedUrl(url); + emit sourceChanged(); + +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML + QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); + if (!localFile.isEmpty()) { + if (!d->fonts.contains(d->url)) { + int id = QFontDatabase::addApplicationFont(localFile); + if (id != -1) { + updateFontInfo(QFontDatabase::applicationFontFamilies(id).at(0), Ready); + QDeclarative1FontObject *fo = new QDeclarative1FontObject(id); + d->fonts[d->url] = fo; + } else { + updateFontInfo(QString(), Error); + } + } else { + updateFontInfo(QFontDatabase::applicationFontFamilies(d->fonts[d->url]->id).at(0), Ready); + } + } else +#endif + { + if (!d->fonts.contains(d->url)) { + QDeclarative1FontObject *fo = new QDeclarative1FontObject; + d->fonts[d->url] = fo; + fo->download(d->url, qmlEngine(this)->networkAccessManager()); + d->status = Loading; + emit statusChanged(); + QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarative1FontLoader::Status)), + this, SLOT(updateFontInfo(QString,QDeclarative1FontLoader::Status))); + } else { + QDeclarative1FontObject *fo = d->fonts[d->url]; + if (fo->id == -1) { + d->status = Loading; + emit statusChanged(); + QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarative1FontLoader::Status)), + this, SLOT(updateFontInfo(QString,QDeclarative1FontLoader::Status))); + } + else + updateFontInfo(QFontDatabase::applicationFontFamilies(fo->id).at(0), Ready); + } + } +} + +void QDeclarative1FontLoader::updateFontInfo(const QString& name, QDeclarative1FontLoader::Status status) +{ + Q_D(QDeclarative1FontLoader); + + if (name != d->name) { + d->name = name; + emit nameChanged(); + } + if (status != d->status) { + if (status == Error) + qmlInfo(this) << "Cannot load font: \"" << d->url.toString() << "\""; + d->status = status; + emit statusChanged(); + } +} + +/*! + \qmlproperty string FontLoader::name + + This property holds the name of the font family. + It is set automatically when a font is loaded using the \c url property. + + Use this to set the \c font.family property of a \c Text item. + + Example: + \qml + Item { + width: 200; height: 50 + + FontLoader { + id: webFont + source: "http://www.mysite.com/myfont.ttf" + } + Text { + text: "Fancy font" + font.family: webFont.name + } + } + \endqml +*/ +QString QDeclarative1FontLoader::name() const +{ + Q_D(const QDeclarative1FontLoader); + return d->name; +} + +void QDeclarative1FontLoader::setName(const QString &name) +{ + Q_D(QDeclarative1FontLoader); + if (d->name == name) + return; + d->name = name; + emit nameChanged(); + d->status = Ready; + emit statusChanged(); +} + +/*! + \qmlproperty enumeration FontLoader::status + + This property holds the status of font loading. It can be one of: + \list + \o FontLoader.Null - no font has been set + \o FontLoader.Ready - the font has been loaded + \o FontLoader.Loading - the font is currently being loaded + \o FontLoader.Error - an error occurred while loading the font + \endlist + + Use this status to provide an update or respond to the status change in some way. + For example, you could: + + \list + \o Trigger a state change: + \qml + State { name: 'loaded'; when: loader.status == FontLoader.Ready } + \endqml + + \o Implement an \c onStatusChanged signal handler: + \qml + FontLoader { + id: loader + onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded') + } + \endqml + + \o Bind to the status value: + \qml + Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' } + \endqml + \endlist +*/ +QDeclarative1FontLoader::Status QDeclarative1FontLoader::status() const +{ + Q_D(const QDeclarative1FontLoader); + return d->status; +} + + + +QT_END_NAMESPACE + +#include diff --git a/src/qtquick1/util/qdeclarativefontloader_p.h b/src/qtquick1/util/qdeclarativefontloader_p.h new file mode 100644 index 0000000000..76fa8e350f --- /dev/null +++ b/src/qtquick1/util/qdeclarativefontloader_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEFONTLOADER_H +#define QDECLARATIVEFONTLOADER_H + +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1FontLoaderPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1FontLoader : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1FontLoader) + Q_ENUMS(Status) + + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + +public: + enum Status { Null = 0, Ready, Loading, Error }; + + QDeclarative1FontLoader(QObject *parent = 0); + ~QDeclarative1FontLoader(); + + QUrl source() const; + void setSource(const QUrl &url); + + QString name() const; + void setName(const QString &name); + + Status status() const; + +private Q_SLOTS: + void updateFontInfo(const QString&, QDeclarative1FontLoader::Status); + +Q_SIGNALS: + void sourceChanged(); + void nameChanged(); + void statusChanged(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1FontLoader) + +QT_END_HEADER + +#endif // QDECLARATIVEFONTLOADER_H + diff --git a/src/qtquick1/util/qdeclarativelistaccessor.cpp b/src/qtquick1/util/qdeclarativelistaccessor.cpp new file mode 100644 index 0000000000..215fe670e5 --- /dev/null +++ b/src/qtquick1/util/qdeclarativelistaccessor.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativelistaccessor_p.h" + +#include + +#include +#include + +// ### Remove me +#include + +QT_BEGIN_NAMESPACE + + + +QDeclarative1ListAccessor::QDeclarative1ListAccessor() +: m_type(Invalid) +{ +} + +QDeclarative1ListAccessor::~QDeclarative1ListAccessor() +{ +} + +QVariant QDeclarative1ListAccessor::list() const +{ + return d; +} + +void QDeclarative1ListAccessor::setList(const QVariant &v, QDeclarativeEngine *engine) +{ + d = v; + + QDeclarativeEnginePrivate *enginePrivate = engine?QDeclarativeEnginePrivate::get(engine):0; + + if (!d.isValid()) { + m_type = Invalid; + } else if (d.userType() == QVariant::StringList) { + m_type = StringList; + } else if (d.userType() == QMetaType::QVariantList) { + m_type = VariantList; + } else if (d.canConvert(QVariant::Int)) { + m_type = Integer; + } else if ((!enginePrivate && QDeclarativeMetaType::isQObject(d.userType())) || + (enginePrivate && enginePrivate->isQObject(d.userType()))) { + QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v); + d = QVariant::fromValue(data); + m_type = Instance; + } else if (d.userType() == qMetaTypeId()) { + m_type = ListProperty; + } else { + m_type = Instance; + } +} + +int QDeclarative1ListAccessor::count() const +{ + switch(m_type) { + case StringList: + return qvariant_cast(d).count(); + case VariantList: + return qvariant_cast(d).count(); + case ListProperty: + return ((QDeclarativeListReference *)d.constData())->count(); + case Instance: + return 1; + case Integer: + return d.toInt(); + default: + case Invalid: + return 0; + } +} + +QVariant QDeclarative1ListAccessor::at(int idx) const +{ + Q_ASSERT(idx >= 0 && idx < count()); + switch(m_type) { + case StringList: + return QVariant::fromValue(qvariant_cast(d).at(idx)); + case VariantList: + return qvariant_cast(d).at(idx); + case ListProperty: + return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx)); + case Instance: + return d; + case Integer: + return QVariant(idx); + default: + case Invalid: + return QVariant(); + } +} + +bool QDeclarative1ListAccessor::isValid() const +{ + return m_type != Invalid; +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativelistaccessor_p.h b/src/qtquick1/util/qdeclarativelistaccessor_p.h new file mode 100644 index 0000000000..6372deec23 --- /dev/null +++ b/src/qtquick1/util/qdeclarativelistaccessor_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVELISTACCESSOR_H +#define QDECLARATIVELISTACCESSOR_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QDeclarativeEngine; + +QT_MODULE(Declarative) + +class Q_AUTOTEST_EXPORT QDeclarative1ListAccessor +{ +public: + QDeclarative1ListAccessor(); + ~QDeclarative1ListAccessor(); + + QVariant list() const; + void setList(const QVariant &, QDeclarativeEngine * = 0); + + bool isValid() const; + + int count() const; + QVariant at(int) const; + + enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer }; + Type type() const { return m_type; } + +private: + Type m_type; + QVariant d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDECLARATIVELISTACCESSOR_H diff --git a/src/qtquick1/util/qdeclarativelistmodel.cpp b/src/qtquick1/util/qdeclarativelistmodel.cpp new file mode 100644 index 0000000000..f9c9ded9b0 --- /dev/null +++ b/src/qtquick1/util/qdeclarativelistmodel.cpp @@ -0,0 +1,1631 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativelistmodel_p_p.h" +#include "QtQuick1/private/qdeclarativelistmodelworkeragent_p.h" +#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QListModelInterface *) + +QT_BEGIN_NAMESPACE + + + +template +void qdeclarativelistmodel_move(int from, int to, int n, T *items) +{ + if (n == 1) { + items->move(from, to); + } else { + T replaced; + int i=0; + typename T::ConstIterator it=items->begin(); it += from+n; + for (; ibegin(); it += from; + for (; ibegin(); t += from; + for (; f != replaced.end(); ++f, ++t) + *t = *f; + } +} + +QDeclarative1ListModelParser::ListInstruction *QDeclarative1ListModelParser::ListModelData::instructions() const +{ + return (QDeclarative1ListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData)); +} + +/*! + \qmlclass ListModel QDeclarative1ListModel + \ingroup qml-working-with-data + \since 4.7 + \brief The ListModel element defines a free-form list data source. + + The ListModel is a simple container of ListElement definitions, each containing data roles. + The contents can be defined dynamically, or explicitly in QML. + + The number of elements in the model can be obtained from its \l count property. + A number of familiar methods are also provided to manipulate the contents of the + model, including append(), insert(), move(), remove() and set(). These methods + accept dictionaries as their arguments; these are translated to ListElement objects + by the model. + + Elements can be manipulated via the model using the setProperty() method, which + allows the roles of the specified element to be set and changed. + + \section1 Example Usage + + The following example shows a ListModel containing three elements, with the roles + "name" and "cost". + + \div {class="float-right"} + \inlineimage listmodel.png + \enddiv + + \snippet doc/src/snippets/declarative/listmodel.qml 0 + + \clearfloat + Roles (properties) in each element must begin with a lower-case letter and + should be common to all elements in a model. The ListElement documentation + provides more guidelines for how elements should be defined. + + Since the example model contains an \c id property, it can be referenced + by views, such as the ListView in this example: + + \snippet doc/src/snippets/declarative/listmodel-simple.qml 0 + \dots 8 + \snippet doc/src/snippets/declarative/listmodel-simple.qml 1 + + It is possible for roles to contain list data. In the following example we + create a list of fruit attributes: + + \snippet doc/src/snippets/declarative/listmodel-nested.qml model + + The delegate displays all the fruit attributes: + + \div {class="float-right"} + \inlineimage listmodel-nested.png + \enddiv + + \snippet doc/src/snippets/declarative/listmodel-nested.qml delegate + + \clearfloat + \section1 Modifying List Models + + The content of a ListModel may be created and modified using the clear(), + append(), set(), insert() and setProperty() methods. For example: + + \snippet doc/src/snippets/declarative/listmodel-modify.qml delegate + + Note that when creating content dynamically the set of available properties + cannot be changed once set. Whatever properties are first added to the model + are the only permitted properties in the model. + + \section1 Using Threaded List Models with WorkerScript + + ListModel can be used together with WorkerScript access a list model + from multiple threads. This is useful if list modifications are + synchronous and take some time: the list operations can be moved to a + different thread to avoid blocking of the main GUI thread. + + Here is an example that uses WorkerScript to periodically append the + current time to a list model: + + \snippet examples/declarative/threading/threadedlistmodel/timedisplay.qml 0 + + The included file, \tt dataloader.js, looks like this: + + \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0 + + The timer in the main example sends messages to the worker script by calling + \l WorkerScript::sendMessage(). When this message is received, + \l{WorkerScript::onMessage}{WorkerScript.onMessage()} is invoked in \c dataloader.js, + which appends the current time to the list model. + + Note the call to sync() from the \l{WorkerScript::onMessage}{WorkerScript.onMessage()} + handler. You must call sync() or else the changes made to the list from the external + thread will not be reflected in the list model in the main thread. + + \section1 Restrictions + + If a list model is to be accessed from a WorkerScript, it cannot + contain list-type data. So, the following model cannot be used from a WorkerScript + because of the list contained in the "attributes" property: + + \code + ListModel { + id: fruitModel + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + } + \endcode + + In addition, the WorkerScript cannot add list-type data to the model. + + \sa {qmlmodels}{Data Models}, {declarative/threading/threadedlistmodel}{Threaded ListModel example}, QtDeclarative +*/ + + +/* + A ListModel internally uses either a NestedListModel_1 or FlatListModel_1. + + A NestedListModel_1 can contain lists of ListElements (which + when retrieved from get() is accessible as a list model within the list + model) whereas a FlatListModel_1 cannot. + + ListModel uses a NestedListModel_1 to begin with, and if the model is later + used from a WorkerScript, it changes to use a FlatListModel_1 instead. This + is because ModelNode (which abstracts the nested list model data) needs + access to the declarative engine and script engine, which cannot be + safely used from outside of the main thread. +*/ + +QDeclarative1ListModel::QDeclarative1ListModel(QObject *parent) +: QListModelInterface(parent), m_agent(0), m_nested(new NestedListModel_1(this)), m_flat(0) +{ +} + +QDeclarative1ListModel::QDeclarative1ListModel(const QDeclarative1ListModel *orig, QDeclarative1ListModelWorkerAgent *parent) +: QListModelInterface(parent), m_agent(0), m_nested(0), m_flat(0) +{ + m_flat = new FlatListModel_1(this); + m_flat->m_parentAgent = parent; + + if (orig->m_flat) { + m_flat->m_roles = orig->m_flat->m_roles; + m_flat->m_strings = orig->m_flat->m_strings; + m_flat->m_values = orig->m_flat->m_values; + + m_flat->m_nodeData.reserve(m_flat->m_values.count()); + for (int i=0; im_values.count(); i++) + m_flat->m_nodeData << 0; + } +} + +QDeclarative1ListModel::~QDeclarative1ListModel() +{ + if (m_agent) + m_agent->release(); + + delete m_nested; + delete m_flat; +} + +bool QDeclarative1ListModel::flatten() +{ + if (m_flat) + return true; + + QList roles = m_nested->roles(); + + QList > values; + bool hasNested = false; + for (int i=0; icount(); i++) { + values.append(m_nested->data(i, roles, &hasNested)); + if (hasNested) + return false; + } + + FlatListModel_1 *flat = new FlatListModel_1(this); + flat->m_values = values; + + for (int i=0; itoString(roles[i]); + flat->m_roles.insert(roles[i], s); + flat->m_strings.insert(s, roles[i]); + } + + flat->m_nodeData.reserve(flat->m_values.count()); + for (int i=0; im_values.count(); i++) + flat->m_nodeData << 0; + + m_flat = flat; + delete m_nested; + m_nested = 0; + return true; +} + +bool QDeclarative1ListModel::inWorkerThread() const +{ + return m_flat && m_flat->m_parentAgent; +} + +QDeclarative1ListModelWorkerAgent *QDeclarative1ListModel::agent() +{ + if (m_agent) + return m_agent; + + if (!flatten()) { + qmlInfo(this) << "List contains list-type data and cannot be used from a worker script"; + return 0; + } + + m_agent = new QDeclarative1ListModelWorkerAgent(this); + return m_agent; +} + +QList QDeclarative1ListModel::roles() const +{ + return m_flat ? m_flat->roles() : m_nested->roles(); +} + +QString QDeclarative1ListModel::toString(int role) const +{ + return m_flat ? m_flat->toString(role) : m_nested->toString(role); +} + +QVariant QDeclarative1ListModel::data(int index, int role) const +{ + if (index >= count() || index < 0) + return QVariant(); + + return m_flat ? m_flat->data(index, role) : m_nested->data(index, role); +} + +/*! + \qmlproperty int ListModel::count + The number of data entries in the model. +*/ +int QDeclarative1ListModel::count() const +{ + return m_flat ? m_flat->count() : m_nested->count(); +} + +/*! + \qmlmethod ListModel::clear() + + Deletes all content from the model. + + \sa append() remove() +*/ +void QDeclarative1ListModel::clear() +{ + int cleared = count(); + if (m_flat) + m_flat->clear(); + else + m_nested->clear(); + + if (!inWorkerThread()) { + emit itemsRemoved(0, cleared); + emit countChanged(); + } +} + +QDeclarative1ListModel *ModelNode::model(const NestedListModel_1 *model) +{ + if (!modelCache) { + modelCache = new QDeclarative1ListModel; + QDeclarativeEngine::setContextForObject(modelCache,QDeclarativeEngine::contextForObject(model->m_listModel)); + modelCache->m_nested->_root = this; // ListModel defaults to nestable model + + for (int i=0; i(values.at(i)); + if (subNode) + subNode->m_model = modelCache->m_nested; + } + } + return modelCache; +} + +ModelObject_1 *ModelNode::object(const NestedListModel_1 *model) +{ + if (!objectCache) { + objectCache = new ModelObject_1(this, + const_cast(model), + QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(model->m_listModel))); + QHash::iterator it; + for (it = properties.begin(); it != properties.end(); ++it) { + objectCache->setValue(it.key().toUtf8(), model->valueForNode(*it)); + } + objectCache->setNodeUpdatesEnabled(true); + } + return objectCache; +} + +/*! + \qmlmethod ListModel::remove(int index) + + Deletes the content at \a index from the model. + + \sa clear() +*/ +void QDeclarative1ListModel::remove(int index) +{ + if (index < 0 || index >= count()) { + qmlInfo(this) << tr("remove: index %1 out of range").arg(index); + return; + } + + if (m_flat) + m_flat->remove(index); + else + m_nested->remove(index); + + if (!inWorkerThread()) { + emit itemsRemoved(index, 1); + emit countChanged(); + } +} + +/*! + \qmlmethod ListModel::insert(int index, jsobject dict) + + Adds a new item to the list model at position \a index, with the + values in \a dict. + + \code + fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"}) + \endcode + + The \a index must be to an existing item in the list, or one past + the end of the list (equivalent to append). + + \sa set() append() +*/ +void QDeclarative1ListModel::insert(int index, const QScriptValue& valuemap) +{ + if (!valuemap.isObject() || valuemap.isArray()) { + qmlInfo(this) << tr("insert: value is not an object"); + return; + } + + if (index < 0 || index > count()) { + qmlInfo(this) << tr("insert: index %1 out of range").arg(index); + return; + } + + bool ok = m_flat ? m_flat->insert(index, valuemap) : m_nested->insert(index, valuemap); + if (ok && !inWorkerThread()) { + emit itemsInserted(index, 1); + emit countChanged(); + } +} + +/*! + \qmlmethod ListModel::move(int from, int to, int n) + + Moves \a n items \a from one position \a to another. + + The from and to ranges must exist; for example, to move the first 3 items + to the end of the list: + + \code + fruitModel.move(0, fruitModel.count - 3, 3) + \endcode + + \sa append() +*/ +void QDeclarative1ListModel::move(int from, int to, int n) +{ + if (n==0 || from==to) + return; + if (!canMove(from, to, n)) { + qmlInfo(this) << tr("move: out of range"); + return; + } + + int origfrom = from; + int origto = to; + int orign = n; + if (from > to) { + // Only move forwards - flip if backwards moving + int tfrom = from; + int tto = to; + from = tto; + to = tto+n; + n = tfrom-tto; + } + + if (m_flat) + m_flat->move(from, to, n); + else + m_nested->move(from, to, n); + + if (!inWorkerThread()) + emit itemsMoved(origfrom, origto, orign); +} + +/*! + \qmlmethod ListModel::append(jsobject dict) + + Adds a new item to the end of the list model, with the + values in \a dict. + + \code + fruitModel.append({"cost": 5.95, "name":"Pizza"}) + \endcode + + \sa set() remove() +*/ +void QDeclarative1ListModel::append(const QScriptValue& valuemap) +{ + if (!valuemap.isObject() || valuemap.isArray()) { + qmlInfo(this) << tr("append: value is not an object"); + return; + } + + insert(count(), valuemap); +} + +/*! + \qmlmethod object ListModel::get(int index) + + Returns the item at \a index in the list model. This allows the item + data to be accessed or modified from JavaScript: + + \code + Component.onCompleted: { + fruitModel.append({"cost": 5.95, "name":"Jackfruit"}); + console.log(fruitModel.get(0).cost); + fruitModel.get(0).cost = 10.95; + } + \endcode + + The \a index must be an element in the list. + + Note that properties of the returned object that are themselves objects + will also be models, and this get() method is used to access elements: + + \code + fruitModel.append(..., "attributes": + [{"name":"spikes","value":"7mm"}, + {"name":"color","value":"green"}]); + fruitModel.get(0).attributes.get(1).value; // == "green" + \endcode + + \warning The returned object is not guaranteed to remain valid. It + should not be used in \l{Property Binding}{property bindings}. + + \sa append() +*/ +QScriptValue QDeclarative1ListModel::get(int index) const +{ + // the internal flat/nested class checks for bad index + return m_flat ? m_flat->get(index) : m_nested->get(index); +} + +/*! + \qmlmethod ListModel::set(int index, jsobject dict) + + Changes the item at \a index in the list model with the + values in \a dict. Properties not appearing in \a dict + are left unchanged. + + \code + fruitModel.set(3, {"cost": 5.95, "name":"Pizza"}) + \endcode + + If \a index is equal to count() then a new item is appended to the + list. Otherwise, \a index must be an element in the list. + + \sa append() +*/ +void QDeclarative1ListModel::set(int index, const QScriptValue& valuemap) +{ + QList roles; + set(index, valuemap, &roles); + if (!roles.isEmpty() && !inWorkerThread()) + emit itemsChanged(index, 1, roles); +} + +void QDeclarative1ListModel::set(int index, const QScriptValue& valuemap, QList *roles) +{ + if (!valuemap.isObject() || valuemap.isArray()) { + qmlInfo(this) << tr("set: value is not an object"); + return; + } + if (index > count() || index < 0) { + qmlInfo(this) << tr("set: index %1 out of range").arg(index); + return; + } + + if (index == count()) { + append(valuemap); + } else { + if (m_flat) + m_flat->set(index, valuemap, roles); + else + m_nested->set(index, valuemap, roles); + } +} + +/*! + \qmlmethod ListModel::setProperty(int index, string property, variant value) + + Changes the \a property of the item at \a index in the list model to \a value. + + \code + fruitModel.setProperty(3, "cost", 5.95) + \endcode + + The \a index must be an element in the list. + + \sa append() +*/ +void QDeclarative1ListModel::setProperty(int index, const QString& property, const QVariant& value) +{ + QList roles; + setProperty(index, property, value, &roles); + if (!roles.isEmpty() && !inWorkerThread()) + emit itemsChanged(index, 1, roles); +} + +void QDeclarative1ListModel::setProperty(int index, const QString& property, const QVariant& value, QList *roles) +{ + if (count() == 0 || index >= count() || index < 0) { + qmlInfo(this) << tr("set: index %1 out of range").arg(index); + return; + } + + if (m_flat) + m_flat->setProperty(index, property, value, roles); + else + m_nested->setProperty(index, property, value, roles); +} + +/*! + \qmlmethod ListModel::sync() + + Writes any unsaved changes to the list model after it has been modified + from a worker script. +*/ +void QDeclarative1ListModel::sync() +{ + // This is just a dummy method to make it look like sync() exists in + // ListModel (and not just QDeclarative1ListModelWorkerAgent) and to let + // us document sync(). + qmlInfo(this) << "List sync() can only be called from a WorkerScript"; +} + +bool QDeclarative1ListModelParser::compileProperty(const QDeclarativeCustomParserProperty &prop, QList &instr, QByteArray &data) +{ + QList values = prop.assignedValues(); + for(int ii = 0; ii < values.count(); ++ii) { + const QVariant &value = values.at(ii); + + if(value.userType() == qMetaTypeId()) { + QDeclarativeCustomParserNode node = + qvariant_cast(value); + + if (node.name() != listElementTypeName) { + const QMetaObject *mo = resolveType(node.name()); + if (mo != &QDeclarative1ListElement::staticMetaObject) { + error(node, QDeclarative1ListModel::tr("ListElement: cannot contain nested elements")); + return false; + } + listElementTypeName = node.name(); // cache right name for next time + } + + { + ListInstruction li; + li.type = ListInstruction::Push; + li.dataIdx = -1; + instr << li; + } + + QList props = node.properties(); + for(int jj = 0; jj < props.count(); ++jj) { + const QDeclarativeCustomParserProperty &nodeProp = props.at(jj); + if (nodeProp.name().isEmpty()) { + error(nodeProp, QDeclarative1ListModel::tr("ListElement: cannot contain nested elements")); + return false; + } + if (nodeProp.name() == "id") { + error(nodeProp, QDeclarative1ListModel::tr("ListElement: cannot use reserved \"id\" property")); + return false; + } + + ListInstruction li; + int ref = data.count(); + data.append(nodeProp.name()); + data.append('\0'); + li.type = ListInstruction::Set; + li.dataIdx = ref; + instr << li; + + if(!compileProperty(nodeProp, instr, data)) + return false; + + li.type = ListInstruction::Pop; + li.dataIdx = -1; + instr << li; + } + + { + ListInstruction li; + li.type = ListInstruction::Pop; + li.dataIdx = -1; + instr << li; + } + + } else { + + QDeclarativeParser::Variant variant = + qvariant_cast(value); + + int ref = data.count(); + + QByteArray d; + d += char(variant.type()); // type tag + if (variant.isString()) { + d += variant.asString().toUtf8(); + } else if (variant.isNumber()) { + d += QByteArray::number(variant.asNumber(),'g',20); + } else if (variant.isBoolean()) { + d += char(variant.asBoolean()); + } else if (variant.isScript()) { + if (definesEmptyList(variant.asScript())) { + d[0] = char(QDeclarativeParser::Variant::Invalid); // marks empty list + } else { + QByteArray script = variant.asScript().toUtf8(); + int v = evaluateEnum(script); + if (v<0) { + if (script.startsWith("QT_TR_NOOP(\"") && script.endsWith("\")")) { + d[0] = char(QDeclarativeParser::Variant::String); + d += script.mid(12,script.length()-14); + } else { + error(prop, QDeclarative1ListModel::tr("ListElement: cannot use script for property value")); + return false; + } + } else { + d[0] = char(QDeclarativeParser::Variant::Number); + d += QByteArray::number(v); + } + } + } + d.append('\0'); + data.append(d); + + ListInstruction li; + li.type = ListInstruction::Value; + li.dataIdx = ref; + instr << li; + } + } + + return true; +} + +QByteArray QDeclarative1ListModelParser::compile(const QList &customProps) +{ + QList instr; + QByteArray data; + listElementTypeName = QByteArray(); // unknown + + for(int ii = 0; ii < customProps.count(); ++ii) { + const QDeclarativeCustomParserProperty &prop = customProps.at(ii); + if(!prop.name().isEmpty()) { // isn't default property + error(prop, QDeclarative1ListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name()))); + return QByteArray(); + } + + if(!compileProperty(prop, instr, data)) { + return QByteArray(); + } + } + + int size = sizeof(ListModelData) + + instr.count() * sizeof(ListInstruction) + + data.count(); + + QByteArray rv; + rv.resize(size); + + ListModelData *lmd = (ListModelData *)rv.data(); + lmd->dataOffset = sizeof(ListModelData) + + instr.count() * sizeof(ListInstruction); + lmd->instrCount = instr.count(); + for (int ii = 0; ii < instr.count(); ++ii) + lmd->instructions()[ii] = instr.at(ii); + ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count()); + + return rv; +} + +void QDeclarative1ListModelParser::setCustomData(QObject *obj, const QByteArray &d) +{ + QDeclarative1ListModel *rv = static_cast(obj); + + ModelNode *root = new ModelNode(rv->m_nested); + rv->m_nested->_root = root; + QStack nodes; + nodes << root; + + bool processingSet = false; + + const ListModelData *lmd = (const ListModelData *)d.constData(); + const char *data = ((const char *)lmd) + lmd->dataOffset; + + for (int ii = 0; ii < lmd->instrCount; ++ii) { + const ListInstruction &instr = lmd->instructions()[ii]; + + switch(instr.type) { + case ListInstruction::Push: + { + ModelNode *n = nodes.top(); + ModelNode *n2 = new ModelNode(rv->m_nested); + n->values << QVariant::fromValue(n2); + nodes.push(n2); + if (processingSet) + n->isArray = true; + } + break; + + case ListInstruction::Pop: + nodes.pop(); + break; + + case ListInstruction::Value: + { + ModelNode *n = nodes.top(); + switch (QDeclarativeParser::Variant::Type(data[instr.dataIdx])) { + case QDeclarativeParser::Variant::Invalid: + n->isArray = true; + break; + case QDeclarativeParser::Variant::Boolean: + n->values.append(bool(data[1 + instr.dataIdx])); + break; + case QDeclarativeParser::Variant::Number: + n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble()); + break; + case QDeclarativeParser::Variant::String: + n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx)); + break; + default: + Q_ASSERT("Format error in ListInstruction"); + } + + processingSet = false; + } + break; + + case ListInstruction::Set: + { + ModelNode *n = nodes.top(); + ModelNode *n2 = new ModelNode(rv->m_nested); + n->properties.insert(QString::fromUtf8(data + instr.dataIdx), n2); + nodes.push(n2); + processingSet = true; + } + break; + } + } + + ModelNode *rootNode = rv->m_nested->_root; + for (int i=0; ivalues.count(); ++i) { + ModelNode *node = qvariant_cast(rootNode->values[i]); + node->listIndex = i; + node->updateListIndexes(); + } +} + +bool QDeclarative1ListModelParser::definesEmptyList(const QString &s) +{ + if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) { + for (int i=1; i= 0 && index < m_values.count()); + if (m_values[index].contains(role)) + return m_values[index][role]; + return QVariant(); +} + +QList FlatListModel_1::roles() const +{ + return m_roles.keys(); +} + +QString FlatListModel_1::toString(int role) const +{ + if (m_roles.contains(role)) + return m_roles[role]; + return QString(); +} + +int FlatListModel_1::count() const +{ + return m_values.count(); +} + +void FlatListModel_1::clear() +{ + m_values.clear(); + + qDeleteAll(m_nodeData); + m_nodeData.clear(); +} + +void FlatListModel_1::remove(int index) +{ + m_values.removeAt(index); + removedNode(index); +} + +bool FlatListModel_1::insert(int index, const QScriptValue &value) +{ + Q_ASSERT(index >= 0 && index <= m_values.count()); + + QHash row; + if (!addValue(value, &row, 0)) + return false; + + m_values.insert(index, row); + insertedNode(index); + + return true; +} + +QScriptValue FlatListModel_1::get(int index) const +{ + QScriptEngine *scriptEngine = m_scriptEngine ? m_scriptEngine : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(m_listModel)); + + if (!scriptEngine) + return 0; + + if (index < 0 || index >= m_values.count()) + return scriptEngine->undefinedValue(); + + FlatListModel_1 *that = const_cast(this); + if (!m_scriptClass) + that->m_scriptClass = new FlatListScriptClass_1(that, scriptEngine); + + FlatNodeData_1 *data = m_nodeData.value(index); + if (!data) { + data = new FlatNodeData_1(index); + that->m_nodeData.replace(index, data); + } + + return QScriptDeclarativeClass::newObject(scriptEngine, m_scriptClass, new FlatNodeObjectData(data)); +} + +void FlatListModel_1::set(int index, const QScriptValue &value, QList *roles) +{ + Q_ASSERT(index >= 0 && index < m_values.count()); + + QHash row = m_values[index]; + if (addValue(value, &row, roles)) + m_values[index] = row; +} + +void FlatListModel_1::setProperty(int index, const QString& property, const QVariant& value, QList *roles) +{ + Q_ASSERT(index >= 0 && index < m_values.count()); + + QHash::Iterator iter = m_strings.find(property); + int role; + if (iter == m_strings.end()) { + role = m_roles.count(); + m_roles.insert(role, property); + m_strings.insert(property, role); + } else { + role = iter.value(); + } + + if (m_values[index][role] != value) { + roles->append(role); + m_values[index][role] = value; + } +} + +void FlatListModel_1::move(int from, int to, int n) +{ + qdeclarativelistmodel_move > >(from, to, n, &m_values); + moveNodes(from, to, n); +} + +bool FlatListModel_1::addValue(const QScriptValue &value, QHash *row, QList *roles) +{ + QScriptValueIterator it(value); + while (it.hasNext()) { + it.next(); + QScriptValue value = it.value(); + if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) { + qmlInfo(m_listModel) << "Cannot add list-type data when modifying or after modification from a worker script"; + return false; + } + + QString name = it.name(); + QVariant v = it.value().toVariant(); + + QHash::Iterator iter = m_strings.find(name); + if (iter == m_strings.end()) { + int role = m_roles.count(); + m_roles.insert(role, name); + iter = m_strings.insert(name, role); + if (roles) + roles->append(role); + } else { + int role = iter.value(); + if (roles && row->contains(role) && row->value(role) != v) + roles->append(role); + } + row->insert(*iter, v); + } + return true; +} + +void FlatListModel_1::insertedNode(int index) +{ + if (index >= 0 && index <= m_values.count()) { + m_nodeData.insert(index, 0); + + for (int i=index + 1; iindex = i; + } + } +} + +void FlatListModel_1::removedNode(int index) +{ + if (index >= 0 && index < m_nodeData.count()) { + delete m_nodeData.takeAt(index); + + for (int i=index; iindex = i; + } + } +} + +void FlatListModel_1::moveNodes(int from, int to, int n) +{ + if (!m_listModel->canMove(from, to, n)) + return; + + qdeclarativelistmodel_move >(from, to, n, &m_nodeData); + + for (int i=from; iindex = i; + } +} + + + +FlatNodeData_1::~FlatNodeData_1() +{ + for (QSet::Iterator iter = objects.begin(); iter != objects.end(); ++iter) { + FlatNodeObjectData *data = *iter; + data->nodeData = 0; + } +} + +void FlatNodeData_1::addData(FlatNodeObjectData *data) +{ + objects.insert(data); +} + +void FlatNodeData_1::removeData(FlatNodeObjectData *data) +{ + objects.remove(data); +} + + +FlatListScriptClass_1::FlatListScriptClass_1(FlatListModel_1 *model, QScriptEngine *seng) + : QScriptDeclarativeClass(seng), + m_model(model) +{ +} + +QScriptDeclarativeClass::Value FlatListScriptClass_1::property(Object *obj, const Identifier &name) +{ + FlatNodeObjectData *objData = static_cast(obj); + if (!objData->nodeData) // item at this index has been deleted + return QScriptDeclarativeClass::Value(engine(), engine()->undefinedValue()); + + int index = objData->nodeData->index; + QString propName = toString(name); + int role = m_model->m_strings.value(propName, -1); + + if (role >= 0 && index >=0 ) { + const QHash &row = m_model->m_values[index]; + QScriptValue sv = engine()->toScriptValue(row[role]); + return QScriptDeclarativeClass::Value(engine(), sv); + } + + return QScriptDeclarativeClass::Value(engine(), engine()->undefinedValue()); +} + +void FlatListScriptClass_1::setProperty(Object *obj, const Identifier &name, const QScriptValue &value) +{ + if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) { + qmlInfo(m_model->m_listModel) << "Cannot add list-type data when modifying or after modification from a worker script"; + return; + } + + FlatNodeObjectData *objData = static_cast(obj); + if (!objData->nodeData) // item at this index has been deleted + return; + + int index = objData->nodeData->index; + QString propName = toString(name); + + int role = m_model->m_strings.value(propName, -1); + if (role >= 0 && index >= 0) { + QHash &row = m_model->m_values[index]; + row[role] = value.toVariant(); + + QList roles; + roles << role; + if (m_model->m_parentAgent) { + // This is the list in the worker thread, so tell the agent to + // emit itemsChanged() later + m_model->m_parentAgent->changedData(index, 1, roles); + } else { + // This is the list in the main thread, so emit itemsChanged() + emit m_model->m_listModel->itemsChanged(index, 1, roles); + } + } +} + +QScriptClass::QueryFlags FlatListScriptClass_1::queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags) +{ + return (QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess); +} + +bool FlatListScriptClass_1::compare(Object *obj1, Object *obj2) +{ + FlatNodeObjectData *data1 = static_cast(obj1); + FlatNodeObjectData *data2 = static_cast(obj2); + + if (!data1->nodeData || !data2->nodeData) + return false; + + return data1->nodeData->index == data2->nodeData->index; +} + + + +NestedListModel_1::NestedListModel_1(QDeclarative1ListModel *base) + : _root(0), m_ownsRoot(false), m_listModel(base), _rolesOk(false) +{ +} + +NestedListModel_1::~NestedListModel_1() +{ + if (m_ownsRoot) + delete _root; +} + +QVariant NestedListModel_1::valueForNode(ModelNode *node, bool *hasNested) const +{ + QObject *rv = 0; + if (hasNested) + *hasNested = false; + + if (node->isArray) { + // List + rv = node->model(this); + if (hasNested) + *hasNested = true; + } else { + if (!node->properties.isEmpty()) { + // Object + rv = node->object(this); + } else if (node->values.count() == 0) { + // Invalid + return QVariant(); + } else if (node->values.count() == 1) { + // Value + QVariant &var = node->values[0]; + ModelNode *valueNode = qvariant_cast(var); + if (valueNode) { + if (!valueNode->properties.isEmpty()) + rv = valueNode->object(this); + else + rv = valueNode->model(this); + } else { + return var; + } + } + } + + if (rv) { + return QVariant::fromValue(rv); + } else { + return QVariant(); + } +} + +QHash NestedListModel_1::data(int index, const QList &roles, bool *hasNested) const +{ + Q_ASSERT(_root && index >= 0 && index < _root->values.count()); + checkRoles(); + QHash rv; + + ModelNode *node = qvariant_cast(_root->values.at(index)); + if (!node) + return rv; + + for (int ii = 0; ii < roles.count(); ++ii) { + const QString &roleString = roleStrings.at(roles.at(ii)); + + QHash::ConstIterator iter = node->properties.find(roleString); + if (iter != node->properties.end()) { + ModelNode *row = *iter; + rv.insert(roles.at(ii), valueForNode(row, hasNested)); + } + } + + return rv; +} + +QVariant NestedListModel_1::data(int index, int role) const +{ + Q_ASSERT(_root && index >= 0 && index < _root->values.count()); + checkRoles(); + QVariant rv; + if (roleStrings.count() < role) + return rv; + + ModelNode *node = qvariant_cast(_root->values.at(index)); + if (!node) + return rv; + + const QString &roleString = roleStrings.at(role); + + QHash::ConstIterator iter = node->properties.find(roleString); + if (iter != node->properties.end()) { + ModelNode *row = *iter; + rv = valueForNode(row); + } + + return rv; +} + +int NestedListModel_1::count() const +{ + if (!_root) return 0; + return _root->values.count(); +} + +void NestedListModel_1::clear() +{ + if (_root) + _root->clear(); +} + +void NestedListModel_1::remove(int index) +{ + if (!_root) + return; + ModelNode *node = qvariant_cast(_root->values.at(index)); + _root->values.removeAt(index); + if (node) + delete node; +} + +bool NestedListModel_1::insert(int index, const QScriptValue& valuemap) +{ + if (!_root) { + _root = new ModelNode(this); + m_ownsRoot = true; + } + + ModelNode *mn = new ModelNode(this); + mn->listIndex = index; + mn->setObjectValue(valuemap); + _root->values.insert(index,QVariant::fromValue(mn)); + return true; +} + +void NestedListModel_1::move(int from, int to, int n) +{ + if (!_root) + return; + qdeclarativelistmodel_move(from, to, n, &_root->values); +} + +QScriptValue NestedListModel_1::get(int index) const +{ + QDeclarativeEngine *eng = qmlEngine(m_listModel); + if (!eng) + return 0; + + if (index < 0 || index >= count()) { + QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(eng); + if (seng) + return seng->undefinedValue(); + return 0; + } + + ModelNode *node = qvariant_cast(_root->values.at(index)); + if (!node) + return 0; + + return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng); +} + +void NestedListModel_1::set(int index, const QScriptValue& valuemap, QList *roles) +{ + Q_ASSERT(index >=0 && index < count()); + + ModelNode *node = qvariant_cast(_root->values.at(index)); + bool emitItemsChanged = node->setObjectValue(valuemap); + if (!emitItemsChanged) + return; + + QScriptValueIterator it(valuemap); + while (it.hasNext()) { + it.next(); + int r = roleStrings.indexOf(it.name()); + if (r < 0) { + r = roleStrings.count(); + roleStrings << it.name(); + } + roles->append(r); + } +} + +void NestedListModel_1::setProperty(int index, const QString& property, const QVariant& value, QList *roles) +{ + Q_ASSERT(index >=0 && index < count()); + + ModelNode *node = qvariant_cast(_root->values.at(index)); + bool emitItemsChanged = node->setProperty(property, value); + if (!emitItemsChanged) + return; + + int r = roleStrings.indexOf(property); + if (r < 0) { + r = roleStrings.count(); + roleStrings << property; + } + roles->append(r); +} + +void NestedListModel_1::checkRoles() const +{ + if (_rolesOk || !_root) + return; + + for (int i = 0; i<_root->values.count(); ++i) { + ModelNode *node = qvariant_cast(_root->values.at(i)); + if (node) { + foreach (const QString &role, node->properties.keys()) { + if (!roleStrings.contains(role)) + roleStrings.append(role); + } + } + } + + _rolesOk = true; +} + +QList NestedListModel_1::roles() const +{ + checkRoles(); + QList rv; + for (int ii = 0; ii < roleStrings.count(); ++ii) + rv << ii; + return rv; +} + +QString NestedListModel_1::toString(int role) const +{ + checkRoles(); + if (role < roleStrings.count()) + return roleStrings.at(role); + else + return QString(); +} + + +ModelNode::ModelNode(NestedListModel_1 *model) +: modelCache(0), objectCache(0), isArray(false), m_model(model), listIndex(-1) +{ +} + +ModelNode::~ModelNode() +{ + clear(); + if (modelCache) { modelCache->m_nested->_root = 0/* ==this */; delete modelCache; modelCache = 0; } + if (objectCache) { delete objectCache; objectCache = 0; } +} + +void ModelNode::clear() +{ + ModelNode *node; + for (int ii = 0; ii < values.count(); ++ii) { + node = qvariant_cast(values.at(ii)); + if (node) { delete node; node = 0; } + } + values.clear(); + + qDeleteAll(properties.values()); + properties.clear(); +} + +bool ModelNode::setObjectValue(const QScriptValue& valuemap, bool writeToCache) +{ + bool emitItemsChanged = false; + + QScriptValueIterator it(valuemap); + while (it.hasNext()) { + it.next(); + ModelNode *prev = properties.value(it.name()); + ModelNode *value = new ModelNode(m_model); + QScriptValue v = it.value(); + + if (v.isArray()) { + value->isArray = true; + value->setListValue(v); + if (writeToCache && objectCache) + objectCache->setValue(it.name().toUtf8(), QVariant::fromValue(value->model(m_model))); + emitItemsChanged = true; // for now, too inefficient to check whether list and sublists have changed + } else { + value->values << v.toVariant(); + if (writeToCache && objectCache) + objectCache->setValue(it.name().toUtf8(), value->values.last()); + if (!emitItemsChanged && prev && prev->values.count() == 1 + && prev->values[0] != value->values.last()) { + emitItemsChanged = true; + } + } + if (properties.contains(it.name())) + delete properties[it.name()]; + properties.insert(it.name(), value); + } + return emitItemsChanged; +} + +void ModelNode::setListValue(const QScriptValue& valuelist) { + values.clear(); + int size = valuelist.property(QLatin1String("length")).toInt32(); + for (int i=0; iisArray = true; + value->setListValue(v); + } else if (v.isObject()) { + value->listIndex = i; + value->setObjectValue(v); + } else { + value->listIndex = i; + value->values << v.toVariant(); + } + values.append(QVariant::fromValue(value)); + } +} + +bool ModelNode::setProperty(const QString& prop, const QVariant& val) { + QHash::const_iterator it = properties.find(prop); + bool emitItemsChanged = false; + if (it != properties.end()) { + if (val != (*it)->values[0]) + emitItemsChanged = true; + (*it)->values[0] = val; + } else { + ModelNode *n = new ModelNode(m_model); + n->values << val; + properties.insert(prop,n); + } + if (objectCache) + objectCache->setValue(prop.toUtf8(), val); + return emitItemsChanged; +} + +void ModelNode::updateListIndexes() +{ + for (QHash::ConstIterator iter = properties.begin(); iter != properties.end(); ++iter) { + ModelNode *node = iter.value(); + if (node->isArray) { + for (int i=0; ivalues.count(); ++i) { + ModelNode *subNode = qvariant_cast(node->values.at(i)); + if (subNode) + subNode->listIndex = i; + } + } + node->updateListIndexes(); + } +} + +/* + Need to call this to emit itemsChanged() for modifications outside of set() + and setProperty(), i.e. if an item returned from get() is modified +*/ +void ModelNode::changedProperty(const QString &name) const +{ + if (listIndex < 0) + return; + + m_model->checkRoles(); + QList roles; + int role = m_model->roleStrings.indexOf(name); + if (role < 0) + roles = m_model->roles(); + else + roles << role; + emit m_model->m_listModel->itemsChanged(listIndex, 1, roles); +} + +void ModelNode::dump(ModelNode *node, int ind) +{ + QByteArray indentBa(ind * 4, ' '); + const char *indent = indentBa.constData(); + + for (int ii = 0; ii < node->values.count(); ++ii) { + ModelNode *subNode = qvariant_cast(node->values.at(ii)); + if (subNode) { + qWarning().nospace() << indent << "Sub-node " << ii; + dump(subNode, ind + 1); + } else { + qWarning().nospace() << indent << "Sub-node " << ii << ": " << node->values.at(ii).toString(); + } + } + + for (QHash::ConstIterator iter = node->properties.begin(); iter != node->properties.end(); ++iter) { + qWarning().nospace() << indent << "Property " << iter.key() << ':'; + dump(iter.value(), ind + 1); + } +} + +ModelObject_1::ModelObject_1(ModelNode *node, NestedListModel_1 *model, QScriptEngine *seng) + : m_model(model), + m_node(node), + m_meta(new ModelNodeMetaObject_1(seng, this)) +{ +} + +void ModelObject_1::setValue(const QByteArray &name, const QVariant &val) +{ + m_meta->setValue(name, val); + //setProperty(name.constData(), val); +} + +void ModelObject_1::setNodeUpdatesEnabled(bool enable) +{ + m_meta->m_enabled = enable; +} + + +ModelNodeMetaObject_1::ModelNodeMetaObject_1(QScriptEngine *seng, ModelObject_1 *object) + : QDeclarative1OpenMetaObject(object), + m_enabled(false), + m_seng(seng), + m_obj(object) +{ +} + +void ModelNodeMetaObject_1::propertyWritten(int index) +{ + if (!m_enabled) + return; + + QString propName = QString::fromUtf8(name(index)); + QVariant value = operator[](index); + + QScriptValue sv = m_seng->newObject(); + sv.setProperty(propName, m_seng->newVariant(value)); + bool changed = m_obj->m_node->setObjectValue(sv, false); + if (changed) + m_obj->m_node->changedProperty(propName); +} + + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativelistmodel_p.h b/src/qtquick1/util/qdeclarativelistmodel_p.h new file mode 100644 index 0000000000..21398f7213 --- /dev/null +++ b/src/qtquick1/util/qdeclarativelistmodel_p.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVELISTMODEL_H +#define QDECLARATIVELISTMODEL_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class FlatListModel_1; +class NestedListModel_1; +class QDeclarative1ListModelWorkerAgent; +struct ModelNode; +class FlatListScriptClass_1; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1ListModel : public QListModelInterface +{ + Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) + +public: + QDeclarative1ListModel(QObject *parent=0); + ~QDeclarative1ListModel(); + + virtual QList roles() const; + virtual QString toString(int role) const; + virtual int count() const; + virtual QVariant data(int index, int role) const; + + Q_INVOKABLE void clear(); + Q_INVOKABLE void remove(int index); + Q_INVOKABLE void append(const QScriptValue&); + Q_INVOKABLE void insert(int index, const QScriptValue&); + Q_INVOKABLE QScriptValue get(int index) const; + Q_INVOKABLE void set(int index, const QScriptValue&); + Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value); + Q_INVOKABLE void move(int from, int to, int count); + Q_INVOKABLE void sync(); + + QDeclarative1ListModelWorkerAgent *agent(); + +Q_SIGNALS: + void countChanged(); + +private: + friend class QDeclarative1ListModelParser; + friend class QDeclarative1ListModelWorkerAgent; + friend class FlatListModel_1; + friend class FlatListScriptClass_1; + friend struct ModelNode; + + // Constructs a flat list model for a worker agent + QDeclarative1ListModel(const QDeclarative1ListModel *orig, QDeclarative1ListModelWorkerAgent *parent); + + void set(int index, const QScriptValue&, QList *roles); + void setProperty(int index, const QString& property, const QVariant& value, QList *roles); + + bool flatten(); + bool inWorkerThread() const; + + inline bool canMove(int from, int to, int n) const { return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0); } + + QDeclarative1ListModelWorkerAgent *m_agent; + NestedListModel_1 *m_nested; + FlatListModel_1 *m_flat; +}; + +// ### FIXME +class QDeclarative1ListElement : public QObject +{ +Q_OBJECT +}; + +class QDeclarative1ListModelParser : public QDeclarativeCustomParser +{ +public: + QByteArray compile(const QList &); + void setCustomData(QObject *, const QByteArray &); + +private: + struct ListInstruction + { + enum { Push, Pop, Value, Set } type; + int dataIdx; + }; + struct ListModelData + { + int dataOffset; + int instrCount; + ListInstruction *instructions() const; + }; + bool compileProperty(const QDeclarativeCustomParserProperty &prop, QList &instr, QByteArray &data); + + bool definesEmptyList(const QString &); + + QByteArray listElementTypeName; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1ListModel) +QML_DECLARE_TYPE(QDeclarative1ListElement) + +QT_END_HEADER + +#endif // QDECLARATIVELISTMODEL_H diff --git a/src/qtquick1/util/qdeclarativelistmodel_p_p.h b/src/qtquick1/util/qdeclarativelistmodel_p_p.h new file mode 100644 index 0000000000..e34f6d850d --- /dev/null +++ b/src/qtquick1/util/qdeclarativelistmodel_p_p.h @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVELISTMODEL_P_P_H +#define QDECLARATIVELISTMODEL_P_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include "QtQuick1/private/qdeclarativelistmodel_p.h" +#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QScriptEngine; + +QT_MODULE(Declarative) + +class QDeclarative1OpenMetaObject; +class QDeclarative1ListModelWorkerAgent; +struct ModelNode; +class FlatListScriptClass_1; +class FlatNodeData_1; + +class FlatListModel_1 +{ +public: + FlatListModel_1(QDeclarative1ListModel *base); + ~FlatListModel_1(); + + QVariant data(int index, int role) const; + + QList roles() const; + QString toString(int role) const; + + int count() const; + void clear(); + void remove(int index); + bool insert(int index, const QScriptValue&); + QScriptValue get(int index) const; + void set(int index, const QScriptValue&, QList *roles); + void setProperty(int index, const QString& property, const QVariant& value, QList *roles); + void move(int from, int to, int count); + +private: + friend class QDeclarative1ListModelWorkerAgent; + friend class QDeclarative1ListModel; + friend class FlatListScriptClass_1; + friend class FlatNodeData_1; + + bool addValue(const QScriptValue &value, QHash *row, QList *roles); + void insertedNode(int index); + void removedNode(int index); + void moveNodes(int from, int to, int n); + + QScriptEngine *m_scriptEngine; + QHash m_roles; + QHash m_strings; + QList > m_values; + QDeclarative1ListModel *m_listModel; + + FlatListScriptClass_1 *m_scriptClass; + QList m_nodeData; + QDeclarative1ListModelWorkerAgent *m_parentAgent; +}; + + +/* + Created when get() is called on a FlatListModel_1. This allows changes to the + object returned by get() to be tracked, and passed onto the model. +*/ +class FlatListScriptClass_1 : public QScriptDeclarativeClass +{ +public: + FlatListScriptClass_1(FlatListModel_1 *model, QScriptEngine *seng); + + Value property(Object *, const Identifier &); + void setProperty(Object *, const Identifier &name, const QScriptValue &); + QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); + bool compare(Object *, Object *); + +private: + FlatListModel_1 *m_model; +}; + +/* + FlatNodeData_1 and FlatNodeObjectData allow objects returned by get() to still + point to the correct list index if move(), insert() or remove() are called. +*/ +struct FlatNodeObjectData; +class FlatNodeData_1 +{ +public: + FlatNodeData_1(int i) + : index(i) {} + + ~FlatNodeData_1(); + + void addData(FlatNodeObjectData *data); + void removeData(FlatNodeObjectData *data); + + int index; + +private: + QSet objects; +}; + +struct FlatNodeObjectData : public QScriptDeclarativeClass::Object +{ + FlatNodeObjectData(FlatNodeData_1 *data) : nodeData(data) { + nodeData->addData(this); + } + + ~FlatNodeObjectData() { + if (nodeData) + nodeData->removeData(this); + } + + FlatNodeData_1 *nodeData; +}; + + + +class NestedListModel_1 +{ +public: + NestedListModel_1(QDeclarative1ListModel *base); + ~NestedListModel_1(); + + QHash data(int index, const QList &roles, bool *hasNested = 0) const; + QVariant data(int index, int role) const; + + QList roles() const; + QString toString(int role) const; + + int count() const; + void clear(); + void remove(int index); + bool insert(int index, const QScriptValue&); + QScriptValue get(int index) const; + void set(int index, const QScriptValue&, QList *roles); + void setProperty(int index, const QString& property, const QVariant& value, QList *roles); + void move(int from, int to, int count); + + QVariant valueForNode(ModelNode *, bool *hasNested = 0) const; + void checkRoles() const; + + ModelNode *_root; + bool m_ownsRoot; + QDeclarative1ListModel *m_listModel; + +private: + friend struct ModelNode; + mutable QStringList roleStrings; + mutable bool _rolesOk; +}; + + +class ModelNodeMetaObject_1; +class ModelObject_1 : public QObject +{ + Q_OBJECT +public: + ModelObject_1(ModelNode *node, NestedListModel_1 *model, QScriptEngine *seng); + void setValue(const QByteArray &name, const QVariant &val); + void setNodeUpdatesEnabled(bool enable); + + NestedListModel_1 *m_model; + ModelNode *m_node; + +private: + ModelNodeMetaObject_1 *m_meta; +}; + +class ModelNodeMetaObject_1 : public QDeclarative1OpenMetaObject +{ +public: + ModelNodeMetaObject_1(QScriptEngine *seng, ModelObject_1 *object); + + bool m_enabled; + +protected: + void propertyWritten(int index); + +private: + QScriptEngine *m_seng; + ModelObject_1 *m_obj; +}; + + +/* + A ModelNode is created for each item in a NestedListModel_1. +*/ +struct ModelNode +{ + ModelNode(NestedListModel_1 *model); + ~ModelNode(); + + QList values; + QHash properties; + + void clear(); + + QDeclarative1ListModel *model(const NestedListModel_1 *model); + ModelObject_1 *object(const NestedListModel_1 *model); + + bool setObjectValue(const QScriptValue& valuemap, bool writeToCache = true); + void setListValue(const QScriptValue& valuelist); + bool setProperty(const QString& prop, const QVariant& val); + void changedProperty(const QString &name) const; + void updateListIndexes(); + static void dump(ModelNode *node, int ind); + + QDeclarative1ListModel *modelCache; + ModelObject_1 *objectCache; + bool isArray; + + NestedListModel_1 *m_model; + int listIndex; // only used for top-level nodes within a list +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(ModelNode *) + +QT_END_HEADER + +#endif // QDECLARATIVELISTMODEL_P_P_H + diff --git a/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp b/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp new file mode 100644 index 0000000000..903f700ee3 --- /dev/null +++ b/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp @@ -0,0 +1,282 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativelistmodelworkeragent_p.h" +#include "QtQuick1/private/qdeclarativelistmodel_p_p.h" +#include +#include +#include + +#include +#include +#include + + +QT_BEGIN_NAMESPACE + + + + +void QDeclarative1ListModelWorkerAgent::Data::clearChange() +{ + changes.clear(); +} + +void QDeclarative1ListModelWorkerAgent::Data::insertChange(int index, int count) +{ + Change c = { Change::Inserted, index, count, 0, QList() }; + changes << c; +} + +void QDeclarative1ListModelWorkerAgent::Data::removeChange(int index, int count) +{ + Change c = { Change::Removed, index, count, 0, QList() }; + changes << c; +} + +void QDeclarative1ListModelWorkerAgent::Data::moveChange(int index, int count, int to) +{ + Change c = { Change::Moved, index, count, to, QList() }; + changes << c; +} + +void QDeclarative1ListModelWorkerAgent::Data::changedChange(int index, int count, const QList &roles) +{ + Change c = { Change::Changed, index, count, 0, roles }; + changes << c; +} + +QDeclarative1ListModelWorkerAgent::QDeclarative1ListModelWorkerAgent(QDeclarative1ListModel *model) + : m_engine(0), + m_ref(1), + m_orig(model), + m_copy(new QDeclarative1ListModel(model, this)) +{ +} + +QDeclarative1ListModelWorkerAgent::~QDeclarative1ListModelWorkerAgent() +{ +} + +void QDeclarative1ListModelWorkerAgent::setScriptEngine(QScriptEngine *eng) +{ + m_engine = eng; + if (m_copy->m_flat) + m_copy->m_flat->m_scriptEngine = eng; +} + +QScriptEngine *QDeclarative1ListModelWorkerAgent::scriptEngine() const +{ + return m_engine; +} + +void QDeclarative1ListModelWorkerAgent::addref() +{ + m_ref.ref(); +} + +void QDeclarative1ListModelWorkerAgent::release() +{ + bool del = !m_ref.deref(); + + if (del) + delete this; +} + +int QDeclarative1ListModelWorkerAgent::count() const +{ + return m_copy->count(); +} + +void QDeclarative1ListModelWorkerAgent::clear() +{ + data.clearChange(); + data.removeChange(0, m_copy->count()); + m_copy->clear(); +} + +void QDeclarative1ListModelWorkerAgent::remove(int index) +{ + int count = m_copy->count(); + m_copy->remove(index); + + if (m_copy->count() != count) + data.removeChange(index, 1); +} + +void QDeclarative1ListModelWorkerAgent::append(const QScriptValue &value) +{ + int count = m_copy->count(); + m_copy->append(value); + + if (m_copy->count() != count) + data.insertChange(m_copy->count() - 1, 1); +} + +void QDeclarative1ListModelWorkerAgent::insert(int index, const QScriptValue &value) +{ + int count = m_copy->count(); + m_copy->insert(index, value); + + if (m_copy->count() != count) + data.insertChange(index, 1); +} + +QScriptValue QDeclarative1ListModelWorkerAgent::get(int index) const +{ + return m_copy->get(index); +} + +void QDeclarative1ListModelWorkerAgent::set(int index, const QScriptValue &value) +{ + QList roles; + m_copy->set(index, value, &roles); + if (!roles.isEmpty()) + data.changedChange(index, 1, roles); +} + +void QDeclarative1ListModelWorkerAgent::setProperty(int index, const QString& property, const QVariant& value) +{ + QList roles; + m_copy->setProperty(index, property, value, &roles); + if (!roles.isEmpty()) + data.changedChange(index, 1, roles); +} + +void QDeclarative1ListModelWorkerAgent::move(int from, int to, int count) +{ + m_copy->move(from, to, count); + data.moveChange(from, to, count); +} + +void QDeclarative1ListModelWorkerAgent::sync() +{ + Sync *s = new Sync; + s->data = data; + s->list = m_copy; + data.changes.clear(); + + mutex.lock(); + QCoreApplication::postEvent(this, s); + syncDone.wait(&mutex); + mutex.unlock(); +} + +void QDeclarative1ListModelWorkerAgent::changedData(int index, int count, const QList &roles) +{ + data.changedChange(index, count, roles); +} + +bool QDeclarative1ListModelWorkerAgent::event(QEvent *e) +{ + if (e->type() == QEvent::User) { + QMutexLocker locker(&mutex); + Sync *s = static_cast(e); + + const QList &changes = s->data.changes; + + if (m_copy) { + bool cc = m_orig->count() != s->list->count(); + + FlatListModel_1 *orig = m_orig->m_flat; + FlatListModel_1 *copy = s->list->m_flat; + if (!orig || !copy) { + syncDone.wakeAll(); + return QObject::event(e); + } + + orig->m_roles = copy->m_roles; + orig->m_strings = copy->m_strings; + orig->m_values = copy->m_values; + + // update the orig->m_nodeData list + for (int ii = 0; ii < changes.count(); ++ii) { + const Change &change = changes.at(ii); + switch (change.type) { + case Change::Inserted: + orig->insertedNode(change.index); + break; + case Change::Removed: + orig->removedNode(change.index); + break; + case Change::Moved: + orig->moveNodes(change.index, change.to, change.count); + break; + case Change::Changed: + break; + } + } + + syncDone.wakeAll(); + locker.unlock(); + + for (int ii = 0; ii < changes.count(); ++ii) { + const Change &change = changes.at(ii); + switch (change.type) { + case Change::Inserted: + emit m_orig->itemsInserted(change.index, change.count); + break; + case Change::Removed: + emit m_orig->itemsRemoved(change.index, change.count); + break; + case Change::Moved: + emit m_orig->itemsMoved(change.index, change.to, change.count); + break; + case Change::Changed: + emit m_orig->itemsChanged(change.index, change.count, change.roles); + break; + } + } + + if (cc) + emit m_orig->countChanged(); + } else { + syncDone.wakeAll(); + } + } + + return QObject::event(e); +} + + + +QT_END_NAMESPACE + diff --git a/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h b/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h new file mode 100644 index 0000000000..f0979c4b31 --- /dev/null +++ b/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVELISTMODELWORKERAGENT_P_H +#define QDECLARATIVELISTMODELWORKERAGENT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1ListModel; +class FlatListScriptClass_1; + +class QDeclarative1ListModelWorkerAgent : public QObject +{ + Q_OBJECT + Q_PROPERTY(int count READ count) + +public: + QDeclarative1ListModelWorkerAgent(QDeclarative1ListModel *); + ~QDeclarative1ListModelWorkerAgent(); + + void setScriptEngine(QScriptEngine *eng); + QScriptEngine *scriptEngine() const; + + void addref(); + void release(); + + int count() const; + + Q_INVOKABLE void clear(); + Q_INVOKABLE void remove(int index); + Q_INVOKABLE void append(const QScriptValue &); + Q_INVOKABLE void insert(int index, const QScriptValue&); + Q_INVOKABLE QScriptValue get(int index) const; + Q_INVOKABLE void set(int index, const QScriptValue &); + Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value); + Q_INVOKABLE void move(int from, int to, int count); + Q_INVOKABLE void sync(); + + struct VariantRef + { + VariantRef() : a(0) {} + VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); } + VariantRef(QDeclarative1ListModelWorkerAgent *_a) : a(_a) { if (a) a->addref(); } + ~VariantRef() { if (a) a->release(); } + + VariantRef &operator=(const VariantRef &o) { + if (o.a) o.a->addref(); + if (a) a->release(); a = o.a; + return *this; + } + + QDeclarative1ListModelWorkerAgent *a; + }; +protected: + virtual bool event(QEvent *); + +private: + friend class QDeclarative1WorkerScriptEnginePrivate; + friend class FlatListScriptClass_1; + QScriptEngine *m_engine; + + struct Change { + enum { Inserted, Removed, Moved, Changed } type; + int index; // Inserted/Removed/Moved/Changed + int count; // Inserted/Removed/Moved/Changed + int to; // Moved + QList roles; + }; + + struct Data { + QList changes; + + void clearChange(); + void insertChange(int index, int count); + void removeChange(int index, int count); + void moveChange(int index, int count, int to); + void changedChange(int index, int count, const QList &roles); + }; + Data data; + + struct Sync : public QEvent { + Sync() : QEvent(QEvent::User) {} + Data data; + QDeclarative1ListModel *list; + }; + + void changedData(int index, int count, const QList &roles); + + QAtomicInt m_ref; + QDeclarative1ListModel *m_orig; + QDeclarative1ListModel *m_copy; + QMutex mutex; + QWaitCondition syncDone; +}; + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QDeclarative1ListModelWorkerAgent::VariantRef) + +QT_END_HEADER + +#endif // QDECLARATIVEWORKERSCRIPT_P_H + diff --git a/src/qtquick1/util/qdeclarativeopenmetaobject.cpp b/src/qtquick1/util/qdeclarativeopenmetaobject.cpp new file mode 100644 index 0000000000..b4864a9a7c --- /dev/null +++ b/src/qtquick1/util/qdeclarativeopenmetaobject.cpp @@ -0,0 +1,384 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" +#include "QtDeclarative/private/qdeclarativepropertycache_p.h" +#include "QtDeclarative/private/qdeclarativedata_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + + + + +class QDeclarative1OpenMetaObjectTypePrivate +{ +public: + QDeclarative1OpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {} + + void init(const QMetaObject *metaObj); + + int propertyOffset; + int signalOffset; + QHash names; + QMetaObjectBuilder mob; + QMetaObject *mem; + QDeclarativePropertyCache *cache; + QDeclarativeEngine *engine; + QSet referers; +}; + +QDeclarative1OpenMetaObjectType::QDeclarative1OpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine) + : d(new QDeclarative1OpenMetaObjectTypePrivate) +{ + d->engine = engine; + d->init(base); +} + +QDeclarative1OpenMetaObjectType::~QDeclarative1OpenMetaObjectType() +{ + if (d->mem) + qFree(d->mem); + if (d->cache) + d->cache->release(); + delete d; +} + + +int QDeclarative1OpenMetaObjectType::propertyOffset() const +{ + return d->propertyOffset; +} + +int QDeclarative1OpenMetaObjectType::signalOffset() const +{ + return d->signalOffset; +} + +int QDeclarative1OpenMetaObjectType::createProperty(const QByteArray &name) +{ + int id = d->mob.propertyCount(); + d->mob.addSignal("__" + QByteArray::number(id) + "()"); + QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id); + propertyCreated(id, build); + qFree(d->mem); + d->mem = d->mob.toMetaObject(); + d->names.insert(name, id); + QSet::iterator it = d->referers.begin(); + while (it != d->referers.end()) { + QDeclarative1OpenMetaObject *omo = *it; + *static_cast(omo) = *d->mem; + if (d->cache) + d->cache->update(d->engine, omo); + ++it; + } + + return d->propertyOffset + id; +} + +void QDeclarative1OpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder) +{ + if (d->referers.count()) + (*d->referers.begin())->propertyCreated(id, builder); +} + +void QDeclarative1OpenMetaObjectTypePrivate::init(const QMetaObject *metaObj) +{ + if (!mem) { + mob.setSuperClass(metaObj); + mob.setClassName(metaObj->className()); + mob.setFlags(QMetaObjectBuilder::DynamicMetaObject); + + mem = mob.toMetaObject(); + + propertyOffset = mem->propertyOffset(); + signalOffset = mem->methodOffset(); + } +} + +//---------------------------------------------------------------------------- + +class QDeclarative1OpenMetaObjectPrivate +{ +public: + QDeclarative1OpenMetaObjectPrivate(QDeclarative1OpenMetaObject *_q) + : q(_q), parent(0), type(0), cacheProperties(false) {} + + inline QVariant &getData(int idx) { + while (data.count() <= idx) + data << QPair(QVariant(), false); + QPair &prop = data[idx]; + if (!prop.second) { + prop.first = q->initialValue(idx); + prop.second = true; + } + return prop.first; + } + + inline void writeData(int idx, const QVariant &value) { + while (data.count() <= idx) + data << QPair(QVariant(), false); + QPair &prop = data[idx]; + prop.first = value; + prop.second = true; + } + + inline bool hasData(int idx) const { + if (idx >= data.count()) + return false; + return data[idx].second; + } + + bool autoCreate; + QDeclarative1OpenMetaObject *q; + QAbstractDynamicMetaObject *parent; + QList > data; + QObject *object; + QDeclarative1OpenMetaObjectType *type; + bool cacheProperties; +}; + +QDeclarative1OpenMetaObject::QDeclarative1OpenMetaObject(QObject *obj, bool automatic) +: d(new QDeclarative1OpenMetaObjectPrivate(this)) +{ + d->autoCreate = automatic; + d->object = obj; + + d->type = new QDeclarative1OpenMetaObjectType(obj->metaObject(), 0); + d->type->d->referers.insert(this); + + QObjectPrivate *op = QObjectPrivate::get(obj); + d->parent = static_cast(op->metaObject); + *static_cast(this) = *d->type->d->mem; + op->metaObject = this; +} + +QDeclarative1OpenMetaObject::QDeclarative1OpenMetaObject(QObject *obj, QDeclarative1OpenMetaObjectType *type, bool automatic) +: d(new QDeclarative1OpenMetaObjectPrivate(this)) +{ + d->autoCreate = automatic; + d->object = obj; + + d->type = type; + d->type->addref(); + d->type->d->referers.insert(this); + + QObjectPrivate *op = QObjectPrivate::get(obj); + d->parent = static_cast(op->metaObject); + *static_cast(this) = *d->type->d->mem; + op->metaObject = this; +} + +QDeclarative1OpenMetaObject::~QDeclarative1OpenMetaObject() +{ + if (d->parent) + delete d->parent; + d->type->d->referers.remove(this); + d->type->release(); + delete d; +} + +QDeclarative1OpenMetaObjectType *QDeclarative1OpenMetaObject::type() const +{ + return d->type; +} + +int QDeclarative1OpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a) +{ + if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) + && id >= d->type->d->propertyOffset) { + int propId = id - d->type->d->propertyOffset; + if (c == QMetaObject::ReadProperty) { + propertyRead(propId); + *reinterpret_cast(a[0]) = d->getData(propId); + } else if (c == QMetaObject::WriteProperty) { + if (propId <= d->data.count() || d->data[propId].first != *reinterpret_cast(a[0])) { + propertyWrite(propId); + d->writeData(propId, *reinterpret_cast(a[0])); + propertyWritten(propId); + activate(d->object, d->type->d->signalOffset + propId, 0); + } + } + return -1; + } else { + if (d->parent) + return d->parent->metaCall(c, id, a); + else + return d->object->qt_metacall(c, id, a); + } +} + +QAbstractDynamicMetaObject *QDeclarative1OpenMetaObject::parent() const +{ + return d->parent; +} + +QVariant QDeclarative1OpenMetaObject::value(int id) const +{ + return d->getData(id); +} + +void QDeclarative1OpenMetaObject::setValue(int id, const QVariant &value) +{ + d->writeData(id, value); + activate(d->object, id + d->type->d->signalOffset, 0); +} + +QVariant QDeclarative1OpenMetaObject::value(const QByteArray &name) const +{ + QHash::ConstIterator iter = d->type->d->names.find(name); + if (iter == d->type->d->names.end()) + return QVariant(); + + return d->getData(*iter); +} + +QVariant &QDeclarative1OpenMetaObject::operator[](const QByteArray &name) +{ + QHash::ConstIterator iter = d->type->d->names.find(name); + Q_ASSERT(iter != d->type->d->names.end()); + + return d->getData(*iter); +} + +QVariant &QDeclarative1OpenMetaObject::operator[](int id) +{ + return d->getData(id); +} + +void QDeclarative1OpenMetaObject::setValue(const QByteArray &name, const QVariant &val) +{ + QHash::ConstIterator iter = d->type->d->names.find(name); + + int id = -1; + if (iter == d->type->d->names.end()) { + id = createProperty(name.constData(), "") - d->type->d->propertyOffset; + } else { + id = *iter; + } + + if (id >= 0) { + QVariant &dataVal = d->getData(id); + if (dataVal == val) + return; + + dataVal = val; + activate(d->object, id + d->type->d->signalOffset, 0); + } +} + +// returns true if this value has been initialized by a call to either value() or setValue() +bool QDeclarative1OpenMetaObject::hasValue(int id) const +{ + return d->hasData(id); +} + +void QDeclarative1OpenMetaObject::setCached(bool c) +{ + if (c == d->cacheProperties || !d->type->d->engine) + return; + + d->cacheProperties = c; + + QDeclarativeData *qmldata = QDeclarativeData::get(d->object, true); + if (d->cacheProperties) { + if (!d->type->d->cache) + d->type->d->cache = new QDeclarativePropertyCache(d->type->d->engine, this); + qmldata->propertyCache = d->type->d->cache; + d->type->d->cache->addref(); + } else { + if (d->type->d->cache) + d->type->d->cache->release(); + qmldata->propertyCache = 0; + } +} + + +int QDeclarative1OpenMetaObject::createProperty(const char *name, const char *) +{ + if (d->autoCreate) + return d->type->createProperty(name); + else + return -1; +} + +void QDeclarative1OpenMetaObject::propertyRead(int) +{ +} + +void QDeclarative1OpenMetaObject::propertyWrite(int) +{ +} + +void QDeclarative1OpenMetaObject::propertyWritten(int) +{ +} + +void QDeclarative1OpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &) +{ +} + +QVariant QDeclarative1OpenMetaObject::initialValue(int) +{ + return QVariant(); +} + +int QDeclarative1OpenMetaObject::count() const +{ + return d->type->d->names.count(); +} + +QByteArray QDeclarative1OpenMetaObject::name(int idx) const +{ + Q_ASSERT(idx >= 0 && idx < d->type->d->names.count()); + + return d->type->d->mob.property(idx).name(); +} + +QObject *QDeclarative1OpenMetaObject::object() const +{ + return d->object; +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeopenmetaobject_p.h b/src/qtquick1/util/qdeclarativeopenmetaobject_p.h new file mode 100644 index 0000000000..3ee6230e71 --- /dev/null +++ b/src/qtquick1/util/qdeclarativeopenmetaobject_p.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEOPENMETAOBJECT_H +#define QDECLARATIVEOPENMETAOBJECT_H + +#include +#include + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QDeclarativeEngine; +class QMetaPropertyBuilder; + +QT_MODULE(Declarative) + +class QDeclarative1OpenMetaObjectTypePrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1OpenMetaObjectType : public QDeclarativeRefCount +{ +public: + QDeclarative1OpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine); + ~QDeclarative1OpenMetaObjectType(); + + int createProperty(const QByteArray &name); + + int propertyOffset() const; + int signalOffset() const; + +protected: + virtual void propertyCreated(int, QMetaPropertyBuilder &); + +private: + QDeclarative1OpenMetaObjectTypePrivate *d; + friend class QDeclarative1OpenMetaObject; + friend class QDeclarative1OpenMetaObjectPrivate; +}; + +class QDeclarative1OpenMetaObjectPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1OpenMetaObject : public QAbstractDynamicMetaObject +{ +public: + QDeclarative1OpenMetaObject(QObject *, bool = true); + QDeclarative1OpenMetaObject(QObject *, QDeclarative1OpenMetaObjectType *, bool = true); + ~QDeclarative1OpenMetaObject(); + + QVariant value(const QByteArray &) const; + void setValue(const QByteArray &, const QVariant &); + QVariant value(int) const; + void setValue(int, const QVariant &); + QVariant &operator[](const QByteArray &); + QVariant &operator[](int); + bool hasValue(int) const; + + int count() const; + QByteArray name(int) const; + + QObject *object() const; + virtual QVariant initialValue(int); + + // Be careful - once setCached(true) is called createProperty() is no + // longer automatically called for new properties. + void setCached(bool); + + QDeclarative1OpenMetaObjectType *type() const; + +protected: + virtual int metaCall(QMetaObject::Call _c, int _id, void **_a); + virtual int createProperty(const char *, const char *); + + virtual void propertyRead(int); + virtual void propertyWrite(int); + virtual void propertyWritten(int); + virtual void propertyCreated(int, QMetaPropertyBuilder &); + + QAbstractDynamicMetaObject *parent() const; + +private: + QDeclarative1OpenMetaObjectPrivate *d; + friend class QDeclarative1OpenMetaObjectType; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDECLARATIVEOPENMETAOBJECT_H diff --git a/src/qtquick1/util/qdeclarativepackage.cpp b/src/qtquick1/util/qdeclarativepackage.cpp new file mode 100644 index 0000000000..989a780f6b --- /dev/null +++ b/src/qtquick1/util/qdeclarativepackage.cpp @@ -0,0 +1,205 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativepackage_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + + + +/*! + \qmlclass Package QDeclarative1Package + \ingroup qml-working-with-data + \brief Package provides a collection of named items. + + The Package class is used in conjunction with + VisualDataModel to enable delegates with a shared context + to be provided to multiple views. + + Any item within a Package may be assigned a name via the + \l{Package::name}{Package.name} attached property. + + The example below creates a Package containing two named items; + \e list and \e grid. The third element in the package (the \l Rectangle) is parented to whichever + delegate it should appear in. This allows an item to move + between views. + + \snippet examples/declarative/modelviews/package/Delegate.qml 0 + + These named items are used as the delegates by the two views who + reference the special \l{VisualDataModel::parts} property to select + a model which provides the chosen delegate. + + \snippet examples/declarative/modelviews/package/view.qml 0 + + \sa {declarative/modelviews/package}{Package example}, {demos/declarative/photoviewer}{Photo Viewer demo}, QtDeclarative +*/ + +/*! + \qmlattachedproperty string Package::name + This attached property holds the name of an item within a Package. +*/ + + +class QDeclarative1PackagePrivate : public QObjectPrivate +{ +public: + QDeclarative1PackagePrivate() {} + + struct DataGuard : public QDeclarativeGuard + { + DataGuard(QObject *obj, QList *l) : list(l) { (QDeclarativeGuard&)*this = obj; } + QList *list; + void objectDestroyed(QObject *) { + // we assume priv will always be destroyed after objectDestroyed calls + list->removeOne(*this); + } + }; + + QList dataList; + static void data_append(QDeclarativeListProperty *prop, QObject *o) { + QList *list = static_cast *>(prop->data); + list->append(DataGuard(o, list)); + } + static void data_clear(QDeclarativeListProperty *prop) { + QList *list = static_cast *>(prop->data); + list->clear(); + } + static QObject *data_at(QDeclarativeListProperty *prop, int index) { + QList *list = static_cast *>(prop->data); + return list->at(index); + } + static int data_count(QDeclarativeListProperty *prop) { + QList *list = static_cast *>(prop->data); + return list->count(); + } +}; + +QHash QDeclarative1PackageAttached::attached; + +QDeclarative1PackageAttached::QDeclarative1PackageAttached(QObject *parent) +: QObject(parent) +{ + attached.insert(parent, this); +} + +QDeclarative1PackageAttached::~QDeclarative1PackageAttached() +{ + attached.remove(parent()); +} + +QString QDeclarative1PackageAttached::name() const +{ + return _name; +} + +void QDeclarative1PackageAttached::setName(const QString &n) +{ + _name = n; +} + +QDeclarative1Package::QDeclarative1Package(QObject *parent) + : QObject(*(new QDeclarative1PackagePrivate), parent) +{ +} + +QDeclarative1Package::~QDeclarative1Package() +{ + Q_D(QDeclarative1Package); + for (int ii = 0; ii < d->dataList.count(); ++ii) { + QObject *obj = d->dataList.at(ii); + obj->setParent(this); + } +} + +QDeclarativeListProperty QDeclarative1Package::data() +{ + Q_D(QDeclarative1Package); + return QDeclarativeListProperty(this, &d->dataList, QDeclarative1PackagePrivate::data_append, + QDeclarative1PackagePrivate::data_count, + QDeclarative1PackagePrivate::data_at, + QDeclarative1PackagePrivate::data_clear); +} + +bool QDeclarative1Package::hasPart(const QString &name) +{ + Q_D(QDeclarative1Package); + for (int ii = 0; ii < d->dataList.count(); ++ii) { + QObject *obj = d->dataList.at(ii); + QDeclarative1PackageAttached *a = QDeclarative1PackageAttached::attached.value(obj); + if (a && a->name() == name) + return true; + } + return false; +} + +QObject *QDeclarative1Package::part(const QString &name) +{ + Q_D(QDeclarative1Package); + if (name.isEmpty() && !d->dataList.isEmpty()) + return d->dataList.at(0); + + for (int ii = 0; ii < d->dataList.count(); ++ii) { + QObject *obj = d->dataList.at(ii); + QDeclarative1PackageAttached *a = QDeclarative1PackageAttached::attached.value(obj); + if (a && a->name() == name) + return obj; + } + + if (name == QLatin1String("default") && !d->dataList.isEmpty()) + return d->dataList.at(0); + + return 0; +} + +QDeclarative1PackageAttached *QDeclarative1Package::qmlAttachedProperties(QObject *o) +{ + return new QDeclarative1PackageAttached(o); +} + + + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativepackage_p.h b/src/qtquick1/util/qdeclarativepackage_p.h new file mode 100644 index 0000000000..33991c9809 --- /dev/null +++ b/src/qtquick1/util/qdeclarativepackage_p.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEPACKAGE_H +#define QDECLARATIVEPACKAGE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1PackagePrivate; +class QDeclarative1PackageAttached; +class Q_AUTOTEST_EXPORT QDeclarative1Package : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1Package) + + Q_CLASSINFO("DefaultProperty", "data") + Q_PROPERTY(QDeclarativeListProperty data READ data SCRIPTABLE false) + +public: + QDeclarative1Package(QObject *parent=0); + virtual ~QDeclarative1Package(); + + QDeclarativeListProperty data(); + + QObject *part(const QString & = QString()); + bool hasPart(const QString &); + + static QDeclarative1PackageAttached *qmlAttachedProperties(QObject *); +}; + +class QDeclarative1PackageAttached : public QObject +{ +Q_OBJECT +Q_PROPERTY(QString name READ name WRITE setName) +public: + QDeclarative1PackageAttached(QObject *parent); + virtual ~QDeclarative1PackageAttached(); + + QString name() const; + void setName(const QString &n); + + static QHash attached; +private: + QString _name; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1Package) +QML_DECLARE_TYPEINFO(QDeclarative1Package, QML_HAS_ATTACHED_PROPERTIES) + +QT_END_HEADER + +#endif // QDECLARATIVEPACKAGE_H diff --git a/src/qtquick1/util/qdeclarativepixmapcache.cpp b/src/qtquick1/util/qdeclarativepixmapcache.cpp new file mode 100644 index 0000000000..0b2e16c2ff --- /dev/null +++ b/src/qtquick1/util/qdeclarativepixmapcache.cpp @@ -0,0 +1,1084 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativepixmapcache_p.h" +#include "QtDeclarative/qdeclarativenetworkaccessmanagerfactory.h" +#include "QtDeclarative/qdeclarativeimageprovider.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define IMAGEREQUEST_MAX_REQUEST_COUNT 8 +#define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16 +#define CACHE_EXPIRE_TIME 30 +#define CACHE_REMOVAL_FRACTION 4 + +QT_BEGIN_NAMESPACE + + + +// The cache limit describes the maximum "junk" in the cache. +// These are the same defaults as QPixmapCache +#if defined(Q_WS_QWS) || defined(Q_WS_WINCE) +static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded +#else +static int cache_limit = 10240 * 1024; // 10 MB cache limit for desktop +#endif + +class QDeclarative1PixmapReader; +class QDeclarative1PixmapData; +class QDeclarative1PixmapReply : public QObject +{ + Q_OBJECT +public: + enum ReadError { NoError, Loading, Decoding }; + + QDeclarative1PixmapReply(QDeclarative1PixmapData *); + ~QDeclarative1PixmapReply(); + + QDeclarative1PixmapData *data; + QDeclarative1PixmapReader *reader; + QSize requestSize; + + bool loading; + int redirectCount; + + class Event : public QEvent { + public: + Event(ReadError, const QString &, const QSize &, const QImage &); + + ReadError error; + QString errorString; + QSize implicitSize; + QImage image; + }; + void postReply(ReadError, const QString &, const QSize &, const QImage &); + + +Q_SIGNALS: + void finished(); + void downloadProgress(qint64, qint64); + +protected: + bool event(QEvent *event); + +private: + Q_DISABLE_COPY(QDeclarative1PixmapReply) + +public: + static int finishedIndex; + static int downloadProgressIndex; +}; + +class QDeclarative1PixmapReaderThreadObject : public QObject { + Q_OBJECT +public: + QDeclarative1PixmapReaderThreadObject(QDeclarative1PixmapReader *); + void processJobs(); + virtual bool event(QEvent *e); +private slots: + void networkRequestDone(); +private: + QDeclarative1PixmapReader *reader; +}; + +class QDeclarative1PixmapData; +class QDeclarative1PixmapReader : public QThread +{ + Q_OBJECT +public: + QDeclarative1PixmapReader(QDeclarativeEngine *eng); + ~QDeclarative1PixmapReader(); + + QDeclarative1PixmapReply *getImage(QDeclarative1PixmapData *); + void cancel(QDeclarative1PixmapReply *rep); + + static QDeclarative1PixmapReader *instance(QDeclarativeEngine *engine); + +protected: + void run(); + +private: + friend class QDeclarative1PixmapReaderThreadObject; + void processJobs(); + void processJob(QDeclarative1PixmapReply *, const QUrl &, const QSize &); + void networkRequestDone(QNetworkReply *); + + QList jobs; + QList cancelled; + QDeclarativeEngine *engine; + QObject *eventLoopQuitHack; + + QMutex mutex; + QDeclarative1PixmapReaderThreadObject *threadObject; + QWaitCondition waitCondition; + + QNetworkAccessManager *networkAccessManager(); + QNetworkAccessManager *accessManager; + + QHash replies; + + static int replyDownloadProgress; + static int replyFinished; + static int downloadProgress; + static int threadNetworkRequestDone; + static QHash readers; + static QMutex readerMutex; +}; + +class QDeclarative1PixmapData +{ +public: + QDeclarative1PixmapData(const QUrl &u, const QSize &s, const QString &e) + : refCount(1), inCache(false), pixmapStatus(QDeclarative1Pixmap::Error), + url(u), errorString(e), requestSize(s), reply(0), prevUnreferenced(0), + prevUnreferencedPtr(0), nextUnreferenced(0) + { + } + + QDeclarative1PixmapData(const QUrl &u, const QSize &r) + : refCount(1), inCache(false), pixmapStatus(QDeclarative1Pixmap::Loading), + url(u), requestSize(r), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0), + nextUnreferenced(0) + { + } + + QDeclarative1PixmapData(const QUrl &u, const QPixmap &p, const QSize &s, const QSize &r) + : refCount(1), inCache(false), privatePixmap(false), pixmapStatus(QDeclarative1Pixmap::Ready), + url(u), pixmap(p), implicitSize(s), requestSize(r), reply(0), prevUnreferenced(0), + prevUnreferencedPtr(0), nextUnreferenced(0) + { + } + + QDeclarative1PixmapData(const QPixmap &p) + : refCount(1), inCache(false), privatePixmap(true), pixmapStatus(QDeclarative1Pixmap::Ready), + pixmap(p), implicitSize(p.size()), requestSize(p.size()), reply(0), prevUnreferenced(0), + prevUnreferencedPtr(0), nextUnreferenced(0) + { + } + + int cost() const; + void addref(); + void release(); + void addToCache(); + void removeFromCache(); + + uint refCount; + + bool inCache:1; + bool privatePixmap:1; + + QDeclarative1Pixmap::Status pixmapStatus; + QUrl url; + QString errorString; + QPixmap pixmap; + QSize implicitSize; + QSize requestSize; + + QDeclarative1PixmapReply *reply; + + QDeclarative1PixmapData *prevUnreferenced; + QDeclarative1PixmapData**prevUnreferencedPtr; + QDeclarative1PixmapData *nextUnreferenced; +}; + +int QDeclarative1PixmapReply::finishedIndex = -1; +int QDeclarative1PixmapReply::downloadProgressIndex = -1; + +// XXX +QHash QDeclarative1PixmapReader::readers; +QMutex QDeclarative1PixmapReader::readerMutex; + +int QDeclarative1PixmapReader::replyDownloadProgress = -1; +int QDeclarative1PixmapReader::replyFinished = -1; +int QDeclarative1PixmapReader::downloadProgress = -1; +int QDeclarative1PixmapReader::threadNetworkRequestDone = -1; + + +void QDeclarative1PixmapReply::postReply(ReadError error, const QString &errorString, + const QSize &implicitSize, const QImage &image) +{ + loading = false; + QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, image)); +} + +QDeclarative1PixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSize, const QImage &i) +: QEvent(QEvent::User), error(e), errorString(s), implicitSize(iSize), image(i) +{ +} + +QNetworkAccessManager *QDeclarative1PixmapReader::networkAccessManager() +{ + if (!accessManager) { + Q_ASSERT(threadObject); + accessManager = QDeclarativeEnginePrivate::get(engine)->createNetworkAccessManager(threadObject); + } + return accessManager; +} + +static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize, + const QSize &requestSize) +{ + QImageReader imgio(dev); + + bool force_scale = false; + if (url.path().endsWith(QLatin1String(".svg"),Qt::CaseInsensitive)) { + imgio.setFormat("svg"); // QSvgPlugin::capabilities bug QTBUG-9053 + force_scale = true; + } + + bool scaled = false; + if (requestSize.width() > 0 || requestSize.height() > 0) { + QSize s = imgio.size(); + if (requestSize.width() && (force_scale || requestSize.width() < s.width())) { + if (requestSize.height() <= 0) + s.setHeight(s.height()*requestSize.width()/s.width()); + s.setWidth(requestSize.width()); scaled = true; + } + if (requestSize.height() && (force_scale || requestSize.height() < s.height())) { + if (requestSize.width() <= 0) + s.setWidth(s.width()*requestSize.height()/s.height()); + s.setHeight(requestSize.height()); scaled = true; + } + if (scaled) { imgio.setScaledSize(s); } + } + + if (impsize) + *impsize = imgio.size(); + + if (imgio.read(image)) { + if (impsize && impsize->width() < 0) + *impsize = image->size(); + return true; + } else { + if (errorString) + *errorString = QDeclarative1Pixmap::tr("Error decoding: %1: %2").arg(url.toString()) + .arg(imgio.errorString()); + return false; + } +} + +QDeclarative1PixmapReader::QDeclarative1PixmapReader(QDeclarativeEngine *eng) +: QThread(eng), engine(eng), threadObject(0), accessManager(0) +{ + eventLoopQuitHack = new QObject; + eventLoopQuitHack->moveToThread(this); + connect(eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection); + start(QThread::IdlePriority); +} + +QDeclarative1PixmapReader::~QDeclarative1PixmapReader() +{ + readerMutex.lock(); + readers.remove(engine); + readerMutex.unlock(); + + eventLoopQuitHack->deleteLater(); + wait(); +} + +void QDeclarative1PixmapReader::networkRequestDone(QNetworkReply *reply) +{ + QDeclarative1PixmapReply *job = replies.take(reply); + + if (job) { + job->redirectCount++; + if (job->redirectCount < IMAGEREQUEST_MAX_REDIRECT_RECURSION) { + QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = reply->url().resolved(redirect.toUrl()); + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + + reply->deleteLater(); + reply = networkAccessManager()->get(req); + + QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress); + QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone); + + replies.insert(reply, job); + return; + } + } + + QImage image; + QDeclarative1PixmapReply::ReadError error = QDeclarative1PixmapReply::NoError; + QString errorString; + QSize readSize; + if (reply->error()) { + error = QDeclarative1PixmapReply::Loading; + errorString = reply->errorString(); + } else { + QByteArray all = reply->readAll(); + QBuffer buff(&all); + buff.open(QIODevice::ReadOnly); + if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize)) { + error = QDeclarative1PixmapReply::Decoding; + } + } + // send completion event to the QDeclarative1PixmapReply + mutex.lock(); + if (!cancelled.contains(job)) job->postReply(error, errorString, readSize, image); + mutex.unlock(); + } + reply->deleteLater(); + + // kick off event loop again incase we have dropped below max request count + threadObject->processJobs(); +} + +QDeclarative1PixmapReaderThreadObject::QDeclarative1PixmapReaderThreadObject(QDeclarative1PixmapReader *i) +: reader(i) +{ +} + +void QDeclarative1PixmapReaderThreadObject::processJobs() +{ + QCoreApplication::postEvent(this, new QEvent(QEvent::User)); +} + +bool QDeclarative1PixmapReaderThreadObject::event(QEvent *e) +{ + if (e->type() == QEvent::User) { + reader->processJobs(); + return true; + } else { + return QObject::event(e); + } +} + +void QDeclarative1PixmapReaderThreadObject::networkRequestDone() +{ + QNetworkReply *reply = static_cast(sender()); + reader->networkRequestDone(reply); +} + +void QDeclarative1PixmapReader::processJobs() +{ + QMutexLocker locker(&mutex); + + while (true) { + if (cancelled.isEmpty() && (jobs.isEmpty() || replies.count() >= IMAGEREQUEST_MAX_REQUEST_COUNT)) + return; // Nothing else to do + + // Clean cancelled jobs + if (cancelled.count()) { + for (int i = 0; i < cancelled.count(); ++i) { + QDeclarative1PixmapReply *job = cancelled.at(i); + QNetworkReply *reply = replies.key(job, 0); + if (reply && reply->isRunning()) { + // cancel any jobs already started + replies.remove(reply); + reply->close(); + } + // deleteLater, since not owned by this thread + job->deleteLater(); + } + cancelled.clear(); + } + + if (!jobs.isEmpty() && replies.count() < IMAGEREQUEST_MAX_REQUEST_COUNT) { + QDeclarative1PixmapReply *runningJob = jobs.takeLast(); + runningJob->loading = true; + + QUrl url = runningJob->data->url; + QSize requestSize = runningJob->data->requestSize; + locker.unlock(); + processJob(runningJob, url, requestSize); + locker.relock(); + } + } +} + +void QDeclarative1PixmapReader::processJob(QDeclarative1PixmapReply *runningJob, const QUrl &url, + const QSize &requestSize) +{ + // fetch + if (url.scheme() == QLatin1String("image")) { + // Use QmlImageProvider + QSize readSize; + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + QImage image = ep->getImageFromProvider(url, &readSize, requestSize); + + QDeclarative1PixmapReply::ReadError errorCode = QDeclarative1PixmapReply::NoError; + QString errorStr; + if (image.isNull()) { + errorCode = QDeclarative1PixmapReply::Loading; + errorStr = QDeclarative1Pixmap::tr("Failed to get image from provider: %1").arg(url.toString()); + } + + mutex.lock(); + if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, image); + mutex.unlock(); + } else { + QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url); + if (!lf.isEmpty()) { + // Image is local - load/decode immediately + QImage image; + QDeclarative1PixmapReply::ReadError errorCode = QDeclarative1PixmapReply::NoError; + QString errorStr; + QFile f(lf); + QSize readSize; + if (f.open(QIODevice::ReadOnly)) { + if (!readImage(url, &f, &image, &errorStr, &readSize, requestSize)) + errorCode = QDeclarative1PixmapReply::Loading; + } else { + errorStr = QDeclarative1Pixmap::tr("Cannot open: %1").arg(url.toString()); + errorCode = QDeclarative1PixmapReply::Loading; + } + mutex.lock(); + if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, image); + mutex.unlock(); + } else { + // Network resource + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + QNetworkReply *reply = networkAccessManager()->get(req); + + QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); + QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone); + + replies.insert(reply, runningJob); + } + } +} + +QDeclarative1PixmapReader *QDeclarative1PixmapReader::instance(QDeclarativeEngine *engine) +{ + readerMutex.lock(); + QDeclarative1PixmapReader *reader = readers.value(engine); + if (!reader) { + reader = new QDeclarative1PixmapReader(engine); + readers.insert(engine, reader); + } + readerMutex.unlock(); + + return reader; +} + +QDeclarative1PixmapReply *QDeclarative1PixmapReader::getImage(QDeclarative1PixmapData *data) +{ + mutex.lock(); + QDeclarative1PixmapReply *reply = new QDeclarative1PixmapReply(data); + reply->reader = this; + jobs.append(reply); + // XXX + if (threadObject) threadObject->processJobs(); + mutex.unlock(); + return reply; +} + +void QDeclarative1PixmapReader::cancel(QDeclarative1PixmapReply *reply) +{ + mutex.lock(); + if (reply->loading) { + cancelled.append(reply); + reply->data = 0; + // XXX + if (threadObject) threadObject->processJobs(); + } else { + jobs.removeAll(reply); + delete reply; + } + mutex.unlock(); +} + +void QDeclarative1PixmapReader::run() +{ + if (replyDownloadProgress == -1) { + const QMetaObject *nr = &QNetworkReply::staticMetaObject; + const QMetaObject *pr = &QDeclarative1PixmapReply::staticMetaObject; + const QMetaObject *ir = &QDeclarative1PixmapReaderThreadObject::staticMetaObject; + replyDownloadProgress = nr->indexOfSignal("downloadProgress(qint64,qint64)"); + replyFinished = nr->indexOfSignal("finished()"); + downloadProgress = pr->indexOfSignal("downloadProgress(qint64,qint64)"); + threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()"); + } + + mutex.lock(); + threadObject = new QDeclarative1PixmapReaderThreadObject(this); + mutex.unlock(); + + processJobs(); + exec(); + + delete threadObject; + threadObject = 0; +} + +class QDeclarative1PixmapKey +{ +public: + const QUrl *url; + const QSize *size; +}; + +inline bool operator==(const QDeclarative1PixmapKey &lhs, const QDeclarative1PixmapKey &rhs) +{ + return *lhs.size == *rhs.size && *lhs.url == *rhs.url; +} + +inline uint qHash(const QDeclarative1PixmapKey &key) +{ + return qHash(*key.url) ^ key.size->width() ^ key.size->height(); +} + +class QDeclarative1PixmapStore : public QObject +{ + Q_OBJECT +public: + QDeclarative1PixmapStore(); + + void unreferencePixmap(QDeclarative1PixmapData *); + void referencePixmap(QDeclarative1PixmapData *); + +protected: + virtual void timerEvent(QTimerEvent *); + +public: + QHash m_cache; + +private: + void shrinkCache(int remove); + + QDeclarative1PixmapData *m_unreferencedPixmaps; + QDeclarative1PixmapData *m_lastUnreferencedPixmap; + + int m_unreferencedCost; + int m_timerId; +}; +Q_GLOBAL_STATIC(QDeclarative1PixmapStore, pixmapStore); + +QDeclarative1PixmapStore::QDeclarative1PixmapStore() +: m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1) +{ +} + +void QDeclarative1PixmapStore::unreferencePixmap(QDeclarative1PixmapData *data) +{ + Q_ASSERT(data->prevUnreferenced == 0); + Q_ASSERT(data->prevUnreferencedPtr == 0); + Q_ASSERT(data->nextUnreferenced == 0); + + data->nextUnreferenced = m_unreferencedPixmaps; + data->prevUnreferencedPtr = &m_unreferencedPixmaps; + + m_unreferencedPixmaps = data; + if (m_unreferencedPixmaps->nextUnreferenced) { + m_unreferencedPixmaps->nextUnreferenced->prevUnreferenced = m_unreferencedPixmaps; + m_unreferencedPixmaps->nextUnreferenced->prevUnreferencedPtr = &m_unreferencedPixmaps->nextUnreferenced; + } + + if (!m_lastUnreferencedPixmap) + m_lastUnreferencedPixmap = data; + + m_unreferencedCost += data->cost(); + + shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit + + if (m_timerId == -1 && m_unreferencedPixmaps) + m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000); +} + +void QDeclarative1PixmapStore::referencePixmap(QDeclarative1PixmapData *data) +{ + Q_ASSERT(data->prevUnreferencedPtr); + + *data->prevUnreferencedPtr = data->nextUnreferenced; + if (data->nextUnreferenced) { + data->nextUnreferenced->prevUnreferencedPtr = data->prevUnreferencedPtr; + data->nextUnreferenced->prevUnreferenced = data->prevUnreferenced; + } + if (m_lastUnreferencedPixmap == data) + m_lastUnreferencedPixmap = data->prevUnreferenced; + + data->nextUnreferenced = 0; + data->prevUnreferencedPtr = 0; + data->prevUnreferenced = 0; + + m_unreferencedCost -= data->cost(); +} + +void QDeclarative1PixmapStore::shrinkCache(int remove) +{ + while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) { + QDeclarative1PixmapData *data = m_lastUnreferencedPixmap; + Q_ASSERT(data->nextUnreferenced == 0); + + *data->prevUnreferencedPtr = 0; + m_lastUnreferencedPixmap = data->prevUnreferenced; + data->prevUnreferencedPtr = 0; + data->prevUnreferenced = 0; + + remove -= data->cost(); + m_unreferencedCost -= data->cost(); + data->removeFromCache(); + delete data; + } +} + +void QDeclarative1PixmapStore::timerEvent(QTimerEvent *) +{ + int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION; + + shrinkCache(removalCost); + + if (m_unreferencedPixmaps == 0) { + killTimer(m_timerId); + m_timerId = -1; + } +} + +QDeclarative1PixmapReply::QDeclarative1PixmapReply(QDeclarative1PixmapData *d) +: data(d), reader(0), requestSize(d->requestSize), loading(false), redirectCount(0) +{ + if (finishedIndex == -1) { + finishedIndex = QDeclarative1PixmapReply::staticMetaObject.indexOfSignal("finished()"); + downloadProgressIndex = QDeclarative1PixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); + } +} + +QDeclarative1PixmapReply::~QDeclarative1PixmapReply() +{ +} + +bool QDeclarative1PixmapReply::event(QEvent *event) +{ + if (event->type() == QEvent::User) { + + if (data) { + Event *de = static_cast(event); + data->pixmapStatus = (de->error == NoError) ? QDeclarative1Pixmap::Ready : QDeclarative1Pixmap::Error; + + if (data->pixmapStatus == QDeclarative1Pixmap::Ready) { + data->pixmap = QPixmap::fromImage(de->image); + data->implicitSize = de->implicitSize; + } else { + data->errorString = de->errorString; + data->removeFromCache(); // We don't continue to cache error'd pixmaps + } + + data->reply = 0; + emit finished(); + } + + delete this; + return true; + } else { + return QObject::event(event); + } +} + +int QDeclarative1PixmapData::cost() const +{ + return (pixmap.width() * pixmap.height() * pixmap.depth()) / 8; +} + +void QDeclarative1PixmapData::addref() +{ + ++refCount; + if (prevUnreferencedPtr) + pixmapStore()->referencePixmap(this); +} + +void QDeclarative1PixmapData::release() +{ + Q_ASSERT(refCount > 0); + --refCount; + + if (refCount == 0) { + if (reply) { + reply->reader->cancel(reply); + reply = 0; + } + + if (pixmapStatus == QDeclarative1Pixmap::Ready) { + pixmapStore()->unreferencePixmap(this); + } else { + removeFromCache(); + delete this; + } + } +} + +void QDeclarative1PixmapData::addToCache() +{ + if (!inCache) { + QDeclarative1PixmapKey key = { &url, &requestSize }; + pixmapStore()->m_cache.insert(key, this); + inCache = true; + } +} + +void QDeclarative1PixmapData::removeFromCache() +{ + if (inCache) { + QDeclarative1PixmapKey key = { &url, &requestSize }; + pixmapStore()->m_cache.remove(key); + inCache = false; + } +} + +static QDeclarative1PixmapData* createPixmapDataSync(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, bool *ok) +{ + if (url.scheme() == QLatin1String("image")) { + QSize readSize; + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); + QDeclarativeImageProvider::ImageType imageType = ep->getImageProviderType(url); + + switch (imageType) { + case QDeclarativeImageProvider::Image: + { + QImage image = ep->getImageFromProvider(url, &readSize, requestSize); + if (!image.isNull()) { + *ok = true; + return new QDeclarative1PixmapData(url, QPixmap::fromImage(image), readSize, requestSize); + } + } + case QDeclarativeImageProvider::Pixmap: + { + QPixmap pixmap = ep->getPixmapFromProvider(url, &readSize, requestSize); + if (!pixmap.isNull()) { + *ok = true; + return new QDeclarative1PixmapData(url, pixmap, readSize, requestSize); + } + } + } + + // no matching provider, or provider has bad image type, or provider returned null image + return new QDeclarative1PixmapData(url, requestSize, + QDeclarative1Pixmap::tr("Failed to get image from provider: %1").arg(url.toString())); + } + + QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url); + if (localFile.isEmpty()) + return 0; + + QFile f(localFile); + QSize readSize; + QString errorString; + + if (f.open(QIODevice::ReadOnly)) { + QImage image; + if (readImage(url, &f, &image, &errorString, &readSize, requestSize)) { + *ok = true; + return new QDeclarative1PixmapData(url, QPixmap::fromImage(image), readSize, requestSize); + } + } else { + errorString = QDeclarative1Pixmap::tr("Cannot open: %1").arg(url.toString()); + } + return new QDeclarative1PixmapData(url, requestSize, errorString); +} + + +struct QDeclarative1PixmapNull { + QUrl url; + QPixmap pixmap; + QSize size; +}; +Q_GLOBAL_STATIC(QDeclarative1PixmapNull, nullPixmap); + +QDeclarative1Pixmap::QDeclarative1Pixmap() +: d(0) +{ +} + +QDeclarative1Pixmap::QDeclarative1Pixmap(QDeclarativeEngine *engine, const QUrl &url) +: d(0) +{ + load(engine, url); +} + +QDeclarative1Pixmap::QDeclarative1Pixmap(QDeclarativeEngine *engine, const QUrl &url, const QSize &size) +: d(0) +{ + load(engine, url, size); +} + +QDeclarative1Pixmap::~QDeclarative1Pixmap() +{ + if (d) { + d->release(); + d = 0; + } +} + +bool QDeclarative1Pixmap::isNull() const +{ + return d == 0; +} + +bool QDeclarative1Pixmap::isReady() const +{ + return status() == Ready; +} + +bool QDeclarative1Pixmap::isError() const +{ + return status() == Error; +} + +bool QDeclarative1Pixmap::isLoading() const +{ + return status() == Loading; +} + +QString QDeclarative1Pixmap::error() const +{ + if (d) + return d->errorString; + else + return QString(); +} + +QDeclarative1Pixmap::Status QDeclarative1Pixmap::status() const +{ + if (d) + return d->pixmapStatus; + else + return Null; +} + +const QUrl &QDeclarative1Pixmap::url() const +{ + if (d) + return d->url; + else + return nullPixmap()->url; +} + +const QSize &QDeclarative1Pixmap::implicitSize() const +{ + if (d) + return d->implicitSize; + else + return nullPixmap()->size; +} + +const QSize &QDeclarative1Pixmap::requestSize() const +{ + if (d) + return d->requestSize; + else + return nullPixmap()->size; +} + +const QPixmap &QDeclarative1Pixmap::pixmap() const +{ + if (d) + return d->pixmap; + else + return nullPixmap()->pixmap; +} + +void QDeclarative1Pixmap::setPixmap(const QPixmap &p) +{ + clear(); + + if (!p.isNull()) + d = new QDeclarative1PixmapData(p); +} + +int QDeclarative1Pixmap::width() const +{ + if (d) + return d->pixmap.width(); + else + return 0; +} + +int QDeclarative1Pixmap::height() const +{ + if (d) + return d->pixmap.height(); + else + return 0; +} + +QRect QDeclarative1Pixmap::rect() const +{ + if (d) + return d->pixmap.rect(); + else + return QRect(); +} + +void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url) +{ + load(engine, url, QSize(), QDeclarative1Pixmap::Cache); +} + +void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, QDeclarative1Pixmap::Options options) +{ + load(engine, url, QSize(), options); +} + +void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &size) +{ + load(engine, url, size, QDeclarative1Pixmap::Cache); +} + +void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, QDeclarative1Pixmap::Options options) +{ + if (d) { d->release(); d = 0; } + + QDeclarative1PixmapKey key = { &url, &requestSize }; + QDeclarative1PixmapStore *store = pixmapStore(); + + QHash::Iterator iter = store->m_cache.find(key); + + if (iter == store->m_cache.end()) { + if (options & QDeclarative1Pixmap::Asynchronous) { + // pixmaps can only be loaded synchronously + if (url.scheme() == QLatin1String("image") + && QDeclarativeEnginePrivate::get(engine)->getImageProviderType(url) == QDeclarativeImageProvider::Pixmap) { + options &= ~QDeclarative1Pixmap::Asynchronous; + } + } + + if (!(options & QDeclarative1Pixmap::Asynchronous)) { + bool ok = false; + d = createPixmapDataSync(engine, url, requestSize, &ok); + if (ok) { + if (options & QDeclarative1Pixmap::Cache) + d->addToCache(); + return; + } + if (d) // loadable, but encountered error while loading + return; + } + + if (!engine) + return; + + QDeclarative1PixmapReader *reader = QDeclarative1PixmapReader::instance(engine); + + d = new QDeclarative1PixmapData(url, requestSize); + if (options & QDeclarative1Pixmap::Cache) + d->addToCache(); + + d->reply = reader->getImage(d); + } else { + d = *iter; + d->addref(); + } +} + +void QDeclarative1Pixmap::clear() +{ + if (d) { + d->release(); + d = 0; + } +} + +void QDeclarative1Pixmap::clear(QObject *obj) +{ + if (d) { + if (d->reply) + QObject::disconnect(d->reply, 0, obj, 0); + d->release(); + d = 0; + } +} + +bool QDeclarative1Pixmap::connectFinished(QObject *object, const char *method) +{ + if (!d || !d->reply) { + qWarning("QDeclarative1Pixmap: connectFinished() called when not loading."); + return false; + } + + return QObject::connect(d->reply, SIGNAL(finished()), object, method); +} + +bool QDeclarative1Pixmap::connectFinished(QObject *object, int method) +{ + if (!d || !d->reply) { + qWarning("QDeclarative1Pixmap: connectFinished() called when not loading."); + return false; + } + + return QMetaObject::connect(d->reply, QDeclarative1PixmapReply::finishedIndex, object, method); +} + +bool QDeclarative1Pixmap::connectDownloadProgress(QObject *object, const char *method) +{ + if (!d || !d->reply) { + qWarning("QDeclarative1Pixmap: connectDownloadProgress() called when not loading."); + return false; + } + + return QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), object, method); +} + +bool QDeclarative1Pixmap::connectDownloadProgress(QObject *object, int method) +{ + if (!d || !d->reply) { + qWarning("QDeclarative1Pixmap: connectDownloadProgress() called when not loading."); + return false; + } + + return QMetaObject::connect(d->reply, QDeclarative1PixmapReply::downloadProgressIndex, object, method); +} + + + +QT_END_NAMESPACE + +#include diff --git a/src/qtquick1/util/qdeclarativepixmapcache_p.h b/src/qtquick1/util/qdeclarativepixmapcache_p.h new file mode 100644 index 0000000000..f0a7770be0 --- /dev/null +++ b/src/qtquick1/util/qdeclarativepixmapcache_p.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEPIXMAPCACHE_H +#define QDECLARATIVEPIXMAPCACHE_H + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QDeclarativeEngine; + +QT_MODULE(Declarative) + +class QDeclarative1PixmapData; +class Q_DECLARATIVE_EXPORT QDeclarative1Pixmap +{ + Q_DECLARE_TR_FUNCTIONS(QDeclarative1Pixmap) +public: + QDeclarative1Pixmap(); + QDeclarative1Pixmap(QDeclarativeEngine *, const QUrl &); + QDeclarative1Pixmap(QDeclarativeEngine *, const QUrl &, const QSize &); + ~QDeclarative1Pixmap(); + + enum Status { Null, Ready, Error, Loading }; + + enum Option { + Asynchronous = 0x00000001, + Cache = 0x00000002 + }; + Q_DECLARE_FLAGS(Options, Option) + + bool isNull() const; + bool isReady() const; + bool isError() const; + bool isLoading() const; + + Status status() const; + QString error() const; + const QUrl &url() const; + const QSize &implicitSize() const; + const QSize &requestSize() const; + const QPixmap &pixmap() const; + void setPixmap(const QPixmap &); + + QRect rect() const; + int width() const; + int height() const; + inline operator const QPixmap &() const; + + void load(QDeclarativeEngine *, const QUrl &); + void load(QDeclarativeEngine *, const QUrl &, QDeclarative1Pixmap::Options options); + void load(QDeclarativeEngine *, const QUrl &, const QSize &); + void load(QDeclarativeEngine *, const QUrl &, const QSize &, QDeclarative1Pixmap::Options options); + + void clear(); + void clear(QObject *); + + bool connectFinished(QObject *, const char *); + bool connectFinished(QObject *, int); + bool connectDownloadProgress(QObject *, const char *); + bool connectDownloadProgress(QObject *, int); + +private: + Q_DISABLE_COPY(QDeclarative1Pixmap) + QDeclarative1PixmapData *d; +}; + +inline QDeclarative1Pixmap::operator const QPixmap &() const +{ + return pixmap(); +} + +Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarative1Pixmap::Options) + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDECLARATIVEPIXMAPCACHE_H diff --git a/src/qtquick1/util/qdeclarativepropertychanges.cpp b/src/qtquick1/util/qdeclarativepropertychanges.cpp new file mode 100644 index 0000000000..c9a512503b --- /dev/null +++ b/src/qtquick1/util/qdeclarativepropertychanges.cpp @@ -0,0 +1,801 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativepropertychanges_p.h" + +#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" +#include "QtDeclarative/private/qdeclarativerewrite_p.h" +#include "QtDeclarative/private/qdeclarativeengine_p.h" +#include "QtDeclarative/private/qdeclarativecompiler_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +QT_BEGIN_NAMESPACE + + + +/*! + \qmlclass PropertyChanges QDeclarative1PropertyChanges + \ingroup qml-state-elements + \since 4.7 + \brief The PropertyChanges element describes new property bindings or values for a state. + + PropertyChanges is used to define the property values or bindings in a + \l State. This enables an item's property values to be changed when it + \l {QML States}{changes between states}. + + To create a PropertyChanges object, specify the \l target item whose + properties are to be modified, and define the new property values or + bindings. For example: + + \snippet doc/src/snippets/declarative/propertychanges.qml import + \codeline + \snippet doc/src/snippets/declarative/propertychanges.qml 0 + + When the mouse is pressed, the \l Rectangle changes to the \e resized + state. In this state, the PropertyChanges object sets the rectangle's + color to blue and the \c height value to that of \c container.height. + + Note this automatically binds \c rect.height to \c container.height + in the \e resized state. If a property binding should not be + established, and the height should just be set to the value of + \c container.height at the time of the state change, set the \l explicit + property to \c true. + + A PropertyChanges object can also override the default signal handler + for an object to implement a signal handler specific to the new state: + + \qml + PropertyChanges { + target: myMouseArea + onClicked: doSomethingDifferent() + } + \endqml + + \note PropertyChanges can be used to change anchor margins, but not other anchor + values; use AnchorChanges for this instead. Similarly, to change an \l Item's + \l {Item::}{parent} value, use ParentChanges instead. + + + \section2 Resetting property values + + The \c undefined value can be used to reset the property value for a state. + In the following example, when \c theText changes to the \e widerText + state, its \c width property is reset, giving the text its natural width + and displaying the whole string on a single line. + + \snippet doc/src/snippets/declarative/propertychanges.qml reset + + + \section2 Immediate property changes in transitions + + When \l{QML Animation and Transitions}{Transitions} are used to animate + state changes, they animate properties from their values in the current + state to those defined in the new state (as defined by PropertyChanges + objects). However, it is sometimes desirable to set a property value + \e immediately during a \l Transition, without animation; in these cases, + the PropertyAction element can be used to force an immediate property + change. + + See the PropertyAction documentation for more details. + + \sa {declarative/animation/states}{states example}, {qmlstate}{States}, QtDeclarative +*/ + +/*! + \qmlproperty Object PropertyChanges::target + This property holds the object which contains the properties to be changed. +*/ + +class QDeclarative1ReplaceSignalHandler : public QDeclarative1ActionEvent +{ +public: + QDeclarative1ReplaceSignalHandler() : expression(0), reverseExpression(0), + rewindExpression(0), ownedExpression(0) {} + ~QDeclarative1ReplaceSignalHandler() { + delete ownedExpression; + } + + virtual QString typeName() const { return QLatin1String("ReplaceSignalHandler"); } + + QDeclarativeProperty property; + QDeclarativeExpression *expression; + QDeclarativeExpression *reverseExpression; + QDeclarativeExpression *rewindExpression; + QDeclarativeGuard ownedExpression; + + virtual void execute(Reason) { + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression); + if (ownedExpression == expression) + ownedExpression = 0; + } + + virtual bool isReversable() { return true; } + virtual void reverse(Reason) { + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression); + if (ownedExpression == reverseExpression) + ownedExpression = 0; + } + + virtual void saveOriginals() { + saveCurrentValues(); + reverseExpression = rewindExpression; + } + + /*virtual void copyOriginals(QDeclarative1ActionEvent *other) + { + QDeclarative1ReplaceSignalHandler *rsh = static_cast(other); + saveCurrentValues(); + if (rsh == this) + return; + reverseExpression = rsh->reverseExpression; + if (rsh->ownedExpression == reverseExpression) { + ownedExpression = rsh->ownedExpression; + rsh->ownedExpression = 0; + } + }*/ + + virtual void rewind() { + ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); + if (ownedExpression == rewindExpression) + ownedExpression = 0; + } + virtual void saveCurrentValues() { + rewindExpression = QDeclarativePropertyPrivate::signalExpression(property); + } + + virtual bool override(QDeclarative1ActionEvent*other) { + if (other == this) + return true; + if (other->typeName() != typeName()) + return false; + if (static_cast(other)->property == property) + return true; + return false; + } +}; + + +class QDeclarative1PropertyChangesPrivate : public QDeclarative1StateOperationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1PropertyChanges) +public: + QDeclarative1PropertyChangesPrivate() : decoded(true), restore(true), + isExplicit(false) {} + + QDeclarativeGuard object; + QByteArray data; + + bool decoded : 1; + bool restore : 1; + bool isExplicit : 1; + + void decode(); + + class ExpressionChange { + public: + ExpressionChange(const QString &_name, + QDeclarativeBinding::Identifier _id, + QDeclarativeExpression *_expr) + : name(_name), id(_id), expression(_expr) {} + QString name; + QDeclarativeBinding::Identifier id; + QDeclarativeExpression *expression; + }; + + QList > properties; + QList expressions; + QList signalReplacements; + + QDeclarativeProperty property(const QString &); +}; + +void +QDeclarative1PropertyChangesParser::compileList(QList > &list, + const QByteArray &pre, + const QDeclarativeCustomParserProperty &prop) +{ + QByteArray propName = pre + prop.name(); + + QList values = prop.assignedValues(); + for (int ii = 0; ii < values.count(); ++ii) { + const QVariant &value = values.at(ii); + + if (value.userType() == qMetaTypeId()) { + error(qvariant_cast(value), + QDeclarative1PropertyChanges::tr("PropertyChanges does not support creating state-specific objects.")); + continue; + } else if(value.userType() == qMetaTypeId()) { + + QDeclarativeCustomParserProperty prop = + qvariant_cast(value); + QByteArray pre = propName + '.'; + compileList(list, pre, prop); + + } else { + list << qMakePair(propName, value); + } + } +} + +QByteArray +QDeclarative1PropertyChangesParser::compile(const QList &props) +{ + QList > data; + for(int ii = 0; ii < props.count(); ++ii) + compileList(data, QByteArray(), props.at(ii)); + + QByteArray rv; + QDataStream ds(&rv, QIODevice::WriteOnly); + + ds << data.count(); + for(int ii = 0; ii < data.count(); ++ii) { + QDeclarativeParser::Variant v = qvariant_cast(data.at(ii).second); + QVariant var; + bool isScript = v.isScript(); + QDeclarativeBinding::Identifier id = 0; + switch(v.type()) { + case QDeclarativeParser::Variant::Boolean: + var = QVariant(v.asBoolean()); + break; + case QDeclarativeParser::Variant::Number: + var = QVariant(v.asNumber()); + break; + case QDeclarativeParser::Variant::String: + var = QVariant(v.asString()); + break; + case QDeclarativeParser::Variant::Invalid: + case QDeclarativeParser::Variant::Script: + var = QVariant(v.asScript()); + { + // Pre-rewrite the expression + QString expression = v.asScript(); + id = rewriteBinding(expression, data.at(ii).first); //### recreates the AST, which is slow + } + break; + } + + ds << QString::fromUtf8(data.at(ii).first) << isScript << var; + if (isScript) + ds << id; + } + + return rv; +} + +void QDeclarative1PropertyChangesPrivate::decode() +{ + Q_Q(QDeclarative1PropertyChanges); + if (decoded) + return; + + QDataStream ds(&data, QIODevice::ReadOnly); + + int count; + ds >> count; + for (int ii = 0; ii < count; ++ii) { + QString name; + bool isScript; + QVariant data; + QDeclarativeBinding::Identifier id = QDeclarativeBinding::Invalid; + ds >> name; + ds >> isScript; + ds >> data; + if (isScript) + ds >> id; + + QDeclarativeProperty prop = property(name); //### better way to check for signal property? + if (prop.type() & QDeclarativeProperty::SignalProperty) { + QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString()); + QDeclarativeData *ddata = QDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); + QDeclarative1ReplaceSignalHandler *handler = new QDeclarative1ReplaceSignalHandler; + handler->property = prop; + handler->expression = expression; + signalReplacements << handler; + } else if (isScript) { + QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString()); + QDeclarativeData *ddata = QDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); + expressions << ExpressionChange(name, id, expression); + } else { + properties << qMakePair(name, data); + } + } + + decoded = true; + data.clear(); +} + +void QDeclarative1PropertyChangesParser::setCustomData(QObject *object, + const QByteArray &data) +{ + QDeclarative1PropertyChangesPrivate *p = + static_cast(QObjectPrivate::get(object)); + p->data = data; + p->decoded = false; +} + +QDeclarative1PropertyChanges::QDeclarative1PropertyChanges() +: QDeclarative1StateOperation(*(new QDeclarative1PropertyChangesPrivate)) +{ +} + +QDeclarative1PropertyChanges::~QDeclarative1PropertyChanges() +{ + Q_D(QDeclarative1PropertyChanges); + for(int ii = 0; ii < d->expressions.count(); ++ii) + delete d->expressions.at(ii).expression; + for(int ii = 0; ii < d->signalReplacements.count(); ++ii) + delete d->signalReplacements.at(ii); +} + +QObject *QDeclarative1PropertyChanges::object() const +{ + Q_D(const QDeclarative1PropertyChanges); + return d->object; +} + +void QDeclarative1PropertyChanges::setObject(QObject *o) +{ + Q_D(QDeclarative1PropertyChanges); + d->object = o; +} + +/*! + \qmlproperty bool PropertyChanges::restoreEntryValues + + This property holds whether the previous values should be restored when + leaving the state. + + The default value is \c true. Setting this value to \c false creates a + temporary state that has permanent effects on property values. +*/ +bool QDeclarative1PropertyChanges::restoreEntryValues() const +{ + Q_D(const QDeclarative1PropertyChanges); + return d->restore; +} + +void QDeclarative1PropertyChanges::setRestoreEntryValues(bool v) +{ + Q_D(QDeclarative1PropertyChanges); + d->restore = v; +} + +QDeclarativeProperty +QDeclarative1PropertyChangesPrivate::property(const QString &property) +{ + Q_Q(QDeclarative1PropertyChanges); + QDeclarativeProperty prop(object, property, qmlContext(q)); + if (!prop.isValid()) { + qmlInfo(q) << QDeclarative1PropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(property); + return QDeclarativeProperty(); + } else if (!(prop.type() & QDeclarativeProperty::SignalProperty) && !prop.isWritable()) { + qmlInfo(q) << QDeclarative1PropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(property); + return QDeclarativeProperty(); + } + return prop; +} + +QDeclarative1PropertyChanges::ActionList QDeclarative1PropertyChanges::actions() +{ + Q_D(QDeclarative1PropertyChanges); + + d->decode(); + + ActionList list; + + for (int ii = 0; ii < d->properties.count(); ++ii) { + + QDeclarative1Action a(d->object, d->properties.at(ii).first, + qmlContext(this), d->properties.at(ii).second); + + if (a.property.isValid()) { + a.restore = restoreEntryValues(); + list << a; + } + } + + for (int ii = 0; ii < d->signalReplacements.count(); ++ii) { + + QDeclarative1ReplaceSignalHandler *handler = d->signalReplacements.at(ii); + + if (handler->property.isValid()) { + QDeclarative1Action a; + a.event = handler; + list << a; + } + } + + for (int ii = 0; ii < d->expressions.count(); ++ii) { + + const QString &property = d->expressions.at(ii).name; + QDeclarativeProperty prop = d->property(property); + + if (prop.isValid()) { + QDeclarative1Action a; + a.restore = restoreEntryValues(); + a.property = prop; + a.fromValue = a.property.read(); + a.specifiedObject = d->object; + a.specifiedProperty = property; + + if (d->isExplicit) { + a.toValue = d->expressions.at(ii).expression->evaluate(); + } else { + QDeclarativeExpression *e = d->expressions.at(ii).expression; + + QDeclarativeBinding::Identifier id = d->expressions.at(ii).id; + QDeclarativeBinding *newBinding = id != QDeclarativeBinding::Invalid ? QDeclarativeBinding::createBinding(id, object(), qmlContext(this), e->sourceFile(), e->lineNumber()) : 0; + if (!newBinding) { + newBinding = new QDeclarativeBinding(e->expression(), object(), qmlContext(this)); + newBinding->setSourceLocation(e->sourceFile(), e->lineNumber()); + } + newBinding->setTarget(prop); + a.toBinding = newBinding; + a.deletableToBinding = true; + } + + list << a; + } + } + + return list; +} + +/*! + \qmlproperty bool PropertyChanges::explicit + + If explicit is set to true, any potential bindings will be interpreted as + once-off assignments that occur when the state is entered. + + In the following example, the addition of explicit prevents \c myItem.width from + being bound to \c parent.width. Instead, it is assigned the value of \c parent.width + at the time of the state change. + \qml + PropertyChanges { + target: myItem + explicit: true + width: parent.width + } + \endqml + + By default, explicit is false. +*/ +bool QDeclarative1PropertyChanges::isExplicit() const +{ + Q_D(const QDeclarative1PropertyChanges); + return d->isExplicit; +} + +void QDeclarative1PropertyChanges::setIsExplicit(bool e) +{ + Q_D(QDeclarative1PropertyChanges); + d->isExplicit = e; +} + +bool QDeclarative1PropertyChanges::containsValue(const QString &name) const +{ + Q_D(const QDeclarative1PropertyChanges); + typedef QPair PropertyEntry; + + QListIterator propertyIterator(d->properties); + while (propertyIterator.hasNext()) { + const PropertyEntry &entry = propertyIterator.next(); + if (entry.first == name) { + return true; + } + } + + return false; +} + +bool QDeclarative1PropertyChanges::containsExpression(const QString &name) const +{ + Q_D(const QDeclarative1PropertyChanges); + typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; + + QListIterator expressionIterator(d->expressions); + while (expressionIterator.hasNext()) { + const ExpressionEntry &entry = expressionIterator.next(); + if (entry.name == name) { + return true; + } + } + + return false; +} + +bool QDeclarative1PropertyChanges::containsProperty(const QString &name) const +{ + return containsValue(name) || containsExpression(name); +} + +void QDeclarative1PropertyChanges::changeValue(const QString &name, const QVariant &value) +{ + Q_D(QDeclarative1PropertyChanges); + typedef QPair PropertyEntry; + typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; + + QMutableListIterator expressionIterator(d->expressions); + while (expressionIterator.hasNext()) { + const ExpressionEntry &entry = expressionIterator.next(); + if (entry.name == name) { + expressionIterator.remove(); + if (state() && state()->isStateActive()) { + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name)); + if (oldBinding) { + QDeclarativePropertyPrivate::setBinding(d->property(name), 0); + oldBinding->destroy(); + } + d->property(name).write(value); + } + + d->properties.append(PropertyEntry(name, value)); + return; + } + } + + QMutableListIterator propertyIterator(d->properties); + while (propertyIterator.hasNext()) { + PropertyEntry &entry = propertyIterator.next(); + if (entry.first == name) { + entry.second = value; + if (state() && state()->isStateActive()) + d->property(name).write(value); + return; + } + } + + QDeclarative1Action action; + action.restore = restoreEntryValues(); + action.property = d->property(name); + action.fromValue = action.property.read(); + action.specifiedObject = object(); + action.specifiedProperty = name; + action.toValue = value; + + propertyIterator.insert(PropertyEntry(name, value)); + if (state() && state()->isStateActive()) { + state()->addEntryToRevertList(action); + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property); + if (oldBinding) + oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); + d->property(name).write(value); + } +} + +void QDeclarative1PropertyChanges::changeExpression(const QString &name, const QString &expression) +{ + Q_D(QDeclarative1PropertyChanges); + typedef QPair PropertyEntry; + typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; + + bool hadValue = false; + + QMutableListIterator propertyIterator(d->properties); + while (propertyIterator.hasNext()) { + PropertyEntry &entry = propertyIterator.next(); + if (entry.first == name) { + propertyIterator.remove(); + hadValue = true; + break; + } + } + + QMutableListIterator expressionIterator(d->expressions); + while (expressionIterator.hasNext()) { + const ExpressionEntry &entry = expressionIterator.next(); + if (entry.name == name) { + entry.expression->setExpression(expression); + if (state() && state()->isStateActive()) { + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name)); + if (oldBinding) { + QDeclarativePropertyPrivate::setBinding(d->property(name), 0); + oldBinding->destroy(); + } + + QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this)); + newBinding->setTarget(d->property(name)); + QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); + } + return; + } + } + + QDeclarativeExpression *newExpression = new QDeclarativeExpression(qmlContext(this), d->object, expression); + expressionIterator.insert(ExpressionEntry(name, QDeclarativeBinding::Invalid, newExpression)); + + if (state() && state()->isStateActive()) { + if (hadValue) { + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name)); + if (oldBinding) { + oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); + state()->changeBindingInRevertList(object(), name, oldBinding); + } + + QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this)); + newBinding->setTarget(d->property(name)); + QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); + } else { + QDeclarative1Action action; + action.restore = restoreEntryValues(); + action.property = d->property(name); + action.fromValue = action.property.read(); + action.specifiedObject = object(); + action.specifiedProperty = name; + + + if (d->isExplicit) { + action.toValue = newExpression->evaluate(); + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(newExpression->expression(), object(), qmlContext(this)); + newBinding->setTarget(d->property(name)); + action.toBinding = newBinding; + action.deletableToBinding = true; + + state()->addEntryToRevertList(action); + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property); + if (oldBinding) + oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); + + QDeclarativePropertyPrivate::setBinding(action.property, newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); + } + } + } + // what about the signal handler? +} + +QVariant QDeclarative1PropertyChanges::property(const QString &name) const +{ + Q_D(const QDeclarative1PropertyChanges); + typedef QPair PropertyEntry; + typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; + + QListIterator propertyIterator(d->properties); + while (propertyIterator.hasNext()) { + const PropertyEntry &entry = propertyIterator.next(); + if (entry.first == name) { + return entry.second; + } + } + + QListIterator expressionIterator(d->expressions); + while (expressionIterator.hasNext()) { + const ExpressionEntry &entry = expressionIterator.next(); + if (entry.name == name) { + return QVariant(entry.expression->expression()); + } + } + + return QVariant(); +} + +void QDeclarative1PropertyChanges::removeProperty(const QString &name) +{ + Q_D(QDeclarative1PropertyChanges); + typedef QPair PropertyEntry; + typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; + + QMutableListIterator expressionIterator(d->expressions); + while (expressionIterator.hasNext()) { + const ExpressionEntry &entry = expressionIterator.next(); + if (entry.name == name) { + expressionIterator.remove(); + state()->removeEntryFromRevertList(object(), name); + return; + } + } + + QMutableListIterator propertyIterator(d->properties); + while (propertyIterator.hasNext()) { + const PropertyEntry &entry = propertyIterator.next(); + if (entry.first == name) { + propertyIterator.remove(); + state()->removeEntryFromRevertList(object(), name); + return; + } + } +} + +QVariant QDeclarative1PropertyChanges::value(const QString &name) const +{ + Q_D(const QDeclarative1PropertyChanges); + typedef QPair PropertyEntry; + + QListIterator propertyIterator(d->properties); + while (propertyIterator.hasNext()) { + const PropertyEntry &entry = propertyIterator.next(); + if (entry.first == name) { + return entry.second; + } + } + + return QVariant(); +} + +QString QDeclarative1PropertyChanges::expression(const QString &name) const +{ + Q_D(const QDeclarative1PropertyChanges); + typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; + + QListIterator expressionIterator(d->expressions); + while (expressionIterator.hasNext()) { + const ExpressionEntry &entry = expressionIterator.next(); + if (entry.name == name) { + return entry.expression->expression(); + } + } + + return QString(); +} + +void QDeclarative1PropertyChanges::detachFromState() +{ + if (state()) + state()->removeAllEntriesFromRevertList(object()); +} + +void QDeclarative1PropertyChanges::attachToState() +{ + if (state()) + state()->addEntriesToRevertList(actions()); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativepropertychanges_p.h b/src/qtquick1/util/qdeclarativepropertychanges_p.h new file mode 100644 index 0000000000..30609d3c2d --- /dev/null +++ b/src/qtquick1/util/qdeclarativepropertychanges_p.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEPROPERTYCHANGES_H +#define QDECLARATIVEPROPERTYCHANGES_H + +#include "QtQuick1/private/qdeclarativestateoperations_p.h" +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1PropertyChangesPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1PropertyChanges : public QDeclarative1StateOperation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1PropertyChanges) + + Q_PROPERTY(QObject *target READ object WRITE setObject) + Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues) + Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit) +public: + QDeclarative1PropertyChanges(); + ~QDeclarative1PropertyChanges(); + + QObject *object() const; + void setObject(QObject *); + + bool restoreEntryValues() const; + void setRestoreEntryValues(bool); + + bool isExplicit() const; + void setIsExplicit(bool); + + virtual ActionList actions(); + + bool containsProperty(const QString &name) const; + bool containsValue(const QString &name) const; + bool containsExpression(const QString &name) const; + void changeValue(const QString &name, const QVariant &value); + void changeExpression(const QString &name, const QString &expression); + void removeProperty(const QString &name); + QVariant value(const QString &name) const; + QString expression(const QString &name) const; + + void detachFromState(); + void attachToState(); + + QVariant property(const QString &name) const; +}; + +class QDeclarative1PropertyChangesParser : public QDeclarativeCustomParser +{ +public: + QDeclarative1PropertyChangesParser() + : QDeclarativeCustomParser(AcceptsAttachedProperties) {} + + void compileList(QList > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop); + + virtual QByteArray compile(const QList &); + virtual void setCustomData(QObject *, const QByteArray &); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1PropertyChanges) + +QT_END_HEADER + +#endif // QDECLARATIVEPROPERTYCHANGES_H diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation.cpp b/src/qtquick1/util/qdeclarativesmoothedanimation.cpp new file mode 100644 index 0000000000..d94c132a56 --- /dev/null +++ b/src/qtquick1/util/qdeclarativesmoothedanimation.cpp @@ -0,0 +1,497 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h" +#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h" + +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" + +#include +#include "QtDeclarative/private/qdeclarativeproperty_p.h" + +#include "QtDeclarative/private/qdeclarativeglobal_p.h" + +#include + +#include + +#define DELAY_STOP_TIMER_INTERVAL 32 + +QT_BEGIN_NAMESPACE + + + +QSmoothedAnimation_1::QSmoothedAnimation_1(QObject *parent) + : QAbstractAnimation(parent), to(0), velocity(200), userDuration(-1), maximumEasingTime(-1), + reversingMode(QDeclarative1SmoothedAnimation::Eased), initialVelocity(0), + trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0) +{ + delayedStopTimer.setInterval(DELAY_STOP_TIMER_INTERVAL); + delayedStopTimer.setSingleShot(true); + connect(&delayedStopTimer, SIGNAL(timeout()), this, SLOT(stop())); +} + +void QSmoothedAnimation_1::restart() +{ + initialVelocity = trackVelocity; + if (state() != QAbstractAnimation::Running) + start(); + else + init(); +} + +void QSmoothedAnimation_1::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/) +{ + if (newState == QAbstractAnimation::Running) + init(); +} + +void QSmoothedAnimation_1::delayedStop() +{ + if (!delayedStopTimer.isActive()) + delayedStopTimer.start(); +} + +int QSmoothedAnimation_1::duration() const +{ + return -1; +} + +bool QSmoothedAnimation_1::recalc() +{ + s = to - initialValue; + vi = initialVelocity; + + s = (invert? -1.0: 1.0) * s; + + if (userDuration > 0 && velocity > 0) { + tf = s / velocity; + if (tf > (userDuration / 1000.)) tf = (userDuration / 1000.); + } else if (userDuration > 0) { + tf = userDuration / 1000.; + } else if (velocity > 0) { + tf = s / velocity; + } else { + return false; + } + + finalDuration = ceil(tf * 1000.0); + + if (maximumEasingTime == 0) { + a = 0; + d = 0; + tp = 0; + td = tf; + vp = velocity; + sp = 0; + sd = s; + } else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) { + qreal met = maximumEasingTime / 1000.; + td = tf - met; + + qreal c1 = td; + qreal c2 = (tf - td) * vi - tf * velocity; + qreal c3 = -0.5 * (tf - td) * vi * vi; + + qreal vp1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1); + + vp = vp1; + a = vp / met; + d = a; + tp = (vp - vi) / a; + sp = vi * tp + 0.5 * a * tp * tp; + sd = sp + (td - tp) * vp; + } else { + qreal c1 = 0.25 * tf * tf; + qreal c2 = 0.5 * vi * tf - s; + qreal c3 = -0.25 * vi * vi; + + qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1); + + qreal tp1 = 0.5 * tf - 0.5 * vi / a1; + qreal vp1 = a1 * tp1 + vi; + + qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1; + + a = a1; + d = a1; + tp = tp1; + td = tp1; + vp = vp1; + sp = sp1; + sd = sp1; + } + return true; +} + +qreal QSmoothedAnimation_1::easeFollow(qreal time_seconds) +{ + qreal value; + if (time_seconds < tp) { + trackVelocity = vi + time_seconds * a; + value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds; + } else if (time_seconds < td) { + time_seconds -= tp; + trackVelocity = vp; + value = sp + time_seconds * vp; + } else if (time_seconds < tf) { + time_seconds -= td; + trackVelocity = vp - time_seconds * a; + value = sd - 0.5 * d * time_seconds * time_seconds + vp * time_seconds; + } else { + trackVelocity = 0; + value = s; + delayedStop(); + } + + // to normalize 's' between [0..1], divide 'value' by 's' + return value; +} + +void QSmoothedAnimation_1::updateCurrentTime(int t) +{ + qreal time_seconds = qreal(t - lastTime) / 1000.; + + qreal value = easeFollow(time_seconds); + value *= (invert? -1.0: 1.0); + QDeclarativePropertyPrivate::write(target, initialValue + value, + QDeclarativePropertyPrivate::BypassInterceptor + | QDeclarativePropertyPrivate::DontRemoveBinding); +} + +void QSmoothedAnimation_1::init() +{ + if (velocity == 0) { + stop(); + return; + } + + if (delayedStopTimer.isActive()) + delayedStopTimer.stop(); + + initialValue = target.read().toReal(); + lastTime = this->currentTime(); + + if (to == initialValue) { + stop(); + return; + } + + bool hasReversed = trackVelocity != 0. && + ((!invert) == ((initialValue - to) > 0)); + + if (hasReversed) { + switch (reversingMode) { + default: + case QDeclarative1SmoothedAnimation::Eased: + initialVelocity = -trackVelocity; + break; + case QDeclarative1SmoothedAnimation::Sync: + QDeclarativePropertyPrivate::write(target, to, + QDeclarativePropertyPrivate::BypassInterceptor + | QDeclarativePropertyPrivate::DontRemoveBinding); + trackVelocity = 0; + stop(); + return; + case QDeclarative1SmoothedAnimation::Immediate: + initialVelocity = 0; + break; + } + } + + trackVelocity = initialVelocity; + + invert = (to < initialValue); + + if (!recalc()) { + QDeclarativePropertyPrivate::write(target, to, + QDeclarativePropertyPrivate::BypassInterceptor + | QDeclarativePropertyPrivate::DontRemoveBinding); + stop(); + return; + } +} + +/*! + \qmlclass SmoothedAnimation QDeclarative1SmoothedAnimation + \ingroup qml-animation-transition + \since 4.7 + \inherits NumberAnimation + \brief The SmoothedAnimation element allows a property to smoothly track a value. + + A SmoothedAnimation animates a property's value to a set target value + using an ease in/out quad easing curve. When the target value changes, + the easing curves used to animate between the old and new target values + are smoothly spliced together to create a smooth movement to the new + target value that maintains the current velocity. + + The follow example shows one \l Rectangle tracking the position of another + using SmoothedAnimation. The green rectangle's \c x and \c y values are + bound to those of the red rectangle. Whenever these values change, the + green rectangle smoothly animates to its new position: + + \snippet doc/src/snippets/declarative/smoothedanimation.qml 0 + + A SmoothedAnimation can be configured by setting the \l velocity at which the + animation should occur, or the \l duration that the animation should take. + If both the \l velocity and \l duration are specified, the one that results in + the quickest animation is chosen for each change in the target value. + + For example, animating from 0 to 800 will take 4 seconds if a velocity + of 200 is set, will take 8 seconds with a duration of 8000 set, and will + take 4 seconds with both a velocity of 200 and a duration of 8000 set. + Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set, + will take 8 seconds with a duration of 8000 set, and will take 8 seconds + with both a velocity of 200 and a duration of 8000 set. + + The default velocity of SmoothedAnimation is 200 units/second. Note that if the range of the + value being animated is small, then the velocity will need to be adjusted + appropriately. For example, the opacity of an item ranges from 0 - 1.0. + To enable a smooth animation in this range the velocity will need to be + set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity + of 0.5 will take 2000 ms to complete. + + Like any other animation element, a SmoothedAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \sa SpringAnimation, NumberAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} +*/ + +QDeclarative1SmoothedAnimation::QDeclarative1SmoothedAnimation(QObject *parent) +: QDeclarative1NumberAnimation(*(new QDeclarative1SmoothedAnimationPrivate), parent) +{ +} + +QDeclarative1SmoothedAnimation::~QDeclarative1SmoothedAnimation() +{ +} + +QDeclarative1SmoothedAnimationPrivate::QDeclarative1SmoothedAnimationPrivate() + : wrapperGroup(new QParallelAnimationGroup), anim(new QSmoothedAnimation_1) +{ + Q_Q(QDeclarative1SmoothedAnimation); + QDeclarative_setParent_noEvent(wrapperGroup, q); + QDeclarative_setParent_noEvent(anim, q); +} + +void QDeclarative1SmoothedAnimationPrivate::updateRunningAnimations() +{ + foreach(QSmoothedAnimation_1* ease, activeAnimations.values()){ + ease->maximumEasingTime = anim->maximumEasingTime; + ease->reversingMode = anim->reversingMode; + ease->velocity = anim->velocity; + ease->userDuration = anim->userDuration; + ease->init(); + } +} + +QAbstractAnimation* QDeclarative1SmoothedAnimation::qtAnimation() +{ + Q_D(QDeclarative1SmoothedAnimation); + return d->wrapperGroup; +} + +void QDeclarative1SmoothedAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1SmoothedAnimation); + QDeclarative1NumberAnimation::transition(actions, modified, direction); + + if (!d->actions) + return; + + QSet anims; + for (int i = 0; i < d->actions->size(); i++) { + QSmoothedAnimation_1 *ease; + bool needsRestart; + if (!d->activeAnimations.contains((*d->actions)[i].property)) { + ease = new QSmoothedAnimation_1(); + d->wrapperGroup->addAnimation(ease); + d->activeAnimations.insert((*d->actions)[i].property, ease); + needsRestart = false; + } else { + ease = d->activeAnimations.value((*d->actions)[i].property); + needsRestart = true; + } + ease->target = (*d->actions)[i].property; + ease->to = (*d->actions)[i].toValue.toReal(); + + // copying public members from main value holder animation + ease->maximumEasingTime = d->anim->maximumEasingTime; + ease->reversingMode = d->anim->reversingMode; + ease->velocity = d->anim->velocity; + ease->userDuration = d->anim->userDuration; + + ease->initialVelocity = ease->trackVelocity; + + if (needsRestart) + ease->init(); + anims.insert(ease); + } + + for (int i = d->wrapperGroup->animationCount() - 1; i >= 0 ; --i) { + if (!anims.contains(d->wrapperGroup->animationAt(i))) { + QSmoothedAnimation_1 *ease = static_cast(d->wrapperGroup->animationAt(i)); + d->activeAnimations.remove(ease->target); + d->wrapperGroup->takeAnimation(i); + delete ease; + } + } +} + +/*! + \qmlproperty enumeration SmoothedAnimation::reversingMode + + Sets how the SmoothedAnimation behaves if an animation direction is reversed. + + Possible values are: + + \list + \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction + \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, beginning with a velocity of 0 + \o SmoothedAnimation.Sync - the property is immediately set to the target value + \endlist +*/ +QDeclarative1SmoothedAnimation::ReversingMode QDeclarative1SmoothedAnimation::reversingMode() const +{ + Q_D(const QDeclarative1SmoothedAnimation); + return (QDeclarative1SmoothedAnimation::ReversingMode) d->anim->reversingMode; +} + +void QDeclarative1SmoothedAnimation::setReversingMode(ReversingMode m) +{ + Q_D(QDeclarative1SmoothedAnimation); + if (d->anim->reversingMode == m) + return; + + d->anim->reversingMode = m; + emit reversingModeChanged(); + d->updateRunningAnimations(); +} + +/*! + \qmlproperty int SmoothedAnimation::duration + + This property holds the animation duration, in msecs, used when tracking the source. + + Setting this to -1 (the default) disables the duration value. + + If the velocity value and the duration value are both enabled, then the animation will + use whichever gives the shorter duration. +*/ +int QDeclarative1SmoothedAnimation::duration() const +{ + Q_D(const QDeclarative1SmoothedAnimation); + return d->anim->userDuration; +} + +void QDeclarative1SmoothedAnimation::setDuration(int duration) +{ + Q_D(QDeclarative1SmoothedAnimation); + if (duration != -1) + QDeclarative1NumberAnimation::setDuration(duration); + if(duration == d->anim->userDuration) + return; + d->anim->userDuration = duration; + d->updateRunningAnimations(); +} + +qreal QDeclarative1SmoothedAnimation::velocity() const +{ + Q_D(const QDeclarative1SmoothedAnimation); + return d->anim->velocity; +} + +/*! + \qmlproperty real SmoothedAnimation::velocity + + This property holds the average velocity allowed when tracking the 'to' value. + + The default velocity of SmoothedAnimation is 200 units/second. + + Setting this to -1 disables the velocity value. + + If the velocity value and the duration value are both enabled, then the animation will + use whichever gives the shorter duration. +*/ +void QDeclarative1SmoothedAnimation::setVelocity(qreal v) +{ + Q_D(QDeclarative1SmoothedAnimation); + if (d->anim->velocity == v) + return; + + d->anim->velocity = v; + emit velocityChanged(); + d->updateRunningAnimations(); +} + +/*! + \qmlproperty int SmoothedAnimation::maximumEasingTime + + This property specifies the maximum time, in msecs, any "eases" during the follow should take. + Setting this property causes the velocity to "level out" after at a time. Setting + a negative value reverts to the normal mode of easing over the entire animation + duration. + + The default value is -1. +*/ +int QDeclarative1SmoothedAnimation::maximumEasingTime() const +{ + Q_D(const QDeclarative1SmoothedAnimation); + return d->anim->maximumEasingTime; +} + +void QDeclarative1SmoothedAnimation::setMaximumEasingTime(int v) +{ + Q_D(QDeclarative1SmoothedAnimation); + if(v == d->anim->maximumEasingTime) + return; + d->anim->maximumEasingTime = v; + emit maximumEasingTimeChanged(); + d->updateRunningAnimations(); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation_p.h b/src/qtquick1/util/qdeclarativesmoothedanimation_p.h new file mode 100644 index 0000000000..89946179da --- /dev/null +++ b/src/qtquick1/util/qdeclarativesmoothedanimation_p.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESMOOTHEDANIMATION_H +#define QDECLARATIVESMOOTHEDANIMATION_H + +#include +#include "QtQuick1/private/qdeclarativeanimation_p.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QDeclarativeProperty; + +QT_MODULE(Declarative) + +class QDeclarative1SmoothedAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1SmoothedAnimation : public QDeclarative1NumberAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1SmoothedAnimation) + Q_ENUMS(ReversingMode) + + Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged) + Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged) + Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged) + +public: + enum ReversingMode { Eased, Immediate, Sync }; + + QDeclarative1SmoothedAnimation(QObject *parent = 0); + ~QDeclarative1SmoothedAnimation(); + + ReversingMode reversingMode() const; + void setReversingMode(ReversingMode); + + virtual int duration() const; + virtual void setDuration(int); + + qreal velocity() const; + void setVelocity(qreal); + + int maximumEasingTime() const; + void setMaximumEasingTime(int); + + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + QAbstractAnimation* qtAnimation(); + +Q_SIGNALS: + void velocityChanged(); + void reversingModeChanged(); + void maximumEasingTimeChanged(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1SmoothedAnimation) + +QT_END_HEADER + +#endif // QDECLARATIVESMOOTHEDANIMATION_H diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h b/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h new file mode 100644 index 0000000000..b31a931873 --- /dev/null +++ b/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESMOOTHEDANIMATION_P_H +#define QDECLARATIVESMOOTHEDANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p.h" + +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QSmoothedAnimation_1 : public QAbstractAnimation +{ +public: + QSmoothedAnimation_1(QObject *parent=0); + + qreal to; + qreal velocity; + int userDuration; + + int maximumEasingTime; + QDeclarative1SmoothedAnimation::ReversingMode reversingMode; + + qreal initialVelocity; + qreal trackVelocity; + + QDeclarativeProperty target; + + int duration() const; + void restart(); + void init(); + +protected: + virtual void updateCurrentTime(int); + virtual void updateState(QAbstractAnimation::State, QAbstractAnimation::State); + +private: + qreal easeFollow(qreal); + qreal initialValue; + + bool invert; + + int finalDuration; + + // Parameters for use in updateCurrentTime() + qreal a; // Acceleration + qreal d; // Deceleration + qreal tf; // Total time + qreal tp; // Time at which peak velocity occurs + qreal td; // Time at which decelleration begins + qreal vp; // Velocity at tp + qreal sp; // Displacement at tp + qreal sd; // Displacement at td + qreal vi; // "Normalized" initialvelocity + qreal s; // Total s + + int lastTime; + + bool recalc(); + void delayedStop(); + + QTimer delayedStopTimer; +}; + +class QDeclarative1SmoothedAnimationPrivate : public QDeclarative1PropertyAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1SmoothedAnimation) +public: + QDeclarative1SmoothedAnimationPrivate(); + void updateRunningAnimations(); + + QParallelAnimationGroup *wrapperGroup; + QSmoothedAnimation_1 *anim; + QHash activeAnimations; +}; + +QT_END_NAMESPACE + +#endif // QDECLARATIVESMOOTHEDANIMATION_P_H diff --git a/src/qtquick1/util/qdeclarativespringanimation.cpp b/src/qtquick1/util/qdeclarativespringanimation.cpp new file mode 100644 index 0000000000..8afa5e7840 --- /dev/null +++ b/src/qtquick1/util/qdeclarativespringanimation.cpp @@ -0,0 +1,466 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativespringanimation_p.h" + +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" +#include + +#include + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + + + + +class QDeclarative1SpringAnimationPrivate : public QDeclarative1PropertyAnimationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1SpringAnimation) +public: + + + struct SpringAnimation { + SpringAnimation() + : currentValue(0), to(0), velocity(0), start(0), duration(0) {} + qreal currentValue; + qreal to; + qreal velocity; + int start; + int duration; + }; + QHash activeAnimations; + + qreal maxVelocity; + qreal velocityms; + int lastTime; + qreal mass; + qreal spring; + qreal damping; + qreal epsilon; + qreal modulus; + + bool useMass : 1; + bool haveModulus : 1; + + enum Mode { + Track, + Velocity, + Spring + }; + Mode mode; + + QDeclarative1SpringAnimationPrivate() + : maxVelocity(0), velocityms(0), lastTime(0) + , mass(1.0), spring(0.), damping(0.), epsilon(0.01) + , modulus(0.0), useMass(false), haveModulus(false) + , mode(Track), clock(0) + { } + + void tick(int time); + bool animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed); + void updateMode(); + + typedef QTickAnimationProxy_1 Clock; + Clock *clock; +}; + +void QDeclarative1SpringAnimationPrivate::tick(int time) +{ + if (mode == Track) { + clock->stop(); + return; + } + int elapsed = time - lastTime; + if (!elapsed) + return; + + if (mode == Spring) { + if (elapsed < 16) // capped at 62fps. + return; + int count = elapsed / 16; + lastTime = time - (elapsed - count * 16); + } else { + lastTime = time; + } + + QMutableHashIterator it(activeAnimations); + while (it.hasNext()) { + it.next(); + if (animate(it.key(), it.value(), elapsed)) + it.remove(); + } + + if (activeAnimations.isEmpty()) + clock->stop(); +} + +bool QDeclarative1SpringAnimationPrivate::animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed) +{ + qreal srcVal = animation.to; + + bool stop = false; + + if (haveModulus) { + animation.currentValue = fmod(animation.currentValue, modulus); + srcVal = fmod(srcVal, modulus); + } + if (mode == Spring) { + // Real men solve the spring DEs using RK4. + // We'll do something much simpler which gives a result that looks fine. + int count = elapsed / 16; + for (int i = 0; i < count; ++i) { + qreal diff = srcVal - animation.currentValue; + if (haveModulus && qAbs(diff) > modulus / 2) { + if (diff < 0) + diff += modulus; + else + diff -= modulus; + } + if (useMass) + animation.velocity = animation.velocity + (spring * diff - damping * animation.velocity) / mass; + else + animation.velocity = animation.velocity + spring * diff - damping * animation.velocity; + if (maxVelocity > 0.) { + // limit velocity + if (animation.velocity > maxVelocity) + animation.velocity = maxVelocity; + else if (animation.velocity < -maxVelocity) + animation.velocity = -maxVelocity; + } + animation.currentValue += animation.velocity * 16.0 / 1000.0; + if (haveModulus) { + animation.currentValue = fmod(animation.currentValue, modulus); + if (animation.currentValue < 0.0) + animation.currentValue += modulus; + } + } + if (qAbs(animation.velocity) < epsilon && qAbs(srcVal - animation.currentValue) < epsilon) { + animation.velocity = 0.0; + animation.currentValue = srcVal; + stop = true; + } + } else { + qreal moveBy = elapsed * velocityms; + qreal diff = srcVal - animation.currentValue; + if (haveModulus && qAbs(diff) > modulus / 2) { + if (diff < 0) + diff += modulus; + else + diff -= modulus; + } + if (diff > 0) { + animation.currentValue += moveBy; + if (haveModulus) + animation.currentValue = fmod(animation.currentValue, modulus); + } else { + animation.currentValue -= moveBy; + if (haveModulus && animation.currentValue < 0.0) + animation.currentValue = fmod(animation.currentValue, modulus) + modulus; + } + if (lastTime - animation.start >= animation.duration) { + animation.currentValue = animation.to; + stop = true; + } + } + + qreal old_to = animation.to; + + QDeclarativePropertyPrivate::write(property, animation.currentValue, + QDeclarativePropertyPrivate::BypassInterceptor | + QDeclarativePropertyPrivate::DontRemoveBinding); + + return (stop && old_to == animation.to); // do not stop if we got restarted +} + +void QDeclarative1SpringAnimationPrivate::updateMode() +{ + if (spring == 0. && maxVelocity == 0.) + mode = Track; + else if (spring > 0.) + mode = Spring; + else { + mode = Velocity; + QHash::iterator it; + for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) { + SpringAnimation &animation = *it; + animation.start = lastTime; + qreal dist = qAbs(animation.currentValue - animation.to); + if (haveModulus && dist > modulus / 2) + dist = modulus - fmod(dist, modulus); + animation.duration = dist / velocityms; + } + } +} + +/*! + \qmlclass SpringAnimation QDeclarative1SpringAnimation + \ingroup qml-animation-transition + \inherits NumberAnimation + \since 4.7 + + \brief The SpringAnimation element allows a property to track a value in a spring-like motion. + + SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to + control the acceleration and the \l damping to control how quickly the effect dies away. + + You can also limit the maximum \l velocity of the animation. + + The following \l Rectangle moves to the position of the mouse using a + SpringAnimation when the mouse is clicked. The use of the \l Behavior + on the \c x and \c y values indicates that whenever these values are + changed, a SpringAnimation should be applied. + + \snippet doc/src/snippets/declarative/springanimation.qml 0 + + Like any other animation element, a SpringAnimation can be applied in a + number of ways, including transitions, behaviors and property value + sources. The \l {QML Animation and Transitions} documentation shows a + variety of methods for creating animations. + + \sa SmoothedAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example} +*/ + +QDeclarative1SpringAnimation::QDeclarative1SpringAnimation(QObject *parent) +: QDeclarative1NumberAnimation(*(new QDeclarative1SpringAnimationPrivate),parent) +{ + Q_D(QDeclarative1SpringAnimation); + d->clock = new QDeclarative1SpringAnimationPrivate::Clock(d, this); +} + +QDeclarative1SpringAnimation::~QDeclarative1SpringAnimation() +{ +} + +/*! + \qmlproperty real SpringAnimation::velocity + + This property holds the maximum velocity allowed when tracking the source. + + The default value is 0 (no maximum velocity). +*/ + +qreal QDeclarative1SpringAnimation::velocity() const +{ + Q_D(const QDeclarative1SpringAnimation); + return d->maxVelocity; +} + +void QDeclarative1SpringAnimation::setVelocity(qreal velocity) +{ + Q_D(QDeclarative1SpringAnimation); + d->maxVelocity = velocity; + d->velocityms = velocity / 1000.0; + d->updateMode(); +} + +/*! + \qmlproperty real SpringAnimation::spring + + This property describes how strongly the target is pulled towards the + source. The default value is 0 (that is, the spring-like motion is disabled). + + The useful value range is 0 - 5.0. + + When this property is set and the \l velocity value is greater than 0, + the \l velocity limits the maximum speed. +*/ +qreal QDeclarative1SpringAnimation::spring() const +{ + Q_D(const QDeclarative1SpringAnimation); + return d->spring; +} + +void QDeclarative1SpringAnimation::setSpring(qreal spring) +{ + Q_D(QDeclarative1SpringAnimation); + d->spring = spring; + d->updateMode(); +} + +/*! + \qmlproperty real SpringAnimation::damping + This property holds the spring damping value. + + This value describes how quickly the spring-like motion comes to rest. + The default value is 0. + + The useful value range is 0 - 1.0. The lower the value, the faster it + comes to rest. +*/ +qreal QDeclarative1SpringAnimation::damping() const +{ + Q_D(const QDeclarative1SpringAnimation); + return d->damping; +} + +void QDeclarative1SpringAnimation::setDamping(qreal damping) +{ + Q_D(QDeclarative1SpringAnimation); + if (damping > 1.) + damping = 1.; + + d->damping = damping; +} + + +/*! + \qmlproperty real SpringAnimation::epsilon + This property holds the spring epsilon. + + The epsilon is the rate and amount of change in the value which is close enough + to 0 to be considered equal to zero. This will depend on the usage of the value. + For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice. + + The default is 0.01. Tuning this value can provide small performance improvements. +*/ +qreal QDeclarative1SpringAnimation::epsilon() const +{ + Q_D(const QDeclarative1SpringAnimation); + return d->epsilon; +} + +void QDeclarative1SpringAnimation::setEpsilon(qreal epsilon) +{ + Q_D(QDeclarative1SpringAnimation); + d->epsilon = epsilon; +} + +/*! + \qmlproperty real SpringAnimation::modulus + This property holds the modulus value. The default value is 0. + + Setting a \a modulus forces the target value to "wrap around" at the modulus. + For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10. +*/ +qreal QDeclarative1SpringAnimation::modulus() const +{ + Q_D(const QDeclarative1SpringAnimation); + return d->modulus; +} + +void QDeclarative1SpringAnimation::setModulus(qreal modulus) +{ + Q_D(QDeclarative1SpringAnimation); + if (d->modulus != modulus) { + d->haveModulus = modulus != 0.0; + d->modulus = modulus; + d->updateMode(); + emit modulusChanged(); + } +} + +/*! + \qmlproperty real SpringAnimation::mass + This property holds the "mass" of the property being moved. + + The value is 1.0 by default. + + A greater mass causes slower movement and a greater spring-like + motion when an item comes to rest. +*/ +qreal QDeclarative1SpringAnimation::mass() const +{ + Q_D(const QDeclarative1SpringAnimation); + return d->mass; +} + +void QDeclarative1SpringAnimation::setMass(qreal mass) +{ + Q_D(QDeclarative1SpringAnimation); + if (d->mass != mass && mass > 0.0) { + d->useMass = mass != 1.0; + d->mass = mass; + emit massChanged(); + } +} + +void QDeclarative1SpringAnimation::transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction) +{ + Q_D(QDeclarative1SpringAnimation); + Q_UNUSED(direction); + + if (d->clock->state() != QAbstractAnimation::Running) { + d->lastTime = 0; + } + + QDeclarative1NumberAnimation::transition(actions, modified, direction); + + if (!d->actions) + return; + + if (!d->actions->isEmpty()) { + for (int i = 0; i < d->actions->size(); ++i) { + const QDeclarativeProperty &property = d->actions->at(i).property; + QDeclarative1SpringAnimationPrivate::SpringAnimation &animation + = d->activeAnimations[property]; + animation.to = d->actions->at(i).toValue.toReal(); + animation.start = d->lastTime; + if (d->fromIsDefined) + animation.currentValue = d->actions->at(i).fromValue.toReal(); + else + animation.currentValue = property.read().toReal(); + if (d->mode == QDeclarative1SpringAnimationPrivate::Velocity) { + qreal dist = qAbs(animation.currentValue - animation.to); + if (d->haveModulus && dist > d->modulus / 2) + dist = d->modulus - fmod(dist, d->modulus); + animation.duration = dist / d->velocityms; + } + } + } +} + + +QAbstractAnimation *QDeclarative1SpringAnimation::qtAnimation() +{ + Q_D(QDeclarative1SpringAnimation); + return d->clock; +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativespringanimation_p.h b/src/qtquick1/util/qdeclarativespringanimation_p.h new file mode 100644 index 0000000000..2eb3f3772c --- /dev/null +++ b/src/qtquick1/util/qdeclarativespringanimation_p.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESPRINGANIMATION_H +#define QDECLARATIVESPRINGANIMATION_H + +#include +#include "QtQuick1/private/qdeclarativeanimation_p.h" + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1SpringAnimationPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1SpringAnimation : public QDeclarative1NumberAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1SpringAnimation) + Q_INTERFACES(QDeclarativePropertyValueSource) + + Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity) + Q_PROPERTY(qreal spring READ spring WRITE setSpring) + Q_PROPERTY(qreal damping READ damping WRITE setDamping) + Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon) + Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged) + Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged) + +public: + QDeclarative1SpringAnimation(QObject *parent=0); + ~QDeclarative1SpringAnimation(); + + qreal velocity() const; + void setVelocity(qreal velocity); + + qreal spring() const; + void setSpring(qreal spring); + + qreal damping() const; + void setDamping(qreal damping); + + qreal epsilon() const; + void setEpsilon(qreal epsilon); + + qreal mass() const; + void setMass(qreal modulus); + + qreal modulus() const; + void setModulus(qreal modulus); + + virtual void transition(QDeclarative1StateActions &actions, + QDeclarativeProperties &modified, + TransitionDirection direction); + +protected: + virtual QAbstractAnimation *qtAnimation(); + +Q_SIGNALS: + void modulusChanged(); + void massChanged(); + void syncChanged(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1SpringAnimation) + +QT_END_HEADER + +#endif // QDECLARATIVESPRINGANIMATION_H diff --git a/src/qtquick1/util/qdeclarativestate.cpp b/src/qtquick1/util/qdeclarativestate.cpp new file mode 100644 index 0000000000..de6fcd0d86 --- /dev/null +++ b/src/qtquick1/util/qdeclarativestate.cpp @@ -0,0 +1,734 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativestate_p_p.h" +#include "QtQuick1/private/qdeclarativestate_p.h" + +#include "QtQuick1/private/qdeclarativetransition_p.h" +#include "QtQuick1/private/qdeclarativestategroup_p.h" +#include "QtQuick1/private/qdeclarativestateoperations_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + + +DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); + +QDeclarative1Action::QDeclarative1Action() +: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), event(0), + specifiedObject(0) +{ +} + +QDeclarative1Action::QDeclarative1Action(QObject *target, const QString &propertyName, + const QVariant &value) +: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), + property(target, propertyName, qmlEngine(target)), toValue(value), + fromBinding(0), event(0), + specifiedObject(target), specifiedProperty(propertyName) +{ + if (property.isValid()) + fromValue = property.read(); +} + +QDeclarative1Action::QDeclarative1Action(QObject *target, const QString &propertyName, + QDeclarativeContext *context, const QVariant &value) +: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), + property(target, propertyName, context), toValue(value), + fromBinding(0), event(0), + specifiedObject(target), specifiedProperty(propertyName) +{ + if (property.isValid()) + fromValue = property.read(); +} + + +QDeclarative1ActionEvent::~QDeclarative1ActionEvent() +{ +} + +QString QDeclarative1ActionEvent::typeName() const +{ + return QString(); +} + +void QDeclarative1ActionEvent::execute(Reason) +{ +} + +bool QDeclarative1ActionEvent::isReversable() +{ + return false; +} + +void QDeclarative1ActionEvent::reverse(Reason) +{ +} + +bool QDeclarative1ActionEvent::changesBindings() +{ + return false; +} + +void QDeclarative1ActionEvent::clearBindings() +{ +} + +bool QDeclarative1ActionEvent::override(QDeclarative1ActionEvent *other) +{ + Q_UNUSED(other); + return false; +} + +QDeclarative1StateOperation::QDeclarative1StateOperation(QObjectPrivate &dd, QObject *parent) + : QObject(dd, parent) +{ +} + +/*! + \qmlclass State QDeclarative1State + \ingroup qml-state-elements + \since 4.7 + \brief The State element defines configurations of objects and properties. + + A \e state is a set of batched changes from the default configuration. + + All items have a default state that defines the default configuration of objects + and property values. New states can be defined by adding State items to the \l {Item::states}{states} property to + allow items to switch between different configurations. These configurations + can, for example, be used to apply different sets of property values or execute + different scripts. + + The following example displays a single \l Rectangle. In the default state, the rectangle + is colored black. In the "clicked" state, a PropertyChanges element changes the + rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state + between the default state and the "clicked" state, thus toggling the color of the + rectangle between black and red. + + \snippet doc/src/snippets/declarative/state.qml 0 + + Notice the default state is referred to using an empty string (""). + + States are commonly used together with \l{QML Animation and Transitions}{Transitions} to provide + animations when state changes occur. + + \note Setting the state of an object from within another state of the same object is + not allowed. + + \sa {declarative/animation/states}{states example}, {qmlstates}{States}, + {QML Animation and Transitions}{Transitions}, QtDeclarative +*/ +QDeclarative1State::QDeclarative1State(QObject *parent) +: QObject(*(new QDeclarative1StatePrivate), parent) +{ + Q_D(QDeclarative1State); + d->transitionManager.setState(this); +} + +QDeclarative1State::~QDeclarative1State() +{ + Q_D(QDeclarative1State); + if (d->group) + d->group->removeState(this); +} + +/*! + \qmlproperty string State::name + This property holds the name of the state. + + Each state should have a unique name within its item. +*/ +QString QDeclarative1State::name() const +{ + Q_D(const QDeclarative1State); + return d->name; +} + +void QDeclarative1State::setName(const QString &n) +{ + Q_D(QDeclarative1State); + d->name = n; + d->named = true; +} + +bool QDeclarative1State::isNamed() const +{ + Q_D(const QDeclarative1State); + return d->named; +} + +bool QDeclarative1State::isWhenKnown() const +{ + Q_D(const QDeclarative1State); + return d->when != 0; +} + +/*! + \qmlproperty bool State::when + This property holds when the state should be applied. + + This should be set to an expression that evaluates to \c true when you want the state to + be applied. For example, the following \l Rectangle changes in and out of the "hidden" + state when the \l MouseArea is pressed: + + \snippet doc/src/snippets/declarative/state-when.qml 0 + + If multiple states in a group have \c when clauses that evaluate to \c true + at the same time, the first matching state will be applied. For example, in + the following snippet \c state1 will always be selected rather than + \c state2 when sharedCondition becomes \c true. + \qml + Item { + states: [ + State { name: "state1"; when: sharedCondition }, + State { name: "state2"; when: sharedCondition } + ] + // ... + } + \endqml +*/ +QDeclarativeBinding *QDeclarative1State::when() const +{ + Q_D(const QDeclarative1State); + return d->when; +} + +void QDeclarative1State::setWhen(QDeclarativeBinding *when) +{ + Q_D(QDeclarative1State); + d->when = when; + if (d->group) + d->group->updateAutoState(); +} + +/*! + \qmlproperty string State::extend + This property holds the state that this state extends. + + When a state extends another state, it inherits all the changes of that state. + + The state being extended is treated as the base state in regards to + the changes specified by the extending state. +*/ +QString QDeclarative1State::extends() const +{ + Q_D(const QDeclarative1State); + return d->extends; +} + +void QDeclarative1State::setExtends(const QString &extends) +{ + Q_D(QDeclarative1State); + d->extends = extends; +} + +/*! + \qmlproperty list State::changes + This property holds the changes to apply for this state + \default + + By default these changes are applied against the default state. If the state + extends another state, then the changes are applied against the state being + extended. +*/ +QDeclarativeListProperty QDeclarative1State::changes() +{ + Q_D(QDeclarative1State); + return QDeclarativeListProperty(this, &d->operations, QDeclarative1StatePrivate::operations_append, + QDeclarative1StatePrivate::operations_count, QDeclarative1StatePrivate::operations_at, + QDeclarative1StatePrivate::operations_clear); +} + +int QDeclarative1State::operationCount() const +{ + Q_D(const QDeclarative1State); + return d->operations.count(); +} + +QDeclarative1StateOperation *QDeclarative1State::operationAt(int index) const +{ + Q_D(const QDeclarative1State); + return d->operations.at(index); +} + +QDeclarative1State &QDeclarative1State::operator<<(QDeclarative1StateOperation *op) +{ + Q_D(QDeclarative1State); + d->operations.append(QDeclarative1StatePrivate::OperationGuard(op, &d->operations)); + return *this; +} + +void QDeclarative1StatePrivate::complete() +{ + Q_Q(QDeclarative1State); + + for (int ii = 0; ii < reverting.count(); ++ii) { + for (int jj = 0; jj < revertList.count(); ++jj) { + if (revertList.at(jj).property() == reverting.at(ii)) { + revertList.removeAt(jj); + break; + } + } + } + reverting.clear(); + + emit q->completed(); +} + +// Generate a list of actions for this state. This includes coelescing state +// actions that this state "extends" +QDeclarative1StateOperation::ActionList +QDeclarative1StatePrivate::generateActionList(QDeclarative1StateGroup *group) const +{ + QDeclarative1StateOperation::ActionList applyList; + if (inState) + return applyList; + + // Prevent "extends" recursion + inState = true; + + if (!extends.isEmpty()) { + QList states = group->states(); + for (int ii = 0; ii < states.count(); ++ii) + if (states.at(ii)->name() == extends) { + qmlExecuteDeferred(states.at(ii)); + applyList = static_cast(states.at(ii)->d_func())->generateActionList(group); + } + } + + foreach(QDeclarative1StateOperation *op, operations) + applyList << op->actions(); + + inState = false; + return applyList; +} + +QDeclarative1StateGroup *QDeclarative1State::stateGroup() const +{ + Q_D(const QDeclarative1State); + return d->group; +} + +void QDeclarative1State::setStateGroup(QDeclarative1StateGroup *group) +{ + Q_D(QDeclarative1State); + d->group = group; +} + +void QDeclarative1State::cancel() +{ + Q_D(QDeclarative1State); + d->transitionManager.cancel(); +} + +void QDeclarative1Action::deleteFromBinding() +{ + if (fromBinding) { + QDeclarativePropertyPrivate::setBinding(property, 0); + fromBinding->destroy(); + fromBinding = 0; + } +} + +bool QDeclarative1State::containsPropertyInRevertList(QObject *target, const QString &name) const +{ + Q_D(const QDeclarative1State); + + if (isStateActive()) { + QListIterator revertListIterator(d->revertList); + + while (revertListIterator.hasNext()) { + const QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); + if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) + return true; + } + } + + return false; +} + +bool QDeclarative1State::changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue) +{ + Q_D(QDeclarative1State); + + if (isStateActive()) { + QMutableListIterator revertListIterator(d->revertList); + + while (revertListIterator.hasNext()) { + QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); + if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) { + simpleAction.setValue(revertValue); + return true; + } + } + } + + return false; +} + +bool QDeclarative1State::changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding) +{ + Q_D(QDeclarative1State); + + if (isStateActive()) { + QMutableListIterator revertListIterator(d->revertList); + + while (revertListIterator.hasNext()) { + QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); + if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) { + if (simpleAction.binding()) + simpleAction.binding()->destroy(); + + simpleAction.setBinding(binding); + return true; + } + } + } + + return false; +} + +bool QDeclarative1State::removeEntryFromRevertList(QObject *target, const QString &name) +{ + Q_D(QDeclarative1State); + + if (isStateActive()) { + QMutableListIterator revertListIterator(d->revertList); + + while (revertListIterator.hasNext()) { + QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); + if (simpleAction.property().object() == target && simpleAction.property().name() == name) { + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property()); + if (oldBinding) { + QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0); + oldBinding->destroy(); + } + + simpleAction.property().write(simpleAction.value()); + if (simpleAction.binding()) + QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding()); + + revertListIterator.remove(); + return true; + } + } + } + + return false; +} + +void QDeclarative1State::addEntryToRevertList(const QDeclarative1Action &action) +{ + Q_D(QDeclarative1State); + + QDeclarative1SimpleAction simpleAction(action); + + d->revertList.append(simpleAction); +} + +void QDeclarative1State::removeAllEntriesFromRevertList(QObject *target) +{ + Q_D(QDeclarative1State); + + if (isStateActive()) { + QMutableListIterator revertListIterator(d->revertList); + + while (revertListIterator.hasNext()) { + QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); + if (simpleAction.property().object() == target) { + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property()); + if (oldBinding) { + QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0); + oldBinding->destroy(); + } + + simpleAction.property().write(simpleAction.value()); + if (simpleAction.binding()) + QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding()); + + revertListIterator.remove(); + } + } + } +} + +void QDeclarative1State::addEntriesToRevertList(const QList &actionList) +{ + Q_D(QDeclarative1State); + if (isStateActive()) { + QList simpleActionList; + + QListIterator actionListIterator(actionList); + while(actionListIterator.hasNext()) { + const QDeclarative1Action &action = actionListIterator.next(); + QDeclarative1SimpleAction simpleAction(action); + action.property.write(action.toValue); + if (!action.toBinding.isNull()) { + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property()); + if (oldBinding) + QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0); + QDeclarativePropertyPrivate::setBinding(simpleAction.property(), action.toBinding.data(), QDeclarativePropertyPrivate::DontRemoveBinding); + } + + simpleActionList.append(simpleAction); + } + + d->revertList.append(simpleActionList); + } +} + +QVariant QDeclarative1State::valueInRevertList(QObject *target, const QString &name) const +{ + Q_D(const QDeclarative1State); + + if (isStateActive()) { + QListIterator revertListIterator(d->revertList); + + while (revertListIterator.hasNext()) { + const QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); + if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) + return simpleAction.value(); + } + } + + return QVariant(); +} + +QDeclarativeAbstractBinding *QDeclarative1State::bindingInRevertList(QObject *target, const QString &name) const +{ + Q_D(const QDeclarative1State); + + if (isStateActive()) { + QListIterator revertListIterator(d->revertList); + + while (revertListIterator.hasNext()) { + const QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); + if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) + return simpleAction.binding(); + } + } + + return 0; +} + +bool QDeclarative1State::isStateActive() const +{ + return stateGroup() && stateGroup()->state() == name(); +} + +void QDeclarative1State::apply(QDeclarative1StateGroup *group, QDeclarative1Transition *trans, QDeclarative1State *revert) +{ + Q_D(QDeclarative1State); + + qmlExecuteDeferred(this); + + cancel(); + if (revert) + revert->cancel(); + d->revertList.clear(); + d->reverting.clear(); + + if (revert) { + QDeclarative1StatePrivate *revertPrivate = + static_cast(revert->d_func()); + d->revertList = revertPrivate->revertList; + revertPrivate->revertList.clear(); + } + + // List of actions caused by this state + QDeclarative1StateOperation::ActionList applyList = d->generateActionList(group); + + // List of actions that need to be reverted to roll back (just) this state + QDeclarative1StatePrivate::SimpleActionList additionalReverts; + // First add the reverse of all the applyList actions + for (int ii = 0; ii < applyList.count(); ++ii) { + QDeclarative1Action &action = applyList[ii]; + + if (action.event) { + if (!action.event->isReversable()) + continue; + bool found = false; + for (int jj = 0; jj < d->revertList.count(); ++jj) { + QDeclarative1ActionEvent *event = d->revertList.at(jj).event(); + if (event && event->typeName() == action.event->typeName()) { + if (action.event->override(event)) { + found = true; + + if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) { + action.event->copyOriginals(d->revertList.at(jj).event()); + + QDeclarative1SimpleAction r(action); + additionalReverts << r; + d->revertList.removeAt(jj); + --jj; + } else if (action.event->isRewindable()) //###why needed? + action.event->saveCurrentValues(); + + break; + } + } + } + if (!found) { + action.event->saveOriginals(); + // Only need to revert the applyList action if the previous + // state doesn't have a higher priority revert already + QDeclarative1SimpleAction r(action); + additionalReverts << r; + } + } else { + bool found = false; + action.fromBinding = QDeclarativePropertyPrivate::binding(action.property); + + for (int jj = 0; jj < d->revertList.count(); ++jj) { + if (d->revertList.at(jj).property() == action.property) { + found = true; + if (d->revertList.at(jj).binding() != action.fromBinding) { + action.deleteFromBinding(); + } + break; + } + } + + if (!found) { + if (!action.restore) { + action.deleteFromBinding();; + } else { + // Only need to revert the applyList action if the previous + // state doesn't have a higher priority revert already + QDeclarative1SimpleAction r(action); + additionalReverts << r; + } + } + } + } + + // Any reverts from a previous state that aren't carried forth + // into this state need to be translated into apply actions + for (int ii = 0; ii < d->revertList.count(); ++ii) { + bool found = false; + if (d->revertList.at(ii).event()) { + QDeclarative1ActionEvent *event = d->revertList.at(ii).event(); + if (!event->isReversable()) + continue; + for (int jj = 0; !found && jj < applyList.count(); ++jj) { + const QDeclarative1Action &action = applyList.at(jj); + if (action.event && action.event->typeName() == event->typeName()) { + if (action.event->override(event)) + found = true; + } + } + } else { + for (int jj = 0; !found && jj < applyList.count(); ++jj) { + const QDeclarative1Action &action = applyList.at(jj); + if (action.property == d->revertList.at(ii).property()) + found = true; + } + } + if (!found) { + QVariant cur = d->revertList.at(ii).property().read(); + QDeclarativeAbstractBinding *delBinding = + QDeclarativePropertyPrivate::setBinding(d->revertList.at(ii).property(), 0); + if (delBinding) + delBinding->destroy(); + + QDeclarative1Action a; + a.property = d->revertList.at(ii).property(); + a.fromValue = cur; + a.toValue = d->revertList.at(ii).value(); + a.toBinding = QDeclarativeAbstractBinding::getPointer(d->revertList.at(ii).binding()); + a.specifiedObject = d->revertList.at(ii).specifiedObject(); + a.specifiedProperty = d->revertList.at(ii).specifiedProperty(); + a.event = d->revertList.at(ii).event(); + a.reverseEvent = d->revertList.at(ii).reverseEvent(); + if (a.event && a.event->isRewindable()) + a.event->saveCurrentValues(); + applyList << a; + // Store these special reverts in the reverting list + d->reverting << d->revertList.at(ii).property(); + } + } + // All the local reverts now become part of the ongoing revertList + d->revertList << additionalReverts; + +#ifndef QT_NO_DEBUG_STREAM + // Output for debugging + if (stateChangeDebug()) { + foreach(const QDeclarative1Action &action, applyList) { + if (action.event) + qWarning() << " QDeclarative1Action event:" << action.event->typeName(); + else + qWarning() << " QDeclarative1Action:" << action.property.object() + << action.property.name() << "From:" << action.fromValue + << "To:" << action.toValue; + } + } +#endif + + d->transitionManager.transition(applyList, trans); +} + +QDeclarative1StateOperation::ActionList QDeclarative1StateOperation::actions() +{ + return ActionList(); +} + +QDeclarative1State *QDeclarative1StateOperation::state() const +{ + Q_D(const QDeclarative1StateOperation); + return d->m_state; +} + +void QDeclarative1StateOperation::setState(QDeclarative1State *state) +{ + Q_D(QDeclarative1StateOperation); + d->m_state = state; +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativestate_p.h b/src/qtquick1/util/qdeclarativestate_p.h new file mode 100644 index 0000000000..fcfa2efead --- /dev/null +++ b/src/qtquick1/util/qdeclarativestate_p.h @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESTATE_H +#define QDECLARATIVESTATE_H + +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QDeclarativeAbstractBinding; +class QDeclarativeBinding; +class QDeclarativeExpression; + +QT_MODULE(Declarative) + +class QDeclarative1ActionEvent; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Action +{ +public: + QDeclarative1Action(); + QDeclarative1Action(QObject *, const QString &, const QVariant &); + QDeclarative1Action(QObject *, const QString &, + QDeclarativeContext *, const QVariant &); + + bool restore:1; + bool actionDone:1; + bool reverseEvent:1; + bool deletableToBinding:1; + + QDeclarativeProperty property; + QVariant fromValue; + QVariant toValue; + + QDeclarativeAbstractBinding *fromBinding; + QWeakPointer toBinding; + QDeclarative1ActionEvent *event; + + //strictly for matching + QObject *specifiedObject; + QString specifiedProperty; + + void deleteFromBinding(); +}; + +class Q_AUTOTEST_EXPORT QDeclarative1ActionEvent +{ +public: + virtual ~QDeclarative1ActionEvent(); + virtual QString typeName() const; + + enum Reason { ActualChange, FastForward }; + + virtual void execute(Reason reason = ActualChange); + virtual bool isReversable(); + virtual void reverse(Reason reason = ActualChange); + virtual void saveOriginals() {} + virtual bool needsCopy() { return false; } + virtual void copyOriginals(QDeclarative1ActionEvent *) {} + + virtual bool isRewindable() { return isReversable(); } + virtual void rewind() {} + virtual void saveCurrentValues() {} + virtual void saveTargetValues() {} + + virtual bool changesBindings(); + virtual void clearBindings(); + virtual bool override(QDeclarative1ActionEvent*other); +}; + +//### rename to QDeclarative1StateChange? +class QDeclarative1StateGroup; +class QDeclarative1State; +class QDeclarative1StateOperationPrivate; +class Q_DECLARATIVE_EXPORT QDeclarative1StateOperation : public QObject +{ + Q_OBJECT +public: + QDeclarative1StateOperation(QObject *parent = 0) + : QObject(parent) {} + typedef QList ActionList; + + virtual ActionList actions(); + + QDeclarative1State *state() const; + void setState(QDeclarative1State *state); + +protected: + QDeclarative1StateOperation(QObjectPrivate &dd, QObject *parent = 0); + +private: + Q_DECLARE_PRIVATE(QDeclarative1StateOperation) + Q_DISABLE_COPY(QDeclarative1StateOperation) +}; + +typedef QDeclarative1StateOperation::ActionList QDeclarative1StateActions; + +class QDeclarative1Transition; +class QDeclarative1StatePrivate; +class Q_DECLARATIVE_EXPORT QDeclarative1State : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen) + Q_PROPERTY(QString extend READ extends WRITE setExtends) + Q_PROPERTY(QDeclarativeListProperty changes READ changes) + Q_CLASSINFO("DefaultProperty", "changes") + Q_CLASSINFO("DeferredPropertyNames", "changes") + +public: + QDeclarative1State(QObject *parent=0); + virtual ~QDeclarative1State(); + + QString name() const; + void setName(const QString &); + bool isNamed() const; + + /*'when' is a QDeclarativeBinding to limit state changes oscillation + due to the unpredictable order of evaluation of bound expressions*/ + bool isWhenKnown() const; + QDeclarativeBinding *when() const; + void setWhen(QDeclarativeBinding *); + + QString extends() const; + void setExtends(const QString &); + + QDeclarativeListProperty changes(); + int operationCount() const; + QDeclarative1StateOperation *operationAt(int) const; + + QDeclarative1State &operator<<(QDeclarative1StateOperation *); + + void apply(QDeclarative1StateGroup *, QDeclarative1Transition *, QDeclarative1State *revert); + void cancel(); + + QDeclarative1StateGroup *stateGroup() const; + void setStateGroup(QDeclarative1StateGroup *); + + bool containsPropertyInRevertList(QObject *target, const QString &name) const; + bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue); + bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding); + bool removeEntryFromRevertList(QObject *target, const QString &name); + void addEntryToRevertList(const QDeclarative1Action &action); + void removeAllEntriesFromRevertList(QObject *target); + void addEntriesToRevertList(const QList &actions); + QVariant valueInRevertList(QObject *target, const QString &name) const; + QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const; + + bool isStateActive() const; + +Q_SIGNALS: + void completed(); + +private: + Q_DECLARE_PRIVATE(QDeclarative1State) + Q_DISABLE_COPY(QDeclarative1State) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1StateOperation) +QML_DECLARE_TYPE(QDeclarative1State) + +QT_END_HEADER + +#endif // QDECLARATIVESTATE_H diff --git a/src/qtquick1/util/qdeclarativestate_p_p.h b/src/qtquick1/util/qdeclarativestate_p_p.h new file mode 100644 index 0000000000..cf3fbd2299 --- /dev/null +++ b/src/qtquick1/util/qdeclarativestate_p_p.h @@ -0,0 +1,253 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESTATE_P_H +#define QDECLARATIVESTATE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtQuick1/private/qdeclarativestate_p.h" + +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" +#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" + +#include +#include + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QDeclarative1SimpleAction +{ +public: + enum State { StartState, EndState }; + QDeclarative1SimpleAction(const QDeclarative1Action &a, State state = StartState) + { + m_property = a.property; + m_specifiedObject = a.specifiedObject; + m_specifiedProperty = a.specifiedProperty; + m_event = a.event; + if (state == StartState) { + m_value = a.fromValue; + if (QDeclarativePropertyPrivate::binding(m_property)) { + m_binding = QDeclarativeAbstractBinding::getPointer(QDeclarativePropertyPrivate::binding(m_property)); + } + m_reverseEvent = true; + } else { + m_value = a.toValue; + m_binding = a.toBinding; + m_reverseEvent = false; + } + } + + ~QDeclarative1SimpleAction() + { + } + + QDeclarative1SimpleAction(const QDeclarative1SimpleAction &other) + : m_property(other.m_property), + m_value(other.m_value), + m_binding(QDeclarativeAbstractBinding::getPointer(other.binding())), + m_specifiedObject(other.m_specifiedObject), + m_specifiedProperty(other.m_specifiedProperty), + m_event(other.m_event), + m_reverseEvent(other.m_reverseEvent) + { + } + + QDeclarative1SimpleAction &operator =(const QDeclarative1SimpleAction &other) + { + m_property = other.m_property; + m_value = other.m_value; + m_binding = QDeclarativeAbstractBinding::getPointer(other.binding()); + m_specifiedObject = other.m_specifiedObject; + m_specifiedProperty = other.m_specifiedProperty; + m_event = other.m_event; + m_reverseEvent = other.m_reverseEvent; + + return *this; + } + + void setProperty(const QDeclarativeProperty &property) + { + m_property = property; + } + + const QDeclarativeProperty &property() const + { + return m_property; + } + + void setValue(const QVariant &value) + { + m_value = value; + } + + const QVariant &value() const + { + return m_value; + } + + void setBinding(QDeclarativeAbstractBinding *binding) + { + m_binding = QDeclarativeAbstractBinding::getPointer(binding); + } + + QDeclarativeAbstractBinding *binding() const + { + return m_binding.data(); + } + + QObject *specifiedObject() const + { + return m_specifiedObject; + } + + const QString &specifiedProperty() const + { + return m_specifiedProperty; + } + + QDeclarative1ActionEvent *event() const + { + return m_event; + } + + bool reverseEvent() const + { + return m_reverseEvent; + } + +private: + QDeclarativeProperty m_property; + QVariant m_value; + QDeclarativeAbstractBinding::Pointer m_binding; + QObject *m_specifiedObject; + QString m_specifiedProperty; + QDeclarative1ActionEvent *m_event; + bool m_reverseEvent; +}; + +class QDeclarative1StateOperationPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1StateOperation) + +public: + + QDeclarative1StateOperationPrivate() + : m_state(0) {} + + QDeclarative1State *m_state; +}; + +class QDeclarative1StatePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1State) + +public: + QDeclarative1StatePrivate() + : when(0), named(false), inState(false), group(0) {} + + typedef QList SimpleActionList; + + QString name; + QDeclarativeBinding *when; + bool named; + + struct OperationGuard : public QDeclarativeGuard + { + OperationGuard(QObject *obj, QList *l) : list(l) { (QDeclarativeGuard&)*this = obj; } + QList *list; + void objectDestroyed(QDeclarative1StateOperation *) { + // we assume priv will always be destroyed after objectDestroyed calls + list->removeOne(*this); + } + }; + QList operations; + + static void operations_append(QDeclarativeListProperty *prop, QDeclarative1StateOperation *op) { + QList *list = static_cast *>(prop->data); + op->setState(qobject_cast(prop->object)); + list->append(OperationGuard(op, list)); + } + static void operations_clear(QDeclarativeListProperty *prop) { + QList *list = static_cast *>(prop->data); + QMutableListIterator listIterator(*list); + while(listIterator.hasNext()) + listIterator.next()->setState(0); + list->clear(); + } + static int operations_count(QDeclarativeListProperty *prop) { + QList *list = static_cast *>(prop->data); + return list->count(); + } + static QDeclarative1StateOperation *operations_at(QDeclarativeListProperty *prop, int index) { + QList *list = static_cast *>(prop->data); + return list->at(index); + } + + QDeclarative1TransitionManager transitionManager; + + SimpleActionList revertList; + QList reverting; + QString extends; + mutable bool inState; + QDeclarative1StateGroup *group; + + QDeclarative1StateOperation::ActionList generateActionList(QDeclarative1StateGroup *) const; + void complete(); +}; + +QT_END_NAMESPACE + +#endif // QDECLARATIVESTATE_P_H diff --git a/src/qtquick1/util/qdeclarativestategroup.cpp b/src/qtquick1/util/qdeclarativestategroup.cpp new file mode 100644 index 0000000000..f04a8d4f03 --- /dev/null +++ b/src/qtquick1/util/qdeclarativestategroup.cpp @@ -0,0 +1,473 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativestategroup_p.h" + +#include "QtQuick1/private/qdeclarativetransition_p.h" +#include "QtQuick1/private/qdeclarativestate_p_p.h" + +#include +#include + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + + + +DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); + +class QDeclarative1StateGroupPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1StateGroup) +public: + QDeclarative1StateGroupPrivate() + : nullState(0), componentComplete(true), + ignoreTrans(false), applyingState(false), unnamedCount(0) {} + + QString currentState; + QDeclarative1State *nullState; + + static void append_state(QDeclarativeListProperty *list, QDeclarative1State *state); + static int count_state(QDeclarativeListProperty *list); + static QDeclarative1State *at_state(QDeclarativeListProperty *list, int index); + static void clear_states(QDeclarativeListProperty *list); + + QList states; + QList transitions; + + bool componentComplete; + bool ignoreTrans; + bool applyingState; + int unnamedCount; + + QDeclarative1Transition *findTransition(const QString &from, const QString &to); + void setCurrentStateInternal(const QString &state, bool = false); + bool updateAutoState(); +}; + +/*! + \qmlclass StateGroup QDeclarative1StateGroup + \ingroup qml-state-elements + \since 4.7 + \brief The StateGroup element provides state support for non-Item elements. + + Item (and all derived elements) provides built in support for states and transitions + via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to + use this support in other (non-Item-derived) elements. + + \qml + MyCustomObject { + StateGroup { + id: myStateGroup + states: State { + name: "state1" + // ... + } + transitions: Transition { + // ... + } + } + + onSomethingHappened: myStateGroup.state = "state1"; + } + \endqml + + \sa {qmlstate}{States} {QML Animation and Transitions}{Transitions}, {QtDeclarative} +*/ + +QDeclarative1StateGroup::QDeclarative1StateGroup(QObject *parent) + : QObject(*(new QDeclarative1StateGroupPrivate), parent) +{ +} + +QDeclarative1StateGroup::~QDeclarative1StateGroup() +{ + Q_D(const QDeclarative1StateGroup); + for (int i = 0; i < d->states.count(); ++i) + d->states.at(i)->setStateGroup(0); +} + +QList QDeclarative1StateGroup::states() const +{ + Q_D(const QDeclarative1StateGroup); + return d->states; +} + +/*! + \qmlproperty list StateGroup::states + This property holds a list of states defined by the state group. + + \qml + StateGroup { + states: [ + State { + // State definition... + }, + State { + // ... + } + // Other states... + ] + } + \endqml + + \sa {qmlstate}{States} +*/ +QDeclarativeListProperty QDeclarative1StateGroup::statesProperty() +{ + Q_D(QDeclarative1StateGroup); + return QDeclarativeListProperty(this, &d->states, &QDeclarative1StateGroupPrivate::append_state, + &QDeclarative1StateGroupPrivate::count_state, + &QDeclarative1StateGroupPrivate::at_state, + &QDeclarative1StateGroupPrivate::clear_states); +} + +void QDeclarative1StateGroupPrivate::append_state(QDeclarativeListProperty *list, QDeclarative1State *state) +{ + QDeclarative1StateGroup *_this = static_cast(list->object); + if (state) { + _this->d_func()->states.append(state); + state->setStateGroup(_this); + } + +} + +int QDeclarative1StateGroupPrivate::count_state(QDeclarativeListProperty *list) +{ + QDeclarative1StateGroup *_this = static_cast(list->object); + return _this->d_func()->states.count(); +} + +QDeclarative1State *QDeclarative1StateGroupPrivate::at_state(QDeclarativeListProperty *list, int index) +{ + QDeclarative1StateGroup *_this = static_cast(list->object); + return _this->d_func()->states.at(index); +} + +void QDeclarative1StateGroupPrivate::clear_states(QDeclarativeListProperty *list) +{ + QDeclarative1StateGroup *_this = static_cast(list->object); + _this->d_func()->setCurrentStateInternal(QString(), true); + for (int i = 0; i < _this->d_func()->states.count(); ++i) { + _this->d_func()->states.at(i)->setStateGroup(0); + } + _this->d_func()->states.clear(); +} + +/*! + \qmlproperty list StateGroup::transitions + This property holds a list of transitions defined by the state group. + + \qml + StateGroup { + transitions: [ + Transition { + // ... + }, + Transition { + // ... + } + // ... + ] + } + \endqml + + \sa {QML Animation and Transitions}{Transitions} +*/ +QDeclarativeListProperty QDeclarative1StateGroup::transitionsProperty() +{ + Q_D(QDeclarative1StateGroup); + return QDeclarativeListProperty(this, d->transitions); +} + +/*! + \qmlproperty string StateGroup::state + + This property holds the name of the current state of the state group. + + This property is often used in scripts to change between states. For + example: + + \js + function toggle() { + if (button.state == 'On') + button.state = 'Off'; + else + button.state = 'On'; + } + \endjs + + If the state group is in its base state (i.e. no explicit state has been + set), \c state will be a blank string. Likewise, you can return a + state group to its base state by setting its current state to \c ''. + + \sa {qmlstates}{States} +*/ +QString QDeclarative1StateGroup::state() const +{ + Q_D(const QDeclarative1StateGroup); + return d->currentState; +} + +void QDeclarative1StateGroup::setState(const QString &state) +{ + Q_D(QDeclarative1StateGroup); + if (d->currentState == state) + return; + + d->setCurrentStateInternal(state); +} + +void QDeclarative1StateGroup::classBegin() +{ + Q_D(QDeclarative1StateGroup); + d->componentComplete = false; +} + +void QDeclarative1StateGroup::componentComplete() +{ + Q_D(QDeclarative1StateGroup); + d->componentComplete = true; + + for (int ii = 0; ii < d->states.count(); ++ii) { + QDeclarative1State *state = d->states.at(ii); + if (!state->isNamed()) + state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount)); + } + + if (d->updateAutoState()) { + return; + } else if (!d->currentState.isEmpty()) { + QString cs = d->currentState; + d->currentState.clear(); + d->setCurrentStateInternal(cs, true); + } +} + +/*! + Returns true if the state was changed, otherwise false. +*/ +bool QDeclarative1StateGroup::updateAutoState() +{ + Q_D(QDeclarative1StateGroup); + return d->updateAutoState(); +} + +bool QDeclarative1StateGroupPrivate::updateAutoState() +{ + Q_Q(QDeclarative1StateGroup); + if (!componentComplete) + return false; + + bool revert = false; + for (int ii = 0; ii < states.count(); ++ii) { + QDeclarative1State *state = states.at(ii); + if (state->isWhenKnown()) { + if (state->isNamed()) { + if (state->when() && state->when()->evaluate().toBool()) { + if (stateChangeDebug()) + qWarning() << "Setting auto state due to:" + << state->when()->expression(); + if (currentState != state->name()) { + q->setState(state->name()); + return true; + } else { + return false; + } + } else if (state->name() == currentState) { + revert = true; + } + } + } + } + if (revert) { + bool rv = !currentState.isEmpty(); + q->setState(QString()); + return rv; + } else { + return false; + } +} + +QDeclarative1Transition *QDeclarative1StateGroupPrivate::findTransition(const QString &from, const QString &to) +{ + QDeclarative1Transition *highest = 0; + int score = 0; + bool reversed = false; + bool done = false; + + for (int ii = 0; !done && ii < transitions.count(); ++ii) { + QDeclarative1Transition *t = transitions.at(ii); + for (int ii = 0; ii < 2; ++ii) + { + if (ii && (!t->reversible() || + (t->fromState() == QLatin1String("*") && + t->toState() == QLatin1String("*")))) + break; + QStringList fromState; + QStringList toState; + + fromState = t->fromState().split(QLatin1Char(',')); + toState = t->toState().split(QLatin1Char(',')); + if (ii == 1) + qSwap(fromState, toState); + int tScore = 0; + if (fromState.contains(from)) + tScore += 2; + else if (fromState.contains(QLatin1String("*"))) + tScore += 1; + else + continue; + + if (toState.contains(to)) + tScore += 2; + else if (toState.contains(QLatin1String("*"))) + tScore += 1; + else + continue; + + if (ii == 1) + reversed = true; + else + reversed = false; + + if (tScore == 4) { + highest = t; + done = true; + break; + } else if (tScore > score) { + score = tScore; + highest = t; + } + } + } + + if (highest) + highest->setReversed(reversed); + + return highest; +} + +void QDeclarative1StateGroupPrivate::setCurrentStateInternal(const QString &state, + bool ignoreTrans) +{ + Q_Q(QDeclarative1StateGroup); + if (!componentComplete) { + currentState = state; + return; + } + + if (applyingState) { + qmlInfo(q) << "Can't apply a state change as part of a state definition."; + return; + } + + applyingState = true; + + QDeclarative1Transition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state); + if (stateChangeDebug()) { + qWarning() << this << "Changing state. From" << currentState << ". To" << state; + if (transition) + qWarning() << " using transition" << transition->fromState() + << transition->toState(); + } + + QDeclarative1State *oldState = 0; + if (!currentState.isEmpty()) { + for (int ii = 0; ii < states.count(); ++ii) { + if (states.at(ii)->name() == currentState) { + oldState = states.at(ii); + break; + } + } + } + + currentState = state; + emit q->stateChanged(currentState); + + QDeclarative1State *newState = 0; + for (int ii = 0; ii < states.count(); ++ii) { + if (states.at(ii)->name() == currentState) { + newState = states.at(ii); + break; + } + } + + if (oldState == 0 || newState == 0) { + if (!nullState) { nullState = new QDeclarative1State; QDeclarative_setParent_noEvent(nullState, q); } + if (!oldState) oldState = nullState; + if (!newState) newState = nullState; + } + + newState->apply(q, transition, oldState); + applyingState = false; + if (!transition) + static_cast(QObjectPrivate::get(newState))->complete(); +} + +QDeclarative1State *QDeclarative1StateGroup::findState(const QString &name) const +{ + Q_D(const QDeclarative1StateGroup); + for (int i = 0; i < d->states.count(); ++i) { + QDeclarative1State *state = d->states.at(i); + if (state->name() == name) + return state; + } + + return 0; +} + +void QDeclarative1StateGroup::removeState(QDeclarative1State *state) +{ + Q_D(QDeclarative1StateGroup); + d->states.removeOne(state); +} + + + +QT_END_NAMESPACE + + diff --git a/src/qtquick1/util/qdeclarativestategroup_p.h b/src/qtquick1/util/qdeclarativestategroup_p.h new file mode 100644 index 0000000000..e7831d4cca --- /dev/null +++ b/src/qtquick1/util/qdeclarativestategroup_p.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESTATEGROUP_H +#define QDECLARATIVESTATEGROUP_H + +#include "QtQuick1/private/qdeclarativestate_p.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + + +QT_MODULE(Declarative) + +class QDeclarative1StateGroupPrivate; +class Q_DECLARATIVE_EXPORT QDeclarative1StateGroup : public QObject, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_INTERFACES(QDeclarativeParserStatus) + Q_DECLARE_PRIVATE(QDeclarative1StateGroup) + + Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) + Q_PROPERTY(QDeclarativeListProperty states READ statesProperty DESIGNABLE false) + Q_PROPERTY(QDeclarativeListProperty transitions READ transitionsProperty DESIGNABLE false) + +public: + QDeclarative1StateGroup(QObject * = 0); + virtual ~QDeclarative1StateGroup(); + + QString state() const; + void setState(const QString &); + + QDeclarativeListProperty statesProperty(); + QList states() const; + + QDeclarativeListProperty transitionsProperty(); + + QDeclarative1State *findState(const QString &name) const; + + virtual void classBegin(); + virtual void componentComplete(); +Q_SIGNALS: + void stateChanged(const QString &); + +private: + friend class QDeclarative1State; + bool updateAutoState(); + void removeState(QDeclarative1State *state); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1StateGroup) + +QT_END_HEADER + +#endif // QDECLARATIVESTATEGROUP_H diff --git a/src/qtquick1/util/qdeclarativestateoperations.cpp b/src/qtquick1/util/qdeclarativestateoperations.cpp new file mode 100644 index 0000000000..26a8e33f6b --- /dev/null +++ b/src/qtquick1/util/qdeclarativestateoperations.cpp @@ -0,0 +1,1591 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativestateoperations_p.h" +#include "QtQuick1/private/qdeclarativeanchors_p_p.h" +#include "QtQuick1/private/qdeclarativeitem_p.h" +#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + + +class QDeclarative1ParentChangePrivate : public QDeclarative1StateOperationPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1ParentChange) +public: + QDeclarative1ParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0), + rewindParent(0), rewindStackBefore(0) {} + + QDeclarativeItem *target; + QDeclarativeGuard parent; + QDeclarativeGuard origParent; + QDeclarativeGuard origStackBefore; + QDeclarativeItem *rewindParent; + QDeclarativeItem *rewindStackBefore; + + QDeclarativeNullableValue xString; + QDeclarativeNullableValue yString; + QDeclarativeNullableValue widthString; + QDeclarativeNullableValue heightString; + QDeclarativeNullableValue scaleString; + QDeclarativeNullableValue rotationString; + + QDeclarativeNullableValue x; + QDeclarativeNullableValue y; + QDeclarativeNullableValue width; + QDeclarativeNullableValue height; + QDeclarativeNullableValue scale; + QDeclarativeNullableValue rotation; + + void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0); +}; + +void QDeclarative1ParentChangePrivate::doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore) +{ + if (targetParent && target && target->parentItem()) { + Q_Q(QDeclarative1ParentChange); + bool ok; + const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok); + if (transform.type() >= QTransform::TxShear || !ok) { + qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under complex transform"); + ok = false; + } + + qreal scale = 1; + qreal rotation = 0; + bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0); + if (ok && !isRotate) { + if (transform.m11() == transform.m22()) + scale = transform.m11(); + else { + qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under non-uniform scale"); + ok = false; + } + } else if (ok && isRotate) { + if (transform.m11() == transform.m22()) + scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); + else { + qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under non-uniform scale"); + ok = false; + } + + if (scale != 0) + rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; + else { + qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under scale of 0"); + ok = false; + } + } + + const QPointF &point = transform.map(QPointF(target->x(),target->y())); + qreal x = point.x(); + qreal y = point.y(); + + // setParentItem will update the transformOriginPoint if needed + target->setParentItem(targetParent); + + if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { + qreal tempxt = target->transformOriginPoint().x(); + qreal tempyt = target->transformOriginPoint().y(); + QTransform t; + t.translate(-tempxt, -tempyt); + t.rotate(rotation); + t.scale(scale, scale); + t.translate(tempxt, tempyt); + const QPointF &offset = t.map(QPointF(0,0)); + x += offset.x(); + y += offset.y(); + } + + if (ok) { + //qDebug() << x << y << rotation << scale; + target->setX(x); + target->setY(y); + target->setRotation(target->rotation() + rotation); + target->setScale(target->scale() * scale); + } + } else if (target) { + target->setParentItem(targetParent); + } + + //restore the original stack position. + //### if stackBefore has also been reparented this won't work + if (stackBefore) + target->stackBefore(stackBefore); +} + +/*! + \preliminary + \qmlclass ParentChange QDeclarative1ParentChange + \ingroup qml-state-elements + \brief The ParentChange element allows you to reparent an Item in a state change. + + ParentChange reparents an item while preserving its visual appearance (position, size, + rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale + the item to its final intended appearance. + + ParentChange can only preserve visual appearance if no complex transforms are involved. + More specifically, it will not work if the transform property has been set for any + items involved in the reparenting (i.e. items in the common ancestor tree + for the original and new parent). + + The example below displays a large red rectangle and a small blue rectangle, side by side. + When the \c blueRect is clicked, it changes to the "reparented" state: its parent is changed to \c redRect and it is + positioned at (10, 10) within the red rectangle, as specified in the ParentChange. + + \snippet doc/src/snippets/declarative/parentchange.qml 0 + + \image parentchange.png + + You can specify at which point in a transition you want a ParentChange to occur by + using a ParentAnimation. +*/ + + +QDeclarative1ParentChange::QDeclarative1ParentChange(QObject *parent) + : QDeclarative1StateOperation(*(new QDeclarative1ParentChangePrivate), parent) +{ +} + +QDeclarative1ParentChange::~QDeclarative1ParentChange() +{ +} + +/*! + \qmlproperty real ParentChange::x + \qmlproperty real ParentChange::y + \qmlproperty real ParentChange::width + \qmlproperty real ParentChange::height + \qmlproperty real ParentChange::scale + \qmlproperty real ParentChange::rotation + These properties hold the new position, size, scale, and rotation + for the item in this state. +*/ +QDeclarativeScriptString QDeclarative1ParentChange::x() const +{ + Q_D(const QDeclarative1ParentChange); + return d->xString.value; +} + +void tryReal(QDeclarativeNullableValue &value, const QString &string) +{ + bool ok = false; + qreal realValue = string.toFloat(&ok); + if (ok) + value = realValue; + else + value.invalidate(); +} + +void QDeclarative1ParentChange::setX(QDeclarativeScriptString x) +{ + Q_D(QDeclarative1ParentChange); + d->xString = x; + tryReal(d->x, x.script()); +} + +bool QDeclarative1ParentChange::xIsSet() const +{ + Q_D(const QDeclarative1ParentChange); + return d->xString.isValid(); +} + +QDeclarativeScriptString QDeclarative1ParentChange::y() const +{ + Q_D(const QDeclarative1ParentChange); + return d->yString.value; +} + +void QDeclarative1ParentChange::setY(QDeclarativeScriptString y) +{ + Q_D(QDeclarative1ParentChange); + d->yString = y; + tryReal(d->y, y.script()); +} + +bool QDeclarative1ParentChange::yIsSet() const +{ + Q_D(const QDeclarative1ParentChange); + return d->yString.isValid(); +} + +QDeclarativeScriptString QDeclarative1ParentChange::width() const +{ + Q_D(const QDeclarative1ParentChange); + return d->widthString.value; +} + +void QDeclarative1ParentChange::setWidth(QDeclarativeScriptString width) +{ + Q_D(QDeclarative1ParentChange); + d->widthString = width; + tryReal(d->width, width.script()); +} + +bool QDeclarative1ParentChange::widthIsSet() const +{ + Q_D(const QDeclarative1ParentChange); + return d->widthString.isValid(); +} + +QDeclarativeScriptString QDeclarative1ParentChange::height() const +{ + Q_D(const QDeclarative1ParentChange); + return d->heightString.value; +} + +void QDeclarative1ParentChange::setHeight(QDeclarativeScriptString height) +{ + Q_D(QDeclarative1ParentChange); + d->heightString = height; + tryReal(d->height, height.script()); +} + +bool QDeclarative1ParentChange::heightIsSet() const +{ + Q_D(const QDeclarative1ParentChange); + return d->heightString.isValid(); +} + +QDeclarativeScriptString QDeclarative1ParentChange::scale() const +{ + Q_D(const QDeclarative1ParentChange); + return d->scaleString.value; +} + +void QDeclarative1ParentChange::setScale(QDeclarativeScriptString scale) +{ + Q_D(QDeclarative1ParentChange); + d->scaleString = scale; + tryReal(d->scale, scale.script()); +} + +bool QDeclarative1ParentChange::scaleIsSet() const +{ + Q_D(const QDeclarative1ParentChange); + return d->scaleString.isValid(); +} + +QDeclarativeScriptString QDeclarative1ParentChange::rotation() const +{ + Q_D(const QDeclarative1ParentChange); + return d->rotationString.value; +} + +void QDeclarative1ParentChange::setRotation(QDeclarativeScriptString rotation) +{ + Q_D(QDeclarative1ParentChange); + d->rotationString = rotation; + tryReal(d->rotation, rotation.script()); +} + +bool QDeclarative1ParentChange::rotationIsSet() const +{ + Q_D(const QDeclarative1ParentChange); + return d->rotationString.isValid(); +} + +QDeclarativeItem *QDeclarative1ParentChange::originalParent() const +{ + Q_D(const QDeclarative1ParentChange); + return d->origParent; +} + +/*! + \qmlproperty Item ParentChange::target + This property holds the item to be reparented +*/ + +QDeclarativeItem *QDeclarative1ParentChange::object() const +{ + Q_D(const QDeclarative1ParentChange); + return d->target; +} + +void QDeclarative1ParentChange::setObject(QDeclarativeItem *target) +{ + Q_D(QDeclarative1ParentChange); + d->target = target; +} + +/*! + \qmlproperty Item ParentChange::parent + This property holds the new parent for the item in this state. +*/ + +QDeclarativeItem *QDeclarative1ParentChange::parent() const +{ + Q_D(const QDeclarative1ParentChange); + return d->parent; +} + +void QDeclarative1ParentChange::setParent(QDeclarativeItem *parent) +{ + Q_D(QDeclarative1ParentChange); + d->parent = parent; +} + +QDeclarative1StateOperation::ActionList QDeclarative1ParentChange::actions() +{ + Q_D(QDeclarative1ParentChange); + if (!d->target || !d->parent) + return ActionList(); + + ActionList actions; + + QDeclarative1Action a; + a.event = this; + actions << a; + + QDeclarativeContext *ctxt = qmlContext(this); + + if (d->xString.isValid()) { + if (d->x.isValid()) { + QDeclarative1Action xa(d->target, QLatin1String("x"), ctxt, d->x.value); + actions << xa; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->xString.value.script(), d->target, ctxt); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x"), ctxt)); + QDeclarative1Action xa; + xa.property = newBinding->property(); + xa.toBinding = newBinding; + xa.fromValue = xa.property.read(); + xa.deletableToBinding = true; + actions << xa; + } + } + + if (d->yString.isValid()) { + if (d->y.isValid()) { + QDeclarative1Action ya(d->target, QLatin1String("y"), ctxt, d->y.value); + actions << ya; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->yString.value.script(), d->target, ctxt); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y"), ctxt)); + QDeclarative1Action ya; + ya.property = newBinding->property(); + ya.toBinding = newBinding; + ya.fromValue = ya.property.read(); + ya.deletableToBinding = true; + actions << ya; + } + } + + if (d->scaleString.isValid()) { + if (d->scale.isValid()) { + QDeclarative1Action sa(d->target, QLatin1String("scale"), ctxt, d->scale.value); + actions << sa; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->scaleString.value.script(), d->target, ctxt); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale"), ctxt)); + QDeclarative1Action sa; + sa.property = newBinding->property(); + sa.toBinding = newBinding; + sa.fromValue = sa.property.read(); + sa.deletableToBinding = true; + actions << sa; + } + } + + if (d->rotationString.isValid()) { + if (d->rotation.isValid()) { + QDeclarative1Action ra(d->target, QLatin1String("rotation"), ctxt, d->rotation.value); + actions << ra; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->rotationString.value.script(), d->target, ctxt); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation"), ctxt)); + QDeclarative1Action ra; + ra.property = newBinding->property(); + ra.toBinding = newBinding; + ra.fromValue = ra.property.read(); + ra.deletableToBinding = true; + actions << ra; + } + } + + if (d->widthString.isValid()) { + if (d->width.isValid()) { + QDeclarative1Action wa(d->target, QLatin1String("width"), ctxt, d->width.value); + actions << wa; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->widthString.value.script(), d->target, ctxt); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width"), ctxt)); + QDeclarative1Action wa; + wa.property = newBinding->property(); + wa.toBinding = newBinding; + wa.fromValue = wa.property.read(); + wa.deletableToBinding = true; + actions << wa; + } + } + + if (d->heightString.isValid()) { + if (d->height.isValid()) { + QDeclarative1Action ha(d->target, QLatin1String("height"), ctxt, d->height.value); + actions << ha; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->heightString.value.script(), d->target, ctxt); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height"), ctxt)); + QDeclarative1Action ha; + ha.property = newBinding->property(); + ha.toBinding = newBinding; + ha.fromValue = ha.property.read(); + ha.deletableToBinding = true; + actions << ha; + } + } + + return actions; +} + +class AccessibleFxItem : public QDeclarativeItem +{ + Q_OBJECT + Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) +public: + int siblingIndex() { + Q_D(QDeclarativeItem); + return d->siblingIndex; + } +}; + +void QDeclarative1ParentChange::saveOriginals() +{ + Q_D(QDeclarative1ParentChange); + saveCurrentValues(); + d->origParent = d->rewindParent; + d->origStackBefore = d->rewindStackBefore; +} + +/*void QDeclarative1ParentChange::copyOriginals(QDeclarative1ActionEvent *other) +{ + Q_D(QDeclarative1ParentChange); + QDeclarative1ParentChange *pc = static_cast(other); + + d->origParent = pc->d_func()->rewindParent; + d->origStackBefore = pc->d_func()->rewindStackBefore; + + saveCurrentValues(); +}*/ + +void QDeclarative1ParentChange::execute(Reason) +{ + Q_D(QDeclarative1ParentChange); + d->doChange(d->parent); +} + +bool QDeclarative1ParentChange::isReversable() +{ + return true; +} + +void QDeclarative1ParentChange::reverse(Reason) +{ + Q_D(QDeclarative1ParentChange); + d->doChange(d->origParent, d->origStackBefore); +} + +QString QDeclarative1ParentChange::typeName() const +{ + return QLatin1String("ParentChange"); +} + +bool QDeclarative1ParentChange::override(QDeclarative1ActionEvent*other) +{ + Q_D(QDeclarative1ParentChange); + if (other->typeName() != QLatin1String("ParentChange")) + return false; + if (QDeclarative1ParentChange *otherPC = static_cast(other)) + return (d->target == otherPC->object()); + return false; +} + +void QDeclarative1ParentChange::saveCurrentValues() +{ + Q_D(QDeclarative1ParentChange); + if (!d->target) { + d->rewindParent = 0; + d->rewindStackBefore = 0; + return; + } + + d->rewindParent = d->target->parentItem(); + d->rewindStackBefore = 0; + + if (!d->rewindParent) + return; + + //try to determine the item's original stack position so we can restore it + int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1; + QList children = d->rewindParent->childItems(); + for (int i = 0; i < children.count(); ++i) { + QDeclarativeItem *child = qobject_cast(children.at(i)); + if (!child) + continue; + if (((AccessibleFxItem*)child)->siblingIndex() == siblingIndex) { + d->rewindStackBefore = child; + break; + } + } +} + +void QDeclarative1ParentChange::rewind() +{ + Q_D(QDeclarative1ParentChange); + d->doChange(d->rewindParent, d->rewindStackBefore); +} + +class QDeclarative1StateChangeScriptPrivate : public QDeclarative1StateOperationPrivate +{ +public: + QDeclarative1StateChangeScriptPrivate() {} + + QDeclarativeScriptString script; + QString name; +}; + +/*! + \qmlclass StateChangeScript QDeclarative1StateChangeScript + \ingroup qml-state-elements + \brief The StateChangeScript element allows you to run a script in a state. + + A StateChangeScript is run upon entering a state. You can optionally use + ScriptAction to specify the point in the transition at which + the StateChangeScript should to be run. + + \snippet snippets/declarative/states/statechangescript.qml state and transition + + \sa ScriptAction +*/ + +QDeclarative1StateChangeScript::QDeclarative1StateChangeScript(QObject *parent) +: QDeclarative1StateOperation(*(new QDeclarative1StateChangeScriptPrivate), parent) +{ +} + +QDeclarative1StateChangeScript::~QDeclarative1StateChangeScript() +{ +} + +/*! + \qmlproperty script StateChangeScript::script + This property holds the script to run when the state is current. +*/ +QDeclarativeScriptString QDeclarative1StateChangeScript::script() const +{ + Q_D(const QDeclarative1StateChangeScript); + return d->script; +} + +void QDeclarative1StateChangeScript::setScript(const QDeclarativeScriptString &s) +{ + Q_D(QDeclarative1StateChangeScript); + d->script = s; +} + +/*! + \qmlproperty string StateChangeScript::name + This property holds the name of the script. This name can be used by a + ScriptAction to target a specific script. + + \sa ScriptAction::scriptName +*/ +QString QDeclarative1StateChangeScript::name() const +{ + Q_D(const QDeclarative1StateChangeScript); + return d->name; +} + +void QDeclarative1StateChangeScript::setName(const QString &n) +{ + Q_D(QDeclarative1StateChangeScript); + d->name = n; +} + +void QDeclarative1StateChangeScript::execute(Reason) +{ + Q_D(QDeclarative1StateChangeScript); + const QString &script = d->script.script(); + if (!script.isEmpty()) { + QDeclarativeExpression expr(d->script.context(), d->script.scopeObject(), script); + QDeclarativeData *ddata = QDeclarativeData::get(this); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); + expr.evaluate(); + if (expr.hasError()) + qmlInfo(this, expr.error()); + } +} + +QDeclarative1StateChangeScript::ActionList QDeclarative1StateChangeScript::actions() +{ + ActionList rv; + QDeclarative1Action a; + a.event = this; + rv << a; + return rv; +} + +QString QDeclarative1StateChangeScript::typeName() const +{ + return QLatin1String("StateChangeScript"); +} + +/*! + \qmlclass AnchorChanges QDeclarative1AnchorChanges + \ingroup qml-state-elements + \brief The AnchorChanges element allows you to change the anchors of an item in a state. + + The AnchorChanges element is used to modify the anchors of an item in a \l State. + + AnchorChanges cannot be used to modify the margins on an item. For this, use + PropertyChanges intead. + + In the following example we change the top and bottom anchors of an item + using AnchorChanges, and the top and bottom anchor margins using + PropertyChanges: + + \snippet doc/src/snippets/declarative/anchorchanges.qml 0 + + \image anchorchanges.png + + AnchorChanges can be animated using AnchorAnimation. + \qml + //animate our anchor changes + Transition { + AnchorAnimation {} + } + \endqml + + Margin animations can be animated using NumberAnimation. + + For more information on anchors see \l {anchor-layout}{Anchor Layouts}. +*/ + +class QDeclarative1AnchorSetPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1AnchorSet) +public: + QDeclarative1AnchorSetPrivate() + : usedAnchors(0), resetAnchors(0), fill(0), + centerIn(0)/*, leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), + margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)*/ + { + } + + QDeclarative1Anchors::Anchors usedAnchors; + QDeclarative1Anchors::Anchors resetAnchors; + + QDeclarativeItem *fill; + QDeclarativeItem *centerIn; + + QDeclarativeScriptString leftScript; + QDeclarativeScriptString rightScript; + QDeclarativeScriptString topScript; + QDeclarativeScriptString bottomScript; + QDeclarativeScriptString hCenterScript; + QDeclarativeScriptString vCenterScript; + QDeclarativeScriptString baselineScript; + + /*qreal leftMargin; + qreal rightMargin; + qreal topMargin; + qreal bottomMargin; + qreal margins; + qreal vCenterOffset; + qreal hCenterOffset; + qreal baselineOffset;*/ +}; + +QDeclarative1AnchorSet::QDeclarative1AnchorSet(QObject *parent) + : QObject(*new QDeclarative1AnchorSetPrivate, parent) +{ +} + +QDeclarative1AnchorSet::~QDeclarative1AnchorSet() +{ +} + +QDeclarativeScriptString QDeclarative1AnchorSet::top() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->topScript; +} + +void QDeclarative1AnchorSet::setTop(const QDeclarativeScriptString &edge) +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors |= QDeclarative1Anchors::TopAnchor; + d->topScript = edge; + if (edge.script() == QLatin1String("undefined")) + resetTop(); +} + +void QDeclarative1AnchorSet::resetTop() +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors &= ~QDeclarative1Anchors::TopAnchor; + d->topScript = QDeclarativeScriptString(); + d->resetAnchors |= QDeclarative1Anchors::TopAnchor; +} + +QDeclarativeScriptString QDeclarative1AnchorSet::bottom() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->bottomScript; +} + +void QDeclarative1AnchorSet::setBottom(const QDeclarativeScriptString &edge) +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors |= QDeclarative1Anchors::BottomAnchor; + d->bottomScript = edge; + if (edge.script() == QLatin1String("undefined")) + resetBottom(); +} + +void QDeclarative1AnchorSet::resetBottom() +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors &= ~QDeclarative1Anchors::BottomAnchor; + d->bottomScript = QDeclarativeScriptString(); + d->resetAnchors |= QDeclarative1Anchors::BottomAnchor; +} + +QDeclarativeScriptString QDeclarative1AnchorSet::verticalCenter() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->vCenterScript; +} + +void QDeclarative1AnchorSet::setVerticalCenter(const QDeclarativeScriptString &edge) +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors |= QDeclarative1Anchors::VCenterAnchor; + d->vCenterScript = edge; + if (edge.script() == QLatin1String("undefined")) + resetVerticalCenter(); +} + +void QDeclarative1AnchorSet::resetVerticalCenter() +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors &= ~QDeclarative1Anchors::VCenterAnchor; + d->vCenterScript = QDeclarativeScriptString(); + d->resetAnchors |= QDeclarative1Anchors::VCenterAnchor; +} + +QDeclarativeScriptString QDeclarative1AnchorSet::baseline() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->baselineScript; +} + +void QDeclarative1AnchorSet::setBaseline(const QDeclarativeScriptString &edge) +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors |= QDeclarative1Anchors::BaselineAnchor; + d->baselineScript = edge; + if (edge.script() == QLatin1String("undefined")) + resetBaseline(); +} + +void QDeclarative1AnchorSet::resetBaseline() +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors &= ~QDeclarative1Anchors::BaselineAnchor; + d->baselineScript = QDeclarativeScriptString(); + d->resetAnchors |= QDeclarative1Anchors::BaselineAnchor; +} + +QDeclarativeScriptString QDeclarative1AnchorSet::left() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->leftScript; +} + +void QDeclarative1AnchorSet::setLeft(const QDeclarativeScriptString &edge) +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors |= QDeclarative1Anchors::LeftAnchor; + d->leftScript = edge; + if (edge.script() == QLatin1String("undefined")) + resetLeft(); +} + +void QDeclarative1AnchorSet::resetLeft() +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors &= ~QDeclarative1Anchors::LeftAnchor; + d->leftScript = QDeclarativeScriptString(); + d->resetAnchors |= QDeclarative1Anchors::LeftAnchor; +} + +QDeclarativeScriptString QDeclarative1AnchorSet::right() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->rightScript; +} + +void QDeclarative1AnchorSet::setRight(const QDeclarativeScriptString &edge) +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors |= QDeclarative1Anchors::RightAnchor; + d->rightScript = edge; + if (edge.script() == QLatin1String("undefined")) + resetRight(); +} + +void QDeclarative1AnchorSet::resetRight() +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors &= ~QDeclarative1Anchors::RightAnchor; + d->rightScript = QDeclarativeScriptString(); + d->resetAnchors |= QDeclarative1Anchors::RightAnchor; +} + +QDeclarativeScriptString QDeclarative1AnchorSet::horizontalCenter() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->hCenterScript; +} + +void QDeclarative1AnchorSet::setHorizontalCenter(const QDeclarativeScriptString &edge) +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors |= QDeclarative1Anchors::HCenterAnchor; + d->hCenterScript = edge; + if (edge.script() == QLatin1String("undefined")) + resetHorizontalCenter(); +} + +void QDeclarative1AnchorSet::resetHorizontalCenter() +{ + Q_D(QDeclarative1AnchorSet); + d->usedAnchors &= ~QDeclarative1Anchors::HCenterAnchor; + d->hCenterScript = QDeclarativeScriptString(); + d->resetAnchors |= QDeclarative1Anchors::HCenterAnchor; +} + +QDeclarativeItem *QDeclarative1AnchorSet::fill() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->fill; +} + +void QDeclarative1AnchorSet::setFill(QDeclarativeItem *f) +{ + Q_D(QDeclarative1AnchorSet); + d->fill = f; +} + +void QDeclarative1AnchorSet::resetFill() +{ + setFill(0); +} + +QDeclarativeItem *QDeclarative1AnchorSet::centerIn() const +{ + Q_D(const QDeclarative1AnchorSet); + return d->centerIn; +} + +void QDeclarative1AnchorSet::setCenterIn(QDeclarativeItem* c) +{ + Q_D(QDeclarative1AnchorSet); + d->centerIn = c; +} + +void QDeclarative1AnchorSet::resetCenterIn() +{ + setCenterIn(0); +} + + +class QDeclarative1AnchorChangesPrivate : public QDeclarative1StateOperationPrivate +{ +public: + QDeclarative1AnchorChangesPrivate() + : target(0), anchorSet(new QDeclarative1AnchorSet), + leftBinding(0), rightBinding(0), hCenterBinding(0), + topBinding(0), bottomBinding(0), vCenterBinding(0), baselineBinding(0), + origLeftBinding(0), origRightBinding(0), origHCenterBinding(0), + origTopBinding(0), origBottomBinding(0), origVCenterBinding(0), + origBaselineBinding(0) + { + + } + ~QDeclarative1AnchorChangesPrivate() { delete anchorSet; } + + QDeclarativeItem *target; + QDeclarative1AnchorSet *anchorSet; + + QDeclarativeBinding *leftBinding; + QDeclarativeBinding *rightBinding; + QDeclarativeBinding *hCenterBinding; + QDeclarativeBinding *topBinding; + QDeclarativeBinding *bottomBinding; + QDeclarativeBinding *vCenterBinding; + QDeclarativeBinding *baselineBinding; + + QDeclarativeAbstractBinding *origLeftBinding; + QDeclarativeAbstractBinding *origRightBinding; + QDeclarativeAbstractBinding *origHCenterBinding; + QDeclarativeAbstractBinding *origTopBinding; + QDeclarativeAbstractBinding *origBottomBinding; + QDeclarativeAbstractBinding *origVCenterBinding; + QDeclarativeAbstractBinding *origBaselineBinding; + + QDeclarative1AnchorLine rewindLeft; + QDeclarative1AnchorLine rewindRight; + QDeclarative1AnchorLine rewindHCenter; + QDeclarative1AnchorLine rewindTop; + QDeclarative1AnchorLine rewindBottom; + QDeclarative1AnchorLine rewindVCenter; + QDeclarative1AnchorLine rewindBaseline; + + qreal fromX; + qreal fromY; + qreal fromWidth; + qreal fromHeight; + + qreal toX; + qreal toY; + qreal toWidth; + qreal toHeight; + + qreal rewindX; + qreal rewindY; + qreal rewindWidth; + qreal rewindHeight; + + bool applyOrigLeft; + bool applyOrigRight; + bool applyOrigHCenter; + bool applyOrigTop; + bool applyOrigBottom; + bool applyOrigVCenter; + bool applyOrigBaseline; + + QDeclarativeNullableValue origWidth; + QDeclarativeNullableValue origHeight; + qreal origX; + qreal origY; + + QList oldBindings; + + QDeclarativeProperty leftProp; + QDeclarativeProperty rightProp; + QDeclarativeProperty hCenterProp; + QDeclarativeProperty topProp; + QDeclarativeProperty bottomProp; + QDeclarativeProperty vCenterProp; + QDeclarativeProperty baselineProp; +}; + +/*! + \qmlproperty Item AnchorChanges::target + This property holds the \l Item for which the anchor changes will be applied. +*/ + +QDeclarative1AnchorChanges::QDeclarative1AnchorChanges(QObject *parent) + : QDeclarative1StateOperation(*(new QDeclarative1AnchorChangesPrivate), parent) +{ +} + +QDeclarative1AnchorChanges::~QDeclarative1AnchorChanges() +{ +} + +QDeclarative1AnchorChanges::ActionList QDeclarative1AnchorChanges::actions() +{ + Q_D(QDeclarative1AnchorChanges); + d->leftBinding = d->rightBinding = d->hCenterBinding = d->topBinding + = d->bottomBinding = d->vCenterBinding = d->baselineBinding = 0; + + d->leftProp = QDeclarativeProperty(d->target, QLatin1String("anchors.left")); + d->rightProp = QDeclarativeProperty(d->target, QLatin1String("anchors.right")); + d->hCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.horizontalCenter")); + d->topProp = QDeclarativeProperty(d->target, QLatin1String("anchors.top")); + d->bottomProp = QDeclarativeProperty(d->target, QLatin1String("anchors.bottom")); + d->vCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.verticalCenter")); + d->baselineProp = QDeclarativeProperty(d->target, QLatin1String("anchors.baseline")); + + QDeclarativeContext *ctxt = qmlContext(this); + + if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::LeftAnchor) { + d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, ctxt); + d->leftBinding->setTarget(d->leftProp); + } + if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::RightAnchor) { + d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, ctxt); + d->rightBinding->setTarget(d->rightProp); + } + if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::HCenterAnchor) { + d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, ctxt); + d->hCenterBinding->setTarget(d->hCenterProp); + } + if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::TopAnchor) { + d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, ctxt); + d->topBinding->setTarget(d->topProp); + } + if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::BottomAnchor) { + d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, ctxt); + d->bottomBinding->setTarget(d->bottomProp); + } + if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::VCenterAnchor) { + d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, ctxt); + d->vCenterBinding->setTarget(d->vCenterProp); + } + if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::BaselineAnchor) { + d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, ctxt); + d->baselineBinding->setTarget(d->baselineProp); + } + + QDeclarative1Action a; + a.event = this; + return ActionList() << a; +} + +QDeclarative1AnchorSet *QDeclarative1AnchorChanges::anchors() +{ + Q_D(QDeclarative1AnchorChanges); + return d->anchorSet; +} + +QDeclarativeItem *QDeclarative1AnchorChanges::object() const +{ + Q_D(const QDeclarative1AnchorChanges); + return d->target; +} + +void QDeclarative1AnchorChanges::setObject(QDeclarativeItem *target) +{ + Q_D(QDeclarative1AnchorChanges); + d->target = target; +} + +/*! + \qmlproperty AnchorLine AnchorChanges::anchors.left + \qmlproperty AnchorLine AnchorChanges::anchors.right + \qmlproperty AnchorLine AnchorChanges::anchors.horizontalCenter + \qmlproperty AnchorLine AnchorChanges::anchors.top + \qmlproperty AnchorLine AnchorChanges::anchors.bottom + \qmlproperty AnchorLine AnchorChanges::anchors.verticalCenter + \qmlproperty AnchorLine AnchorChanges::anchors.baseline + + These properties change the respective anchors of the item. + + To reset an anchor you can assign \c undefined: + \qml + AnchorChanges { + target: myItem + anchors.left: undefined //remove myItem's left anchor + anchors.right: otherItem.right + } + \endqml +*/ + +void QDeclarative1AnchorChanges::execute(Reason reason) +{ + Q_D(QDeclarative1AnchorChanges); + if (!d->target) + return; + + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + //incorporate any needed "reverts" + if (d->applyOrigLeft) { + if (!d->origLeftBinding) + targetPrivate->anchors()->resetLeft(); + QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); + } + if (d->applyOrigRight) { + if (!d->origRightBinding) + targetPrivate->anchors()->resetRight(); + QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); + } + if (d->applyOrigHCenter) { + if (!d->origHCenterBinding) + targetPrivate->anchors()->resetHorizontalCenter(); + QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); + } + if (d->applyOrigTop) { + if (!d->origTopBinding) + targetPrivate->anchors()->resetTop(); + QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); + } + if (d->applyOrigBottom) { + if (!d->origBottomBinding) + targetPrivate->anchors()->resetBottom(); + QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); + } + if (d->applyOrigVCenter) { + if (!d->origVCenterBinding) + targetPrivate->anchors()->resetVerticalCenter(); + QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); + } + if (d->applyOrigBaseline) { + if (!d->origBaselineBinding) + targetPrivate->anchors()->resetBaseline(); + QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); + } + + //destroy old bindings + if (reason == ActualChange) { + for (int i = 0; i < d->oldBindings.size(); ++i) { + QDeclarativeAbstractBinding *binding = d->oldBindings.at(i); + if (binding) + binding->destroy(); + } + d->oldBindings.clear(); + } + + //reset any anchors that have been specified as "undefined" + if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::LeftAnchor) { + targetPrivate->anchors()->resetLeft(); + QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); + } + if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::RightAnchor) { + targetPrivate->anchors()->resetRight(); + QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); + } + if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::HCenterAnchor) { + targetPrivate->anchors()->resetHorizontalCenter(); + QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); + } + if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::TopAnchor) { + targetPrivate->anchors()->resetTop(); + QDeclarativePropertyPrivate::setBinding(d->topProp, 0); + } + if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::BottomAnchor) { + targetPrivate->anchors()->resetBottom(); + QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); + } + if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::VCenterAnchor) { + targetPrivate->anchors()->resetVerticalCenter(); + QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); + } + if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::BaselineAnchor) { + targetPrivate->anchors()->resetBaseline(); + QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); + } + + //set any anchors that have been specified + if (d->leftBinding) + QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), d->leftBinding); + if (d->rightBinding) + QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), d->rightBinding); + if (d->hCenterBinding) + QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), d->hCenterBinding); + if (d->topBinding) + QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), d->topBinding); + if (d->bottomBinding) + QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), d->bottomBinding); + if (d->vCenterBinding) + QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), d->vCenterBinding); + if (d->baselineBinding) + QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), d->baselineBinding); +} + +bool QDeclarative1AnchorChanges::isReversable() +{ + return true; +} + +void QDeclarative1AnchorChanges::reverse(Reason reason) +{ + Q_D(QDeclarative1AnchorChanges); + if (!d->target) + return; + + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + //reset any anchors set by the state + if (d->leftBinding) { + targetPrivate->anchors()->resetLeft(); + QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0); + if (reason == ActualChange) { + d->leftBinding->destroy(); d->leftBinding = 0; + } + } + if (d->rightBinding) { + targetPrivate->anchors()->resetRight(); + QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0); + if (reason == ActualChange) { + d->rightBinding->destroy(); d->rightBinding = 0; + } + } + if (d->hCenterBinding) { + targetPrivate->anchors()->resetHorizontalCenter(); + QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0); + if (reason == ActualChange) { + d->hCenterBinding->destroy(); d->hCenterBinding = 0; + } + } + if (d->topBinding) { + targetPrivate->anchors()->resetTop(); + QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0); + if (reason == ActualChange) { + d->topBinding->destroy(); d->topBinding = 0; + } + } + if (d->bottomBinding) { + targetPrivate->anchors()->resetBottom(); + QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0); + if (reason == ActualChange) { + d->bottomBinding->destroy(); d->bottomBinding = 0; + } + } + if (d->vCenterBinding) { + targetPrivate->anchors()->resetVerticalCenter(); + QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0); + if (reason == ActualChange) { + d->vCenterBinding->destroy(); d->vCenterBinding = 0; + } + } + if (d->baselineBinding) { + targetPrivate->anchors()->resetBaseline(); + QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0); + if (reason == ActualChange) { + d->baselineBinding->destroy(); d->baselineBinding = 0; + } + } + + //restore previous anchors + if (d->origLeftBinding) + QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); + if (d->origRightBinding) + QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); + if (d->origHCenterBinding) + QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); + if (d->origTopBinding) + QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); + if (d->origBottomBinding) + QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); + if (d->origVCenterBinding) + QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); + if (d->origBaselineBinding) + QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); + + //restore any absolute geometry changed by the state's anchors + QDeclarative1Anchors::Anchors stateVAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::Vertical_Mask; + QDeclarative1Anchors::Anchors origVAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarative1Anchors::Vertical_Mask; + QDeclarative1Anchors::Anchors stateHAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::Horizontal_Mask; + QDeclarative1Anchors::Anchors origHAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarative1Anchors::Horizontal_Mask; + + bool stateSetWidth = (stateHAnchors && + stateHAnchors != QDeclarative1Anchors::LeftAnchor && + stateHAnchors != QDeclarative1Anchors::RightAnchor && + stateHAnchors != QDeclarative1Anchors::HCenterAnchor); + bool origSetWidth = (origHAnchors && + origHAnchors != QDeclarative1Anchors::LeftAnchor && + origHAnchors != QDeclarative1Anchors::RightAnchor && + origHAnchors != QDeclarative1Anchors::HCenterAnchor); + if (d->origWidth.isValid() && stateSetWidth && !origSetWidth) + d->target->setWidth(d->origWidth.value); + + bool stateSetHeight = (stateVAnchors && + stateVAnchors != QDeclarative1Anchors::TopAnchor && + stateVAnchors != QDeclarative1Anchors::BottomAnchor && + stateVAnchors != QDeclarative1Anchors::VCenterAnchor && + stateVAnchors != QDeclarative1Anchors::BaselineAnchor); + bool origSetHeight = (origVAnchors && + origVAnchors != QDeclarative1Anchors::TopAnchor && + origVAnchors != QDeclarative1Anchors::BottomAnchor && + origVAnchors != QDeclarative1Anchors::VCenterAnchor && + origVAnchors != QDeclarative1Anchors::BaselineAnchor); + if (d->origHeight.isValid() && stateSetHeight && !origSetHeight) + d->target->setHeight(d->origHeight.value); + + if (stateHAnchors && !origHAnchors) + d->target->setX(d->origX); + + if (stateVAnchors && !origVAnchors) + d->target->setY(d->origY); +} + +QString QDeclarative1AnchorChanges::typeName() const +{ + return QLatin1String("AnchorChanges"); +} + +QList QDeclarative1AnchorChanges::additionalActions() +{ + Q_D(QDeclarative1AnchorChanges); + QList extra; + + QDeclarative1Anchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors; + bool hChange = combined & QDeclarative1Anchors::Horizontal_Mask; + bool vChange = combined & QDeclarative1Anchors::Vertical_Mask; + + if (d->target) { + QDeclarativeContext *ctxt = qmlContext(this); + QDeclarative1Action a; + if (hChange && d->fromX != d->toX) { + a.property = QDeclarativeProperty(d->target, QLatin1String("x"), ctxt); + a.toValue = d->toX; + extra << a; + } + if (vChange && d->fromY != d->toY) { + a.property = QDeclarativeProperty(d->target, QLatin1String("y"), ctxt); + a.toValue = d->toY; + extra << a; + } + if (hChange && d->fromWidth != d->toWidth) { + a.property = QDeclarativeProperty(d->target, QLatin1String("width"), ctxt); + a.toValue = d->toWidth; + extra << a; + } + if (vChange && d->fromHeight != d->toHeight) { + a.property = QDeclarativeProperty(d->target, QLatin1String("height"), ctxt); + a.toValue = d->toHeight; + extra << a; + } + } + + return extra; +} + +bool QDeclarative1AnchorChanges::changesBindings() +{ + return true; +} + +void QDeclarative1AnchorChanges::saveOriginals() +{ + Q_D(QDeclarative1AnchorChanges); + if (!d->target) + return; + + d->origLeftBinding = QDeclarativePropertyPrivate::binding(d->leftProp); + d->origRightBinding = QDeclarativePropertyPrivate::binding(d->rightProp); + d->origHCenterBinding = QDeclarativePropertyPrivate::binding(d->hCenterProp); + d->origTopBinding = QDeclarativePropertyPrivate::binding(d->topProp); + d->origBottomBinding = QDeclarativePropertyPrivate::binding(d->bottomProp); + d->origVCenterBinding = QDeclarativePropertyPrivate::binding(d->vCenterProp); + d->origBaselineBinding = QDeclarativePropertyPrivate::binding(d->baselineProp); + + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + if (targetPrivate->widthValid) + d->origWidth = d->target->width(); + if (targetPrivate->heightValid) + d->origHeight = d->target->height(); + d->origX = d->target->x(); + d->origY = d->target->y(); + + d->applyOrigLeft = d->applyOrigRight = d->applyOrigHCenter = d->applyOrigTop + = d->applyOrigBottom = d->applyOrigVCenter = d->applyOrigBaseline = false; + + saveCurrentValues(); +} + +void QDeclarative1AnchorChanges::copyOriginals(QDeclarative1ActionEvent *other) +{ + Q_D(QDeclarative1AnchorChanges); + QDeclarative1AnchorChanges *ac = static_cast(other); + QDeclarative1AnchorChangesPrivate *acp = ac->d_func(); + + QDeclarative1Anchors::Anchors combined = acp->anchorSet->d_func()->usedAnchors | + acp->anchorSet->d_func()->resetAnchors; + + //probably also need to revert some things + d->applyOrigLeft = (combined & QDeclarative1Anchors::LeftAnchor); + d->applyOrigRight = (combined & QDeclarative1Anchors::RightAnchor); + d->applyOrigHCenter = (combined & QDeclarative1Anchors::HCenterAnchor); + d->applyOrigTop = (combined & QDeclarative1Anchors::TopAnchor); + d->applyOrigBottom = (combined & QDeclarative1Anchors::BottomAnchor); + d->applyOrigVCenter = (combined & QDeclarative1Anchors::VCenterAnchor); + d->applyOrigBaseline = (combined & QDeclarative1Anchors::BaselineAnchor); + + d->origLeftBinding = acp->origLeftBinding; + d->origRightBinding = acp->origRightBinding; + d->origHCenterBinding = acp->origHCenterBinding; + d->origTopBinding = acp->origTopBinding; + d->origBottomBinding = acp->origBottomBinding; + d->origVCenterBinding = acp->origVCenterBinding; + d->origBaselineBinding = acp->origBaselineBinding; + + d->origWidth = acp->origWidth; + d->origHeight = acp->origHeight; + d->origX = acp->origX; + d->origY = acp->origY; + + d->oldBindings.clear(); + d->oldBindings << acp->leftBinding << acp->rightBinding << acp->hCenterBinding + << acp->topBinding << acp->bottomBinding << acp->baselineBinding; + + saveCurrentValues(); +} + +void QDeclarative1AnchorChanges::clearBindings() +{ + Q_D(QDeclarative1AnchorChanges); + if (!d->target) + return; + + //### should this (saving "from" values) be moved to saveCurrentValues()? + d->fromX = d->target->x(); + d->fromY = d->target->y(); + d->fromWidth = d->target->width(); + d->fromHeight = d->target->height(); + + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + //reset any anchors with corresponding reverts + //reset any anchors that have been specified as "undefined" + //reset any anchors that we'll be setting in the state + QDeclarative1Anchors::Anchors combined = d->anchorSet->d_func()->resetAnchors | + d->anchorSet->d_func()->usedAnchors; + if (d->applyOrigLeft || (combined & QDeclarative1Anchors::LeftAnchor)) { + targetPrivate->anchors()->resetLeft(); + QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); + } + if (d->applyOrigRight || (combined & QDeclarative1Anchors::RightAnchor)) { + targetPrivate->anchors()->resetRight(); + QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); + } + if (d->applyOrigHCenter || (combined & QDeclarative1Anchors::HCenterAnchor)) { + targetPrivate->anchors()->resetHorizontalCenter(); + QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); + } + if (d->applyOrigTop || (combined & QDeclarative1Anchors::TopAnchor)) { + targetPrivate->anchors()->resetTop(); + QDeclarativePropertyPrivate::setBinding(d->topProp, 0); + } + if (d->applyOrigBottom || (combined & QDeclarative1Anchors::BottomAnchor)) { + targetPrivate->anchors()->resetBottom(); + QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); + } + if (d->applyOrigVCenter || (combined & QDeclarative1Anchors::VCenterAnchor)) { + targetPrivate->anchors()->resetVerticalCenter(); + QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); + } + if (d->applyOrigBaseline || (combined & QDeclarative1Anchors::BaselineAnchor)) { + targetPrivate->anchors()->resetBaseline(); + QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); + } +} + +bool QDeclarative1AnchorChanges::override(QDeclarative1ActionEvent*other) +{ + if (other->typeName() != QLatin1String("AnchorChanges")) + return false; + if (static_cast(this) == other) + return true; + if (static_cast(other)->object() == object()) + return true; + return false; +} + +void QDeclarative1AnchorChanges::rewind() +{ + Q_D(QDeclarative1AnchorChanges); + if (!d->target) + return; + + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + + //restore previous values (but not previous bindings, i.e. anchors) + d->target->setX(d->rewindX); + d->target->setY(d->rewindY); + if (targetPrivate->widthValid) { + d->target->setWidth(d->rewindWidth); + } + if (targetPrivate->heightValid) { + d->target->setHeight(d->rewindHeight); + } +} + +void QDeclarative1AnchorChanges::saveCurrentValues() +{ + Q_D(QDeclarative1AnchorChanges); + if (!d->target) + return; + + QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); + d->rewindLeft = targetPrivate->anchors()->left(); + d->rewindRight = targetPrivate->anchors()->right(); + d->rewindHCenter = targetPrivate->anchors()->horizontalCenter(); + d->rewindTop = targetPrivate->anchors()->top(); + d->rewindBottom = targetPrivate->anchors()->bottom(); + d->rewindVCenter = targetPrivate->anchors()->verticalCenter(); + d->rewindBaseline = targetPrivate->anchors()->baseline(); + + d->rewindX = d->target->x(); + d->rewindY = d->target->y(); + d->rewindWidth = d->target->width(); + d->rewindHeight = d->target->height(); +} + +void QDeclarative1AnchorChanges::saveTargetValues() +{ + Q_D(QDeclarative1AnchorChanges); + if (!d->target) + return; + + d->toX = d->target->x(); + d->toY = d->target->y(); + d->toWidth = d->target->width(); + d->toHeight = d->target->height(); +} + +#include +#include + + + +QT_END_NAMESPACE + diff --git a/src/qtquick1/util/qdeclarativestateoperations_p.h b/src/qtquick1/util/qdeclarativestateoperations_p.h new file mode 100644 index 0000000000..7d0b618c3b --- /dev/null +++ b/src/qtquick1/util/qdeclarativestateoperations_p.h @@ -0,0 +1,299 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESTATEOPERATIONS_H +#define QDECLARATIVESTATEOPERATIONS_H + +#include "QtQuick1/private/qdeclarativestate_p.h" + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1ParentChangePrivate; +class Q_AUTOTEST_EXPORT QDeclarative1ParentChange : public QDeclarative1StateOperation, public QDeclarative1ActionEvent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1ParentChange) + + Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) + Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) + Q_PROPERTY(QDeclarativeScriptString x READ x WRITE setX) + Q_PROPERTY(QDeclarativeScriptString y READ y WRITE setY) + Q_PROPERTY(QDeclarativeScriptString width READ width WRITE setWidth) + Q_PROPERTY(QDeclarativeScriptString height READ height WRITE setHeight) + Q_PROPERTY(QDeclarativeScriptString scale READ scale WRITE setScale) + Q_PROPERTY(QDeclarativeScriptString rotation READ rotation WRITE setRotation) +public: + QDeclarative1ParentChange(QObject *parent=0); + ~QDeclarative1ParentChange(); + + QDeclarativeItem *object() const; + void setObject(QDeclarativeItem *); + + QDeclarativeItem *parent() const; + void setParent(QDeclarativeItem *); + + QDeclarativeItem *originalParent() const; + + QDeclarativeScriptString x() const; + void setX(QDeclarativeScriptString x); + bool xIsSet() const; + + QDeclarativeScriptString y() const; + void setY(QDeclarativeScriptString y); + bool yIsSet() const; + + QDeclarativeScriptString width() const; + void setWidth(QDeclarativeScriptString width); + bool widthIsSet() const; + + QDeclarativeScriptString height() const; + void setHeight(QDeclarativeScriptString height); + bool heightIsSet() const; + + QDeclarativeScriptString scale() const; + void setScale(QDeclarativeScriptString scale); + bool scaleIsSet() const; + + QDeclarativeScriptString rotation() const; + void setRotation(QDeclarativeScriptString rotation); + bool rotationIsSet() const; + + virtual ActionList actions(); + + virtual void saveOriginals(); + //virtual void copyOriginals(QDeclarative1ActionEvent*); + virtual void execute(Reason reason = ActualChange); + virtual bool isReversable(); + virtual void reverse(Reason reason = ActualChange); + virtual QString typeName() const; + virtual bool override(QDeclarative1ActionEvent*other); + virtual void rewind(); + virtual void saveCurrentValues(); +}; + +class QDeclarative1StateChangeScriptPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1StateChangeScript : public QDeclarative1StateOperation, public QDeclarative1ActionEvent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1StateChangeScript) + + Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) + Q_PROPERTY(QString name READ name WRITE setName) + +public: + QDeclarative1StateChangeScript(QObject *parent=0); + ~QDeclarative1StateChangeScript(); + + virtual ActionList actions(); + + virtual QString typeName() const; + + QDeclarativeScriptString script() const; + void setScript(const QDeclarativeScriptString &); + + QString name() const; + void setName(const QString &); + + virtual void execute(Reason reason = ActualChange); +}; + +class QDeclarative1AnchorChanges; +class QDeclarative1AnchorSetPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1AnchorSet : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QDeclarativeScriptString left READ left WRITE setLeft RESET resetLeft) + Q_PROPERTY(QDeclarativeScriptString right READ right WRITE setRight RESET resetRight) + Q_PROPERTY(QDeclarativeScriptString horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter) + Q_PROPERTY(QDeclarativeScriptString top READ top WRITE setTop RESET resetTop) + Q_PROPERTY(QDeclarativeScriptString bottom READ bottom WRITE setBottom RESET resetBottom) + Q_PROPERTY(QDeclarativeScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) + Q_PROPERTY(QDeclarativeScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline) + //Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill) + //Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn) + + /*Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) + Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) + Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) + Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) + Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) + Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) + Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) + Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())*/ + +public: + QDeclarative1AnchorSet(QObject *parent=0); + virtual ~QDeclarative1AnchorSet(); + + QDeclarativeScriptString left() const; + void setLeft(const QDeclarativeScriptString &edge); + void resetLeft(); + + QDeclarativeScriptString right() const; + void setRight(const QDeclarativeScriptString &edge); + void resetRight(); + + QDeclarativeScriptString horizontalCenter() const; + void setHorizontalCenter(const QDeclarativeScriptString &edge); + void resetHorizontalCenter(); + + QDeclarativeScriptString top() const; + void setTop(const QDeclarativeScriptString &edge); + void resetTop(); + + QDeclarativeScriptString bottom() const; + void setBottom(const QDeclarativeScriptString &edge); + void resetBottom(); + + QDeclarativeScriptString verticalCenter() const; + void setVerticalCenter(const QDeclarativeScriptString &edge); + void resetVerticalCenter(); + + QDeclarativeScriptString baseline() const; + void setBaseline(const QDeclarativeScriptString &edge); + void resetBaseline(); + + QDeclarativeItem *fill() const; + void setFill(QDeclarativeItem *); + void resetFill(); + + QDeclarativeItem *centerIn() const; + void setCenterIn(QDeclarativeItem *); + void resetCenterIn(); + + /*qreal leftMargin() const; + void setLeftMargin(qreal); + + qreal rightMargin() const; + void setRightMargin(qreal); + + qreal horizontalCenterOffset() const; + void setHorizontalCenterOffset(qreal); + + qreal topMargin() const; + void setTopMargin(qreal); + + qreal bottomMargin() const; + void setBottomMargin(qreal); + + qreal margins() const; + void setMargins(qreal); + + qreal verticalCenterOffset() const; + void setVerticalCenterOffset(qreal); + + qreal baselineOffset() const; + void setBaselineOffset(qreal);*/ + + QDeclarative1Anchors::Anchors usedAnchors() const; + +/*Q_SIGNALS: + void leftMarginChanged(); + void rightMarginChanged(); + void topMarginChanged(); + void bottomMarginChanged(); + void marginsChanged(); + void verticalCenterOffsetChanged(); + void horizontalCenterOffsetChanged(); + void baselineOffsetChanged();*/ + +private: + friend class QDeclarative1AnchorChanges; + Q_DISABLE_COPY(QDeclarative1AnchorSet) + Q_DECLARE_PRIVATE(QDeclarative1AnchorSet) +}; + +class QDeclarative1AnchorChangesPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1AnchorChanges : public QDeclarative1StateOperation, public QDeclarative1ActionEvent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1AnchorChanges) + + Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) + Q_PROPERTY(QDeclarative1AnchorSet *anchors READ anchors CONSTANT) + +public: + QDeclarative1AnchorChanges(QObject *parent=0); + ~QDeclarative1AnchorChanges(); + + virtual ActionList actions(); + + QDeclarative1AnchorSet *anchors(); + + QDeclarativeItem *object() const; + void setObject(QDeclarativeItem *); + + virtual void execute(Reason reason = ActualChange); + virtual bool isReversable(); + virtual void reverse(Reason reason = ActualChange); + virtual QString typeName() const; + virtual bool override(QDeclarative1ActionEvent*other); + virtual bool changesBindings(); + virtual void saveOriginals(); + virtual bool needsCopy() { return true; } + virtual void copyOriginals(QDeclarative1ActionEvent*); + virtual void clearBindings(); + virtual void rewind(); + virtual void saveCurrentValues(); + + QList additionalActions(); + virtual void saveTargetValues(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1ParentChange) +QML_DECLARE_TYPE(QDeclarative1StateChangeScript) +QML_DECLARE_TYPE(QDeclarative1AnchorSet) +QML_DECLARE_TYPE(QDeclarative1AnchorChanges) + +QT_END_HEADER + +#endif // QDECLARATIVESTATEOPERATIONS_H diff --git a/src/qtquick1/util/qdeclarativestyledtext.cpp b/src/qtquick1/util/qdeclarativestyledtext.cpp new file mode 100644 index 0000000000..46d2224f5e --- /dev/null +++ b/src/qtquick1/util/qdeclarativestyledtext.cpp @@ -0,0 +1,351 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "QtQuick1/private/qdeclarativestyledtext_p.h" + +/* + QDeclarative1StyledText supports few tags: + + - bold + - italic +
- new line + + + The opening and closing tags must be correctly nested. +*/ + +QT_BEGIN_NAMESPACE + + + +class QDeclarative1StyledTextPrivate +{ +public: + QDeclarative1StyledTextPrivate(const QString &t, QTextLayout &l) : text(t), layout(l), baseFont(layout.font()) {} + + void parse(); + bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format); + bool parseCloseTag(const QChar *&ch, const QString &textIn); + void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut); + bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format); + QPair parseAttribute(const QChar *&ch, const QString &textIn); + QStringRef parseValue(const QChar *&ch, const QString &textIn); + + inline void skipSpace(const QChar *&ch) { + while (ch->isSpace() && !ch->isNull()) + ++ch; + } + + QString text; + QTextLayout &layout; + QFont baseFont; + + static const QChar lessThan; + static const QChar greaterThan; + static const QChar equals; + static const QChar singleQuote; + static const QChar doubleQuote; + static const QChar slash; + static const QChar ampersand; +}; + +const QChar QDeclarative1StyledTextPrivate::lessThan(QLatin1Char('<')); +const QChar QDeclarative1StyledTextPrivate::greaterThan(QLatin1Char('>')); +const QChar QDeclarative1StyledTextPrivate::equals(QLatin1Char('=')); +const QChar QDeclarative1StyledTextPrivate::singleQuote(QLatin1Char('\'')); +const QChar QDeclarative1StyledTextPrivate::doubleQuote(QLatin1Char('\"')); +const QChar QDeclarative1StyledTextPrivate::slash(QLatin1Char('/')); +const QChar QDeclarative1StyledTextPrivate::ampersand(QLatin1Char('&')); + +QDeclarative1StyledText::QDeclarative1StyledText(const QString &string, QTextLayout &layout) +: d(new QDeclarative1StyledTextPrivate(string, layout)) +{ +} + +QDeclarative1StyledText::~QDeclarative1StyledText() +{ + delete d; +} + +void QDeclarative1StyledText::parse(const QString &string, QTextLayout &layout) +{ + if (string.isEmpty()) + return; + QDeclarative1StyledText styledText(string, layout); + styledText.d->parse(); +} + +void QDeclarative1StyledTextPrivate::parse() +{ + QList ranges; + QStack formatStack; + + QString drawText; + drawText.reserve(text.count()); + + int textStart = 0; + int textLength = 0; + int rangeStart = 0; + const QChar *ch = text.constData(); + while (!ch->isNull()) { + if (*ch == lessThan) { + if (textLength) + drawText.append(QStringRef(&text, textStart, textLength)); + if (rangeStart != drawText.length() && formatStack.count()) { + QTextLayout::FormatRange formatRange; + formatRange.format = formatStack.top(); + formatRange.start = rangeStart; + formatRange.length = drawText.length() - rangeStart; + ranges.append(formatRange); + } + rangeStart = drawText.length(); + ++ch; + if (*ch == slash) { + ++ch; + if (parseCloseTag(ch, text)) { + if (formatStack.count()) + formatStack.pop(); + } + } else { + QTextCharFormat format; + if (formatStack.count()) + format = formatStack.top(); + if (parseTag(ch, text, drawText, format)) + formatStack.push(format); + } + textStart = ch - text.constData() + 1; + textLength = 0; + } else if (*ch == ampersand) { + ++ch; + drawText.append(QStringRef(&text, textStart, textLength)); + parseEntity(ch, text, drawText); + textStart = ch - text.constData() + 1; + textLength = 0; + } else { + ++textLength; + } + if (!ch->isNull()) + ++ch; + } + if (textLength) + drawText.append(QStringRef(&text, textStart, textLength)); + if (rangeStart != drawText.length() && formatStack.count()) { + QTextLayout::FormatRange formatRange; + formatRange.format = formatStack.top(); + formatRange.start = rangeStart; + formatRange.length = drawText.length() - rangeStart; + ranges.append(formatRange); + } + + layout.setText(drawText); + layout.setAdditionalFormats(ranges); +} + +bool QDeclarative1StyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format) +{ + skipSpace(ch); + + int tagStart = ch - textIn.constData(); + int tagLength = 0; + while (!ch->isNull()) { + if (*ch == greaterThan) { + QStringRef tag(&textIn, tagStart, tagLength); + const QChar char0 = tag.at(0); + if (char0 == QLatin1Char('b')) { + if (tagLength == 1) + format.setFontWeight(QFont::Bold); + else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) { + textOut.append(QChar(QChar::LineSeparator)); + return false; + } + } else if (char0 == QLatin1Char('i')) { + if (tagLength == 1) + format.setFontItalic(true); + } + return true; + } else if (ch->isSpace()) { + // may have params. + QStringRef tag(&textIn, tagStart, tagLength); + if (tag == QLatin1String("font")) + return parseFontAttributes(ch, textIn, format); + if (*ch == greaterThan || ch->isNull()) + continue; + } else if (*ch != slash){ + tagLength++; + } + ++ch; + } + + return false; +} + +bool QDeclarative1StyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn) +{ + skipSpace(ch); + + int tagStart = ch - textIn.constData(); + int tagLength = 0; + while (!ch->isNull()) { + if (*ch == greaterThan) { + QStringRef tag(&textIn, tagStart, tagLength); + const QChar char0 = tag.at(0); + if (char0 == QLatin1Char('b')) { + if (tagLength == 1) + return true; + else if (tag.at(1) == QLatin1Char('r') && tagLength == 2) + return true; + } else if (char0 == QLatin1Char('i')) { + if (tagLength == 1) + return true; + } else if (tag == QLatin1String("font")) { + return true; + } + return false; + } else if (!ch->isSpace()){ + tagLength++; + } + ++ch; + } + + return false; +} + +void QDeclarative1StyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut) +{ + int entityStart = ch - textIn.constData(); + int entityLength = 0; + while (!ch->isNull()) { + if (*ch == QLatin1Char(';')) { + QStringRef entity(&textIn, entityStart, entityLength); + if (entity == QLatin1String("gt")) + textOut += QChar(62); + else if (entity == QLatin1String("lt")) + textOut += QChar(60); + else if (entity == QLatin1String("amp")) + textOut += QChar(38); + return; + } + ++entityLength; + ++ch; + } +} + +bool QDeclarative1StyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format) +{ + bool valid = false; + QPair attr; + do { + attr = parseAttribute(ch, textIn); + if (attr.first == QLatin1String("color")) { + valid = true; + format.setForeground(QColor(attr.second.toString())); + } else if (attr.first == QLatin1String("size")) { + valid = true; + int size = attr.second.toString().toInt(); + if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+')) + size += 3; + if (size >= 1 && size <= 7) { + static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 }; + format.setFontPointSize(baseFont.pointSize() * scaling[size-1]); + } + } + } while (!ch->isNull() && !attr.first.isEmpty()); + + return valid; +} + +QPair QDeclarative1StyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn) +{ + skipSpace(ch); + + int attrStart = ch - textIn.constData(); + int attrLength = 0; + while (!ch->isNull()) { + if (*ch == greaterThan) { + break; + } else if (*ch == equals) { + ++ch; + if (*ch != singleQuote && *ch != doubleQuote) { + while (*ch != greaterThan && !ch->isNull()) + ++ch; + break; + } + ++ch; + if (!attrLength) + break; + QStringRef attr(&textIn, attrStart, attrLength); + QStringRef val = parseValue(ch, textIn); + if (!val.isEmpty()) + return QPair(attr,val); + break; + } else { + ++attrLength; + } + ++ch; + } + + return QPair(); +} + +QStringRef QDeclarative1StyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn) +{ + int valStart = ch - textIn.constData(); + int valLength = 0; + while (*ch != singleQuote && *ch != doubleQuote && !ch->isNull()) { + ++valLength; + ++ch; + } + if (ch->isNull()) + return QStringRef(); + ++ch; // skip quote + + return QStringRef(&textIn, valStart, valLength); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativestyledtext_p.h b/src/qtquick1/util/qdeclarativestyledtext_p.h new file mode 100644 index 0000000000..43a391a9d5 --- /dev/null +++ b/src/qtquick1/util/qdeclarativestyledtext_p.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESTYLEDTEXT_H +#define QDECLARATIVESTYLEDTEXT_H + +#include + +QT_BEGIN_NAMESPACE + +class QPainter; +class QPointF; +class QString; +class QTextLayout; + +class QDeclarative1StyledTextPrivate; + +class Q_AUTOTEST_EXPORT QDeclarative1StyledText +{ +public: + static void parse(const QString &string, QTextLayout &layout); + +private: + QDeclarative1StyledText(const QString &string, QTextLayout &layout); + ~QDeclarative1StyledText(); + + QDeclarative1StyledTextPrivate *d; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/qtquick1/util/qdeclarativesystempalette.cpp b/src/qtquick1/util/qdeclarativesystempalette.cpp new file mode 100644 index 0000000000..311a2bf16e --- /dev/null +++ b/src/qtquick1/util/qdeclarativesystempalette.cpp @@ -0,0 +1,316 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativesystempalette_p.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + + + +class QDeclarative1SystemPalettePrivate : public QObjectPrivate +{ +public: + QPalette palette; + QPalette::ColorGroup group; +}; + + + +/*! + \qmlclass SystemPalette QDeclarative1SystemPalette + \ingroup qml-utility-elements + \since 4.7 + \brief The SystemPalette element provides access to the Qt palettes. + + The SystemPalette element provides access to the Qt application + palettes. This provides information about the standard colors used + for application windows, buttons and other features. These colors + are grouped into three \e {color groups}: \c Active, \c Inactive, + and \c Disabled. See the QPalette documentation for details about + color groups and the properties provided by SystemPalette. + + This can be used to color items in a way that provides a more + native look and feel. + + The following example creates a palette from the \c Active color + group and uses this to color the window and text items + appropriately: + + \snippet doc/src/snippets/declarative/systempalette.qml 0 + + \sa QPalette +*/ +QDeclarative1SystemPalette::QDeclarative1SystemPalette(QObject *parent) + : QObject(*(new QDeclarative1SystemPalettePrivate), parent) +{ + Q_D(QDeclarative1SystemPalette); + d->palette = QApplication::palette(); + d->group = QPalette::Active; + qApp->installEventFilter(this); +} + +QDeclarative1SystemPalette::~QDeclarative1SystemPalette() +{ +} + +/*! + \qmlproperty color SystemPalette::window + The window (general background) color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::window() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Window); +} + +/*! + \qmlproperty color SystemPalette::windowText + The window text (general foreground) color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::windowText() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::WindowText); +} + +/*! + \qmlproperty color SystemPalette::base + The base color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::base() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Base); +} + +/*! + \qmlproperty color SystemPalette::text + The text color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::text() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Text); +} + +/*! + \qmlproperty color SystemPalette::alternateBase + The alternate base color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::alternateBase() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::AlternateBase); +} + +/*! + \qmlproperty color SystemPalette::button + The button color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::button() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Button); +} + +/*! + \qmlproperty color SystemPalette::buttonText + The button text foreground color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::buttonText() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::ButtonText); +} + +/*! + \qmlproperty color SystemPalette::light + The light color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::light() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Light); +} + +/*! + \qmlproperty color SystemPalette::midlight + The midlight color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::midlight() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Midlight); +} + +/*! + \qmlproperty color SystemPalette::dark + The dark color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::dark() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Dark); +} + +/*! + \qmlproperty color SystemPalette::mid + The mid color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::mid() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Mid); +} + +/*! + \qmlproperty color SystemPalette::shadow + The shadow color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::shadow() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Shadow); +} + +/*! + \qmlproperty color SystemPalette::highlight + The highlight color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::highlight() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::Highlight); +} + +/*! + \qmlproperty color SystemPalette::highlightedText + The highlighted text color of the current color group. + + \sa QPalette::ColorRole +*/ +QColor QDeclarative1SystemPalette::highlightedText() const +{ + Q_D(const QDeclarative1SystemPalette); + return d->palette.color(d->group, QPalette::HighlightedText); +} + +/*! + \qmlproperty enumeration SystemPalette::colorGroup + + The color group of the palette. This can be one of: + + \list + \o SystemPalette.Active (default) + \o SystemPalette.Inactive + \o SystemPalette.Disabled + \endlist + + \sa QPalette::ColorGroup +*/ +QDeclarative1SystemPalette::ColorGroup QDeclarative1SystemPalette::colorGroup() const +{ + Q_D(const QDeclarative1SystemPalette); + return (QDeclarative1SystemPalette::ColorGroup)d->group; +} + +void QDeclarative1SystemPalette::setColorGroup(QDeclarative1SystemPalette::ColorGroup colorGroup) +{ + Q_D(QDeclarative1SystemPalette); + d->group = (QPalette::ColorGroup)colorGroup; + emit paletteChanged(); +} + +bool QDeclarative1SystemPalette::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == qApp) { + if (event->type() == QEvent::ApplicationPaletteChange) { + QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); + return false; + } + } + return QObject::eventFilter(watched, event); +} + +bool QDeclarative1SystemPalette::event(QEvent *event) +{ + Q_D(QDeclarative1SystemPalette); + if (event->type() == QEvent::ApplicationPaletteChange) { + d->palette = QApplication::palette(); + emit paletteChanged(); + return true; + } + return QObject::event(event); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativesystempalette_p.h b/src/qtquick1/util/qdeclarativesystempalette_p.h new file mode 100644 index 0000000000..3dd1933748 --- /dev/null +++ b/src/qtquick1/util/qdeclarativesystempalette_p.h @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVESYSTEMPALETTE_H +#define QDECLARATIVESYSTEMPALETTE_H + +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1SystemPalettePrivate; +class Q_AUTOTEST_EXPORT QDeclarative1SystemPalette : public QObject +{ + Q_OBJECT + Q_ENUMS(ColorGroup) + Q_DECLARE_PRIVATE(QDeclarative1SystemPalette) + + Q_PROPERTY(QDeclarative1SystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) + Q_PROPERTY(QColor window READ window NOTIFY paletteChanged) + Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged) + Q_PROPERTY(QColor base READ base NOTIFY paletteChanged) + Q_PROPERTY(QColor text READ text NOTIFY paletteChanged) + Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged) + Q_PROPERTY(QColor button READ button NOTIFY paletteChanged) + Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged) + Q_PROPERTY(QColor light READ light NOTIFY paletteChanged) + Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged) + Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged) + Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged) + Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged) + Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged) + Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged) + +public: + QDeclarative1SystemPalette(QObject *parent=0); + ~QDeclarative1SystemPalette(); + + enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled }; + + QColor window() const; + QColor windowText() const; + + QColor base() const; + QColor text() const; + QColor alternateBase() const; + + QColor button() const; + QColor buttonText() const; + + QColor light() const; + QColor midlight() const; + QColor dark() const; + QColor mid() const; + QColor shadow() const; + + QColor highlight() const; + QColor highlightedText() const; + + QDeclarative1SystemPalette::ColorGroup colorGroup() const; + void setColorGroup(QDeclarative1SystemPalette::ColorGroup); + +Q_SIGNALS: + void paletteChanged(); + +private: + bool eventFilter(QObject *watched, QEvent *event); + bool event(QEvent *event); + +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1SystemPalette) + +QT_END_HEADER + +#endif // QDECLARATIVESYSTEMPALETTE_H diff --git a/src/qtquick1/util/qdeclarativetimeline.cpp b/src/qtquick1/util/qdeclarativetimeline.cpp new file mode 100644 index 0000000000..0b5cbc85b3 --- /dev/null +++ b/src/qtquick1/util/qdeclarativetimeline.cpp @@ -0,0 +1,951 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativetimeline_p_p.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + + + +struct Update { + Update(QDeclarative1TimeLineValue *_g, qreal _v) + : g(_g), v(_v) {} + Update(const QDeclarative1TimeLineCallback &_e) + : g(0), v(0), e(_e) {} + + QDeclarative1TimeLineValue *g; + qreal v; + QDeclarative1TimeLineCallback e; +}; + +struct QDeclarative1TimeLinePrivate +{ + QDeclarative1TimeLinePrivate(QDeclarative1TimeLine *); + + struct Op { + enum Type { + Pause, + Set, + Move, + MoveBy, + Accel, + AccelDistance, + Execute + }; + Op() {} + Op(Type t, int l, qreal v, qreal v2, int o, + const QDeclarative1TimeLineCallback &ev = QDeclarative1TimeLineCallback(), const QEasingCurve &es = QEasingCurve()) + : type(t), length(l), value(v), value2(v2), order(o), event(ev), + easing(es) {} + Op(const Op &o) + : type(o.type), length(o.length), value(o.value), value2(o.value2), + order(o.order), event(o.event), easing(o.easing) {} + Op &operator=(const Op &o) { + type = o.type; length = o.length; value = o.value; + value2 = o.value2; order = o.order; event = o.event; + easing = o.easing; + return *this; + } + + Type type; + int length; + qreal value; + qreal value2; + + int order; + QDeclarative1TimeLineCallback event; + QEasingCurve easing; + }; + struct TimeLine + { + TimeLine() : length(0), consumedOpLength(0), base(0.) {} + QList ops; + int length; + int consumedOpLength; + qreal base; + }; + + int length; + int syncPoint; + typedef QHash Ops; + Ops ops; + QDeclarative1TimeLine *q; + + void add(QDeclarative1TimeLineObject &, const Op &); + qreal value(const Op &op, int time, qreal base, bool *) const; + + int advance(int); + + bool clockRunning; + int prevTime; + + int order; + + QDeclarative1TimeLine::SyncMode syncMode; + int syncAdj; + QList > *updateQueue; +}; + +QDeclarative1TimeLinePrivate::QDeclarative1TimeLinePrivate(QDeclarative1TimeLine *parent) +: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QDeclarative1TimeLine::LocalSync), syncAdj(0), updateQueue(0) +{ +} + +void QDeclarative1TimeLinePrivate::add(QDeclarative1TimeLineObject &g, const Op &o) +{ + if (g._t && g._t != q) { + qWarning() << "QDeclarative1TimeLine: Cannot modify a QDeclarative1TimeLineValue owned by" + << "another timeline."; + return; + } + g._t = q; + + Ops::Iterator iter = ops.find(&g); + if (iter == ops.end()) { + iter = ops.insert(&g, TimeLine()); + if (syncPoint > 0) + q->pause(g, syncPoint); + } + if (!iter->ops.isEmpty() && + o.type == Op::Pause && + iter->ops.last().type == Op::Pause) { + iter->ops.last().length += o.length; + iter->length += o.length; + } else { + iter->ops.append(o); + iter->length += o.length; + } + + if (iter->length > length) + length = iter->length; + + if (!clockRunning) { + q->stop(); + prevTime = 0; + clockRunning = true; + + if (syncMode == QDeclarative1TimeLine::LocalSync) { + syncAdj = -1; + } else { + syncAdj = 0; + } + q->start(); +/* q->tick(0); + if (syncMode == QDeclarative1TimeLine::LocalSync) { + syncAdj = -1; + } else { + syncAdj = 0; + } + */ + } +} + +qreal QDeclarative1TimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const +{ + Q_ASSERT(time >= 0); + Q_ASSERT(time <= op.length); + *changed = true; + + switch(op.type) { + case Op::Pause: + *changed = false; + return base; + case Op::Set: + return op.value; + case Op::Move: + if (time == 0) { + return base; + } else if (time == (op.length)) { + return op.value; + } else { + qreal delta = op.value - base; + qreal pTime = (qreal)(time) / (qreal)op.length; + if (op.easing.type() == QEasingCurve::Linear) + return base + delta * pTime; + else + return base + delta * op.easing.valueForProgress(pTime); + } + case Op::MoveBy: + if (time == 0) { + return base; + } else if (time == (op.length)) { + return base + op.value; + } else { + qreal delta = op.value; + qreal pTime = (qreal)(time) / (qreal)op.length; + if (op.easing.type() == QEasingCurve::Linear) + return base + delta * pTime; + else + return base + delta * op.easing.valueForProgress(pTime); + } + case Op::Accel: + if (time == 0) { + return base; + } else { + qreal t = (qreal)(time) / 1000.0f; + qreal delta = op.value * t + 0.5f * op.value2 * t * t; + return base + delta; + } + case Op::AccelDistance: + if (time == 0) { + return base; + } else if (time == (op.length)) { + return base + op.value2; + } else { + qreal t = (qreal)(time) / 1000.0f; + qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length; + qreal delta = op.value * t + 0.5f * accel * t * t; + return base + delta; + + } + case Op::Execute: + op.event.d0(op.event.d1); + *changed = false; + return -1; + } + + return base; +} + +/*! + \internal + \class QDeclarative1TimeLine + \brief The QDeclarative1TimeLine class provides a timeline for controlling animations. + + QDeclarative1TimeLine is similar to QTimeLine except: + \list + \i It updates QDeclarative1TimeLineValue instances directly, rather than maintaining a single + current value. + + For example, the following animates a simple value over 200 milliseconds: + \code + QDeclarative1TimeLineValue v(); + QDeclarative1TimeLine tl; + tl.move(v, 100., 200); + tl.start() + \endcode + + If your program needs to know when values are changed, it can either + connect to the QDeclarative1TimeLine's updated() signal, or inherit from QDeclarative1TimeLineValue + and reimplement the QDeclarative1TimeLineValue::setValue() method. + + \i Supports multiple QDeclarative1TimeLineValue, arbitrary start and end values and allows + animations to be strung together for more complex effects. + + For example, the following animation moves the x and y coordinates of + an object from wherever they are to the position (100, 100) in 50 + milliseconds and then further animates them to (100, 200) in 50 + milliseconds: + + \code + QDeclarative1TimeLineValue x(); + QDeclarative1TimeLineValue y(); + + QDeclarative1TimeLine tl; + tl.start(); + + tl.move(x, 100., 50); + tl.move(y, 100., 50); + tl.move(y, 200., 50); + \endcode + + \i All QDeclarative1TimeLine instances share a single, synchronized clock. + + Actions scheduled within the same event loop tick are scheduled + synchronously against each other, regardless of the wall time between the + scheduling. Synchronized scheduling applies both to within the same + QDeclarative1TimeLine and across separate QDeclarative1TimeLine's within the same process. + + \endlist + + Currently easing functions are not supported. +*/ + + +/*! + Construct a new QDeclarative1TimeLine with the specified \a parent. +*/ +QDeclarative1TimeLine::QDeclarative1TimeLine(QObject *parent) +: QAbstractAnimation(parent) +{ + d = new QDeclarative1TimeLinePrivate(this); +} + +/*! + Destroys the time line. Any inprogress animations are canceled, but not + completed. +*/ +QDeclarative1TimeLine::~QDeclarative1TimeLine() +{ + for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin(); + iter != d->ops.end(); + ++iter) + iter.key()->_t = 0; + + delete d; d = 0; +} + +/*! + \enum QDeclarative1TimeLine::SyncMode + */ + +/*! + Return the timeline's synchronization mode. + */ +QDeclarative1TimeLine::SyncMode QDeclarative1TimeLine::syncMode() const +{ + return d->syncMode; +} + +/*! + Set the timeline's synchronization mode to \a syncMode. + */ +void QDeclarative1TimeLine::setSyncMode(SyncMode syncMode) +{ + d->syncMode = syncMode; +} + +/*! + Pause \a obj for \a time milliseconds. +*/ +void QDeclarative1TimeLine::pause(QDeclarative1TimeLineObject &obj, int time) +{ + if (time <= 0) return; + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Pause, time, 0., 0., d->order++); + d->add(obj, op); +} + +/*! + Execute the \a event. + */ +void QDeclarative1TimeLine::callback(const QDeclarative1TimeLineCallback &callback) +{ + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback); + d->add(*callback.callbackObject(), op); +} + +/*! + Set the \a value of \a timeLineValue. +*/ +void QDeclarative1TimeLine::set(QDeclarative1TimeLineValue &timeLineValue, qreal value) +{ + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Set, 0, value, 0., d->order++); + d->add(timeLineValue, op); +} + +/*! + Decelerate \a timeLineValue from the starting \a velocity to zero at the + given \a acceleration rate. Although the \a acceleration is technically + a deceleration, it should always be positive. The QDeclarative1TimeLine will ensure + that the deceleration is in the opposite direction to the initial velocity. +*/ +int QDeclarative1TimeLine::accel(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal acceleration) +{ + if (acceleration == 0.0f) + return -1; + + if ((velocity > 0.0f) == (acceleration > 0.0f)) + acceleration = acceleration * -1.0f; + + int time = static_cast(-1000 * velocity / acceleration); + + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); + d->add(timeLineValue, op); + + return time; +} + +/*! + \overload + + Decelerate \a timeLineValue from the starting \a velocity to zero at the + given \a acceleration rate over a maximum distance of maxDistance. + + If necessary, QDeclarative1TimeLine will reduce the acceleration to ensure that the + entire operation does not require a move of more than \a maxDistance. + \a maxDistance should always be positive. +*/ +int QDeclarative1TimeLine::accel(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance) +{ + if (maxDistance == 0.0f || acceleration == 0.0f) + return -1; + + Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f); + + qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance); + if (maxAccel > acceleration) + acceleration = maxAccel; + + if ((velocity > 0.0f) == (acceleration > 0.0f)) + acceleration = acceleration * -1.0f; + + int time = static_cast(-1000 * velocity / acceleration); + + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); + d->add(timeLineValue, op); + + return time; +} + +/*! + Decelerate \a timeLineValue from the starting \a velocity to zero over the given + \a distance. This is like accel(), but the QDeclarative1TimeLine calculates the exact + deceleration to use. + + \a distance should be positive. +*/ +int QDeclarative1TimeLine::accelDistance(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal distance) +{ + if (distance == 0.0f || velocity == 0.0f) + return -1; + + Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f)); + + int time = static_cast(1000 * (2.0f * distance) / velocity); + + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++); + d->add(timeLineValue, op); + + return time; +} + +/*! + Linearly change the \a timeLineValue from its current value to the given + \a destination value over \a time milliseconds. +*/ +void QDeclarative1TimeLine::move(QDeclarative1TimeLineValue &timeLineValue, qreal destination, int time) +{ + if (time <= 0) return; + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++); + d->add(timeLineValue, op); +} + +/*! + Change the \a timeLineValue from its current value to the given \a destination + value over \a time milliseconds using the \a easing curve. + */ +void QDeclarative1TimeLine::move(QDeclarative1TimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time) +{ + if (time <= 0) return; + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QDeclarative1TimeLineCallback(), easing); + d->add(timeLineValue, op); +} + +/*! + Linearly change the \a timeLineValue from its current value by the \a change amount + over \a time milliseconds. +*/ +void QDeclarative1TimeLine::moveBy(QDeclarative1TimeLineValue &timeLineValue, qreal change, int time) +{ + if (time <= 0) return; + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++); + d->add(timeLineValue, op); +} + +/*! + Change the \a timeLineValue from its current value by the \a change amount over + \a time milliseconds using the \a easing curve. + */ +void QDeclarative1TimeLine::moveBy(QDeclarative1TimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time) +{ + if (time <= 0) return; + QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QDeclarative1TimeLineCallback(), easing); + d->add(timeLineValue, op); +} + +/*! + Cancel (but don't complete) all scheduled actions for \a timeLineValue. +*/ +void QDeclarative1TimeLine::reset(QDeclarative1TimeLineValue &timeLineValue) +{ + if (!timeLineValue._t) + return; + if (timeLineValue._t != this) { + qWarning() << "QDeclarative1TimeLine: Cannot reset a QDeclarative1TimeLineValue owned by another timeline."; + return; + } + remove(&timeLineValue); + timeLineValue._t = 0; +} + +int QDeclarative1TimeLine::duration() const +{ + return -1; +} + +/*! + Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo + within this timeline. + + Following operations on \a timeLineValue in this timeline will be scheduled after + all the currently scheduled actions on \a syncTo are complete. In + pseudo-code this is equivalent to: + \code + QDeclarative1TimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue))) + \endcode +*/ +void QDeclarative1TimeLine::sync(QDeclarative1TimeLineValue &timeLineValue, QDeclarative1TimeLineValue &syncTo) +{ + QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo); + if (iter == d->ops.end()) + return; + int length = iter->length; + + iter = d->ops.find(&timeLineValue); + if (iter == d->ops.end()) { + pause(timeLineValue, length); + } else { + int glength = iter->length; + pause(timeLineValue, length - glength); + } +} + +/*! + Synchronize the end point of \a timeLineValue to the endpoint of the longest + action cursrently scheduled in the timeline. + + In pseudo-code, this is equivalent to: + \code + QDeclarative1TimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue)) + \endcode +*/ +void QDeclarative1TimeLine::sync(QDeclarative1TimeLineValue &timeLineValue) +{ + QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue); + if (iter == d->ops.end()) { + pause(timeLineValue, d->length); + } else { + pause(timeLineValue, d->length - iter->length); + } +} + +/* + Synchronize all currently and future scheduled values in this timeline to + the longest action currently scheduled. + + For example: + \code + value1->setValue(0.); + value2->setValue(0.); + value3->setValue(0.); + QDeclarative1TimeLine tl; + ... + tl.move(value1, 10, 200); + tl.move(value2, 10, 100); + tl.sync(); + tl.move(value2, 20, 100); + tl.move(value3, 20, 100); + \endcode + + will result in: + + \table + \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms + \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10 + \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0 + \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0 + \endtable +*/ + +/*void QDeclarative1TimeLine::sync() +{ + for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin(); + iter != d->ops.end(); + ++iter) + pause(*iter.key(), d->length - iter->length); + d->syncPoint = d->length; +}*/ + +/*! + \internal + + Temporary hack. + */ +void QDeclarative1TimeLine::setSyncPoint(int sp) +{ + d->syncPoint = sp; +} + +/*! + \internal + + Temporary hack. + */ +int QDeclarative1TimeLine::syncPoint() const +{ + return d->syncPoint; +} + +/*! + Returns true if the timeline is active. An active timeline is one where + QDeclarative1TimeLineValue actions are still pending. +*/ +bool QDeclarative1TimeLine::isActive() const +{ + return !d->ops.isEmpty(); +} + +/*! + Completes the timeline. All queued actions are played to completion, and then discarded. For example, + \code + QDeclarative1TimeLineValue v(0.); + QDeclarative1TimeLine tl; + tl.move(v, 100., 1000.); + // 500 ms passes + // v.value() == 50. + tl.complete(); + // v.value() == 100. + \endcode +*/ +void QDeclarative1TimeLine::complete() +{ + d->advance(d->length); +} + +/*! + Resets the timeline. All queued actions are discarded and QDeclarative1TimeLineValue's retain their current value. For example, + \code + QDeclarative1TimeLineValue v(0.); + QDeclarative1TimeLine tl; + tl.move(v, 100., 1000.); + // 500 ms passes + // v.value() == 50. + tl.clear(); + // v.value() == 50. + \endcode +*/ +void QDeclarative1TimeLine::clear() +{ + for (QDeclarative1TimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter) + iter.key()->_t = 0; + d->ops.clear(); + d->length = 0; + d->syncPoint = 0; + //XXX need stop here? +} + +int QDeclarative1TimeLine::time() const +{ + return d->prevTime; +} + +/*! + \fn void QDeclarative1TimeLine::updated() + + Emitted each time the timeline modifies QDeclarative1TimeLineValues. Even if multiple + QDeclarative1TimeLineValues are changed, this signal is only emitted once for each clock tick. +*/ + +void QDeclarative1TimeLine::updateCurrentTime(int v) +{ + if (d->syncAdj == -1) + d->syncAdj = v; + v -= d->syncAdj; + + int timeChanged = v - d->prevTime; +#if 0 + if (!timeChanged) + return; +#endif + d->prevTime = v; + d->advance(timeChanged); + emit updated(); + + // Do we need to stop the clock? + if (d->ops.isEmpty()) { + stop(); + d->prevTime = 0; + d->clockRunning = false; + emit completed(); + } /*else if (pauseTime > 0) { + GfxClock::cancelClock(); + d->prevTime = 0; + GfxClock::pauseFor(pauseTime); + d->syncAdj = 0; + d->clockRunning = false; + }*/ else if (/*!GfxClock::isActive()*/ state() != Running) { + stop(); + d->prevTime = 0; + d->clockRunning = true; + d->syncAdj = 0; + start(); + } +} + +bool operator<(const QPair &lhs, + const QPair &rhs) +{ + return lhs.first < rhs.first; +} + +int QDeclarative1TimeLinePrivate::advance(int t) +{ + int pauseTime = -1; + + // XXX - surely there is a more efficient way? + do { + pauseTime = -1; + // Minimal advance time + int advanceTime = t; + for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) { + TimeLine &tl = *iter; + Op &op = tl.ops.first(); + int length = op.length - tl.consumedOpLength; + + if (length < advanceTime) { + advanceTime = length; + if (advanceTime == 0) + break; + } + } + t -= advanceTime; + + // Process until then. A zero length advance time will only process + // sets. + QList > updates; + + for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) { + QDeclarative1TimeLineValue *v = static_cast(iter.key()); + TimeLine &tl = *iter; + Q_ASSERT(!tl.ops.isEmpty()); + + do { + Op &op = tl.ops.first(); + if (advanceTime == 0 && op.length != 0) + continue; + + if (tl.consumedOpLength == 0 && + op.type != Op::Pause && + op.type != Op::Execute) + tl.base = v->value(); + + if ((tl.consumedOpLength + advanceTime) == op.length) { + if (op.type == Op::Execute) { + updates << qMakePair(op.order, Update(op.event)); + } else { + bool changed = false; + qreal val = value(op, op.length, tl.base, &changed); + if (changed) + updates << qMakePair(op.order, Update(v, val)); + } + tl.length -= qMin(advanceTime, tl.length); + tl.consumedOpLength = 0; + tl.ops.removeFirst(); + } else { + tl.consumedOpLength += advanceTime; + bool changed = false; + qreal val = value(op, tl.consumedOpLength, tl.base, &changed); + if (changed) + updates << qMakePair(op.order, Update(v, val)); + tl.length -= qMin(advanceTime, tl.length); + break; + } + + } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0); + + + if (tl.ops.isEmpty()) { + iter = ops.erase(iter); + v->_t = 0; + } else { + if (tl.ops.first().type == Op::Pause && pauseTime != 0) { + int opPauseTime = tl.ops.first().length - tl.consumedOpLength; + if (pauseTime == -1 || opPauseTime < pauseTime) + pauseTime = opPauseTime; + } else { + pauseTime = 0; + } + ++iter; + } + } + + length -= qMin(length, advanceTime); + syncPoint -= advanceTime; + + qSort(updates.begin(), updates.end()); + updateQueue = &updates; + for (int ii = 0; ii < updates.count(); ++ii) { + const Update &v = updates.at(ii).second; + if (v.g) { + v.g->setValue(v.v); + } else { + v.e.d0(v.e.d1); + } + } + updateQueue = 0; + } while(t); + + return pauseTime; +} + +void QDeclarative1TimeLine::remove(QDeclarative1TimeLineObject *v) +{ + QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(v); + Q_ASSERT(iter != d->ops.end()); + + int len = iter->length; + d->ops.erase(iter); + if (len == d->length) { + // We need to recalculate the length + d->length = 0; + for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin(); + iter != d->ops.end(); + ++iter) { + + if (iter->length > d->length) + d->length = iter->length; + + } + } + if (d->ops.isEmpty()) { + stop(); + d->clockRunning = false; + } else if (/*!GfxClock::isActive()*/ state() != Running) { + stop(); + d->prevTime = 0; + d->clockRunning = true; + + if (d->syncMode == QDeclarative1TimeLine::LocalSync) { + d->syncAdj = -1; + } else { + d->syncAdj = 0; + } + start(); + } + + if (d->updateQueue) { + for (int ii = 0; ii < d->updateQueue->count(); ++ii) { + if (d->updateQueue->at(ii).second.g == v || + d->updateQueue->at(ii).second.e.callbackObject() == v) { + d->updateQueue->removeAt(ii); + --ii; + } + } + } + + +} + +/*! + \internal + \class QDeclarative1TimeLineValue + \brief The QDeclarative1TimeLineValue class provides a value that can be modified by QDeclarative1TimeLine. +*/ + +/*! + \fn QDeclarative1TimeLineValue::QDeclarative1TimeLineValue(qreal value = 0) + + Construct a new QDeclarative1TimeLineValue with an initial \a value. +*/ + +/*! + \fn qreal QDeclarative1TimeLineValue::value() const + + Return the current value. +*/ + +/*! + \fn void QDeclarative1TimeLineValue::setValue(qreal value) + + Set the current \a value. +*/ + +/*! + \fn QDeclarative1TimeLine *QDeclarative1TimeLineValue::timeLine() const + + If a QDeclarative1TimeLine is operating on this value, return a pointer to it, + otherwise return null. +*/ + + +QDeclarative1TimeLineObject::QDeclarative1TimeLineObject() +: _t(0) +{ +} + +QDeclarative1TimeLineObject::~QDeclarative1TimeLineObject() +{ + if (_t) { + _t->remove(this); + _t = 0; + } +} + +QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback() +: d0(0), d1(0), d2(0) +{ +} + +QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback(QDeclarative1TimeLineObject *b, Callback f, void *d) +: d0(f), d1(d), d2(b) +{ +} + +QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback(const QDeclarative1TimeLineCallback &o) +: d0(o.d0), d1(o.d1), d2(o.d2) +{ +} + +QDeclarative1TimeLineCallback &QDeclarative1TimeLineCallback::operator=(const QDeclarative1TimeLineCallback &o) +{ + d0 = o.d0; + d1 = o.d1; + d2 = o.d2; + return *this; +} + +QDeclarative1TimeLineObject *QDeclarative1TimeLineCallback::callbackObject() const +{ + return d2; +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativetimeline_p_p.h b/src/qtquick1/util/qdeclarativetimeline_p_p.h new file mode 100644 index 0000000000..73f1ebfabe --- /dev/null +++ b/src/qtquick1/util/qdeclarativetimeline_p_p.h @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVETIMELINE_H +#define QDECLARATIVETIMELINE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QEasingCurve; +class QDeclarative1TimeLineValue; +class QDeclarative1TimeLineCallback; +struct QDeclarative1TimeLinePrivate; +class QDeclarative1TimeLineObject; +class Q_AUTOTEST_EXPORT QDeclarative1TimeLine : public QAbstractAnimation +{ +Q_OBJECT +public: + QDeclarative1TimeLine(QObject *parent = 0); + ~QDeclarative1TimeLine(); + + enum SyncMode { LocalSync, GlobalSync }; + SyncMode syncMode() const; + void setSyncMode(SyncMode); + + void pause(QDeclarative1TimeLineObject &, int); + void callback(const QDeclarative1TimeLineCallback &); + void set(QDeclarative1TimeLineValue &, qreal); + + int accel(QDeclarative1TimeLineValue &, qreal velocity, qreal accel); + int accel(QDeclarative1TimeLineValue &, qreal velocity, qreal accel, qreal maxDistance); + int accelDistance(QDeclarative1TimeLineValue &, qreal velocity, qreal distance); + + void move(QDeclarative1TimeLineValue &, qreal destination, int time = 500); + void move(QDeclarative1TimeLineValue &, qreal destination, const QEasingCurve &, int time = 500); + void moveBy(QDeclarative1TimeLineValue &, qreal change, int time = 500); + void moveBy(QDeclarative1TimeLineValue &, qreal change, const QEasingCurve &, int time = 500); + + void sync(); + void setSyncPoint(int); + int syncPoint() const; + + void sync(QDeclarative1TimeLineValue &); + void sync(QDeclarative1TimeLineValue &, QDeclarative1TimeLineValue &); + + void reset(QDeclarative1TimeLineValue &); + + void complete(); + void clear(); + bool isActive() const; + + int time() const; + + virtual int duration() const; +Q_SIGNALS: + void updated(); + void completed(); + +protected: + virtual void updateCurrentTime(int); + +private: + void remove(QDeclarative1TimeLineObject *); + friend class QDeclarative1TimeLineObject; + friend struct QDeclarative1TimeLinePrivate; + QDeclarative1TimeLinePrivate *d; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1TimeLineObject +{ +public: + QDeclarative1TimeLineObject(); + virtual ~QDeclarative1TimeLineObject(); + +protected: + friend class QDeclarative1TimeLine; + friend struct QDeclarative1TimeLinePrivate; + QDeclarative1TimeLine *_t; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1TimeLineValue : public QDeclarative1TimeLineObject +{ +public: + QDeclarative1TimeLineValue(qreal v = 0.) : _v(v) {} + + virtual qreal value() const { return _v; } + virtual void setValue(qreal v) { _v = v; } + + QDeclarative1TimeLine *timeLine() const { return _t; } + + operator qreal() const { return _v; } + QDeclarative1TimeLineValue &operator=(qreal v) { setValue(v); return *this; } +private: + friend class QDeclarative1TimeLine; + friend struct QDeclarative1TimeLinePrivate; + qreal _v; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1TimeLineCallback +{ +public: + typedef void (*Callback)(void *); + + QDeclarative1TimeLineCallback(); + QDeclarative1TimeLineCallback(QDeclarative1TimeLineObject *b, Callback, void * = 0); + QDeclarative1TimeLineCallback(const QDeclarative1TimeLineCallback &o); + + QDeclarative1TimeLineCallback &operator=(const QDeclarative1TimeLineCallback &o); + QDeclarative1TimeLineObject *callbackObject() const; + +private: + friend struct QDeclarative1TimeLinePrivate; + Callback d0; + void *d1; + QDeclarative1TimeLineObject *d2; +}; + +template +class QDeclarative1TimeLineValueProxy : public QDeclarative1TimeLineValue +{ +public: + QDeclarative1TimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) + : QDeclarative1TimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0) + { + Q_ASSERT(_class); + } + + QDeclarative1TimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.) + : QDeclarative1TimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func) + { + Q_ASSERT(_class); + } + + virtual void setValue(qreal v) + { + QDeclarative1TimeLineValue::setValue(v); + if (_setFunctionReal) (_class->*_setFunctionReal)(v); + else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v); + } + +private: + T *_class; + void (T::*_setFunctionReal)(qreal); + void (T::*_setFunctionInt)(int); +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/qtquick1/util/qdeclarativetimer.cpp b/src/qtquick1/util/qdeclarativetimer.cpp new file mode 100644 index 0000000000..2456dc06cf --- /dev/null +++ b/src/qtquick1/util/qdeclarativetimer.cpp @@ -0,0 +1,328 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativetimer_p.h" + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + + + + + +class QDeclarative1TimerPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1Timer) +public: + QDeclarative1TimerPrivate() + : interval(1000), running(false), repeating(false), triggeredOnStart(false) + , classBegun(false), componentComplete(false), firstTick(true) {} + int interval; + QPauseAnimation pause; + bool running : 1; + bool repeating : 1; + bool triggeredOnStart : 1; + bool classBegun : 1; + bool componentComplete : 1; + bool firstTick : 1; +}; + +/*! + \qmlclass Timer QDeclarative1Timer + \ingroup qml-utility-elements + \since 4.7 + \brief The Timer item triggers a handler at a specified interval. + + A Timer can be used to trigger an action either once, or repeatedly + at a given interval. + + Here is a Timer that shows the current date and time, and updates + the text every 500 milliseconds. It uses the JavaScript \c Date + object to access the current time. + + \qml + import QtQuick 1.0 + + Item { + Timer { + interval: 500; running: true; repeat: true + onTriggered: time.text = Date().toString() + } + + Text { id: time } + } + \endqml + + The Timer element is synchronized with the animation timer. Since the animation + timer is usually set to 60fps, the resolution of Timer will be + at best 16ms. + + If the Timer is running and one of its properties is changed, the + elapsed time will be reset. For example, if a Timer with interval of + 1000ms has its \e repeat property changed 500ms after starting, the + elapsed time will be reset to 0, and the Timer will be triggered + 1000ms later. + + \sa {declarative/toys/clocks}{Clocks example} +*/ + +QDeclarative1Timer::QDeclarative1Timer(QObject *parent) + : QObject(*(new QDeclarative1TimerPrivate), parent) +{ + Q_D(QDeclarative1Timer); + connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked())); + connect(&d->pause, SIGNAL(finished()), this, SLOT(finished())); + d->pause.setLoopCount(1); + d->pause.setDuration(d->interval); +} + +/*! + \qmlproperty int Timer::interval + + Sets the \a interval between triggers, in milliseconds. + + The default interval is 1000 milliseconds. +*/ +void QDeclarative1Timer::setInterval(int interval) +{ + Q_D(QDeclarative1Timer); + if (interval != d->interval) { + d->interval = interval; + update(); + emit intervalChanged(); + } +} + +int QDeclarative1Timer::interval() const +{ + Q_D(const QDeclarative1Timer); + return d->interval; +} + +/*! + \qmlproperty bool Timer::running + + If set to true, starts the timer; otherwise stops the timer. + For a non-repeating timer, \a running is set to false after the + timer has been triggered. + + \a running defaults to false. + + \sa repeat +*/ +bool QDeclarative1Timer::isRunning() const +{ + Q_D(const QDeclarative1Timer); + return d->running; +} + +void QDeclarative1Timer::setRunning(bool running) +{ + Q_D(QDeclarative1Timer); + if (d->running != running) { + d->running = running; + d->firstTick = true; + emit runningChanged(); + update(); + } +} + +/*! + \qmlproperty bool Timer::repeat + + If \a repeat is true the timer is triggered repeatedly at the + specified interval; otherwise, the timer will trigger once at the + specified interval and then stop (i.e. running will be set to false). + + \a repeat defaults to false. + + \sa running +*/ +bool QDeclarative1Timer::isRepeating() const +{ + Q_D(const QDeclarative1Timer); + return d->repeating; +} + +void QDeclarative1Timer::setRepeating(bool repeating) +{ + Q_D(QDeclarative1Timer); + if (repeating != d->repeating) { + d->repeating = repeating; + update(); + emit repeatChanged(); + } +} + +/*! + \qmlproperty bool Timer::triggeredOnStart + + When a timer is started, the first trigger is usually after the specified + interval has elapsed. It is sometimes desirable to trigger immediately + when the timer is started; for example, to establish an initial + state. + + If \a triggeredOnStart is true, the timer is triggered immediately + when started, and subsequently at the specified interval. Note that if + \e repeat is set to false, the timer is triggered twice; once on start, + and again at the interval. + + \a triggeredOnStart defaults to false. + + \sa running +*/ +bool QDeclarative1Timer::triggeredOnStart() const +{ + Q_D(const QDeclarative1Timer); + return d->triggeredOnStart; +} + +void QDeclarative1Timer::setTriggeredOnStart(bool triggeredOnStart) +{ + Q_D(QDeclarative1Timer); + if (d->triggeredOnStart != triggeredOnStart) { + d->triggeredOnStart = triggeredOnStart; + update(); + emit triggeredOnStartChanged(); + } +} + +/*! + \qmlmethod Timer::start() + \brief Starts the timer. + + If the timer is already running, calling this method has no effect. The + \c running property will be true following a call to \c start(). +*/ +void QDeclarative1Timer::start() +{ + setRunning(true); +} + +/*! + \qmlmethod Timer::stop() + \brief Stops the timer. + + If the timer is not running, calling this method has no effect. The + \c running property will be false following a call to \c stop(). +*/ +void QDeclarative1Timer::stop() +{ + setRunning(false); +} + +/*! + \qmlmethod Timer::restart() + \brief Restarts the timer. + + If the Timer is not running it will be started, otherwise it will be + stopped, reset to initial state and started. The \c running property + will be true following a call to \c restart(). +*/ +void QDeclarative1Timer::restart() +{ + setRunning(false); + setRunning(true); +} + +void QDeclarative1Timer::update() +{ + Q_D(QDeclarative1Timer); + if (d->classBegun && !d->componentComplete) + return; + d->pause.stop(); + if (d->running) { + d->pause.setCurrentTime(0); + d->pause.setLoopCount(d->repeating ? -1 : 1); + d->pause.setDuration(d->interval); + d->pause.start(); + if (d->triggeredOnStart && d->firstTick) { + QCoreApplication::removePostedEvents(this, QEvent::MetaCall); + QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection); + } + } +} + +void QDeclarative1Timer::classBegin() +{ + Q_D(QDeclarative1Timer); + d->classBegun = true; +} + +void QDeclarative1Timer::componentComplete() +{ + Q_D(QDeclarative1Timer); + d->componentComplete = true; + update(); +} + +/*! + \qmlsignal Timer::onTriggered() + + This handler is called when the Timer is triggered. +*/ +void QDeclarative1Timer::ticked() +{ + Q_D(QDeclarative1Timer); + if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick))) + emit triggered(); + d->firstTick = false; +} + +void QDeclarative1Timer::finished() +{ + Q_D(QDeclarative1Timer); + if (d->repeating || !d->running) + return; + emit triggered(); + d->running = false; + d->firstTick = false; + emit runningChanged(); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativetimer_p.h b/src/qtquick1/util/qdeclarativetimer_p.h new file mode 100644 index 0000000000..5465773280 --- /dev/null +++ b/src/qtquick1/util/qdeclarativetimer_p.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVETIMER_H +#define QDECLARATIVETIMER_H + +#include + +#include +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1TimerPrivate; +class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1Timer : public QObject, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1Timer) + Q_INTERFACES(QDeclarativeParserStatus) + Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) + Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) + Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged) + Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged) + Q_PROPERTY(QObject *parent READ parent CONSTANT) + +public: + QDeclarative1Timer(QObject *parent=0); + + void setInterval(int interval); + int interval() const; + + bool isRunning() const; + void setRunning(bool running); + + bool isRepeating() const; + void setRepeating(bool repeating); + + bool triggeredOnStart() const; + void setTriggeredOnStart(bool triggeredOnStart); + +protected: + void classBegin(); + void componentComplete(); + +public Q_SLOTS: + void start(); + void stop(); + void restart(); + +Q_SIGNALS: + void triggered(); + void runningChanged(); + void intervalChanged(); + void repeatChanged(); + void triggeredOnStartChanged(); + +private: + void update(); + +private Q_SLOTS: + void ticked(); + void finished(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1Timer) + +QT_END_HEADER + +#endif diff --git a/src/qtquick1/util/qdeclarativetransition.cpp b/src/qtquick1/util/qdeclarativetransition.cpp new file mode 100644 index 0000000000..7a2d4af94e --- /dev/null +++ b/src/qtquick1/util/qdeclarativetransition.cpp @@ -0,0 +1,349 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativestate_p.h" +#include "QtQuick1/private/qdeclarativestategroup_p.h" +#include "QtQuick1/private/qdeclarativestate_p_p.h" +#include "QtQuick1/private/qdeclarativestateoperations_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" +#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" + +#include + +QT_BEGIN_NAMESPACE + + + +/*! + \qmlclass Transition QDeclarative1Transition + \ingroup qml-animation-transition + \since 4.7 + \brief The Transition element defines animated transitions that occur on state changes. + + A Transition defines the animations to be applied when a \l State change occurs. + + For example, the following \l Rectangle has two states: the default state, and + an added "moved" state. In the "moved state, the rectangle's position changes + to (50, 50). The added Transition specifies that when the rectangle + changes between the default and the "moved" state, any changes + to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. + + \snippet doc/src/snippets/declarative/transition.qml 0 + + Notice the example does not require \l{PropertyAnimation::}{to} and + \l{PropertyAnimation::}{from} values for the NumberAnimation. As a convenience, + these properties are automatically set to the values of \c x and \c y before + and after the state change; the \c from values are provided by + the current values of \c x and \c y, and the \c to values are provided by + the PropertyChanges object. If you wish, you can provide \l{PropertyAnimation::}{to} and + \l{PropertyAnimation::}{from} values anyway to override the default values. + + By default, a Transition's animations are applied for any state change in the + parent item. The Transition \l {Transition::}{from} and \l {Transition::}{to} + values can be set to restrict the animations to only be applied when changing + from one particular state to another. + + To define multiple transitions, specify \l Item::transitions as a list: + + \snippet doc/src/snippets/declarative/transitions-list.qml list of transitions + + If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular + state change. In the example above, when changing to \c state1, the first transition will be used, rather + than the more generic second transition. + + If a state change has a Transition that matches the same property as a + \l Behavior, the Transition animation overrides the \l Behavior for that + state change. + + \sa {QML Animation and Transitions}, {declarative/animation/states}{states example}, {qmlstates}{States}, {QtDeclarative} +*/ + +//ParallelAnimationWrapper_1 allows us to do a "callback" when the animation finishes, rather than connecting +//and disconnecting signals and slots frequently +class ParallelAnimationWrapper_1 : public QParallelAnimationGroup +{ + Q_OBJECT +public: + ParallelAnimationWrapper_1(QObject *parent = 0) : QParallelAnimationGroup(parent) {} + QDeclarative1TransitionPrivate *trans; +protected: + virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); +}; + +class QDeclarative1TransitionPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1Transition) +public: + QDeclarative1TransitionPrivate() + : fromState(QLatin1String("*")), toState(QLatin1String("*")), + reversed(false), reversible(false), endState(0) + { + group.trans = this; + } + + QString fromState; + QString toState; + bool reversed; + bool reversible; + ParallelAnimationWrapper_1 group; + QDeclarative1TransitionManager *endState; + + void complete() + { + endState->complete(); + } + static void append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *a); + static int animation_count(QDeclarativeListProperty *list); + static QDeclarative1AbstractAnimation* animation_at(QDeclarativeListProperty *list, int pos); + static void clear_animations(QDeclarativeListProperty *list); + QList animations; +}; + +void QDeclarative1TransitionPrivate::append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *a) +{ + QDeclarative1Transition *q = static_cast(list->object); + q->d_func()->animations.append(a); + q->d_func()->group.addAnimation(a->qtAnimation()); + a->setDisableUserControl(); +} + +int QDeclarative1TransitionPrivate::animation_count(QDeclarativeListProperty *list) +{ + QDeclarative1Transition *q = static_cast(list->object); + return q->d_func()->animations.count(); +} + +QDeclarative1AbstractAnimation* QDeclarative1TransitionPrivate::animation_at(QDeclarativeListProperty *list, int pos) +{ + QDeclarative1Transition *q = static_cast(list->object); + return q->d_func()->animations.at(pos); +} + +void QDeclarative1TransitionPrivate::clear_animations(QDeclarativeListProperty *list) +{ + QDeclarative1Transition *q = static_cast(list->object); + while (q->d_func()->animations.count()) { + QDeclarative1AbstractAnimation *firstAnim = q->d_func()->animations.at(0); + q->d_func()->group.removeAnimation(firstAnim->qtAnimation()); + q->d_func()->animations.removeAll(firstAnim); + } +} + +void ParallelAnimationWrapper_1::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) +{ + QParallelAnimationGroup::updateState(newState, oldState); + if (newState == Stopped && (duration() == -1 + || (direction() == QAbstractAnimation::Forward && currentLoopTime() == duration()) + || (direction() == QAbstractAnimation::Backward && currentLoopTime() == 0))) + { + trans->complete(); + } +} + + + +QDeclarative1Transition::QDeclarative1Transition(QObject *parent) + : QObject(*(new QDeclarative1TransitionPrivate), parent) +{ +} + +QDeclarative1Transition::~QDeclarative1Transition() +{ +} + +void QDeclarative1Transition::stop() +{ + Q_D(QDeclarative1Transition); + d->group.stop(); +} + +void QDeclarative1Transition::setReversed(bool r) +{ + Q_D(QDeclarative1Transition); + d->reversed = r; +} + +void QDeclarative1Transition::prepare(QDeclarative1StateOperation::ActionList &actions, + QList &after, + QDeclarative1TransitionManager *endState) +{ + Q_D(QDeclarative1Transition); + + qmlExecuteDeferred(this); + + if (d->reversed) { + for (int ii = d->animations.count() - 1; ii >= 0; --ii) { + d->animations.at(ii)->transition(actions, after, QDeclarative1AbstractAnimation::Backward); + } + } else { + for (int ii = 0; ii < d->animations.count(); ++ii) { + d->animations.at(ii)->transition(actions, after, QDeclarative1AbstractAnimation::Forward); + } + } + + d->endState = endState; + d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); + d->group.start(); +} + +/*! + \qmlproperty string Transition::from + \qmlproperty string Transition::to + + These properties indicate the state changes that trigger the transition. + + The default values for these properties is "*" (that is, any state). + + For example, the following transition has not set the \c to and \c from + properties, so the animation is always applied when changing between + the two states (i.e. when the mouse is pressed and released). + + \snippet doc/src/snippets/declarative/transition-from-to.qml 0 + + If the transition was changed to this: + + \snippet doc/src/snippets/declarative/transition-from-to-modified.qml modified transition + + The animation would only be applied when changing from the default state to + the "brighter" state (i.e. when the mouse is pressed, but not on release). + + \sa reversible +*/ +QString QDeclarative1Transition::fromState() const +{ + Q_D(const QDeclarative1Transition); + return d->fromState; +} + +void QDeclarative1Transition::setFromState(const QString &f) +{ + Q_D(QDeclarative1Transition); + if (f == d->fromState) + return; + + d->fromState = f; + emit fromChanged(); +} + +/*! + \qmlproperty bool Transition::reversible + This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed. + + The default value is false. + + By default, transitions run in parallel and are applied to all state + changes if the \l from and \l to states have not been set. In this + situation, the transition is automatically applied when a state change + is reversed, and it is not necessary to set this property to reverse + the transition. + + However, if a SequentialAnimation is used, or if the \l from or \l to + properties have been set, this property will need to be set to reverse + a transition when a state change is reverted. For example, the following + transition applies a sequential animation when the mouse is pressed, + and reverses the sequence of the animation when the mouse is released: + + \snippet doc/src/snippets/declarative/transition-reversible.qml 0 + + If the transition did not set the \c to and \c reversible values, then + on the mouse release, the transition would play the PropertyAnimation + before the ColorAnimation instead of reversing the sequence. +*/ +bool QDeclarative1Transition::reversible() const +{ + Q_D(const QDeclarative1Transition); + return d->reversible; +} + +void QDeclarative1Transition::setReversible(bool r) +{ + Q_D(QDeclarative1Transition); + if (r == d->reversible) + return; + + d->reversible = r; + emit reversibleChanged(); +} + +QString QDeclarative1Transition::toState() const +{ + Q_D(const QDeclarative1Transition); + return d->toState; +} + +void QDeclarative1Transition::setToState(const QString &t) +{ + Q_D(QDeclarative1Transition); + if (t == d->toState) + return; + + d->toState = t; + emit toChanged(); +} + +/*! + \qmlproperty list Transition::animations + \default + + This property holds a list of the animations to be run for this transition. + + \snippet examples/declarative/toys/dynamicscene/dynamicscene.qml top-level transitions + + The top-level animations are run in parallel. To run them sequentially, + define them within a SequentialAnimation: + + \snippet doc/src/snippets/declarative/transition-reversible.qml sequential animations +*/ +QDeclarativeListProperty QDeclarative1Transition::animations() +{ + Q_D(QDeclarative1Transition); + return QDeclarativeListProperty(this, &d->animations, QDeclarative1TransitionPrivate::append_animation, + QDeclarative1TransitionPrivate::animation_count, + QDeclarative1TransitionPrivate::animation_at, + QDeclarative1TransitionPrivate::clear_animations); +} + + + +QT_END_NAMESPACE + +#include diff --git a/src/qtquick1/util/qdeclarativetransition_p.h b/src/qtquick1/util/qdeclarativetransition_p.h new file mode 100644 index 0000000000..f3f7afae6d --- /dev/null +++ b/src/qtquick1/util/qdeclarativetransition_p.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVETRANSITION_H +#define QDECLARATIVETRANSITION_H + +#include "QtQuick1/private/qdeclarativestate_p.h" + +#include + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1AbstractAnimation; +class QDeclarative1TransitionPrivate; +class QDeclarative1TransitionManager; +class Q_DECLARATIVE_EXPORT QDeclarative1Transition : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDeclarative1Transition) + + Q_PROPERTY(QString from READ fromState WRITE setFromState NOTIFY fromChanged) + Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged) + Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged) + Q_PROPERTY(QDeclarativeListProperty animations READ animations) + Q_CLASSINFO("DefaultProperty", "animations") + Q_CLASSINFO("DeferredPropertyNames", "animations") + +public: + QDeclarative1Transition(QObject *parent=0); + ~QDeclarative1Transition(); + + QString fromState() const; + void setFromState(const QString &); + + QString toState() const; + void setToState(const QString &); + + bool reversible() const; + void setReversible(bool); + + QDeclarativeListProperty animations(); + + void prepare(QDeclarative1StateOperation::ActionList &actions, + QList &after, + QDeclarative1TransitionManager *end); + + void setReversed(bool r); + void stop(); + +Q_SIGNALS: + void fromChanged(); + void toChanged(); + void reversibleChanged(); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1Transition) + +QT_END_HEADER + +#endif // QDECLARATIVETRANSITION_H diff --git a/src/qtquick1/util/qdeclarativetransitionmanager.cpp b/src/qtquick1/util/qdeclarativetransitionmanager.cpp new file mode 100644 index 0000000000..914168119a --- /dev/null +++ b/src/qtquick1/util/qdeclarativetransitionmanager.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" + +#include "QtQuick1/private/qdeclarativestate_p_p.h" +#include "QtQuick1/private/qdeclarativestate_p.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + + +DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); + +class QDeclarative1TransitionManagerPrivate +{ +public: + QDeclarative1TransitionManagerPrivate() + : state(0) {} + + void applyBindings(); + typedef QList SimpleActionList; + QDeclarative1State *state; + QDeclarativeGuard transition; + QDeclarative1StateOperation::ActionList bindingsList; + SimpleActionList completeList; +}; + +QDeclarative1TransitionManager::QDeclarative1TransitionManager() +: d(new QDeclarative1TransitionManagerPrivate) +{ +} + +void QDeclarative1TransitionManager::setState(QDeclarative1State *s) +{ + d->state = s; +} + +QDeclarative1TransitionManager::~QDeclarative1TransitionManager() +{ + delete d; d = 0; +} + +void QDeclarative1TransitionManager::complete() +{ + d->applyBindings(); + + for (int ii = 0; ii < d->completeList.count(); ++ii) { + const QDeclarativeProperty &prop = d->completeList.at(ii).property(); + prop.write(d->completeList.at(ii).value()); + } + + d->completeList.clear(); + + if (d->state) + static_cast(QObjectPrivate::get(d->state))->complete(); +} + +void QDeclarative1TransitionManagerPrivate::applyBindings() +{ + foreach(const QDeclarative1Action &action, bindingsList) { + if (!action.toBinding.isNull()) { + QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data()); + } else if (action.event) { + if (action.reverseEvent) + action.event->reverse(); + else + action.event->execute(); + } + + } + + bindingsList.clear(); +} + +void QDeclarative1TransitionManager::transition(const QList &list, + QDeclarative1Transition *transition) +{ + cancel(); + + QDeclarative1StateOperation::ActionList applyList = list; + // Determine which actions are binding changes. + foreach(const QDeclarative1Action &action, applyList) { + if (action.toBinding) + d->bindingsList << action; + if (action.fromBinding) + QDeclarativePropertyPrivate::setBinding(action.property, 0); // Disable current binding + if (action.event && action.event->changesBindings()) { //### assume isReversable()? + d->bindingsList << action; + action.event->clearBindings(); + } + } + + // Animated transitions need both the start and the end value for + // each property change. In the presence of bindings, the end values + // are non-trivial to calculate. As a "best effort" attempt, we first + // apply all the property and binding changes, then read all the actual + // final values, then roll back the changes and proceed as normal. + // + // This doesn't catch everything, and it might be a little fragile in + // some cases - but whatcha going to do? + + if (!d->bindingsList.isEmpty()) { + + // Apply all the property and binding changes + for (int ii = 0; ii < applyList.size(); ++ii) { + const QDeclarative1Action &action = applyList.at(ii); + if (!action.toBinding.isNull()) { + QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + } else if (!action.event) { + QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + } else if (action.event->isReversable()) { + if (action.reverseEvent) + action.event->reverse(QDeclarative1ActionEvent::FastForward); + else + action.event->execute(QDeclarative1ActionEvent::FastForward); + } + } + + // Read all the end values for binding changes + for (int ii = 0; ii < applyList.size(); ++ii) { + QDeclarative1Action *action = &applyList[ii]; + if (action->event) { + action->event->saveTargetValues(); + continue; + } + const QDeclarativeProperty &prop = action->property; + if (!action->toBinding.isNull() || !action->toValue.isValid()) { + action->toValue = prop.read(); + } + } + + // Revert back to the original values + foreach(const QDeclarative1Action &action, applyList) { + if (action.event) { + if (action.event->isReversable()) { + action.event->clearBindings(); + action.event->rewind(); + action.event->clearBindings(); //### shouldn't be needed + } + continue; + } + + if (action.toBinding) + QDeclarativePropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition + + QDeclarativePropertyPrivate::write(action.property, action.fromValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); + } + } + + if (transition) { + QList touched; + d->transition = transition; + d->transition->prepare(applyList, touched, this); + + // Modify the action list to remove actions handled in the transition + for (int ii = 0; ii < applyList.count(); ++ii) { + const QDeclarative1Action &action = applyList.at(ii); + + if (action.event) { + + if (action.actionDone) { + applyList.removeAt(ii); + --ii; + } + + } else { + + if (touched.contains(action.property)) { + if (action.toValue != action.fromValue) + d->completeList << + QDeclarative1SimpleAction(action, QDeclarative1SimpleAction::EndState); + + applyList.removeAt(ii); + --ii; + } + + } + } + } + + // Any actions remaining have not been handled by the transition and should + // be applied immediately. We skip applying bindings, as they are all + // applied at the end in applyBindings() to avoid any nastiness mid + // transition + foreach(const QDeclarative1Action &action, applyList) { + if (action.event && !action.event->changesBindings()) { + if (action.event->isReversable() && action.reverseEvent) + action.event->reverse(); + else + action.event->execute(); + } else if (!action.event && !action.toBinding) { + action.property.write(action.toValue); + } + } +#ifndef QT_NO_DEBUG_STREAM + if (stateChangeDebug()) { + foreach(const QDeclarative1Action &action, applyList) { + if (action.event) + qWarning() << " No transition for event:" << action.event->typeName(); + else + qWarning() << " No transition for:" << action.property.object() + << action.property.name() << "From:" << action.fromValue + << "To:" << action.toValue; + } + } +#endif + if (!transition) + d->applyBindings(); +} + +void QDeclarative1TransitionManager::cancel() +{ + if (d->transition) { + // ### this could potentially trigger a complete in rare circumstances + d->transition->stop(); + d->transition = 0; + } + + for(int i = 0; i < d->bindingsList.count(); ++i) { + QDeclarative1Action action = d->bindingsList[i]; + if (!action.toBinding.isNull() && action.deletableToBinding) { + QDeclarativePropertyPrivate::setBinding(action.property, 0); + action.toBinding.data()->destroy(); + action.toBinding.clear(); + action.deletableToBinding = false; + } else if (action.event) { + //### what do we do here? + } + + } + d->bindingsList.clear(); + d->completeList.clear(); +} + + + +QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h b/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h new file mode 100644 index 0000000000..3f4100786f --- /dev/null +++ b/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVETRANSITIONMANAGER_P_H +#define QDECLARATIVETRANSITIONMANAGER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtQuick1/private/qdeclarativestateoperations_p.h" + +QT_BEGIN_NAMESPACE + +class QDeclarative1StatePrivate; +class QDeclarative1TransitionManagerPrivate; +class Q_AUTOTEST_EXPORT QDeclarative1TransitionManager +{ +public: + QDeclarative1TransitionManager(); + ~QDeclarative1TransitionManager(); + + void transition(const QList &, QDeclarative1Transition *transition); + + void cancel(); + +private: + Q_DISABLE_COPY(QDeclarative1TransitionManager) + QDeclarative1TransitionManagerPrivate *d; + + void complete(); + void setState(QDeclarative1State *); + + friend class QDeclarative1State; + friend class QDeclarative1TransitionPrivate; +}; + +QT_END_NAMESPACE + +#endif // QDECLARATIVETRANSITIONMANAGER_P_H diff --git a/src/qtquick1/util/qdeclarativeutilmodule.cpp b/src/qtquick1/util/qdeclarativeutilmodule.cpp new file mode 100644 index 0000000000..65afa3655f --- /dev/null +++ b/src/qtquick1/util/qdeclarativeutilmodule.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativeutilmodule_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p.h" +#include "QtQuick1/private/qdeclarativeanimation_p_p.h" +#include "QtQuick1/private/qdeclarativebehavior_p.h" +#include "QtQuick1/private/qdeclarativebind_p.h" +#include "QtQuick1/private/qdeclarativeconnections_p.h" +#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h" +#include "QtQuick1/private/qdeclarativefontloader_p.h" +#include "QtQuick1/private/qdeclarativelistaccessor_p.h" +//#include "QtQuick1/private/qdeclarativelistmodel_p.h" +#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" +#include "QtQuick1/private/qdeclarativepackage_p.h" +#include "QtQuick1/private/qdeclarativepixmapcache_p.h" +#include "QtQuick1/private/qdeclarativepropertychanges_p.h" +#include "QtQuick1/private/qdeclarativespringanimation_p.h" +#include "QtQuick1/private/qdeclarativestategroup_p.h" +#include "QtQuick1/private/qdeclarativestateoperations_p.h" +#include "QtQuick1/private/qdeclarativestate_p.h" +#include "QtQuick1/private/qdeclarativestate_p_p.h" +#include "QtQuick1/private/qdeclarativestyledtext_p.h" +#include "QtQuick1/private/qdeclarativesystempalette_p.h" +#include "QtQuick1/private/qdeclarativetimeline_p_p.h" +#include "QtQuick1/private/qdeclarativetimer_p.h" +#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" +#include "QtQuick1/private/qdeclarativetransition_p.h" +#include "QtQuick1/private/qdeclarativeapplication_p.h" +#include "QtQuick1/qdeclarativeview.h" +#include +#include +#ifndef QT_NO_XMLPATTERNS +#include "QtQuick1/private/qdeclarativexmllistmodel_p.h" +#endif + + +void QDeclarative1UtilModule::defineModule(QDeclarativeQtQuick1Module::Module module) +{ + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType(); + + if (module == QDeclarativeQtQuick1Module::QtQuick1) { + qmlRegisterUncreatableType("QtQuick",1,1,"Application", QDeclarative1Application::tr("Application is an abstract class")); + + qmlRegisterType("QtQuick",1,0,"AnchorAnimation"); + qmlRegisterType("QtQuick",1,0,"AnchorChanges"); + qmlRegisterType("QtQuick",1,0,"Behavior"); + qmlRegisterType("QtQuick",1,0,"Binding"); + qmlRegisterType("QtQuick",1,0,"ColorAnimation"); + qmlRegisterType("QtQuick",1,0,"Connections"); + qmlRegisterType("QtQuick",1,0,"SmoothedAnimation"); + qmlRegisterType("QtQuick",1,0,"FontLoader"); + // qmlRegisterType("QtQuick",1,0,"ListElement"); + qmlRegisterType("QtQuick",1,0,"NumberAnimation"); + qmlRegisterType("QtQuick",1,0,"Package"); + qmlRegisterType("QtQuick",1,0,"ParallelAnimation"); + qmlRegisterType("QtQuick",1,0,"ParentAnimation"); + qmlRegisterType("QtQuick",1,0,"ParentChange"); + qmlRegisterType("QtQuick",1,0,"PauseAnimation"); + qmlRegisterType("QtQuick",1,0,"PropertyAction"); + qmlRegisterType("QtQuick",1,0,"PropertyAnimation"); + qmlRegisterType("QtQuick",1,0,"RotationAnimation"); + qmlRegisterType("QtQuick",1,0,"ScriptAction"); + qmlRegisterType("QtQuick",1,0,"SequentialAnimation"); + qmlRegisterType("QtQuick",1,0,"SpringAnimation"); + qmlRegisterType("QtQuick",1,0,"StateChangeScript"); + qmlRegisterType("QtQuick",1,0,"StateGroup"); + qmlRegisterType("QtQuick",1,0,"State"); + qmlRegisterType("QtQuick",1,0,"SystemPalette"); + qmlRegisterType("QtQuick",1,0,"Timer"); + qmlRegisterType("QtQuick",1,0,"Transition"); + qmlRegisterType("QtQuick",1,0,"Vector3dAnimation"); +#ifdef QT_NO_XMLPATTERNS + qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlListModel", + qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); + qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlRole", + qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); +#else + qmlRegisterType("QtQuick",1,0,"XmlListModel"); + qmlRegisterType("QtQuick",1,0,"XmlRole"); +#endif + + + qmlRegisterUncreatableType("QtQuick",1,0,"Animation",QDeclarative1AbstractAnimation::tr("Animation is an abstract class")); + + // qmlRegisterCustomType("QtQuick",1,0,"ListModel", new QDeclarative1ListModelParser); + qmlRegisterCustomType("QtQuick",1,0,"PropertyChanges", new QDeclarative1PropertyChangesParser); + qmlRegisterCustomType("QtQuick",1,0,"Connections", new QDeclarative1ConnectionsParser); + } else if (module == QDeclarativeQtQuick1Module::Qt47) { + qmlRegisterType("Qt",4,7,"AnchorAnimation"); + qmlRegisterType("Qt",4,7,"AnchorChanges"); + qmlRegisterType("Qt",4,7,"Behavior"); + qmlRegisterType("Qt",4,7,"Binding"); + qmlRegisterType("Qt",4,7,"ColorAnimation"); + qmlRegisterType("Qt",4,7,"Connections"); + qmlRegisterType("Qt",4,7,"SmoothedAnimation"); + qmlRegisterType("Qt",4,7,"FontLoader"); + // qmlRegisterType("Qt",4,7,"ListElement"); + qmlRegisterType("Qt",4,7,"NumberAnimation"); + qmlRegisterType("Qt",4,7,"Package"); + qmlRegisterType("Qt",4,7,"ParallelAnimation"); + qmlRegisterType("Qt",4,7,"ParentAnimation"); + qmlRegisterType("Qt",4,7,"ParentChange"); + qmlRegisterType("Qt",4,7,"PauseAnimation"); + qmlRegisterType("Qt",4,7,"PropertyAction"); + qmlRegisterType("Qt",4,7,"PropertyAnimation"); + qmlRegisterType("Qt",4,7,"RotationAnimation"); + qmlRegisterType("Qt",4,7,"ScriptAction"); + qmlRegisterType("Qt",4,7,"SequentialAnimation"); + qmlRegisterType("Qt",4,7,"SpringAnimation"); + qmlRegisterType("Qt",4,7,"StateChangeScript"); + qmlRegisterType("Qt",4,7,"StateGroup"); + qmlRegisterType("Qt",4,7,"State"); + qmlRegisterType("Qt",4,7,"SystemPalette"); + qmlRegisterType("Qt",4,7,"Timer"); + qmlRegisterType("Qt",4,7,"Transition"); + qmlRegisterType("Qt",4,7,"Vector3dAnimation"); +#ifdef QT_NO_XMLPATTERNS + qmlRegisterTypeNotAvailable("Qt",4,7,"XmlListModel", + qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); + qmlRegisterTypeNotAvailable("Qt",4,7,"XmlRole", + qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); +#else + qmlRegisterType("Qt",4,7,"XmlListModel"); + qmlRegisterType("Qt",4,7,"XmlRole"); +#endif + + qmlRegisterUncreatableType("Qt",4,7,"Animation",QDeclarative1AbstractAnimation::tr("Animation is an abstract class")); + + // qmlRegisterCustomType("Qt", 4,7, "ListModel", new QDeclarative1ListModelParser); + qmlRegisterCustomType("Qt", 4, 7, "PropertyChanges", new QDeclarative1PropertyChangesParser); + qmlRegisterCustomType("Qt", 4, 7, "Connections", new QDeclarative1ConnectionsParser); + } +} + + + diff --git a/src/qtquick1/util/qdeclarativeutilmodule_p.h b/src/qtquick1/util/qdeclarativeutilmodule_p.h new file mode 100644 index 0000000000..b6561ccd3f --- /dev/null +++ b/src/qtquick1/util/qdeclarativeutilmodule_p.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEUTILMODULE_H +#define QDECLARATIVEUTILMODULE_H + +#include +#include "../qtquick1_p.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarative1UtilModule +{ +public: + static void defineModule(QDeclarativeQtQuick1Module::Module module); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QDECLARATIVEUTILMODULE_H diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/qtquick1/util/qdeclarativeview.cpp similarity index 95% rename from src/declarative/util/qdeclarativeview.cpp rename to src/qtquick1/util/qdeclarativeview.cpp index bab991b175..b6ba7a4fcb 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/qtquick1/util/qdeclarativeview.cpp @@ -39,17 +39,17 @@ ** ****************************************************************************/ -#include "qdeclarativeview.h" +#include "QtQuick1/qdeclarativeview.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #include #include @@ -66,18 +66,18 @@ #include #include #include -#include +#include #include -#include +#include QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) -class QDeclarativeScene : public QGraphicsScene +class QDeclarative1Scene : public QGraphicsScene { public: - QDeclarativeScene(QObject *parent = 0); + QDeclarative1Scene(QObject *parent = 0); protected: virtual void keyPressEvent(QKeyEvent *); @@ -88,39 +88,39 @@ class QDeclarativeScene : public QGraphicsScene virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *); }; -QDeclarativeScene::QDeclarativeScene(QObject *parent) : QGraphicsScene(parent) +QDeclarative1Scene::QDeclarative1Scene(QObject *parent) : QGraphicsScene(parent) { } -void QDeclarativeScene::keyPressEvent(QKeyEvent *e) +void QDeclarative1Scene::keyPressEvent(QKeyEvent *e) { QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key); QGraphicsScene::keyPressEvent(e); } -void QDeclarativeScene::keyReleaseEvent(QKeyEvent *e) +void QDeclarative1Scene::keyReleaseEvent(QKeyEvent *e) { QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key); QGraphicsScene::keyReleaseEvent(e); } -void QDeclarativeScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) +void QDeclarative1Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) { QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse); QGraphicsScene::mouseMoveEvent(e); } -void QDeclarativeScene::mousePressEvent(QGraphicsSceneMouseEvent *e) +void QDeclarative1Scene::mousePressEvent(QGraphicsSceneMouseEvent *e) { QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse); QGraphicsScene::mousePressEvent(e); } -void QDeclarativeScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) +void QDeclarative1Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse); @@ -279,7 +279,7 @@ void QDeclarativeViewPrivate::init() { Q_Q(QDeclarativeView); engine = new QDeclarativeEngine(); - q->setScene(new QDeclarativeScene(q)); + q->setScene(new QDeclarative1Scene(q)); q->setOptimizationFlags(QGraphicsView::DontSavePainterState); q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); diff --git a/src/declarative/util/qdeclarativeview.h b/src/qtquick1/util/qdeclarativeview.h similarity index 100% rename from src/declarative/util/qdeclarativeview.h rename to src/qtquick1/util/qdeclarativeview.h index 6959d246e4..cfe1d458dc 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/qtquick1/util/qdeclarativeview.h @@ -52,13 +52,13 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) - class QGraphicsObject; class QDeclarativeEngine; class QDeclarativeContext; class QDeclarativeError; +QT_MODULE(Declarative) + class QDeclarativeViewPrivate; class Q_DECLARATIVE_EXPORT QDeclarativeView : public QGraphicsView { diff --git a/src/qtquick1/util/qdeclarativexmllistmodel.cpp b/src/qtquick1/util/qdeclarativexmllistmodel.cpp new file mode 100644 index 0000000000..1f89f95a34 --- /dev/null +++ b/src/qtquick1/util/qdeclarativexmllistmodel.cpp @@ -0,0 +1,1058 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "QtQuick1/private/qdeclarativexmllistmodel_p.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +Q_DECLARE_METATYPE(QDeclarative1XmlQueryResult) + +QT_BEGIN_NAMESPACE + + + + +typedef QPair QDeclarative1XmlListRange; + +#define XMLLISTMODEL_CLEAR_ID 0 + +/*! + \qmlclass XmlRole QDeclarative1XmlListModelRole + \ingroup qml-working-with-data + \since 4.7 + \brief The XmlRole element allows you to specify a role for an XmlListModel. + + \sa {QtDeclarative} +*/ + +/*! + \qmlproperty string XmlRole::name + + The name for the role. This name is used to access the model data for this role. + + For example, the following model has a role named "title", which can be accessed + from the view's delegate: + + \qml + XmlListModel { + id: xmlModel + // ... + XmlRole { + name: "title" + query: "title/string()" + } + } + \endqml + + \qml + ListView { + model: xmlModel + delegate: Text { text: title } + } + \endqml +*/ + +/*! + \qmlproperty string XmlRole::query + The relative XPath expression query for this role. The query must be relative; it cannot start + with a '/'. + + For example, if there is an XML document like this: + + \quotefile doc/src/snippets/declarative/xmlrole.xml + + Here are some valid XPath expressions for XmlRole queries on this document: + + \snippet doc/src/snippets/declarative/xmlrole.qml 0 + \dots 4 + \snippet doc/src/snippets/declarative/xmlrole.qml 1 + + See the \l{http://www.w3.org/TR/xpath20/}{W3C XPath 2.0 specification} for more information. +*/ + +/*! + \qmlproperty bool XmlRole::isKey + Defines whether this is a key role. + + Key roles are used to to determine whether a set of values should + be updated or added to the XML list model when XmlListModel::reload() + is called. + + \sa XmlListModel +*/ + +struct XmlQueryJob +{ + int queryId; + QByteArray data; + QString query; + QString namespaces; + QStringList roleQueries; + QList roleQueryErrorId; // the ptr to send back if there is an error + QStringList keyRoleQueries; + QStringList keyRoleResultsCache; + QString prefix; +}; + +class QDeclarative1XmlQuery : public QObject +{ + Q_OBJECT +public: + QDeclarative1XmlQuery(QObject *parent=0) + : QObject(parent), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1) { + qRegisterMetaType("QDeclarative1XmlQueryResult"); + moveToThread(&m_thread); + m_thread.start(QThread::IdlePriority); + } + + ~QDeclarative1XmlQuery() { + if(m_thread.isRunning()) { + m_thread.quit(); + m_thread.wait(); + } + } + + void abort(int id) { + QMutexLocker ml(&m_mutex); + if (id != -1) { + m_jobs.remove(id); + } + } + + int doQuery(QString query, QString namespaces, QByteArray data, QList* roleObjects, QStringList keyRoleResultsCache) { + { + QMutexLocker m1(&m_mutex); + m_queryIds.ref(); + if (m_queryIds <= 0) + m_queryIds = 1; + } + + XmlQueryJob job; + job.queryId = m_queryIds; + job.data = data; + job.query = QLatin1String("doc($src)") + query; + job.namespaces = namespaces; + job.keyRoleResultsCache = keyRoleResultsCache; + + for (int i=0; icount(); i++) { + if (!roleObjects->at(i)->isValid()) { + job.roleQueries << QString(); + continue; + } + job.roleQueries << roleObjects->at(i)->query(); + job.roleQueryErrorId << static_cast(roleObjects->at(i)); + if (roleObjects->at(i)->isKey()) + job.keyRoleQueries << job.roleQueries.last(); + } + + { + QMutexLocker ml(&m_mutex); + m_jobs.insert(m_queryIds, job); + } + + QMetaObject::invokeMethod(this, "processQuery", Qt::QueuedConnection, Q_ARG(int, job.queryId)); + return job.queryId; + } + +private slots: + void processQuery(int queryId) { + XmlQueryJob job; + + { + QMutexLocker ml(&m_mutex); + if (!m_jobs.contains(queryId)) + return; + job = m_jobs.value(queryId); + } + + QDeclarative1XmlQueryResult result; + result.queryId = job.queryId; + doQueryJob(&job, &result); + doSubQueryJob(&job, &result); + + { + QMutexLocker ml(&m_mutex); + if (m_jobs.contains(queryId)) { + emit queryCompleted(result); + m_jobs.remove(queryId); + } + } + } + +Q_SIGNALS: + void queryCompleted(const QDeclarative1XmlQueryResult &); + void error(void*, const QString&); + +protected: + + +private: + void doQueryJob(XmlQueryJob *job, QDeclarative1XmlQueryResult *currentResult); + void doSubQueryJob(XmlQueryJob *job, QDeclarative1XmlQueryResult *currentResult); + void getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const; + void addIndexToRangeList(QList *ranges, int index) const; + +private: + QMutex m_mutex; + QThread m_thread; + QMap m_jobs; + QAtomicInt m_queryIds; +}; + +Q_GLOBAL_STATIC(QDeclarative1XmlQuery, globalXmlQuery) + +void QDeclarative1XmlQuery::doQueryJob(XmlQueryJob *currentJob, QDeclarative1XmlQueryResult *currentResult) +{ + Q_ASSERT(currentJob->queryId != -1); + + QString r; + QXmlQuery query; + QBuffer buffer(¤tJob->data); + buffer.open(QIODevice::ReadOnly); + query.bindVariable(QLatin1String("src"), &buffer); + query.setQuery(currentJob->namespaces + currentJob->query); + query.evaluateTo(&r); + + //always need a single root element + QByteArray xml = "\n" + r.toUtf8() + ""; + QBuffer b(&xml); + b.open(QIODevice::ReadOnly); + + QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces; + QString prefix = QLatin1String("doc($inputDocument)/dummy:items") + + currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/'))); + + //figure out how many items we are dealing with + int count = -1; + { + QXmlResultItems result; + QXmlQuery countquery; + countquery.bindVariable(QLatin1String("inputDocument"), &b); + countquery.setQuery(namespaces + QLatin1String("count(") + prefix + QLatin1Char(')')); + countquery.evaluateTo(&result); + QXmlItem item(result.next()); + if (item.isAtomicValue()) + count = item.toAtomicValue().toInt(); + } + + currentJob->data = xml; + currentJob->prefix = namespaces + prefix + QLatin1Char('/'); + currentResult->size = (count > 0 ? count : 0); +} + +void QDeclarative1XmlQuery::getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const +{ + const QStringList &keysQueries = currentJob.keyRoleQueries; + QString keysQuery; + if (keysQueries.count() == 1) + keysQuery = currentJob.prefix + keysQueries[0]; + else if (keysQueries.count() > 1) + keysQuery = currentJob.prefix + QLatin1String("concat(") + keysQueries.join(QLatin1String(",")) + QLatin1String(")"); + + if (!keysQuery.isEmpty()) { + query->setQuery(keysQuery); + QXmlResultItems resultItems; + query->evaluateTo(&resultItems); + QXmlItem item(resultItems.next()); + while (!item.isNull()) { + values->append(item.toAtomicValue().toString()); + item = resultItems.next(); + } + } +} + +void QDeclarative1XmlQuery::addIndexToRangeList(QList *ranges, int index) const { + if (ranges->isEmpty()) + ranges->append(qMakePair(index, 1)); + else if (ranges->last().first + ranges->last().second == index) + ranges->last().second += 1; + else + ranges->append(qMakePair(index, 1)); +} + +void QDeclarative1XmlQuery::doSubQueryJob(XmlQueryJob *currentJob, QDeclarative1XmlQueryResult *currentResult) +{ + Q_ASSERT(currentJob->queryId != -1); + + QBuffer b(¤tJob->data); + b.open(QIODevice::ReadOnly); + + QXmlQuery subquery; + subquery.bindVariable(QLatin1String("inputDocument"), &b); + + QStringList keyRoleResults; + getValuesOfKeyRoles(*currentJob, &keyRoleResults, &subquery); + + // See if any values of key roles have been inserted or removed. + + if (currentJob->keyRoleResultsCache.isEmpty()) { + currentResult->inserted << qMakePair(0, currentResult->size); + } else { + if (keyRoleResults != currentJob->keyRoleResultsCache) { + QStringList temp; + for (int i=0; ikeyRoleResultsCache.count(); i++) { + if (!keyRoleResults.contains(currentJob->keyRoleResultsCache[i])) + addIndexToRangeList(¤tResult->removed, i); + else + temp << currentJob->keyRoleResultsCache[i]; + } + + for (int i=0; iinserted, i); + } + } + } + } + currentResult->keyRoleResultsCache = keyRoleResults; + + // Get the new values for each role. + //### we might be able to condense even further (query for everything in one go) + const QStringList &queries = currentJob->roleQueries; + for (int i = 0; i < queries.size(); ++i) { + QList resultList; + if (!queries[i].isEmpty()) { + subquery.setQuery(currentJob->prefix + QLatin1String("(let $v := string(") + queries[i] + QLatin1String(") return if ($v) then ") + queries[i] + QLatin1String(" else \"\")")); + if (subquery.isValid()) { + QXmlResultItems resultItems; + subquery.evaluateTo(&resultItems); + QXmlItem item(resultItems.next()); + while (!item.isNull()) { + resultList << item.toAtomicValue(); //### we used to trim strings + item = resultItems.next(); + } + } else { + emit error(currentJob->roleQueryErrorId.at(i), queries[i]); + } + } + //### should warn here if things have gone wrong. + while (resultList.count() < currentResult->size) + resultList << QVariant(); + currentResult->data << resultList; + b.seek(0); + } + + //this method is much slower, but works better for incremental loading + /*for (int j = 0; j < m_size; ++j) { + QList resultList; + for (int i = 0; i < m_roleObjects->size(); ++i) { + QDeclarative1XmlListModelRole *role = m_roleObjects->at(i); + subquery.setQuery(m_prefix.arg(j+1) + role->query()); + if (role->isStringList()) { + QStringList data; + subquery.evaluateTo(&data); + resultList << QVariant(data); + //qDebug() << data; + } else { + QString s; + subquery.evaluateTo(&s); + if (role->isCData()) { + //un-escape + s.replace(QLatin1String("<"), QLatin1String("<")); + s.replace(QLatin1String(">"), QLatin1String(">")); + s.replace(QLatin1String("&"), QLatin1String("&")); + } + resultList << s.trimmed(); + //qDebug() << s; + } + b.seek(0); + } + m_modelData << resultList; + }*/ +} + +class QDeclarative1XmlListModelPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QDeclarative1XmlListModel) +public: + QDeclarative1XmlListModelPrivate() + : isComponentComplete(true), size(-1), highestRole(Qt::UserRole) + , reply(0), status(QDeclarative1XmlListModel::Null), progress(0.0) + , queryId(-1), roleObjects(), redirectCount(0) {} + + + void notifyQueryStarted(bool remoteSource) { + Q_Q(QDeclarative1XmlListModel); + progress = remoteSource ? 0.0 : 1.0; + status = QDeclarative1XmlListModel::Loading; + errorString.clear(); + emit q->progressChanged(progress); + emit q->statusChanged(status); + } + + bool isComponentComplete; + QUrl src; + QString xml; + QString query; + QString namespaces; + int size; + QList roles; + QStringList roleNames; + int highestRole; + QNetworkReply *reply; + QDeclarative1XmlListModel::Status status; + QString errorString; + qreal progress; + int queryId; + QStringList keyRoleResultsCache; + QList roleObjects; + static void append_role(QDeclarativeListProperty *list, QDeclarative1XmlListModelRole *role); + static void clear_role(QDeclarativeListProperty *list); + QList > data; + int redirectCount; +}; + + +void QDeclarative1XmlListModelPrivate::append_role(QDeclarativeListProperty *list, QDeclarative1XmlListModelRole *role) +{ + QDeclarative1XmlListModel *_this = qobject_cast(list->object); + if (_this && role) { + int i = _this->d_func()->roleObjects.count(); + _this->d_func()->roleObjects.append(role); + if (_this->d_func()->roleNames.contains(role->name())) { + qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name()); + return; + } + _this->d_func()->roles.insert(i, _this->d_func()->highestRole); + _this->d_func()->roleNames.insert(i, role->name()); + ++_this->d_func()->highestRole; + } +} + +//### clear needs to invalidate any cached data (in data table) as well +// (and the model should emit the appropriate signals) +void QDeclarative1XmlListModelPrivate::clear_role(QDeclarativeListProperty *list) +{ + QDeclarative1XmlListModel *_this = static_cast(list->object); + _this->d_func()->roles.clear(); + _this->d_func()->roleNames.clear(); + _this->d_func()->roleObjects.clear(); +} + +/*! + \qmlclass XmlListModel QDeclarative1XmlListModel + \ingroup qml-working-with-data + \since 4.7 + \brief The XmlListModel element is used to specify a read-only model using XPath expressions. + + XmlListModel is used to create a read-only model from XML data. It can be used as a data source + for view elements (such as ListView, PathView, GridView) and other elements that interact with model + data (such as \l Repeater). + + For example, if there is a XML document at http://www.mysite.com/feed.xml like this: + + \code + + + ... + + + A blog post + Sat, 07 Sep 2010 10:00:01 GMT + + + Another blog post + Sat, 07 Sep 2010 15:35:01 GMT + + + + \endcode + + A XmlListModel could create a model from this data, like this: + + \qml + import QtQuick 1.0 + + XmlListModel { + id: xmlModel + source: "http://www.mysite.com/feed.xml" + query: "/rss/channel/item" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "pubDate"; query: "pubDate/string()" } + } + \endqml + + The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate + a model item for each \c in the XML document. + + The XmlRole objects define the + model item attributes. Here, each model item will have \c title and \c pubDate + attributes that match the \c title and \c pubDate values of its corresponding \c . + (See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.) + + The model could be used in a ListView, like this: + + \qml + ListView { + width: 180; height: 300 + model: xmlModel + delegate: Text { text: title + ": " + pubDate } + } + \endqml + + \image qml-xmllistmodel-example.png + + The XmlListModel data is loaded asynchronously, and \l status + is set to \c XmlListModel.Ready when loading is complete. + Note this means when XmlListModel is used for a view, the view is not + populated until the model is loaded. + + + \section2 Using key XML roles + + You can define certain roles as "keys" so that when reload() is called, + the model will only add and refresh data that contains new values for + these keys. + + For example, if above role for "pubDate" was defined like this instead: + + \qml + XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true } + \endqml + + Then when reload() is called, the model will only add and reload + items with a "pubDate" value that is not already + present in the model. + + This is useful when displaying the contents of XML documents that + are incrementally updated (such as RSS feeds) to avoid repainting the + entire contents of a model in a view. + + If multiple key roles are specified, the model only adds and reload items + with a combined value of all key roles that is not already present in + the model. + + \sa {RSS News} +*/ + +QDeclarative1XmlListModel::QDeclarative1XmlListModel(QObject *parent) + : QListModelInterface(*(new QDeclarative1XmlListModelPrivate), parent) +{ + connect(globalXmlQuery(), SIGNAL(queryCompleted(QDeclarative1XmlQueryResult)), + this, SLOT(queryCompleted(QDeclarative1XmlQueryResult))); + connect(globalXmlQuery(), SIGNAL(error(void*,QString)), + this, SLOT(queryError(void*,QString))); +} + +QDeclarative1XmlListModel::~QDeclarative1XmlListModel() +{ +} + +/*! + \qmlproperty list XmlListModel::roles + + The roles to make available for this model. +*/ +QDeclarativeListProperty QDeclarative1XmlListModel::roleObjects() +{ + Q_D(QDeclarative1XmlListModel); + QDeclarativeListProperty list(this, d->roleObjects); + list.append = &QDeclarative1XmlListModelPrivate::append_role; + list.clear = &QDeclarative1XmlListModelPrivate::clear_role; + return list; +} + +QHash QDeclarative1XmlListModel::data(int index, const QList &roles) const +{ + Q_D(const QDeclarative1XmlListModel); + QHash rv; + for (int i = 0; i < roles.size(); ++i) { + int role = roles.at(i); + int roleIndex = d->roles.indexOf(role); + rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index)); + } + return rv; +} + +QVariant QDeclarative1XmlListModel::data(int index, int role) const +{ + Q_D(const QDeclarative1XmlListModel); + int roleIndex = d->roles.indexOf(role); + return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index); +} + +/*! + \qmlproperty int XmlListModel::count + The number of data entries in the model. +*/ +int QDeclarative1XmlListModel::count() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->size; +} + +QList QDeclarative1XmlListModel::roles() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->roles; +} + +QString QDeclarative1XmlListModel::toString(int role) const +{ + Q_D(const QDeclarative1XmlListModel); + int index = d->roles.indexOf(role); + if (index == -1) + return QString(); + return d->roleNames.at(index); +} + +/*! + \qmlproperty url XmlListModel::source + The location of the XML data source. + + If both \c source and \l xml are set, \l xml is used. +*/ +QUrl QDeclarative1XmlListModel::source() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->src; +} + +void QDeclarative1XmlListModel::setSource(const QUrl &src) +{ + Q_D(QDeclarative1XmlListModel); + if (d->src != src) { + d->src = src; + if (d->xml.isEmpty()) // src is only used if d->xml is not set + reload(); + emit sourceChanged(); + } +} + +/*! + \qmlproperty string XmlListModel::xml + This property holds the XML data for this model, if set. + + The text is assumed to be UTF-8 encoded. + + If both \l source and \c xml are set, \c xml is used. +*/ +QString QDeclarative1XmlListModel::xml() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->xml; +} + +void QDeclarative1XmlListModel::setXml(const QString &xml) +{ + Q_D(QDeclarative1XmlListModel); + if (d->xml != xml) { + d->xml = xml; + reload(); + emit xmlChanged(); + } +} + +/*! + \qmlproperty string XmlListModel::query + An absolute XPath query representing the base query for creating model items + from this model's XmlRole objects. The query should start with '/' or '//'. +*/ +QString QDeclarative1XmlListModel::query() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->query; +} + +void QDeclarative1XmlListModel::setQuery(const QString &query) +{ + Q_D(QDeclarative1XmlListModel); + if (!query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << QCoreApplication::translate("QDeclarative1XmlRoleList", "An XmlListModel query must start with '/' or \"//\""); + return; + } + + if (d->query != query) { + d->query = query; + reload(); + emit queryChanged(); + } +} + +/*! + \qmlproperty string XmlListModel::namespaceDeclarations + The namespace declarations to be used in the XPath queries. + + The namespaces should be declared as in XQuery. For example, if a requested document + at http://mysite.com/feed.xml uses the namespace "http://www.w3.org/2005/Atom", + this can be declared as the default namespace: + + \qml + XmlListModel { + source: "http://mysite.com/feed.xml" + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + } + \endqml +*/ +QString QDeclarative1XmlListModel::namespaceDeclarations() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->namespaces; +} + +void QDeclarative1XmlListModel::setNamespaceDeclarations(const QString &declarations) +{ + Q_D(QDeclarative1XmlListModel); + if (d->namespaces != declarations) { + d->namespaces = declarations; + reload(); + emit namespaceDeclarationsChanged(); + } +} + +/*! + \qmlmethod object XmlListModel::get(int index) + + Returns the item at \a index in the model. + + For example, for a model like this: + + \qml + XmlListModel { + id: model + source: "http://mysite.com/feed.xml" + query: "/feed/entry" + XmlRole { name: "title"; query: "title/string()" } + } + \endqml + + This will access the \c title value for the first item in the model: + + \js + var title = model.get(0).title; + \endjs +*/ +QDeclarativeV8Handle QDeclarative1XmlListModel::get(int index) const +{ + // Must be called with a context and handle scope + Q_D(const QDeclarative1XmlListModel); + + if (index < 0 || index >= count()) + return QDeclarativeV8Handle::fromHandle(v8::Undefined()); + + QDeclarativeEngine *engine = qmlContext(this)->engine(); + QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(engine); + v8::Local rv = v8::Object::New(); + for (int ii = 0; ii < d->roleObjects.count(); ++ii) + rv->Set(v8engine->toString(d->roleObjects[ii]->name()), + v8engine->fromVariant(d->data.value(ii).value(index))); + + return QDeclarativeV8Handle::fromHandle(rv); +} + +/*! + \qmlproperty enumeration XmlListModel::status + Specifies the model loading status, which can be one of the following: + + \list + \o XmlListModel.Null - No XML data has been set for this model. + \o XmlListModel.Ready - The XML data has been loaded into the model. + \o XmlListModel.Loading - The model is in the process of reading and loading XML data. + \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details + about the error. + \endlist + + \sa progress + +*/ +QDeclarative1XmlListModel::Status QDeclarative1XmlListModel::status() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->status; +} + +/*! + \qmlproperty real XmlListModel::progress + + This indicates the current progress of the downloading of the XML data + source. This value ranges from 0.0 (no data downloaded) to + 1.0 (all data downloaded). If the XML data is not from a remote source, + the progress becomes 1.0 as soon as the data is read. + + Note that when the progress is 1.0, the XML data has been downloaded, but + it is yet to be loaded into the model at this point. Use the status + property to find out when the XML data has been read and loaded into + the model. + + \sa status, source +*/ +qreal QDeclarative1XmlListModel::progress() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->progress; +} + +/*! + \qmlmethod void XmlListModel::errorString() + + Returns a string description of the last error that occurred + if \l status is XmlListModel::Error. +*/ +QString QDeclarative1XmlListModel::errorString() const +{ + Q_D(const QDeclarative1XmlListModel); + return d->errorString; +} + +void QDeclarative1XmlListModel::classBegin() +{ + Q_D(QDeclarative1XmlListModel); + d->isComponentComplete = false; +} + +void QDeclarative1XmlListModel::componentComplete() +{ + Q_D(QDeclarative1XmlListModel); + d->isComponentComplete = true; + reload(); +} + +/*! + \qmlmethod XmlListModel::reload() + + Reloads the model. + + If no key roles have been specified, all existing model + data is removed, and the model is rebuilt from scratch. + + Otherwise, items are only added if the model does not already + contain items with matching key role values. + + \sa {Using key XML roles}, XmlRole::isKey +*/ +void QDeclarative1XmlListModel::reload() +{ + Q_D(QDeclarative1XmlListModel); + + if (!d->isComponentComplete) + return; + + globalXmlQuery()->abort(d->queryId); + d->queryId = -1; + + if (d->size < 0) + d->size = 0; + + if (d->reply) { + d->reply->abort(); + if (d->reply) { + // abort will generally have already done this (and more) + d->reply->deleteLater(); + d->reply = 0; + } + } + + if (!d->xml.isEmpty()) { + d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache); + d->notifyQueryStarted(false); + + } else if (d->src.isEmpty()) { + d->queryId = XMLLISTMODEL_CLEAR_ID; + d->notifyQueryStarted(false); + QTimer::singleShot(0, this, SLOT(dataCleared())); + + } else { + d->notifyQueryStarted(true); + QNetworkRequest req(d->src); + req.setRawHeader("Accept", "application/xml,*/*"); + d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req); + QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); + QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), + this, SLOT(requestProgress(qint64,qint64))); + } +} + +#define XMLLISTMODEL_MAX_REDIRECT 16 + +void QDeclarative1XmlListModel::requestFinished() +{ + Q_D(QDeclarative1XmlListModel); + + d->redirectCount++; + if (d->redirectCount < XMLLISTMODEL_MAX_REDIRECT) { + QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirect.isValid()) { + QUrl url = d->reply->url().resolved(redirect.toUrl()); + d->reply->deleteLater(); + d->reply = 0; + setSource(url); + return; + } + } + d->redirectCount = 0; + + if (d->reply->error() != QNetworkReply::NoError) { + d->errorString = d->reply->errorString(); + disconnect(d->reply, 0, this, 0); + d->reply->deleteLater(); + d->reply = 0; + + int count = this->count(); + d->data.clear(); + d->size = 0; + if (count > 0) { + emit itemsRemoved(0, count); + emit countChanged(); + } + + d->status = Error; + d->queryId = -1; + emit statusChanged(d->status); + } else { + QByteArray data = d->reply->readAll(); + if (data.isEmpty()) { + d->queryId = XMLLISTMODEL_CLEAR_ID; + QTimer::singleShot(0, this, SLOT(dataCleared())); + } else { + d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache); + } + disconnect(d->reply, 0, this, 0); + d->reply->deleteLater(); + d->reply = 0; + + d->progress = 1.0; + emit progressChanged(d->progress); + } +} + +void QDeclarative1XmlListModel::requestProgress(qint64 received, qint64 total) +{ + Q_D(QDeclarative1XmlListModel); + if (d->status == Loading && total > 0) { + d->progress = qreal(received)/total; + emit progressChanged(d->progress); + } +} + +void QDeclarative1XmlListModel::dataCleared() +{ + Q_D(QDeclarative1XmlListModel); + QDeclarative1XmlQueryResult r; + r.queryId = XMLLISTMODEL_CLEAR_ID; + r.size = 0; + r.removed << qMakePair(0, count()); + r.keyRoleResultsCache = d->keyRoleResultsCache; + queryCompleted(r); +} + +void QDeclarative1XmlListModel::queryError(void* object, const QString& error) +{ + // Be extra careful, object may no longer exist, it's just an ID. + Q_D(QDeclarative1XmlListModel); + for (int i=0; iroleObjects.count(); i++) { + if (d->roleObjects.at(i) == static_cast(object)) { + qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error); + return; + } + } + qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error); +} + +void QDeclarative1XmlListModel::queryCompleted(const QDeclarative1XmlQueryResult &result) +{ + Q_D(QDeclarative1XmlListModel); + if (result.queryId != d->queryId) + return; + + int origCount = d->size; + bool sizeChanged = result.size != d->size; + + d->size = result.size; + d->data = result.data; + d->keyRoleResultsCache = result.keyRoleResultsCache; + d->status = Ready; + d->errorString.clear(); + d->queryId = -1; + + bool hasKeys = false; + for (int i=0; iroleObjects.count(); i++) { + if (d->roleObjects[i]->isKey()) { + hasKeys = true; + break; + } + } + if (!hasKeys) { + if (!(origCount == 0 && d->size == 0)) { + emit itemsRemoved(0, origCount); + emit itemsInserted(0, d->size); + emit countChanged(); + } + + } else { + for (int i=0; istatus); +} + + + +QT_END_NAMESPACE + +#include diff --git a/src/qtquick1/util/qdeclarativexmllistmodel_p.h b/src/qtquick1/util/qdeclarativexmllistmodel_p.h new file mode 100644 index 0000000000..7b2ddbf268 --- /dev/null +++ b/src/qtquick1/util/qdeclarativexmllistmodel_p.h @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEXMLLISTMODEL_H +#define QDECLARATIVEXMLLISTMODEL_H + +#include +#include + +#include +#include + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QDeclarativeContext; +class QDeclarative1XmlListModelRole; +class QDeclarative1XmlListModelPrivate; + +struct QDeclarative1XmlQueryResult { + int queryId; + int size; + QList > data; + QList > inserted; + QList > removed; + QStringList keyRoleResultsCache; +}; + +class Q_AUTOTEST_EXPORT QDeclarative1XmlListModel : public QListModelInterface, public QDeclarativeParserStatus +{ + Q_OBJECT + Q_INTERFACES(QDeclarativeParserStatus) + Q_ENUMS(Status) + + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString xml READ xml WRITE setXml NOTIFY xmlChanged) + Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged) + Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations NOTIFY namespaceDeclarationsChanged) + Q_PROPERTY(QDeclarativeListProperty roles READ roleObjects) + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_CLASSINFO("DefaultProperty", "roles") + +public: + QDeclarative1XmlListModel(QObject *parent = 0); + ~QDeclarative1XmlListModel(); + + virtual QHash data(int index, const QList &roles = (QList())) const; + virtual QVariant data(int index, int role) const; + virtual int count() const; + virtual QList roles() const; + virtual QString toString(int role) const; + + QDeclarativeListProperty roleObjects(); + + QUrl source() const; + void setSource(const QUrl&); + + QString xml() const; + void setXml(const QString&); + + QString query() const; + void setQuery(const QString&); + + QString namespaceDeclarations() const; + void setNamespaceDeclarations(const QString&); + + Q_INVOKABLE QDeclarativeV8Handle get(int index) const; + + enum Status { Null, Ready, Loading, Error }; + Status status() const; + qreal progress() const; + + Q_INVOKABLE QString errorString() const; + + virtual void classBegin(); + virtual void componentComplete(); + +Q_SIGNALS: + void statusChanged(QDeclarative1XmlListModel::Status); + void progressChanged(qreal progress); + void countChanged(); + void sourceChanged(); + void xmlChanged(); + void queryChanged(); + void namespaceDeclarationsChanged(); + +public Q_SLOTS: + // ### need to use/expose Expiry to guess when to call this? + // ### property to auto-call this on reasonable Expiry? + // ### LastModified/Age also useful to guess. + // ### Probably also applies to other network-requesting types. + void reload(); + +private Q_SLOTS: + void requestFinished(); + void requestProgress(qint64,qint64); + void dataCleared(); + void queryCompleted(const QDeclarative1XmlQueryResult &); + void queryError(void* object, const QString& error); + +private: + Q_DECLARE_PRIVATE(QDeclarative1XmlListModel) + Q_DISABLE_COPY(QDeclarative1XmlListModel) +}; + +class Q_AUTOTEST_EXPORT QDeclarative1XmlListModelRole : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged) + Q_PROPERTY(bool isKey READ isKey WRITE setIsKey NOTIFY isKeyChanged) +public: + QDeclarative1XmlListModelRole() : m_isKey(false) {} + ~QDeclarative1XmlListModelRole() {} + + QString name() const { return m_name; } + void setName(const QString &name) { + if (name == m_name) + return; + m_name = name; + emit nameChanged(); + } + + QString query() const { return m_query; } + void setQuery(const QString &query) + { + if (query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << tr("An XmlRole query must not start with '/'"); + return; + } + if (m_query == query) + return; + m_query = query; + emit queryChanged(); + } + + bool isKey() const { return m_isKey; } + void setIsKey(bool b) { + if (m_isKey == b) + return; + m_isKey = b; + emit isKeyChanged(); + } + + bool isValid() { + return !m_name.isEmpty() && !m_query.isEmpty(); + } + +Q_SIGNALS: + void nameChanged(); + void queryChanged(); + void isKeyChanged(); + +private: + QString m_name; + QString m_query; + bool m_isKey; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QDeclarative1XmlListModel) +QML_DECLARE_TYPE(QDeclarative1XmlListModelRole) + +QT_END_HEADER + +#endif // QDECLARATIVEXMLLISTMODEL_H diff --git a/src/qtquick1/util/util.pri b/src/qtquick1/util/util.pri new file mode 100644 index 0000000000..c5e68b78e3 --- /dev/null +++ b/src/qtquick1/util/util.pri @@ -0,0 +1,69 @@ +INCLUDEPATH += $$PWD + +SOURCES += \ + $$PWD/qdeclarativeapplication.cpp \ + $$PWD/qdeclarativeview.cpp \ + $$PWD/qdeclarativeconnections.cpp \ + $$PWD/qdeclarativepackage.cpp \ + $$PWD/qdeclarativeanimation.cpp \ + $$PWD/qdeclarativesystempalette.cpp \ + $$PWD/qdeclarativespringanimation.cpp \ + $$PWD/qdeclarativesmoothedanimation.cpp \ + $$PWD/qdeclarativestate.cpp\ + $$PWD/qdeclarativetransitionmanager.cpp \ + $$PWD/qdeclarativestateoperations.cpp \ + $$PWD/qdeclarativepropertychanges.cpp \ + $$PWD/qdeclarativestategroup.cpp \ + $$PWD/qdeclarativetransition.cpp \ +# $$PWD/qdeclarativelistmodel.cpp\ +# $$PWD/qdeclarativelistmodelworkeragent.cpp \ + $$PWD/qdeclarativelistaccessor.cpp \ + $$PWD/qdeclarativeopenmetaobject.cpp \ + $$PWD/qdeclarativetimeline.cpp \ + $$PWD/qdeclarativetimer.cpp \ + $$PWD/qdeclarativebind.cpp \ + $$PWD/qdeclarativepixmapcache.cpp \ + $$PWD/qdeclarativebehavior.cpp \ + $$PWD/qdeclarativefontloader.cpp \ + $$PWD/qdeclarativestyledtext.cpp \ + $$PWD/qdeclarativeutilmodule.cpp\ + +HEADERS += \ + $$PWD/qdeclarativeapplication_p.h \ + $$PWD/qdeclarativeutilmodule_p.h\ + $$PWD/qdeclarativeview.h \ + $$PWD/qdeclarativeconnections_p.h \ + $$PWD/qdeclarativepackage_p.h \ + $$PWD/qdeclarativeanimation_p.h \ + $$PWD/qdeclarativeanimation_p_p.h \ + $$PWD/qdeclarativesystempalette_p.h \ + $$PWD/qdeclarativespringanimation_p.h \ + $$PWD/qdeclarativesmoothedanimation_p.h \ + $$PWD/qdeclarativesmoothedanimation_p_p.h \ + $$PWD/qdeclarativestate_p.h\ + $$PWD/qdeclarativestateoperations_p.h \ + $$PWD/qdeclarativepropertychanges_p.h \ + $$PWD/qdeclarativestate_p_p.h\ + $$PWD/qdeclarativetransitionmanager_p_p.h \ + $$PWD/qdeclarativestategroup_p.h \ + $$PWD/qdeclarativetransition_p.h \ +# $$PWD/qdeclarativelistmodel_p.h\ +# $$PWD/qdeclarativelistmodel_p_p.h\ +# $$PWD/qdeclarativelistmodelworkeragent_p.h \ + $$PWD/qdeclarativelistaccessor_p.h \ + $$PWD/qdeclarativeopenmetaobject_p.h \ + $$PWD/qdeclarativetimeline_p_p.h \ + $$PWD/qdeclarativetimer_p.h \ + $$PWD/qdeclarativebind_p.h \ + $$PWD/qdeclarativepixmapcache_p.h \ + $$PWD/qdeclarativebehavior_p.h \ + $$PWD/qdeclarativefontloader_p.h \ + $$PWD/qdeclarativestyledtext_p.h \ + +contains(QT_CONFIG, xmlpatterns) { + QT+=xmlpatterns + SOURCES += $$PWD/qdeclarativexmllistmodel.cpp + HEADERS += $$PWD/qdeclarativexmllistmodel_p.h +} else { + DEFINES += QT_NO_XMLPATTERNS +} diff --git a/src/src.pro b/src/src.pro index e825502451..1fa93c5b34 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += v8 declarative plugins +SUBDIRS += v8 declarative qtquick1 plugins contains(QT_CONFIG, qmltest): SUBDIRS += qmltest SUBDIRS += imports diff --git a/sync.profile b/sync.profile index fa79ed1737..f7aec34d06 100644 --- a/sync.profile +++ b/sync.profile @@ -1,5 +1,6 @@ %modules = ( # path to module name map "QtDeclarative" => "$basedir/src/declarative", + "QtQuick1" => "$basedir/src/qtquick1", "QtQuickTest" => "$basedir/src/qmltest", ); %moduleheaders = ( # restrict the module headers to those found in relative path @@ -15,6 +16,7 @@ ); %modulepris = ( "QtDeclarative" => "$basedir/modules/qt_declarative.pri", + "QtQuick1" => "$basedir/modules/qt_qtquick1.pri", "QtQuickTest" => "$basedir/modules/qt_qmltest.pri", ); # Module dependencies. diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 2543261eeb..8f351b7653 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,6 +1,7 @@ TEMPLATE=subdirs SUBDIRS=\ declarative \ + qtquick1 \ contains(QT_CONFIG, qmltest): SUBDIRS += qmltest diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index d72f745d25..183c920ece 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -15,51 +15,29 @@ PUBLICTESTS += \ qdeclarativeerror \ qdeclarativefolderlistmodel \ qdeclarativeinfo \ - qdeclarativelayoutitem \ qdeclarativelistreference \ qdeclarativemoduleplugin \ - qdeclarativeparticles \ qdeclarativepixmapcache \ qdeclarativeqt \ - qdeclarativeview \ - qdeclarativeviewer \ - qdeclarativexmlhttprequest \ - moduleqt47 + qdeclarativexmlhttprequest PRIVATETESTS += \ - qdeclarativeanchors \ - qdeclarativeanimatedimage \ qdeclarativeanimations \ qdeclarativeapplication \ qdeclarativebehaviors \ qdeclarativebinding \ - qdeclarativeborderimage \ qdeclarativeconnection \ qdeclarativedebug \ qdeclarativedebugclient \ qdeclarativedebughelper \ qdeclarativedebugservice \ qdeclarativeecmascript \ - qdeclarativeflickable \ - qdeclarativeflipable \ - qdeclarativefocusscope \ - qdeclarativefontloader \ - qdeclarativegridview \ - qdeclarativeimage \ qdeclarativeimageprovider \ qdeclarativeinstruction \ - qdeclarativeitem \ qdeclarativelanguage \ qdeclarativelistmodel \ - qdeclarativelistview \ - qdeclarativeloader \ - qdeclarativemousearea \ - qdeclarativepathview \ - qdeclarativepincharea \ - qdeclarativepositioners \ qdeclarativeproperty \ qdeclarativepropertymap \ - qdeclarativerepeater \ # qdeclarativescriptdebugging \ qdeclarativesmoothedanimation \ qdeclarativespringanimation \ @@ -67,12 +45,8 @@ PRIVATETESTS += \ qdeclarativesqldatabase \ qdeclarativestates \ qdeclarativesystempalette \ - qdeclarativetext \ - qdeclarativetextedit \ - qdeclarativetextinput \ qdeclarativetimer \ qdeclarativevaluetypes \ - qdeclarativevisualdatamodel \ qdeclarativeworkerscript \ qdeclarativexmllistmodel \ qpacketprotocol \ diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 5b02c36ae9..8c3c030692 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_examples.cpp @@ -18,4 +18,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro deleted file mode 100644 index d44a902d07..0000000000 --- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ /dev/null @@ -1,17 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative network -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp -macx:CONFIG -= app_bundle - -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativeanimations/data/Double.qml b/tests/auto/declarative/qdeclarativeanimations/data/Double.qml index b247fcee5f..99ffca1d62 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/Double.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/Double.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: container diff --git a/tests/auto/declarative/qdeclarativeanimations/data/attached.qml b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml index c5d5535bb7..9dcfcd8752 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/attached.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/attached.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 180; height: 200; diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml index 3e7ebe7440..9634c2c169 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badproperty1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml index 40235eee15..c121172a99 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badproperty2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml index 0a8a7ea7f9..43e1ec8572 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 240 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml index 118bbbc889..5341cb3d1c 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 240 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml index 2599e70cc9..182efa0840 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 240 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml b/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml index 5dafb0e344..f091e2430f 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/badtype4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml index e2ce07fbfc..c0c0c65e3f 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontAutoStart.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml index 6b8031769f..3eee0cfd35 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml b/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml index 2563c01d4f..e7b4164e4e 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dontStart2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml b/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml index aff69e5c12..e0e46dcef5 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/dotproperty.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/doubleRegistrationBug.qml index f0fdf9cfb5..9ef3da20c0 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/doubleRegistrationBug.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/doubleRegistrationBug.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400; height: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml index a97b3fd5bf..76129dd15e 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml index 9a77467820..1a7166e3f3 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/mixedtype2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml index 04741ff348..909c533e7b 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/nonTransitionBug.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: root diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml index e6af9acc93..f0f730967c 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml index 60ec456c71..6b7f026e0b 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml index e86eca1316..5eb65496d4 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml index 04d41c64c1..dfe8ad17e7 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml index e139f8c6c0..075fc9bc5a 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/properties5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml index 8e2b41db6c..968c5f6285 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml index 6b846852ff..f06165604a 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml index c9d8e95bd3..7d3b3b9c6d 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml index 61e8a96788..1c31a79634 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml index b023943007..a2ff746900 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml index 7c88a7f038..d3db01efb0 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition6.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition7.qml b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition7.qml index fbef95e572..98898de8ef 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition7.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/propertiesTransition7.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/registrationBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/registrationBug.qml index 7dc29f9315..633da4e17f 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/registrationBug.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/registrationBug.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: rect diff --git a/tests/auto/declarative/qdeclarativeanimations/data/rotation.qml b/tests/auto/declarative/qdeclarativeanimations/data/rotation.qml index ac158df719..4dc42a1bd2 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/rotation.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/rotation.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 600; height: 200 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml index 7d33ed7175..bec6fab368 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { color: "skyblue" width: 500 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml index fa9cd400ac..7a636b4003 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml index f6343a1bff..9788761ee8 100644 --- a/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml +++ b/tests/auto/declarative/qdeclarativeanimations/data/valuesource2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro index b37714165c..2669e5a8e3 100644 --- a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro +++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative opengl SOURCES += tst_qdeclarativeanimations.cpp macx:CONFIG -= app_bundle @@ -13,4 +13,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private opengl-private diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index 00db2d43ae..cf911c6bef 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -41,10 +41,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -101,32 +101,32 @@ private slots: void tst_qdeclarativeanimations::simpleProperty() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativePropertyAnimation animation; animation.setTarget(&rect); - animation.setProperty("pos"); - animation.setTo(QPointF(200,200)); + animation.setProperty("x"); + animation.setTo(200); QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "pos"); - QVERIFY(animation.to().toPointF() == QPointF(200,200)); + QVERIFY(animation.property() == "x"); + QVERIFY(animation.to().toReal() == 200.0); animation.start(); QVERIFY(animation.isRunning()); QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.pos(), QPointF(200,200)); + QTIMED_COMPARE(rect.x(), 200.0); - rect.setPos(0,0); + rect.setPos(QPointF(0,0)); animation.start(); animation.pause(); QVERIFY(animation.isRunning()); QVERIFY(animation.isPaused()); animation.setCurrentTime(125); QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.pos(), QPointF(100,100)); + QCOMPARE(rect.x(),100.0); } void tst_qdeclarativeanimations::simpleNumber() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativeNumberAnimation animation; animation.setTarget(&rect); animation.setProperty("x"); @@ -151,7 +151,7 @@ void tst_qdeclarativeanimations::simpleNumber() void tst_qdeclarativeanimations::simpleColor() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativeColorAnimation animation; animation.setTarget(&rect); animation.setProperty("color"); @@ -185,7 +185,7 @@ void tst_qdeclarativeanimations::simpleColor() void tst_qdeclarativeanimations::simpleRotation() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativeRotationAnimation animation; animation.setTarget(&rect); animation.setProperty("rotation"); @@ -211,7 +211,7 @@ void tst_qdeclarativeanimations::simpleRotation() void tst_qdeclarativeanimations::alwaysRunToEnd() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativePropertyAnimation animation; animation.setTarget(&rect); animation.setProperty("x"); @@ -231,7 +231,7 @@ void tst_qdeclarativeanimations::alwaysRunToEnd() void tst_qdeclarativeanimations::complete() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativePropertyAnimation animation; animation.setTarget(&rect); animation.setProperty("x"); @@ -252,7 +252,7 @@ void tst_qdeclarativeanimations::complete() void tst_qdeclarativeanimations::resume() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativePropertyAnimation animation; animation.setTarget(&rect); animation.setProperty("x"); @@ -279,28 +279,28 @@ void tst_qdeclarativeanimations::resume() void tst_qdeclarativeanimations::dotProperty() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativeNumberAnimation animation; animation.setTarget(&rect); animation.setProperty("border.width"); animation.setTo(10); animation.start(); QTest::qWait(animation.duration()+50); - QTIMED_COMPARE(rect.border()->width(), 10); + QTIMED_COMPARE(rect.border()->width(), 10.0); rect.border()->setWidth(0); animation.start(); animation.pause(); animation.setCurrentTime(125); QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.border()->width(), 5); + QCOMPARE(rect.border()->width(), 5.0); } void tst_qdeclarativeanimations::badTypes() { //don't crash { - QDeclarativeView *view = new QDeclarativeView; + QSGView *view = new QSGView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); qApp->processEvents(); @@ -334,12 +334,12 @@ void tst_qdeclarativeanimations::badTypes() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("state1"); + QSGItemPrivate::get(rect)->setState("state1"); QTest::qWait(1000 + 50); - QDeclarativeRectangle *myRect = rect->findChild("MyRect"); + QSGRectangle *myRect = rect->findChild("MyRect"); QVERIFY(myRect); QCOMPARE(myRect->x(),qreal(200)); } @@ -354,13 +354,13 @@ void tst_qdeclarativeanimations::badProperties() QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); QByteArray message = QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; QTest::ignoreMessage(QtWarningMsg, message); - QDeclarativeRectangle *rect = qobject_cast(c1.create()); + QSGRectangle *rect = qobject_cast(c1.create()); QVERIFY(rect); QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml")); message = QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; QTest::ignoreMessage(QtWarningMsg, message); - rect = qobject_cast(c2.create()); + rect = qobject_cast(c2.create()); QVERIFY(rect); //### should we warn here are well? @@ -376,12 +376,12 @@ void tst_qdeclarativeanimations::mixedTypes() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("state1"); + QSGItemPrivate::get(rect)->setState("state1"); QTest::qWait(500); - QDeclarativeRectangle *myRect = rect->findChild("MyRect"); + QSGRectangle *myRect = rect->findChild("MyRect"); QVERIFY(myRect); //rather inexact -- is there a better way? @@ -392,12 +392,12 @@ void tst_qdeclarativeanimations::mixedTypes() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("state1"); + QSGItemPrivate::get(rect)->setState("state1"); QTest::qWait(500); - QDeclarativeRectangle *myRect = rect->findChild("MyRect"); + QSGRectangle *myRect = rect->findChild("MyRect"); QVERIFY(myRect); //rather inexact -- is there a better way? @@ -412,10 +412,10 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -424,10 +424,10 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -436,10 +436,10 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(300)); @@ -448,10 +448,10 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->y(),qreal(200)); @@ -461,10 +461,10 @@ void tst_qdeclarativeanimations::properties() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(100)); @@ -478,11 +478,11 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGItemPrivate::get(rect)->setState("moved"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -491,12 +491,12 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); + QSGItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); QCOMPARE(myRect->y(),qreal(100)); QTest::qWait(waitDuration); @@ -506,12 +506,12 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); + QSGItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); QCOMPARE(myRect->y(),qreal(100)); } @@ -519,12 +519,12 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); + QSGItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -533,12 +533,12 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); + QSGItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -547,12 +547,12 @@ void tst_qdeclarativeanimations::propertiesTransition() /*{ QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); + QSGItemPrivate::get(rect)->setState("moved"); QCOMPARE(myRect->x(),qreal(100)); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(100)); @@ -561,11 +561,11 @@ void tst_qdeclarativeanimations::propertiesTransition() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition7.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QDeclarativeRectangle *myRect = rect->findChild("TheRect"); + QSGItemPrivate::get(rect)->setState("moved"); + QSGRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); QTIMED_COMPARE(myRect->x(),qreal(200)); @@ -593,7 +593,7 @@ void tst_qdeclarativeanimations::attached() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml")); QTest::ignoreMessage(QtDebugMsg, "off"); QTest::ignoreMessage(QtDebugMsg, "on"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); } @@ -604,7 +604,7 @@ void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); @@ -617,7 +617,7 @@ void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); @@ -630,7 +630,7 @@ void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); @@ -649,7 +649,7 @@ void tst_qdeclarativeanimations::dontStart() QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); @@ -664,7 +664,7 @@ void tst_qdeclarativeanimations::dontStart() QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); @@ -677,7 +677,7 @@ void tst_qdeclarativeanimations::easingProperties() { { QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nNumberAnimation { easing.type: \"InOutQuad\" }"; + QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }"; QDeclarativeComponent animationComponent(&engine); animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); @@ -688,7 +688,7 @@ void tst_qdeclarativeanimations::easingProperties() { QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }"; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }"; QDeclarativeComponent animationComponent(&engine); animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); @@ -700,7 +700,7 @@ void tst_qdeclarativeanimations::easingProperties() { QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}"; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}"; QDeclarativeComponent animationComponent(&engine); animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); @@ -713,7 +713,7 @@ void tst_qdeclarativeanimations::easingProperties() { QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }"; + QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }"; QDeclarativeComponent animationComponent(&engine); animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativePropertyAnimation *animObject = qobject_cast(animationComponent.create()); @@ -728,15 +728,15 @@ void tst_qdeclarativeanimations::rotation() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/rotation.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *rr = rect->findChild("rr"); - QDeclarativeRectangle *rr2 = rect->findChild("rr2"); - QDeclarativeRectangle *rr3 = rect->findChild("rr3"); - QDeclarativeRectangle *rr4 = rect->findChild("rr4"); + QSGRectangle *rr = rect->findChild("rr"); + QSGRectangle *rr2 = rect->findChild("rr2"); + QSGRectangle *rr3 = rect->findChild("rr3"); + QSGRectangle *rr4 = rect->findChild("rr4"); - QDeclarativeItemPrivate::get(rect)->setState("state1"); + QSGItemPrivate::get(rect)->setState("state1"); QTest::qWait(800); qreal r1 = rr->rotation(); qreal r2 = rr2->rotation(); @@ -759,10 +759,10 @@ void tst_qdeclarativeanimations::runningTrueBug() //ensure we start correctly when "running: true" is explicitly set QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrueBug.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *cloud = rect->findChild("cloud"); + QSGRectangle *cloud = rect->findChild("cloud"); QVERIFY(cloud); QTest::qWait(1000); QVERIFY(cloud->x() > qreal(0)); @@ -776,10 +776,10 @@ void tst_qdeclarativeanimations::nonTransitionBug() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/nonTransitionBug.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarativeRectangle *mover = rect->findChild("mover"); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); + QSGRectangle *mover = rect->findChild("mover"); mover->setX(100); QCOMPARE(mover->x(), qreal(100)); @@ -802,7 +802,7 @@ void tst_qdeclarativeanimations::registrationBug() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/registrationBug.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); QTRY_COMPARE(rect->property("value"), QVariant(int(100))); } @@ -812,7 +812,7 @@ void tst_qdeclarativeanimations::doubleRegistrationBug() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/doubleRegistrationBug.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); QDeclarativeAbstractAnimation *anim = rect->findChild("animation"); @@ -823,7 +823,7 @@ void tst_qdeclarativeanimations::doubleRegistrationBug() //QTBUG-16736 void tst_qdeclarativeanimations::alwaysRunToEndRestartBug() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativePropertyAnimation animation; animation.setTarget(&rect); animation.setProperty("x"); diff --git a/tests/auto/declarative/qdeclarativeapplication/tst_qdeclarativeapplication.cpp b/tests/auto/declarative/qdeclarativeapplication/tst_qdeclarativeapplication.cpp index c2cfcd89d6..264a95d8d6 100644 --- a/tests/auto/declarative/qdeclarativeapplication/tst_qdeclarativeapplication.cpp +++ b/tests/auto/declarative/qdeclarativeapplication/tst_qdeclarativeapplication.cpp @@ -43,9 +43,8 @@ #include "../../../shared/util.h" #include #include -#include -#include -#include +#include +#include class tst_qdeclarativeapplication : public QObject { @@ -68,12 +67,11 @@ tst_qdeclarativeapplication::tst_qdeclarativeapplication() void tst_qdeclarativeapplication::active() { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); + component.setData("import QtQuick 2.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile("")); + QSGItem *item = qobject_cast(component.create()); QVERIFY(item); - QGraphicsScene scene; - QGraphicsView view(&scene); - scene.addItem(item); + QSGView view; + item->setParentItem(view.rootObject()); // not active QVERIFY(!item->property("active").toBool()); @@ -99,12 +97,11 @@ void tst_qdeclarativeapplication::active() void tst_qdeclarativeapplication::layoutDirection() { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); + component.setData("import QtQuick 2.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile("")); + QSGItem *item = qobject_cast(component.create()); QVERIFY(item); - QGraphicsScene scene; - QGraphicsView view(&scene); - scene.addItem(item); + QSGView view; + item->setParentItem(view.rootObject()); // not mirrored QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml index a452447f31..5aceefa743 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/binding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/color.qml b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml index c4b783a0f0..a318578a9b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/color.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/color.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml index 88ddfaa1a7..f033ec5aeb 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/cpptrigger.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml index aa384c335f..ed35a308f7 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/delayedRegistration.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: container diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml index f6cfa5e33d..20860d8dde 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/disabled.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml index e318dd2567..38e1ea9d9e 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/dontStart.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: wrapper diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml index 6c78a84540..d8f115390a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/empty.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml index 3baa1ac23a..20875c30e3 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/explicit.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml index ddb5bbd40c..a05ab7d54b 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml index c0b71cdb04..2f3de5131c 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupProperty2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 @@ -6,7 +6,7 @@ Rectangle { id: rect objectName: "MyRect" width: 100; height: 100; color: "green" - Behavior on pos.x { NumberAnimation { duration: 500; } } + Behavior on border.width { NumberAnimation { duration: 500; } } } MouseArea { id: clicker @@ -17,7 +17,7 @@ Rectangle { when: clicker.pressed PropertyChanges { target: rect - pos.x: 200; + border.width: 4; } } } diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml index 8aa590bca1..6835902bc5 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/groupedPropertyCrash.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 200 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml index 76379c00a2..3e8d88734d 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/loop.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml index c5c78d1aa2..6357094cfe 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/nonSelecting2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml index d19da298b2..f8c2731d86 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/parent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml index 03b542164b..c6bef581a4 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/qtbug12295.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 200 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml index 56ac216c5a..5731cb3efd 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml index 25cdf10acf..4fd1136f3a 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/runningTrue.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: root diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml index c05cdaa940..ff71f2b1b0 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/scripttrigger.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml index 6ba0118660..c64a6e1928 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/simple.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 height: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml index fca416c08c..9fa74ca39e 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400 diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml index eb627613d4..0654ef3644 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 800; diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro index 0861ab6286..e0720aa6fd 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative opengl SOURCES += tst_qdeclarativebehaviors.cpp macx:CONFIG -= app_bundle @@ -13,4 +13,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private opengl-private diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 01d0b321a1..191a96f81d 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -42,12 +42,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include -#include +#include #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -88,13 +88,13 @@ void tst_qdeclarativebehaviors::simpleBehavior() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); QTRY_VERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + QSGItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); //i.e. the behavior has been triggered delete rect; @@ -104,12 +104,12 @@ void tst_qdeclarativebehaviors::scriptTriggered() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); rect->setColor(QColor("red")); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); //i.e. the behavior has been triggered delete rect; @@ -119,10 +119,10 @@ void tst_qdeclarativebehaviors::cppTriggered() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QTRY_VERIFY(innerRect); innerRect->setProperty("x", 200); @@ -136,11 +136,11 @@ void tst_qdeclarativebehaviors::loop() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); //don't crash - QDeclarativeItemPrivate::get(rect)->setState("moved"); + QSGItemPrivate::get(rect)->setState("moved"); delete rect; } @@ -149,12 +149,12 @@ void tst_qdeclarativebehaviors::colorBehavior() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("red"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("red")); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("green")); + QSGItemPrivate::get(rect)->setState("red"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("red")); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("green")); //i.e. the behavior has been triggered delete rect; @@ -164,12 +164,12 @@ void tst_qdeclarativebehaviors::parentBehavior() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("reparented"); - QTRY_VERIFY(rect->findChild("MyRect")->parentItem() != rect->findChild("NewParent")); - QTRY_VERIFY(rect->findChild("MyRect")->parentItem() == rect->findChild("NewParent")); + QSGItemPrivate::get(rect)->setState("reparented"); + QTRY_VERIFY(rect->findChild("MyRect")->parentItem() != rect->findChild("NewParent")); + QTRY_VERIFY(rect->findChild("MyRect")->parentItem() == rect->findChild("NewParent")); delete rect; } @@ -178,11 +178,11 @@ void tst_qdeclarativebehaviors::replaceBinding() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGItemPrivate::get(rect)->setState("moved"); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QTRY_VERIFY(innerRect); QTRY_VERIFY(innerRect->x() > 0); QTRY_VERIFY(innerRect->x() < 200); @@ -193,7 +193,7 @@ void tst_qdeclarativebehaviors::replaceBinding() rect->setProperty("movedx", 210); QTRY_COMPARE(innerRect->x(), (qreal)210); - QDeclarativeItemPrivate::get(rect)->setState(""); + QSGItemPrivate::get(rect)->setState(""); QTRY_VERIFY(innerRect->x() > 10); QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered QTRY_COMPARE(innerRect->x(), (qreal)10); @@ -207,30 +207,33 @@ void tst_qdeclarativebehaviors::replaceBinding() void tst_qdeclarativebehaviors::group() { + /* XXX TODO Create a test element for this case. { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); + qDebug() << c.errorString(); QTRY_VERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); + QSGItemPrivate::get(rect)->setState("moved"); //QTest::qWait(200); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); //i.e. the behavior has been triggered delete rect; } + */ { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QTRY_VERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + QSGItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->border()->width() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->border()->width() < 4); //i.e. the behavior has been triggered delete rect; @@ -241,11 +244,11 @@ void tst_qdeclarativebehaviors::emptyBehavior() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QSGItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately delete rect; @@ -255,12 +258,12 @@ void tst_qdeclarativebehaviors::explicitSelection() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + QSGItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); //i.e. the behavior has been triggered delete rect; @@ -270,11 +273,11 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QSGItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately delete rect; @@ -286,7 +289,7 @@ void tst_qdeclarativebehaviors::reassignedAnimation() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QCOMPARE(qobject_cast( rect->findChild("MyBehavior")->animation())->duration(), 200); @@ -298,12 +301,12 @@ void tst_qdeclarativebehaviors::disabled() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QSGItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately delete rect; @@ -317,7 +320,7 @@ void tst_qdeclarativebehaviors::dontStart() QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); @@ -332,10 +335,10 @@ void tst_qdeclarativebehaviors::startup() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *innerRect = rect->findChild("innerRect"); + QSGRectangle *innerRect = rect->findChild("innerRect"); QVERIFY(innerRect); QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately @@ -346,13 +349,13 @@ void tst_qdeclarativebehaviors::startup() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *innerRect = rect->findChild("innerRect"); + QSGRectangle *innerRect = rect->findChild("innerRect"); QVERIFY(innerRect); - QDeclarativeText *text = rect->findChild(); + QSGText *text = rect->findChild(); QVERIFY(text); QCOMPARE(innerRect->x(), text->width()); //should be set immediately @@ -366,7 +369,7 @@ void tst_qdeclarativebehaviors::groupedPropertyCrash() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupedPropertyCrash.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); //don't crash } @@ -375,7 +378,7 @@ void tst_qdeclarativebehaviors::runningTrue() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrue.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); QDeclarativeAbstractAnimation *animation = rect->findChild("rotAnim"); @@ -391,16 +394,17 @@ void tst_qdeclarativebehaviors::sameValue() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *target = rect->findChild("myRect"); + QSGRectangle *target = rect->findChild("myRect"); QVERIFY(target); target->setX(100); QCOMPARE(target->x(), qreal(100)); target->setProperty("x", 0); + qDebug() << "x" << target->x(); QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. @@ -419,10 +423,10 @@ void tst_qdeclarativebehaviors::delayedRegistration() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/delayedRegistration.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItem *innerRect = rect->property("myItem").value(); + QSGItem *innerRect = rect->property("myItem").value(); QVERIFY(innerRect != 0); QCOMPARE(innerRect->property("x").toInt(), int(0)); diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml index 94497368a7..87aabe975a 100644 --- a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml +++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: screen diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml index 3e99e2b5e6..4a08141d11 100644 --- a/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml +++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: screen diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp index 127309e1e4..7bfd0e07ff 100644 --- a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp +++ b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #include "../../../shared/util.h" @@ -75,7 +74,7 @@ void tst_qdeclarativebinding::binding() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); QDeclarativeBind *binding3 = qobject_cast(rect->findChild("binding3")); @@ -103,7 +102,7 @@ void tst_qdeclarativebinding::whenAfterValue() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); QCOMPARE(rect->color(), QColor("yellow")); diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro deleted file mode 100644 index aeb8a5dfcd..0000000000 --- a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro +++ /dev/null @@ -1,18 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui network -macx:CONFIG -= app_bundle - -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp - -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml b/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml index 4a067911df..da5db8e8e6 100644 --- a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml +++ b/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml @@ -1,16 +1,13 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item{ id: root property QtObject qobject : null property QtObject declarativeitem : null - property QtObject graphicswidget: null Component{id: a; QtObject{} } Component{id: b; Item{} } - Component{id: c; QGraphicsWidget{} } Component.onCompleted: { root.qobject = a.createObject(root); root.declarativeitem = b.createObject(root); - root.graphicswidget = c.createObject(root); } } diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml b/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml index 0da3bda50f..122c6a87c8 100644 --- a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml +++ b/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item{ id: root diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index 93dc567c6a..9cbc98d75a 100644 --- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -41,10 +41,9 @@ #include #include -#include #include #include -#include +#include #include #include @@ -111,21 +110,14 @@ void tst_qdeclarativecomponent::qmlCreateObject() QObject *testObject2 = object->property("declarativeitem").value(); QVERIFY(testObject2); QVERIFY(testObject2->parent() == object); - QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem"); - - //Note that QGraphicsObjects are not exposed to QML for instantiation, and so can't be used in a component directly - //Also this is actually the extended type QDeclarativeGraphicsWidget, but it still doesn't inherit QDeclarativeItem - QGraphicsObject *testObject3 = qobject_cast(object->property("graphicswidget").value()); - QVERIFY(testObject3); - QVERIFY(testObject3->parent() == object); - QVERIFY(testObject3->parentItem() == qobject_cast(object)); - QCOMPARE(testObject3->metaObject()->className(), "QDeclarativeGraphicsWidget"); + QCOMPARE(testObject2->metaObject()->className(), "QSGItem"); } void tst_qdeclarativecomponent::qmlCreateObjectWithProperties() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/createObjectWithScript.qml")); + qDebug() << component.errorString(); QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); QObject *object = component.create(); QVERIFY(object != 0); diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml index dd92cb9c67..154c309c9c 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { Component { diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml index 459c34617b..05d06bda94 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: screen diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml index 8eddf43fe6..9d25cba649 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: screen diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml index 953347a3b2..bcd281256f 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: screen diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml index 3702bdbe73..ad8d4d91a8 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: screen diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml index 376a2182fe..256b2626a7 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { Connections { diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml index 677af152ce..a602479783 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { Connections { fakeProperty: {} } diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml index 127e58e657..8123afe707 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { Connections { onfakeProperty: {} } diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml index 6a82528e1a..16c0534b68 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { Connections { diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml index c5990830cd..ce851fc3db 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: screen; width: 50 diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml index f0dbaba5a6..b23d2fc145 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 Connections { id: connection; target: connection; onTargetChanged: 1 == 1 } diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml index 94c9c7ca7f..9e88f0ff8f 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 Connections {} diff --git a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml b/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml index 00507d919c..6692050deb 100644 --- a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml +++ b/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: screen; width: 50 diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro index 56bf59f851..564b088817 100644 --- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro +++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private opengl-private diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp index f0edf40b87..37cce5c578 100644 --- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include "../../../shared/util.h" #include @@ -107,7 +107,7 @@ void tst_qdeclarativeconnection::connection() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); + QSGItem *item = qobject_cast(c.create()); QVERIFY(item != 0); @@ -124,7 +124,7 @@ void tst_qdeclarativeconnection::trimming() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); + QSGItem *item = qobject_cast(c.create()); QVERIFY(item != 0); @@ -145,18 +145,18 @@ void tst_qdeclarativeconnection::targetChanged() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/connection-targetchange.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); + QSGItem *item = qobject_cast(c.create()); QVERIFY(item != 0); QDeclarativeConnections *connections = item->findChild("connections"); QVERIFY(connections); - QDeclarativeItem *item1 = item->findChild("item1"); + QSGItem *item1 = item->findChild("item1"); QVERIFY(item1); item1->setWidth(200); - QDeclarativeItem *item2 = item->findChild("item2"); + QSGItem *item2 = item->findChild("item2"); QVERIFY(item2); QVERIFY(connections->target() == item2); @@ -190,7 +190,7 @@ void tst_qdeclarativeconnection::unknownSignals() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, url); - QDeclarativeItem *item = qobject_cast(c.create()); + QSGItem *item = qobject_cast(c.create()); QVERIFY(item != 0); // check that connection is created (they are all runtime errors) diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index 8871e45f4f..ade51c43f6 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -50,13 +50,13 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -84,7 +84,7 @@ class tst_QDeclarativeDebug : public QObject QDeclarativeDebugConnection *m_conn; QDeclarativeEngineDebug *m_dbg; QDeclarativeEngine *m_engine; - QDeclarativeItem *m_rootItem; + QSGItem *m_rootItem; QObjectList m_components; @@ -228,7 +228,7 @@ void tst_QDeclarativeDebug::recursiveObjectTest(QObject *o, const QDeclarativeDe QCOMPARE(p.value(), pmeta.read(o)); if (p.name() == "parent") - QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QDeclarativeItem*"); + QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QSGItem*"); else QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName())); @@ -303,7 +303,7 @@ void tst_QDeclarativeDebug::initTestCase() m_engine = new QDeclarativeEngine(this); QList qml; - qml << "import QtQuick 1.0\n" + qml << "import QtQuick 2.0\n" "import Test 1.0\n" "Item {" "id: root\n" @@ -326,11 +326,11 @@ void tst_QDeclarativeDebug::initTestCase() "}"; // add second component to test multiple root contexts - qml << "import QtQuick 1.0\n" + qml << "import QtQuick 2.0\n" "Item {}"; // and a third to test methods - qml << "import QtQuick 1.0\n" + qml << "import QtQuick 2.0\n" "Item {" "function myMethodNoArgs() { return 3; }\n" "function myMethod(a) { return a + 9; }\n" @@ -338,7 +338,7 @@ void tst_QDeclarativeDebug::initTestCase() "}"; // and a fourth to test states - qml << "import QtQuick 1.0\n" + qml << "import QtQuick 2.0\n" "Rectangle {\n" "id:rootRect\n" "width:100\n" @@ -369,9 +369,9 @@ void tst_QDeclarativeDebug::initTestCase() QDeclarativeComponent component(m_engine); component.setData(qml[i], QUrl::fromLocalFile("")); QVERIFY(component.isReady()); // fails if bad syntax - m_components << qobject_cast(component.create()); + m_components << qobject_cast(component.create()); } - m_rootItem = qobject_cast(m_components.first()); + m_rootItem = qobject_cast(m_components.first()); // add an extra context to test for multiple contexts QDeclarativeContext *context = new QDeclarativeContext(m_engine->rootContext(), this); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml index 0eda67d51a..e8e108fa44 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml index f539fb62b4..062772106b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyTypeObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml index a4b0527436..823c0ef367 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml index 4a42518575..aa1a1d6061 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string greeting: "hello world" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml index 829d405c3c..eaca0a7f92 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { function testFunction() { return 19; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml index f542c64a91..3b3e84a900 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int b: obj.prop.a diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml index df494af5a1..f341cce3c9 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int a: 3 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml b/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml index 3427a3b27a..f6398d254d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int children: root.children.length diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml index f0808c4cb8..ff6c553c31 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml index 4f07cbf616..bba9033235 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: me diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml index 937ae91c9b..3e4cda6ba3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml index a01dc5b0b2..de5f49ffc5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: me diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml index da6c795b12..f228b2c19f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml index 5bf9f6a2ed..b5bc280d11 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: me diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml index a23ad4a0dd..6c16ff5604 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: me diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml index ac20371472..441098bd39 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: me diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml index 9443c01d50..86ff6b6bb3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyTypeObject { Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml index c66ef6939e..11fb7ccad2 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml index 68dbcfad97..31f7c44fcc 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a: 10 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml index 0f23297570..3fbf931fca 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { objectProperty: MyQmlObject {} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml index 3182d6b4ab..1e92aca825 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int changeCount: 0 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml index 50ef0b34dd..3549d8c556 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int changeCount: 0 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml index 343cf91720..d611e0fe30 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int changeCount: 0 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml index b8459875df..a6862517c6 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int changeCount: 0 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml index d31c89382b..f91fb71f1f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int changeCount: 0 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml index 58b7adb841..7c46306772 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { //real diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml index 1af77d5aff..e97b75c8d0 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property CustomObject myObject diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml index 18a57ba625..308a01ce6f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyDeferredObject { value: undefined // error is resolved before complete diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml index 131fa6f2b8..2a9ce44b20 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml index 4de405dcce..97acddf5fc 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { function calculate() { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml index 7ba51ef068..24c12bf694 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml index 661cd5c4d9..a752b8c0d3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test1: false; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml index 2102821aac..b8d5e5e60f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml index c197ef8335..a4ce55e245 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml index 9738d2cf24..2c382e871a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property MyExtendedObject a; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml index b0e897efff..7734a11dd8 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyExtendedObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml index 6cd8751c93..af2da7023c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test1: false; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml index c8c926aea8..0f78eaf1dc 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "functionAssignment.js" as Script diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml index 2ba02d1d76..230a626600 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { function myFunction() { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml index 6dcdefcbca..ece23269f1 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { objectProperty: if(1) otherObject diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml index 32b86110e4..650ed7c73e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { objectProperty: otherObject diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml b/tests/auto/declarative/qdeclarativeecmascript/data/in.qml index f9cccb5a5c..f84c9a1481 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/in.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml index 61b0461833..5ce2ed78ec 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "include.js" as IncludeTest QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml index 1633ebaa25..fbebcdcd58 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "include_callback.js" as IncludeTest QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml index a648969426..7b23c76baa 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "include_pragma_outer.js" as Script Item { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml index 0dfc74ff20..fe020a55df 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "include_remote.js" as IncludeTest QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml index 05a7399601..e8ef609fed 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "include_remote_missing.js" as IncludeTest QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml index e9f1c89bd8..28b1003fd4 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "include_shared.js" as IncludeTest QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml index 6ab25f272a..160a90b574 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml index 87b2d7e4a0..4612273727 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml index e93007ab9a..4223c25f31 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int test diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml index 698b672259..97c72bd9a6 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "importPragmaLibrary.js" as TestPragmaLibraryImport diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml index 581ae671e3..d006343782 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "importPragmaLibrary.js" as TestPragmaLibraryImport diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml index 4a284ad886..456a10c7f0 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "testScriptImport.js" as TestScriptImport import "testModuleImport.js" as TestModuleImport diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml index 7add311326..29de15c197 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 // We use the components specified in SpecialRectangleOne.qml and SpecialRectangleTwo.qml diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml index 0df841c78c..aff61cc436 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 // For backward compatibility, importing a script which has no imports, // should run the script in the parent context. See QTBUG-17518. diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml index 9bf969cc61..73193a35a5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 // This should fail, since if the script does have imports // of its own, it should run in its own context. diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml index fe7e88a829..ef2fc591b3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "testModuleImport.js" as TestModuleImport diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml index e7fb7656f0..d0c37ad9ba 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "testScriptImport.js" as TestScriptImport diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml index fa720a64eb..edd103bd82 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "testModuleImport.js" as TestModuleImport diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml index c2cbce9f80..28e2026f8d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "testScriptImport.js" as TestScriptImport diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml index 7e4a73ae42..f04ce007d8 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "importPragmaLibrary.js" as ImportPragmaLibrary diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml index c0789424de..5884e2719b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "libraryScriptAssert.js" as Test QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml index 7b940758ea..bdb1265a21 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml index 7940ab8c3d..690024b928 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test: children diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml index 81ea536651..6ebe4790bb 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml @@ -1,5 +1,5 @@ import Qt.test 1.1 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant a diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml index 44d421e8ee..8a7e24d788 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyRevisionedClass diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml index 121642e0cf..43e87948cd 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyRevisionedSubclass diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml index 123650e4e8..2f82d685fa 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.1 MyRevisionedSubclass diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml index 1090b48f74..365780a560 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { function testFunction() { return 19; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml index 34c50d6647..a3bd7bebf8 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 MethodsObject { function testFunction2() { return 17; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml index bebdf3d883..ede2759e2e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property alias blah: item.x diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApi.qml b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApi.qml index 23c1eb0bb8..67e8c1b08a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApi.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApi.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 as QtTest // module API installed into existing uri import Qt.test.scriptApi 1.0 as QtTestScriptApi // script module API installed into new uri diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiCaching.qml b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiCaching.qml index 9cee8c3065..f6ce2058a7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiCaching.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiCaching.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 as QtTest // module API installed into existing uri import Qt.test.scriptApi 1.0 as QtTestScriptApi // script module API installed into new uri diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMajorVersionFail.qml b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMajorVersionFail.qml index eca29ab2cf..fb050f65bc 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMajorVersionFail.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMajorVersionFail.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 // this qml file attempts to import an invalid version of a qobject module API. diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMinorVersionFail.qml b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMinorVersionFail.qml index e360bd1668..e06be667f7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMinorVersionFail.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiMinorVersionFail.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 // this qml file attempts to import an invalid version of a qobject module API. diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiWriting.qml b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiWriting.qml index 90a674681c..500c35e211 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiWriting.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/moduleApiWriting.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 as QtTest // module API installed into existing uri diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml index d9c63e67bd..e349ced98f 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string test: thing.stringProperty diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml index 9e0bcf09bb..23276f778d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml b/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml index 7e7da8d7a8..b4a417e04e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml index e86cc961af..e96df6b40e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml index cbd2d3e7e8..1aee7a1670 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property QtObject test diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml b/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml index ca8c90d818..20b9ec2935 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { objectName: "hello" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml index ef0e304ac1..845f74b1aa 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml index 53427b76e5..855a264995 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Component.onCompleted: { var a = getObject(); a = null; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml index 0455271dac..34523ec1c7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml b/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml index 7deb84a1be..53711db3f4 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyDerivedObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml index 2e9e1736cb..3c1986d721 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int test: getObjects().length diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml index 02357d45f4..90263e5124 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string test: "aaaa" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml index 7fcf2bebd7..6c7e8806e6 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "qtbug_11600.js" as Test QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml index 05c482cae7..b1b062ed35 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml index e531efcd5a..90711c8d09 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml b/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml index cbbbbf921a..a9e7dd2a95 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/ScarceResourceSignalComponent.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/ScarceResourceSignalComponent.qml index fb40bdc2de..e10fcfe36a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/ScarceResourceSignalComponent.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/ScarceResourceSignalComponent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant scarceResourceCopy diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopy.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopy.qml index 82184354d8..ee5b05b28a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopy.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopy.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 // Here we import a scarce resource directly. diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyFromJs.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyFromJs.qml index 60c26ac4f2..40f6d7bbd6 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyFromJs.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyFromJs.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 import "scarceResourceTest.js" as ScarceResourceProviderJs diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImport.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImport.qml index 0513b0840e..08acc1b694 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImport.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImport.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 import "scarceResourceCopyImport.js" as ScarceResourceCopyImportJs diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportFail.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportFail.qml index d3c4d4ed65..613d3a8ee8 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportFail.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportFail.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 import "scarceResourceCopyImportFail.js" as ScarceResourceCopyImportFailJs diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportNoBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportNoBinding.qml index 72cd4dac8a..81deec0713 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportNoBinding.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyImportNoBinding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 // the following js import doesn't manually preserve or destroy any resources diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyNoBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyNoBinding.qml index 681a382427..4adef39980 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyNoBinding.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceCopyNoBinding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceDestroyedCopy.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceDestroyedCopy.qml index 87ceda9d7a..e47c37aba3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceDestroyedCopy.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceDestroyedCopy.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 import "scarceResourceTest.js" as ScarceResourceProviderJs diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunction.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunction.qml index e3e7aed9ee..fe3707b5d3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunction.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunction.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 // Here we import a scarce resource directly. diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunctionFail.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunctionFail.qml index 9b07080054..38de0ae0aa 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunctionFail.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceFunctionFail.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 // In this example, a common syntax error will only be "caught" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceSignal.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceSignal.qml index 9c920b1aa0..1d5a39c52d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceSignal.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceSignal.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTest.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTest.qml index 3775172c04..1d4e67055e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTest.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTest.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 // Here we import a scarce resource directly, and use it in a binding. diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestMultiple.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestMultiple.qml index 3139382b05..9a6ee30ff1 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestMultiple.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestMultiple.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 import "scarceResourceTest.js" as ScarceResourceProviderJs diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestPreserve.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestPreserve.qml index d810377a51..d7a40312ab 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestPreserve.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scarceresources/scarceResourceTestPreserve.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 import "scarceResourceTest.js" as ScarceResourceProviderJs diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml index 9555b7f95b..fe1c4c7931 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int a: 0 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml index 0b0770e6b9..9add81809c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml index 405746c459..6dbcbe2a40 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property bool test1: false; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml index 1c81e4e945..5897b533d7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: me diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml index 63dba2fc9f..a00352b684 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml index 65697d9382..ace473756e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "scriptConnect.1.js" as Script MyQmlObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml index 86ff7987d8..cdf2d6ad98 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "scriptConnect.2.js" as Script MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml index db2f00578c..b0e40565c0 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml index a2d90ff819..ef5331c94a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml index 21fac15d69..8dcacbcbb7 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml index 4053091988..06b6f0fa62 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "scriptConnect.6.js" as Script MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml index bbe70249ba..e546ee44d8 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "scriptDisconnect.1.js" as Script MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml index 8a166f41ff..e70cd8b900 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "scriptDisconnect.1.js" as Script MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml index 548f2a12f7..6f47776ea5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "scriptDisconnect.1.js" as Script MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml index 11b22d7216..b3887545fb 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "scriptDisconnect.1.js" as Script MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml b/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml index 2d090b8f0d..b967f0984c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml index 7a6aba74be..b30aa8b4cd 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int test: myObject.object.a diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml index 8410d33319..d98d7e9c81 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { property real base: 50 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml b/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml index 2932c77826..e709e3a8bd 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test1: (a === true) diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml index 1e5afdf54a..c44acf4fd1 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml index 60d39fa171..451bb51996 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant obj: nested diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml b/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml index 849dfadd4f..6aa8480365 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool runTest: false diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml b/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml index 31bf69d33f..3854b069a0 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml index 035f0374e8..a1ba5df071 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro deleted file mode 100644 index f0c95f071a..0000000000 --- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro +++ /dev/null @@ -1,18 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui network -macx:CONFIG -= app_bundle - -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp - -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro deleted file mode 100644 index 75837d7359..0000000000 --- a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ /dev/null @@ -1,18 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui network -macx:CONFIG -= app_bundle - -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp - -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index cc42aa06ca..6ddc3bcb58 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include "../../../shared/util.h" @@ -229,24 +229,24 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide engine.addImageProvider("test", provider); QVERIFY(engine.imageProvider("test") != 0); - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + source + "\"; " + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; " + (async ? "asynchronous: true; " : "") + properties + " }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QSGImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); if (async) - QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); + QTRY_VERIFY(obj->status() == QSGImage::Loading); QCOMPARE(obj->source(), QUrl(source)); if (error.isEmpty()) { if (async) - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QSGImage::Ready); else - QVERIFY(obj->status() == QDeclarativeImage::Ready); + QVERIFY(obj->status() == QSGImage::Ready); if (QByteArray(QTest::currentDataTag()).startsWith("qimage")) QCOMPARE(static_cast(provider)->lastImageId, imageId); else @@ -254,15 +254,13 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QCOMPARE(obj->width(), qreal(size.width())); QCOMPARE(obj->height(), qreal(size.height())); - QCOMPARE(obj->pixmap().width(), size.width()); - QCOMPARE(obj->pixmap().height(), size.height()); - QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); + QCOMPARE(obj->fillMode(), QSGImage::Stretch); QCOMPARE(obj->progress(), 1.0); } else { if (async) - QTRY_VERIFY(obj->status() == QDeclarativeImage::Error); + QTRY_VERIFY(obj->status() == QSGImage::Error); else - QVERIFY(obj->status() == QDeclarativeImage::Error); + QVERIFY(obj->status() == QSGImage::Error); } delete obj; @@ -313,10 +311,10 @@ void tst_qdeclarativeimageprovider::requestPixmap_async() QVERIFY(engine.imageProvider("test") != 0); // pixmaps are loaded synchronously regardless of 'asynchronous' value - QString componentStr = "import QtQuick 1.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }"; + QString componentStr = "import QtQuick 2.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QSGImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); delete obj; @@ -340,13 +338,13 @@ void tst_qdeclarativeimageprovider::removeProvider() QVERIFY(engine.imageProvider("test") != 0); // add provider, confirm it works - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + newImageFileName() + "\" }"; + QString componentStr = "import QtQuick 2.0\nImage { source: \"" + newImageFileName() + "\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QSGImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - QCOMPARE(obj->status(), QDeclarativeImage::Ready); + QCOMPARE(obj->status(), QSGImage::Ready); // remove the provider and confirm QString fileName = newImageFileName(); @@ -356,7 +354,7 @@ void tst_qdeclarativeimageprovider::removeProvider() engine.removeImageProvider("test"); obj->setSource(QUrl(fileName)); - QCOMPARE(obj->status(), QDeclarativeImage::Error); + QCOMPARE(obj->status(), QSGImage::Error); delete obj; } @@ -401,7 +399,7 @@ void tst_qdeclarativeimageprovider::threadTest() engine.addImageProvider("test_thread", provider); QVERIFY(engine.imageProvider("test_thread") != 0); - QString componentStr = "import QtQuick 1.0\nItem { \n" + QString componentStr = "import QtQuick 2.0\nItem { \n" "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n" "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n" "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n" @@ -412,17 +410,17 @@ void tst_qdeclarativeimageprovider::threadTest() QObject *obj = component.create(); //MUST not deadlock QVERIFY(obj != 0); - QList images = obj->findChildren(); + QList images = obj->findChildren(); QCOMPARE(images.count(), 4); QTest::qWait(100); - foreach(QDeclarativeImage *img, images) { - QCOMPARE(img->status(), QDeclarativeImage::Loading); + foreach(QSGImage *img, images) { + QCOMPARE(img->status(), QSGImage::Loading); } provider->ok = true; provider->cond.wakeAll(); QTest::qWait(250); - foreach(QDeclarativeImage *img, images) { - QTRY_VERIFY(img->status() == QDeclarativeImage::Ready); + foreach(QSGImage *img, images) { + QTRY_VERIFY(img->status() == QSGImage::Ready); } } diff --git a/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml b/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml index d8ae8ae3ba..cfe47589df 100644 --- a/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml +++ b/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant nested diff --git a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml index a2afb6102a..4b19b11699 100644 --- a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml +++ b/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant nested diff --git a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml index f3516c606c..d199a612c4 100644 --- a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml +++ b/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant nested diff --git a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml index 937cd641e6..6a8e2fbc90 100644 --- a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml +++ b/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant nested diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml index 6a33deffad..2cb7cbe2e0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml index 919f5d86a2..134e1440b5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant other diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml index 3f73538b24..54b548e049 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property alias obj : otherObj diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml b/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml index 428790d83d..e09eca2ff3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Alias3 {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml b/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml index 0bc2025414..9265ffb1df 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml b/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml index 9349a93877..889450b565 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { QtObject {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml index cf32b45687..addc4265a9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml index 0687ce3995..f48a77598c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml b/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml index 5de8a4a76e..4667adda14 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int super_a: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml index 3a7022bdcd..c2ab70ffd6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant child diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml index 4526cf043e..42513e463f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property InlineAssignmentsOverrideBindingsType2 nested: InlineAssignmentsOverrideBindingsType2 { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml index 4127ca4375..4a45535a50 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml index f63283e773..59df88216e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Text {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml b/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml index 8aaddacec4..7d49b0ac98 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property QtObject o1 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml b/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml index 0ba4bd6d6f..06a3212916 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { x: "You can't assign a string to a real!" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml index c2ac5c8458..947f14811f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { property int a: Math.max(10, 9) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml index c3d0e1ef47..11fb9d9578 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { property int a: Math.max(10, 9) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml index 44167af178..dbb3f06d32 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml index 7e5559a7b3..16a6d9d903 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant other diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml index 0c839ee7b1..cee2a88cf7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml index 663e8d0efb..54d3c320e0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property QtObject o; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml index ec5536e7e8..0dc54d6787 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property QtObject object diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml index d480611c62..3cb280ef47 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant other diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml index 0a49ad51f2..01cf9142b2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant other diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml index f04b1f6052..60e66921d2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml index a15a718891..089130d14c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 AliasPropertyChangeSignalsType { id: root diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml index 7944deb44c..4e11b9174a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml index ed214ffe5a..717cd84536 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml index ab6f3df8cf..de476ae47f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: 1 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml index aab7ed2c20..1f731c539c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant a; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml index 3cde2e8269..54fef61ef0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 as Qt47 +import QtQuick 2.0 as Qt47 Qt47.QtObject { Qt47: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml index 1e932251df..3637ded26f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml @@ -1,6 +1,6 @@ import Test 1.0 import Test 1.0 as Namespace -import QtQuick 1.0 +import QtQuick 2.0 QtObject { MyQmlObject.value: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml index f4f66ddab4..a22772bd89 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml index 7d677b5704..fbe315f771 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: myId diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml index 1b9af8bd85..bac23ef903 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { Component { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml index 806613c2a5..d07695477d 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { QtObject {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml index e94022a145..9867377bb9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { x: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml index 8f81a5a9ce..010949a35f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { id: QtObject {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml index 94bf189b5d..b1a31195eb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { property int a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml index 69990cae5b..fb7a079d39 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { signal a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml index 5db98152d4..17824b4ede 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { function a() {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml index d04da62463..232b320fb0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test diff --git a/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml b/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml index 6ac71eea98..2b8d285348 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { objectName: "Hello" + "World" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml index c1e47900b0..57241ffc28 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int on diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml index 50bc2aeb69..c42173ddfb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 ListModel { ListElement { a: 10 } ListElement { id: foo; a: 12 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml index 4cf68272ed..76a8a4773f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 ListModel { ListElement { a: 10 } ListElement { a: 12 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml b/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml index f15373f1dd..03f5c1ff7e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml index d98dfdb5a5..66a78eb67f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyTypeObject { grouped { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml b/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml index 87dc3d3ea2..31d17fd55f 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyContainer { QtObject { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml index ba65d78322..b5b29148a2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { onDestroyed: print("Hello World!") diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml b/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml index 0cdbdd73fe..905ee48e0b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property QtObject object: DontDoubleCallClassBeginItem {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml index 2b6dd5d584..3dbd5b0b2e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { default property QtObject a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml index 7d11d990b5..5d4efeebb2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml index b0f2828eda..f084947eaf 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { signal a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml index e28cad3a68..3691529aa9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { function a() {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml index 8e4acc05aa..64ba907415 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property UnknownType a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml index cdad72b5d2..2214bacda0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyCustomParserType { propa: a + 10 propb: Math.min(a, 10) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml index c03ec49278..6f822ba157 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml @@ -1,5 +1,5 @@ -import QtQuick 1.0 -import QtQuick 1.0 as Qt47 +import QtQuick 2.0 +import QtQuick 2.0 as Qt47 Qt.QtObject { property Qt47.QtObject objectProperty diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml index ed25c4b8a9..5d072b160a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml @@ -1,6 +1,6 @@ import Test 1.0 -import QtQuick 1.0 -import QtQuick 1.0 as Qt47 +import QtQuick 2.0 +import QtQuick 2.0 as Qt47 QtObject { property QtObject objectProperty diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml index 782adefad9..cd403b3d46 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { default property int intProperty : 10 property bool boolProperty: false diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml index 64848fe8b6..b86e89b5e7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 DynamicPropertiesNestedType { property int a: 13 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml index 78978dbace..d80d94be09 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { signal signal1 function slot1() {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml index 3eda6612c4..ff083250f0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Font { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml b/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml index 247f527fed..804e76b932 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import com.Nokia.installedtest 1.0 QtObject { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml index 39e384662b..45ad40501b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml @@ -1,4 +1,4 @@ import Test 1.0 as Rectangle -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml b/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml index 9589692e66..5cbee0264b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml @@ -1,5 +1,5 @@ // imports... import "will-not-be-found" -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml index d11000be78..15b6dc3a6e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 IncorrectCaseType { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml index cf32b45687..addc4265a9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml b/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml index 8f3c5cef79..4390d22d45 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 InlineAssignmentsOverrideBindingsType { property int test: nested.value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml b/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml index a52bd23df5..a6f277adb2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyContainer { Component { id: myComponent diff --git a/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml index 444e234825..f85e3e4e5b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { interfaceProperty: MyQmlObject {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml index 13bdb12196..8aab61e49e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property alias a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml index b6378c39ef..b85b2584eb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property alias a: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml index c6dc44c4ef..20864b9a41 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { MyQmlObject.foo: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml index 4942c21282..20906de606 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml @@ -1,5 +1,5 @@ import Test 1.0 as Namespace -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Namespace.MadeUpClass.foo: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml index e1fc8c15ef..95add15147 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml @@ -1,5 +1,5 @@ import Test 1.0 as Namespace -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Namespace.madeUpClass.foo: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml index 6938122171..050e619ff2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml @@ -1,5 +1,5 @@ import Test 1.0 as Namespace -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Namespace.MyQmlObject.foo: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml index 842600f014..24b09a53d5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { MyQmlObject: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml index 6f372a63b6..fb38ee9536 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml @@ -1,5 +1,5 @@ import Test 1.0 as Namespace -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Namespace.MyQmlObject: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml index 07eb6f3432..789e42f7ef 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { MyQmlObject: QtObject {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml index b72567412d..9060a55d00 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Test.MyQmlObject: QtObject {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml index 50004edf84..47b6cc37d8 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { MyTypeObject.foo: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml index 7cdf5cde33..146934f7ac 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml @@ -1,5 +1,5 @@ import Test 1.0 as Namespace -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Namespace.MyTypeObject.foo: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml index 503e9fa793..73724aa6e7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { MadeUpClass.foo: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml index 94afb16cf2..fa46b8242a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant o; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml index d4fbf423b5..3e516738d6 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int o; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml index 580a0f3975..37e7c5d4d0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 -import QtQuick 1.0 as qt +import QtQuick 2.0 +import QtQuick 2.0 as qt QtObject {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml index bd26bc59a5..f9b322e35c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int parseInt diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml index 9985d3327b..56daa9c09a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 as Qt47 +import QtQuick 2.0 as Qt47 Qt47.Rectangle {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml index f63283e773..59df88216e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Text {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml index 7f491eb802..26a5d6bba9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml index 03bf25bc74..ed1b09e419 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Image {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml index 9985d3327b..56daa9c09a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 as Qt47 +import QtQuick 2.0 as Qt47 Qt47.Rectangle {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml index f63283e773..59df88216e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Text {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml index c02dd33b38..1af190633d 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyContainer { containerChildren: QtObject {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml b/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml index 85abbdc511..74439c66d4 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { ListModel { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml index 1f60951d30..dcfe37d6fc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property list listProperty diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml index 4b37ed3518..fbb37705a1 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml @@ -1,5 +1,5 @@ // Check that a property in a later revision (prop2) cannot be assigned -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.0 MyRevisionedClass diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml index a3f97f8d34..a888b1aaf4 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { function MyMethod() {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml index e0e844234c..92aefef8c4 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { onClicked: console.log("Hello world!") } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml index bbd05a1ffb..cc1df4d181 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { NestedErrorsType {} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml b/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml index 548b7b8637..28852f1a0c 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Keys { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml b/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml index e75f9044e9..89e6777f8a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyTypeObject { // We set a and b to ensure that onCompleted is executed after bindings and diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml index 77fe2ff3c1..7d6da260b4 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyTypeObject { // We set a and b to ensure that onCompleted is executed after bindings and diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml index 0b46ceb685..6b43e6cc89 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property blah a; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml index 3ff16868bf..e6aa00e730 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property invalidmodifier a; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml index b219120af8..978c1aa80b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property invalidmodifier a; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml index bfadc9d496..bb94e84244 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { readonly property int a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml index 1bb4850777..a1401d2fdc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { readonly property int a: value diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml index b5b3f423bb..88f493f9a9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int Hello diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml b/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml index f9ec68a40a..05eb319947 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int Hello: 10 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml index a7ef16af68..7d6fea24db 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int test: { var _ = 1; _ } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml index a165de8d16..fa690ba6bc 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int test: if (b == 1) 123; else 321; diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml index dea52c98a8..55c507f67e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml index 18c65c34d1..db8a3da2b2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { MyQmlObject.value: 10 } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml index c70a55c381..e3c56b701a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant child diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml b/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml index 4d3d7d2a44..823439acdd 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.1 MyRevisionedClass diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml b/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml index 57d76b1c28..78ab51a4b7 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.1 MyRevisionedSubclass diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml b/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml index f107356edf..d00758387e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.1 MyRevisionedSubclass diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml index 7d1a9db2a7..1c27baa4e8 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { signal mySignal(nontype a) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml index e7780a0529..2b00ab80bb 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { signal mySignal(,) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml index 4289bce212..1bfcfff7b5 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { signal mySignal(a) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml index 6ce417db63..653c14e6aa 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { signal MySignal diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml index 2fd7fd2be0..e2760cb418 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property QtObject a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml index da56cb8243..ccbc6f0849 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant a diff --git a/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml b/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml index 0b054d0243..f789a905f2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml index 0b054d0243..f789a905f2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml b/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml index cc3f1c25b9..169b245450 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int notifyCount: 0 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml b/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml index 8c747157d4..3e8bca0368 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.1 MySubclass diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml index 0699d67d91..973fdada24 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyQmlObject { qmlobjectProperty: QtObject {} } diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml index 289cd216fa..4ce04c46d2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/LocalInternal.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 Image { source: "pics/blue.png" } diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml index 0b054d0243..f789a905f2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/Test.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { } diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/UndeclaredLocal.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/UndeclaredLocal.qml index 289cd216fa..4ce04c46d2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/UndeclaredLocal.qml +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/UndeclaredLocal.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 Image { source: "pics/blue.png" } diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml index 0b054d0243..f789a905f2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml @@ -1,2 +1,2 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { } diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml index 76d11dca0e..1480ae8683 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/subdir/SubTest.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 Text {} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 3c6ce9da6d..adf78873a3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -1389,7 +1389,7 @@ void tst_qdeclarativelanguage::reservedWords() { QFETCH(QByteArray, word); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nQtObject { property string " + word + " }", QUrl()); + component.setData("import QtQuick 2.0\nQtObject { property string " + word + " }", QUrl()); QCOMPARE(component.errorString(), QLatin1String(":2 Expected token `identifier'\n")); } @@ -1568,17 +1568,17 @@ void tst_qdeclarativelanguage::importsLocal_data() QTest::newRow("local import") << "import \"subdir\"\n" // QT-613 "Test {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("local import second") - << "import QtQuick 1.0\nimport \"subdir\"\n" + << "import QtQuick 2.0\nimport \"subdir\"\n" "Test {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("local import subsubdir") - << "import QtQuick 1.0\nimport \"subdir/subsubdir\"\n" + << "import QtQuick 2.0\nimport \"subdir/subsubdir\"\n" "SubTest {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("local import QTBUG-7721 A") << "subdir.Test {}" // no longer allowed (QTBUG-7721) @@ -1592,7 +1592,7 @@ void tst_qdeclarativelanguage::importsLocal_data() QTest::newRow("local import as") << "import \"subdir\" as T\n" "T.Test {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("wrong local import as") << "import \"subdir\" as T\n" @@ -1658,11 +1658,11 @@ void tst_qdeclarativelanguage::importsRemote_data() QString serverdir = "http://127.0.0.1:14447/qtest/declarative/qmllanguage"; - QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QDeclarativeRectangle" + QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QSGRectangle" << ""; - QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QDeclarativeText" + QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QSGText" << ""; - QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QDeclarativeImage" + QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QSGImage" << ""; QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << "" << "WrongTestLocal is not a type"; @@ -1696,27 +1696,27 @@ void tst_qdeclarativelanguage::importsInstalled_data() QTest::newRow("installed import 0") << "import com.nokia.installedtest0 0.0\n" "InstalledTestTP {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("installed import 0 as TP") << "import com.nokia.installedtest0 0.0 as TP\n" "TP.InstalledTestTP {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("installed import 1") << "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("installed import 2") << "import com.nokia.installedtest 1.3\n" "InstalledTest {}" - << "QDeclarativeRectangle" + << "QSGRectangle" << ""; QTest::newRow("installed import 3") << "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << "QDeclarativeText" + << "QSGText" << ""; QTest::newRow("installed import minor version not available") // QTBUG-11936 << "import com.nokia.installedtest 0.1\n" @@ -1759,26 +1759,26 @@ void tst_qdeclarativelanguage::importsOrder_data() "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << (!qmlCheckTypes()?"QDeclarativeText":"") + << (!qmlCheckTypes()?"QSGText":"") << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4"); QTest::newRow("installed import overrides 1") << "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << (!qmlCheckTypes()?"QDeclarativeText":"") + << (!qmlCheckTypes()?"QSGText":"") << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); QTest::newRow("installed import overrides 2") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << (!qmlCheckTypes()?"QDeclarativeRectangle":"") + << (!qmlCheckTypes()?"QSGRectangle":"") << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); QTest::newRow("installed import re-overrides 1") << "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "import com.nokia.installedtest 1.4\n" "InstalledTest {}" - << (!qmlCheckTypes()?"QDeclarativeText":"") + << (!qmlCheckTypes()?"QSGText":"") << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0"); QTest::newRow("installed import re-overrides 2") << "import com.nokia.installedtest 1.4\n" @@ -1786,41 +1786,41 @@ void tst_qdeclarativelanguage::importsOrder_data() "import com.nokia.installedtest 1.4\n" "import com.nokia.installedtest 1.0\n" "InstalledTest {}" - << (!qmlCheckTypes()?"QDeclarativeRectangle":"") + << (!qmlCheckTypes()?"QSGRectangle":"") << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4"); QTest::newRow("installed import versus builtin 1") << "import com.nokia.installedtest 1.5\n" - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "Rectangle {}" - << (!qmlCheckTypes()?"QDeclarativeRectangle":"") + << (!qmlCheckTypes()?"QSGRectangle":"") << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest"); QTest::newRow("installed import versus builtin 2") << - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" - << (!qmlCheckTypes()?"QDeclarativeText":"") + << (!qmlCheckTypes()?"QSGText":"") << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt"); QTest::newRow("namespaces cannot be overridden by types 1") << - "import QtQuick 1.0 as Rectangle\n" + "import QtQuick 2.0 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle {}" << "" << "Namespace Rectangle cannot be used as a type"; QTest::newRow("namespaces cannot be overridden by types 2") << - "import QtQuick 1.0 as Rectangle\n" + "import QtQuick 2.0 as Rectangle\n" "import com.nokia.installedtest 1.5\n" "Rectangle.Image {}" - << "QDeclarativeImage" + << "QSGImage" << ""; QTest::newRow("local last 1") << "LocalLast {}" - << "QDeclarativeText" + << "QSGText" << ""; QTest::newRow("local last 2") << "import com.nokia.installedtest 1.0\n" "LocalLast {}" - << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml + << (!qmlCheckTypes()?"QSGRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory"); } @@ -1879,7 +1879,7 @@ void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod() void tst_qdeclarativelanguage::crash1() { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nComponent {}", QUrl()); + component.setData("import QtQuick 2.0\nComponent {}", QUrl()); } void tst_qdeclarativelanguage::crash2() diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml b/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml index 93697f3307..f73d66b318 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml +++ b/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property string result diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml b/tests/auto/declarative/qdeclarativelistmodel/data/model.qml index a1a599c9a5..5973ea8adf 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml +++ b/tests/auto/declarative/qdeclarativelistmodel/data/model.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: item diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml index cc6d9de8a0..4a331e2b3e 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml +++ b/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 ListView { width: 100 height: 250 diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml b/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml index ffe417ae2a..58bf1ccd04 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml +++ b/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 ListModel { id: model diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro index 902a0510cd..85340e70e6 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro +++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro @@ -15,4 +15,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private opengl-private diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 07a6d82752..cfd3981214 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include -#include -#include +#include +#include #include #include #include @@ -69,8 +69,8 @@ class tst_qdeclarativelistmodel : public QObject private: int roleFromName(const QDeclarativeListModel *model, const QString &roleName); - QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model); - void waitForWorker(QDeclarativeItem *item); + QSGItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model); + void waitForWorker(QSGItem *item); private slots: void static_types(); @@ -118,16 +118,16 @@ int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, return -1; } -QDeclarativeItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model) +QSGItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model) { - QDeclarativeItem *item = qobject_cast(component->create()); + QSGItem *item = qobject_cast(component->create()); QDeclarativeEngine::setContextForObject(model, eng->rootContext()); if (item) item->setProperty("model", qVariantFromValue(model)); return item; } -void tst_qdeclarativelistmodel::waitForWorker(QDeclarativeItem *item) +void tst_qdeclarativelistmodel::waitForWorker(QSGItem *item) { QEventLoop loop; QTimer timer; @@ -169,7 +169,7 @@ void tst_qdeclarativelistmodel::static_types_data() QTest::newRow("enum") << "ListElement { foo: Text.AlignHCenter }" - << QVariant(double(QDeclarativeText::AlignHCenter)); + << QVariant(double(QSGText::AlignHCenter)); } void tst_qdeclarativelistmodel::static_types() @@ -177,7 +177,7 @@ void tst_qdeclarativelistmodel::static_types() QFETCH(QString, qml); QFETCH(QVariant, value); - qml = "import QtQuick 1.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }"; + qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }"; QDeclarativeEngine engine; QDeclarativeComponent component(&engine); @@ -201,7 +201,7 @@ void tst_qdeclarativelistmodel::static_i18n() { QString expect = QString::fromUtf8("na\303\257ve"); - QString componentStr = "import QtQuick 1.0\nItem { property string prop1: model.get(0).prop1; property string prop2: model.get(0).prop2; ListModel { id: model; ListElement { prop1: \""+expect+"\"; prop2: QT_TR_NOOP(\""+expect+"\") } } }"; + QString componentStr = "import QtQuick 2.0\nItem { property string prop1: model.get(0).prop1; property string prop2: model.get(0).prop2; ListModel { id: model; ListElement { prop1: \""+expect+"\"; prop2: QT_TR_NOOP(\""+expect+"\") } } }"; QDeclarativeEngine engine; QDeclarativeComponent component(&engine); component.setData(componentStr.toUtf8(), QUrl::fromLocalFile("")); @@ -224,7 +224,7 @@ void tst_qdeclarativelistmodel::static_nestedElements() QString elementsStr = elements.join(",\n") + "\n"; QString componentStr = - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "Item {\n" " property variant count: model.get(0).attributes.count\n" " ListModel {\n" @@ -405,7 +405,7 @@ void tst_qdeclarativelistmodel::dynamic_worker() QDeclarativeListModel model; QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QSGItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); QSignalSpy spyCount(&model, SIGNAL(countChanged())); @@ -451,7 +451,7 @@ void tst_qdeclarativelistmodel::dynamic_worker_sync() QDeclarativeListModel model; QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QSGItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) @@ -505,7 +505,7 @@ void tst_qdeclarativelistmodel::convertNestedToFlat_fail() QDeclarativeListModel model; QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QSGItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); RUNEVAL(item, "model.append({foo: 123})"); @@ -548,7 +548,7 @@ void tst_qdeclarativelistmodel::convertNestedToFlat_ok() QDeclarativeListModel model; QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QSGItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); RUNEVAL(item, "model.append({foo: 123})"); @@ -592,7 +592,7 @@ void tst_qdeclarativelistmodel::enumerate() QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/enumerate.qml")); QVERIFY(!component.isError()); - QDeclarativeItem *item = qobject_cast(component.create()); + QSGItem *item = qobject_cast(component.create()); QVERIFY(item != 0); QStringList r = item->property("result").toString().split(":"); QCOMPARE(r[0],QLatin1String("val1=1Y")); @@ -609,47 +609,47 @@ void tst_qdeclarativelistmodel::error_data() QTest::addColumn("error"); QTest::newRow("id not allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { id: fred } }" + << "import QtQuick 2.0\nListModel { ListElement { id: fred } }" << "ListElement: cannot use reserved \"id\" property"; QTest::newRow("id allowed in ListModel") - << "import QtQuick 1.0\nListModel { id:model }" + << "import QtQuick 2.0\nListModel { id:model }" << ""; QTest::newRow("random properties not allowed in ListModel") - << "import QtQuick 1.0\nListModel { foo:123 }" + << "import QtQuick 2.0\nListModel { foo:123 }" << "ListModel: undefined property 'foo'"; QTest::newRow("random properties allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { foo:123 } }" + << "import QtQuick 2.0\nListModel { ListElement { foo:123 } }" << ""; QTest::newRow("bindings not allowed in ListElement") - << "import QtQuick 1.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" + << "import QtQuick 2.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" << "ListElement: cannot use script for property value"; QTest::newRow("random object list properties allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" + << "import QtQuick 2.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" << ""; QTest::newRow("default properties not allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { Item { } } }" + << "import QtQuick 2.0\nListModel { ListElement { Item { } } }" << "ListElement: cannot contain nested elements"; QTest::newRow("QML elements not allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { a: Item { } } }" + << "import QtQuick 2.0\nListModel { ListElement { a: Item { } } }" << "ListElement: cannot contain nested elements"; QTest::newRow("qualified ListElement supported") - << "import QtQuick 1.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }" + << "import QtQuick 2.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }" << ""; QTest::newRow("qualified ListElement required") - << "import QtQuick 1.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }" + << "import QtQuick 2.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }" << "ListElement is not a type"; QTest::newRow("unknown qualified ListElement not allowed") - << "import QtQuick 1.0\nListModel { Foo.ListElement { a: 123 } }" + << "import QtQuick 2.0\nListModel { Foo.ListElement { a: 123 } }" << "Foo.ListElement - Foo is not a namespace"; } @@ -674,7 +674,7 @@ void tst_qdeclarativelistmodel::error() void tst_qdeclarativelistmodel::syncError() { - QString qml = "import QtQuick 1.0\nListModel { id: lm; Component.onCompleted: lm.sync() }"; + QString qml = "import QtQuick 2.0\nListModel { id: lm; Component.onCompleted: lm.sync() }"; QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript"; QDeclarativeEngine engine; @@ -721,7 +721,7 @@ void tst_qdeclarativelistmodel::get() QDeclarativeEngine engine; QDeclarativeComponent component(&engine); component.setData( - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "ListModel { \n" "ListElement { roleA: 100 }\n" "ListElement { roleA: 200; roleB: 400 } \n" @@ -779,7 +779,7 @@ void tst_qdeclarativelistmodel::get_worker() QDeclarativeListModel model; QDeclarativeEngine eng; QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QSGItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); // Add some values like get() test @@ -833,7 +833,7 @@ void tst_qdeclarativelistmodel::get_nested() QDeclarativeEngine eng; QDeclarativeComponent component(&eng); component.setData( - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "ListModel { \n" "ListElement {\n" "listRoleA: [\n" @@ -960,7 +960,7 @@ void tst_qdeclarativelistmodel::property_changes() QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:"; - QString qml = "import QtQuick 1.0\n" + QString qml = "import QtQuick 2.0\n" "Connections {\n" "property bool gotSignal: false\n" "target: model.get(0)\n" @@ -1055,7 +1055,7 @@ void tst_qdeclarativelistmodel::property_changes_worker() QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); - QDeclarativeItem *item = createWorkerTest(&engine, &component, &model); + QSGItem *item = createWorkerTest(&engine, &component, &model); QVERIFY(item != 0); QDeclarativeExpression expr(engine.rootContext(), &model, script_setup); diff --git a/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml b/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml index 0687ce3995..f48a77598c 100644 --- a/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml +++ b/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a diff --git a/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml b/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml index 9ddc763356..99a61a7680 100644 --- a/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml +++ b/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property list myList diff --git a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml index 39a49e81fe..3728cd0311 100644 --- a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml +++ b/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property list myList; diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro deleted file mode 100644 index d32535897e..0000000000 --- a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro +++ /dev/null @@ -1,20 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui network -macx:CONFIG -= app_bundle - -INCLUDEPATH += ../shared/ -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_qdeclarativeloader.cpp \ - ../shared/testhttpserver.cpp - -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml index a45ac2dd8c..67fb18feb0 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 // this qml file uses a type which is meant to be defined // in a plugin which is specified in the qmldir file. diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml index 83c65538ba..ea9611691e 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: moduleRoot diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml index 3eb29f43da..0fa9f6e051 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 // the type loader will implicitly search "." for a qmldir // and the qmldir has various syntax errors in it. diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml index 70b2bfd837..a0ac0c72c7 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml @@ -1,5 +1,5 @@ import com.nokia.AutoTestQmlMixedPluginType 1.5 -import QtQuick 1.0 +import QtQuick 2.0 Item { property bool test: false diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml index da6ff4656a..1346cbdb7b 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml @@ -1,5 +1,5 @@ import com.nokia.AutoTestQmlMixedPluginType 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { property bool test: false diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml index 59fd084a49..bda59f0a32 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml @@ -1,5 +1,5 @@ import com.nokia.AutoTestQmlVersionPluginType 1.9 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { } diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml index 2065c0712f..2e556e76d6 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml @@ -1,5 +1,5 @@ import com.nokia.AutoTestQmlVersionPluginType 1.1 -import QtQuick 1.0 +import QtQuick 2.0 QtObject { } diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml index 18dcd26f60..617bdaaf67 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 -Item {} \ No newline at end of file +Item {} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml index ce51cbd2ec..36d69e901f 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int value: 89 diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml index 49613aab2d..617bdaaf67 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item {} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml index f19a336d69..fac5d8f4b9 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item {} diff --git a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro deleted file mode 100644 index 0584c6120e..0000000000 --- a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro +++ /dev/null @@ -1,18 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui network -macx:CONFIG -= app_bundle - -HEADERS += ../shared/testhttpserver.h -SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp - -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml b/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml index cef86b4f58..1fe150548a 100644 --- a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml +++ b/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a: 10 diff --git a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml b/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml index a253a58da9..f101f38a2d 100644 --- a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml +++ b/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml b/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml index a91d3ed9ad..55010b69a9 100644 --- a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml +++ b/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property TestType test diff --git a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp index 180a24cc7e..5583701b12 100644 --- a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp +++ b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include class tst_QDeclarativePropertyMap : public QObject @@ -172,10 +172,10 @@ void tst_QDeclarativePropertyMap::changed() QDeclarativeContext *ctxt = engine.rootContext(); ctxt->setContextProperty(QLatin1String("testdata"), &map); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }", + component.setData("import QtQuick 2.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }", QUrl::fromLocalFile("")); QVERIFY(component.isReady()); - QDeclarativeText *txt = qobject_cast(component.create()); + QSGText *txt = qobject_cast(component.create()); QVERIFY(txt); QCOMPARE(txt->text(), QString('X')); QCOMPARE(spy.count(), 1); @@ -213,7 +213,7 @@ void tst_QDeclarativePropertyMap::crashBug() context.setContextProperty("map", &map); QDeclarativeComponent c(&engine); - c.setData("import QtQuick 1.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl()); + c.setData("import QtQuick 2.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl()); QObject *obj = c.create(&context); delete obj; } diff --git a/tests/auto/declarative/qdeclarativeqt/data/atob.qml b/tests/auto/declarative/qdeclarativeqt/data/atob.qml index f74aae830a..0d684003a1 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/atob.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/atob.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string test1: Qt.atob() diff --git a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml b/tests/auto/declarative/qdeclarativeqt/data/btoa.qml index 63b58c07b4..0ecd01d284 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/btoa.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string test1: Qt.btoa() diff --git a/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml index fe47f3ff7c..4c581cf245 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/consoleLog.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml index 9d0dd345ce..3ebc9f14f8 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool emptyArg: false diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml index 6ac470ea8b..2a824e5362 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int test: 1913 diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml index 5b8c1b1331..a52453e8fa 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "createComponent_lib.js" as Test Item { diff --git a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml index 8c35ebf1a5..87601b1cc8 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml @@ -1,14 +1,14 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root // errors resulting in exceptions property QtObject incorrectArgCount1: Qt.createQmlObject() - property QtObject incorrectArgCount2: Qt.createQmlObject("import QtQuick 1.0\nQtObject{}", root, "main.qml", 10) - property QtObject noParent: Qt.createQmlObject("import QtQuick 1.0\nQtObject{\nproperty int test: 13}", 0) - property QtObject notAvailable: Qt.createQmlObject("import QtQuick 1.0\nQtObject{Blah{}}", root) - property QtObject errors: Qt.createQmlObject("import QtQuick 1.0\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") + property QtObject incorrectArgCount2: Qt.createQmlObject("import QtQuick 2.0\nQtObject{}", root, "main.qml", 10) + property QtObject noParent: Qt.createQmlObject("import QtQuick 2.0\nQtObject{\nproperty int test: 13}", 0) + property QtObject notAvailable: Qt.createQmlObject("import QtQuick 2.0\nQtObject{Blah{}}", root) + property QtObject errors: Qt.createQmlObject("import QtQuick 2.0\nQtObject{\nproperty int test: 13\nproperty int test: 13\n}", root, "main.qml") property bool emptyArg: false @@ -18,14 +18,14 @@ Item { // errors resulting in nulls emptyArg = (Qt.createQmlObject("", root) == null); try { - Qt.createQmlObject("import QtQuick 1.0\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root) + Qt.createQmlObject("import QtQuick 2.0\nQtObject{property int test\nonTestChanged: QtObject{}\n}", root) } catch (error) { console.log("RunTimeError: ",error.message); } - var o = Qt.createQmlObject("import QtQuick 1.0\nQtObject{\nproperty int test: 13\n}", root); + var o = Qt.createQmlObject("import QtQuick 2.0\nQtObject{\nproperty int test: 13\n}", root); success = (o.test == 13); - Qt.createQmlObject("import QtQuick 1.0\nItem {}\n", root); + Qt.createQmlObject("import QtQuick 2.0\nItem {}\n", root); } } diff --git a/tests/auto/declarative/qdeclarativeqt/data/darker.qml b/tests/auto/declarative/qdeclarativeqt/data/darker.qml index d2ef866d59..ce6c705fb4 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/darker.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/darker.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) diff --git a/tests/auto/declarative/qdeclarativeqt/data/enums.qml b/tests/auto/declarative/qdeclarativeqt/data/enums.qml index aec6f63c06..5a2ff534af 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/enums.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/enums.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int test1: Qt.Key_Escape diff --git a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml b/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml index c9f50d4886..70245ab159 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: Qt.fontFamilies(10) diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml index f520aeb40a..7a462c8eeb 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property date dateFromString: "2008-12-24" diff --git a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml index 3bcc7912b1..ff9622b339 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/hsla.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property color test1: Qt.hsla(1, 0, 0, 0.8); diff --git a/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml b/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml index 37b952d448..6829209518 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml index 67f0d0f30d..7db5e1edeb 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/lighter.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) diff --git a/tests/auto/declarative/qdeclarativeqt/data/md5.qml b/tests/auto/declarative/qdeclarativeqt/data/md5.qml index 32e90c041e..bec1ed1fe7 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/md5.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/md5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string test1: Qt.md5() diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml index dc4049c9a3..37b9f513d9 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Component.onCompleted: Qt.openUrlExternally("test:url") diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml index 456653b81d..4bf584d134 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "openUrlExternally_lib.js" as Test Item { diff --git a/tests/auto/declarative/qdeclarativeqt/data/point.qml b/tests/auto/declarative/qdeclarativeqt/data/point.qml index 8b0188eaa7..fe12ee6232 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/point.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/point.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: Qt.point(19, 34); diff --git a/tests/auto/declarative/qdeclarativeqt/data/quit.qml b/tests/auto/declarative/qdeclarativeqt/data/quit.qml index 62564a6492..e3b91660e7 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/quit.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/quit.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { Component.onCompleted: Qt.quit() diff --git a/tests/auto/declarative/qdeclarativeqt/data/rect.qml b/tests/auto/declarative/qdeclarativeqt/data/rect.qml index 872bf50eb7..b294b22c5b 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/rect.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/rect.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: Qt.rect(10, 13, 100, 109) diff --git a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml index bbafc6d98c..3b010f68cb 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/rgba.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property color test1: Qt.rgba(1, 0, 0, 0.8); diff --git a/tests/auto/declarative/qdeclarativeqt/data/size.qml b/tests/auto/declarative/qdeclarativeqt/data/size.qml index 8e102eb6cb..41051f4216 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/size.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/size.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: Qt.size(19, 34); diff --git a/tests/auto/declarative/qdeclarativeqt/data/tint.qml b/tests/auto/declarative/qdeclarativeqt/data/tint.qml index f8738865f2..816e6e9b08 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/tint.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/tint.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property color test1: Qt.tint("red", "blue"); diff --git a/tests/auto/declarative/qdeclarativeqt/data/vector.qml b/tests/auto/declarative/qdeclarativeqt/data/vector.qml index f494fe0531..5a949515ed 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/vector.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/vector.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property variant test1: Qt.vector3d(1, 0, 0.9); diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 948307d955..4a9bb4513c 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #ifdef Q_OS_SYMBIAN @@ -434,7 +434,7 @@ void tst_qdeclarativeqt::createQmlObject() QCOMPARE(object->property("emptyArg").toBool(), true); QCOMPARE(object->property("success").toBool(), true); - QDeclarativeItem *item = qobject_cast(object); + QSGItem *item = qobject_cast(object); QVERIFY(item != 0); QVERIFY(item->childItems().count() == 1); diff --git a/tests/auto/declarative/qdeclarativescriptdebugging/data/backtrace1.qml b/tests/auto/declarative/qdeclarativescriptdebugging/data/backtrace1.qml index 9096c32a8e..8bba61ec15 100644 --- a/tests/auto/declarative/qdeclarativescriptdebugging/data/backtrace1.qml +++ b/tests/auto/declarative/qdeclarativescriptdebugging/data/backtrace1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 import "backtrace1.js" as Script diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation1.qml b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation1.qml index 3a2c4e386b..3631f971f0 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation1.qml +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation1.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 SmoothedAnimation {} diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation2.qml b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation2.qml index 47935d48f0..b07120234a 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation2.qml +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 SmoothedAnimation { to: 10; duration: 300; reversingMode: SmoothedAnimation.Immediate diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation3.qml b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation3.qml index fe44cce14b..8d5dc4a92b 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation3.qml +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimation3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 SmoothedAnimation { to: 10; velocity: 250; reversingMode: SmoothedAnimation.Sync diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml index 65611227d0..81d36bf015 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400; height: 400; color: "blue" diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml index 5036d5f225..e136df84f6 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 300; height: 300; diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp index bab9045b9a..243f4e716b 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include "../../../shared/util.h" @@ -125,7 +125,7 @@ void tst_qdeclarativesmoothedanimation::disabled() void tst_qdeclarativesmoothedanimation::simpleAnimation() { - QDeclarativeRectangle rect; + QSGRectangle rect; QDeclarativeSmoothedAnimation animation; animation.setTarget(&rect); animation.setProperty("x"); @@ -155,10 +155,10 @@ void tst_qdeclarativesmoothedanimation::valueSource() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationValueSource.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *theRect = rect->findChild("theRect"); + QSGRectangle *theRect = rect->findChild("theRect"); QVERIFY(theRect); QDeclarativeSmoothedAnimation *easeX = rect->findChild("easeX"); @@ -187,10 +187,10 @@ void tst_qdeclarativesmoothedanimation::behavior() QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationBehavior.qml")); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - QDeclarativeRectangle *theRect = rect->findChild("theRect"); + QSGRectangle *theRect = rect->findChild("theRect"); QVERIFY(theRect); QDeclarativeSmoothedAnimation *easeX = rect->findChild("easeX"); diff --git a/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml index 8890a78fdb..9f52aa56c1 100644 --- a/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml +++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 SpringAnimation { } diff --git a/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml index de75bb06cb..172cc57ca8 100644 --- a/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml +++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 SpringAnimation { to: 1.44; velocity: 0.9 diff --git a/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml index b68d769f01..f4dc121eb8 100644 --- a/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml +++ b/tests/auto/declarative/qdeclarativespringanimation/data/springanimation3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 SpringAnimation { to: 1.44; velocity: 0.9 diff --git a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp b/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp index 94b1cd630a..7517bd3498 100644 --- a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp +++ b/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp @@ -42,7 +42,7 @@ #include "../../../shared/util.h" #include #include -#include +#include #include #include /* @@ -203,7 +203,7 @@ void tst_qdeclarativesqldatabase::testQml() QFETCH(QString, jsfile); QString qml= - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "import \""+jsfile+"\" as JS\n" "Text { text: JS.test() }"; @@ -211,7 +211,7 @@ void tst_qdeclarativesqldatabase::testQml() QDeclarativeComponent component(engine); component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports QVERIFY(!component.isError()); - QDeclarativeText *text = qobject_cast(component.create()); + QSGText *text = qobject_cast(component.create()); QVERIFY(text != 0); QCOMPARE(text->text(),QString("passed")); } diff --git a/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml b/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml index d91f504455..1ea346b841 100644 --- a/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml +++ b/tests/auto/declarative/qdeclarativestates/data/ExtendedRectangle.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: extendedRect objectName: "extendedRect" diff --git a/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml index 6ad3b4a6ba..01eb32cd4d 100644 --- a/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml +++ b/tests/auto/declarative/qdeclarativestates/data/Implementation/MyType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { Column { diff --git a/tests/auto/declarative/qdeclarativestates/data/QTBUG-14830.qml b/tests/auto/declarative/qdeclarativestates/data/QTBUG-14830.qml index 7f9ddbfa2d..5ba7c3ad6f 100644 --- a/tests/auto/declarative/qdeclarativestates/data/QTBUG-14830.qml +++ b/tests/auto/declarative/qdeclarativestates/data/QTBUG-14830.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 1024 diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml index fad27080fe..378f5390f9 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: container diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml index e1d4d66abd..dc7f8ef0d1 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 200; height: 200 diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml index 116b844489..af49575854 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: container diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml index eaff37345b..28b55818bd 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 200; height: 200 diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml index ea7b251151..b1ca968fb9 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChanges5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 200; height: 200 diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml index ca96da8855..9af0e4645a 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorChangesCrash.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: container diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml index 6277111e68..6512533b37 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: container color: "red" diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml index d8b02e9b32..574ef473ce 100644 --- a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: root diff --git a/tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml index 2cad0504b2..413af2ee42 100644 --- a/tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml +++ b/tests/auto/declarative/qdeclarativestates/data/attachedPropertyChanges.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { id: item diff --git a/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml index ccd126f6a7..6cbf524ec2 100644 --- a/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml +++ b/tests/auto/declarative/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml index 2060f03009..59b67d0863 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle diff --git a/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml index a329da33dd..55f88120aa 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle diff --git a/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml index cb054d214d..361ab0b091 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle diff --git a/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml b/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml index 7a740e570c..b29f0fcf22 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicBinding4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle diff --git a/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml index 08ce7875f0..3e2b73acde 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml index ab97ba18b5..5ff46cc60c 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml index 73ac34d7ff..e46e98f75e 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml b/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml index b5df922190..7da1e0fb2e 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicChanges4.qml @@ -1,5 +1,5 @@ import Qt.test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyRectangle { id: rect diff --git a/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml b/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml index 58c9fbe231..00f5fee287 100644 --- a/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml +++ b/tests/auto/declarative/qdeclarativestates/data/basicExtension.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/deleting.qml b/tests/auto/declarative/qdeclarativestates/data/deleting.qml index d1b3fd3a10..b8e8d33c17 100644 --- a/tests/auto/declarative/qdeclarativestates/data/deleting.qml +++ b/tests/auto/declarative/qdeclarativestates/data/deleting.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/deletingState.qml b/tests/auto/declarative/qdeclarativestates/data/deletingState.qml index 654e09cb2e..68a9c2a24d 100644 --- a/tests/auto/declarative/qdeclarativestates/data/deletingState.qml +++ b/tests/auto/declarative/qdeclarativestates/data/deletingState.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/editProperties.qml b/tests/auto/declarative/qdeclarativestates/data/editProperties.qml index 08d0209615..9bff3657ba 100644 --- a/tests/auto/declarative/qdeclarativestates/data/editProperties.qml +++ b/tests/auto/declarative/qdeclarativestates/data/editProperties.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle diff --git a/tests/auto/declarative/qdeclarativestates/data/explicit.qml b/tests/auto/declarative/qdeclarativestates/data/explicit.qml index 426731914f..d09893a1db 100644 --- a/tests/auto/declarative/qdeclarativestates/data/explicit.qml +++ b/tests/auto/declarative/qdeclarativestates/data/explicit.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle property color sourceColor: "blue" diff --git a/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml b/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml index a4b77b122e..573341520d 100644 --- a/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml +++ b/tests/auto/declarative/qdeclarativestates/data/extendsBug.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 200 diff --git a/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml b/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml index a98c96bedc..6a5c7003f6 100644 --- a/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml +++ b/tests/auto/declarative/qdeclarativestates/data/fakeExtension.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/illegalObj.qml b/tests/auto/declarative/qdeclarativestates/data/illegalObj.qml index e6444325a3..a2bbd5d32b 100644 --- a/tests/auto/declarative/qdeclarativestates/data/illegalObj.qml +++ b/tests/auto/declarative/qdeclarativestates/data/illegalObj.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myItem diff --git a/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml b/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml index c04b03c94b..9cb39c0728 100644 --- a/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml +++ b/tests/auto/declarative/qdeclarativestates/data/illegalTempState.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: card diff --git a/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml b/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml index 4d500d9e05..a93860f5cc 100644 --- a/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml +++ b/tests/auto/declarative/qdeclarativestates/data/legalTempState.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: card diff --git a/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml b/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml index 4973b82c3f..ce502699bb 100644 --- a/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml +++ b/tests/auto/declarative/qdeclarativestates/data/nonExistantProp.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange1.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange1.qml index 2f7e80eb08..663ad1a264 100644 --- a/tests/auto/declarative/qdeclarativestates/data/parentChange1.qml +++ b/tests/auto/declarative/qdeclarativestates/data/parentChange1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400; height: 400 diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml index bdd0c6c282..ae290e961e 100644 --- a/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/parentChange2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: newParent diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml index 55f3ead7c6..46665cb4c8 100644 --- a/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml +++ b/tests/auto/declarative/qdeclarativestates/data/parentChange3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400; height: 400 diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml index ae05b05072..22de72f8c9 100644 --- a/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml +++ b/tests/auto/declarative/qdeclarativestates/data/parentChange4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400; height: 400 diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml index 32a0b91cd9..c353d2637f 100644 --- a/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml +++ b/tests/auto/declarative/qdeclarativestates/data/parentChange5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400; height: 400 diff --git a/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml b/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml index 70ad894ffc..b373dbba20 100644 --- a/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml +++ b/tests/auto/declarative/qdeclarativestates/data/parentChange6.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 400; height: 400 diff --git a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml index 3ab3c3252e..ddd636493d 100644 --- a/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml +++ b/tests/auto/declarative/qdeclarativestates/data/propertyErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/reset.qml b/tests/auto/declarative/qdeclarativestates/data/reset.qml index a140ffab4d..f0ecab0950 100644 --- a/tests/auto/declarative/qdeclarativestates/data/reset.qml +++ b/tests/auto/declarative/qdeclarativestates/data/reset.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 640 diff --git a/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml b/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml index dfd7c1794a..950a522841 100644 --- a/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml +++ b/tests/auto/declarative/qdeclarativestates/data/restoreEntryValues.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/returnToBase.qml b/tests/auto/declarative/qdeclarativestates/data/returnToBase.qml index a0d053cf03..9a0ee82397 100644 --- a/tests/auto/declarative/qdeclarativestates/data/returnToBase.qml +++ b/tests/auto/declarative/qdeclarativestates/data/returnToBase.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: theRect diff --git a/tests/auto/declarative/qdeclarativestates/data/script.qml b/tests/auto/declarative/qdeclarativestates/data/script.qml index 630aaf0ffa..218f0fae74 100644 --- a/tests/auto/declarative/qdeclarativestates/data/script.qml +++ b/tests/auto/declarative/qdeclarativestates/data/script.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRectangle width: 100; height: 100 diff --git a/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml index 0eaf547644..9ab8037e51 100644 --- a/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml +++ b/tests/auto/declarative/qdeclarativestates/data/signalOverride.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyRectangle { diff --git a/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml index ef26ff14e7..4e5e335b8b 100644 --- a/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/signalOverride2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyRectangle { diff --git a/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml index 8e9b698383..3e2ae1e93d 100644 --- a/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml +++ b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyRectangle { diff --git a/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml index 74df9430c3..3937874aa2 100644 --- a/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml +++ b/tests/auto/declarative/qdeclarativestates/data/signalOverrideCrash2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: myRect diff --git a/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml index 4425b4dd49..35eacff07b 100644 --- a/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml +++ b/tests/auto/declarative/qdeclarativestates/data/unnamedWhen.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: theRect diff --git a/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml b/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml index 743f5404b0..516ac034d6 100644 --- a/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml +++ b/tests/auto/declarative/qdeclarativestates/data/urlResolution.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "Implementation" Rectangle { diff --git a/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml index 48aef5a6ce..92025a2054 100644 --- a/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml +++ b/tests/auto/declarative/qdeclarativestates/data/whenOrdering.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { property bool condition1: false diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro index 2efefed56b..c34b8d8319 100644 --- a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro +++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro @@ -13,4 +13,4 @@ symbian: { } CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private opengl-private diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 9fafa7d1fd..a59ca2607f 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -41,12 +41,13 @@ #include #include #include -#include -#include -#include +#include +#include +#include +#include #include #include -#include +#include #include #ifdef Q_OS_SYMBIAN @@ -68,7 +69,7 @@ class MyAttached : public QObject int m_foo; }; -class MyRect : public QDeclarativeRectangle +class MyRect : public QSGRectangle { Q_OBJECT Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) @@ -164,8 +165,8 @@ void tst_qdeclarativestates::basicChanges() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); @@ -179,8 +180,8 @@ void tst_qdeclarativestates::basicChanges() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); @@ -200,33 +201,33 @@ void tst_qdeclarativestates::basicChanges() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),2); + QCOMPARE(rect->border()->width(),2.0); rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),2); + QCOMPARE(rect->border()->width(),2.0); rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); } @@ -260,7 +261,7 @@ void tst_qdeclarativestates::attachedPropertyChanges() QDeclarativeComponent component(&engine, SRCDIR "/data/attachedPropertyChanges.qml"); QVERIFY(component.isReady()); - QDeclarativeItem *item = qobject_cast(component.create()); + QSGItem *item = qobject_cast(component.create()); QVERIFY(item != 0); QCOMPARE(item->width(), 50.0); @@ -280,42 +281,42 @@ void tst_qdeclarativestates::basicExtension() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),2); + QCOMPARE(rect->border()->width(),2.0); rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); rectPrivate->setState("bordered"); QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),2); + QCOMPARE(rect->border()->width(),2.0); rectPrivate->setState(""); QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); + QCOMPARE(rect->border()->width(),1.0); } { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); @@ -346,8 +347,8 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); @@ -374,8 +375,8 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); @@ -405,8 +406,8 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); @@ -430,8 +431,8 @@ void tst_qdeclarativestates::basicBinding() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGRectangle *rect = qobject_cast(rectComponent.create()); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); @@ -470,7 +471,7 @@ void tst_qdeclarativestates::signalOverride() rect->doSomething(); QCOMPARE(rect->color(),QColor("blue")); - QDeclarativeItemPrivate::get(rect)->setState("green"); + QSGItemPrivate::get(rect)->setState("green"); rect->doSomething(); QCOMPARE(rect->color(),QColor("green")); } @@ -484,8 +485,8 @@ void tst_qdeclarativestates::signalOverride() rect->doSomething(); QCOMPARE(rect->color(),QColor("blue")); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); - QDeclarativeItemPrivate::get(innerRect)->setState("green"); + QSGRectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); + QSGItemPrivate::get(innerRect)->setState("green"); rect->doSomething(); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(innerRect->color(),QColor("green")); @@ -501,7 +502,7 @@ void tst_qdeclarativestates::signalOverrideCrash() MyRect *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate::get(rect)->setState("overridden"); + QSGItemPrivate::get(rect)->setState("overridden"); rect->doSomething(); } @@ -510,12 +511,12 @@ void tst_qdeclarativestates::signalOverrideCrash2() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash2.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate::get(rect)->setState("state1"); - QDeclarativeItemPrivate::get(rect)->setState("state2"); - QDeclarativeItemPrivate::get(rect)->setState("state1"); + QSGItemPrivate::get(rect)->setState("state1"); + QSGItemPrivate::get(rect)->setState("state2"); + QSGItemPrivate::get(rect)->setState("state1"); delete rect; } @@ -526,10 +527,10 @@ void tst_qdeclarativestates::parentChange() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange1.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); QDeclarativeListReference list(rect, "states"); @@ -537,14 +538,14 @@ void tst_qdeclarativestates::parentChange() QVERIFY(state != 0); qmlExecuteDeferred(state); - QDeclarativeParentChange *pChange = qobject_cast(state->operationAt(0)); + QSGParentChange *pChange = qobject_cast(state->operationAt(0)); QVERIFY(pChange != 0); - QDeclarativeItem *nParent = qobject_cast(rect->findChild("NewParent")); + QSGItem *nParent = qobject_cast(rect->findChild("NewParent")); QVERIFY(nParent != 0); QCOMPARE(pChange->parent(), nParent); - QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QSGItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(-133)); @@ -553,10 +554,10 @@ void tst_qdeclarativestates::parentChange() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); rectPrivate->setState("reparented"); @@ -568,10 +569,10 @@ void tst_qdeclarativestates::parentChange() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); rectPrivate->setState("reparented"); @@ -590,13 +591,13 @@ void tst_qdeclarativestates::parentChange() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange6.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QSGItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(180)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(-105)); @@ -610,14 +611,14 @@ void tst_qdeclarativestates::parentChangeErrors() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); - QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QSGItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -626,14 +627,14 @@ void tst_qdeclarativestates::parentChangeErrors() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange5.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); - QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QSGItemPrivate::get(rect)->setState("reparented"); QCOMPARE(innerRect->rotation(), qreal(0)); QCOMPARE(innerRect->scale(), qreal(1)); QCOMPARE(innerRect->x(), qreal(5)); @@ -646,11 +647,11 @@ void tst_qdeclarativestates::anchorChanges() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); QDeclarativeListReference list(rect, "states"); @@ -658,15 +659,15 @@ void tst_qdeclarativestates::anchorChanges() QVERIFY(state != 0); qmlExecuteDeferred(state); - QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QSGAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); rectPrivate->setState("right"); QCOMPARE(innerRect->x(), qreal(150)); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QSGAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); rectPrivate->setState(""); QCOMPARE(innerRect->x(), qreal(5)); @@ -679,11 +680,11 @@ void tst_qdeclarativestates::anchorChanges2() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); rectPrivate->setState("right"); @@ -700,17 +701,17 @@ void tst_qdeclarativestates::anchorChanges3() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QSGItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); QVERIFY(leftGuideline != 0); - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QSGItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); QVERIFY(bottomGuideline != 0); QDeclarativeListReference list(rect, "states"); @@ -718,19 +719,19 @@ void tst_qdeclarativestates::anchorChanges3() QVERIFY(state != 0); qmlExecuteDeferred(state); - QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QSGAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); rectPrivate->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->left().item, QSGItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QSGItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->bottom().item, QSGItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QSGItemPrivate::get(bottomGuideline)->bottom().anchorLine); QCOMPARE(innerRect->x(), qreal(10)); QCOMPARE(innerRect->y(), qreal(0)); @@ -751,16 +752,16 @@ void tst_qdeclarativestates::anchorChanges4() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QSGItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); QVERIFY(leftGuideline != 0); - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QSGItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); QVERIFY(bottomGuideline != 0); QDeclarativeListReference list(rect, "states"); @@ -768,15 +769,15 @@ void tst_qdeclarativestates::anchorChanges4() QVERIFY(state != 0); qmlExecuteDeferred(state); - QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QSGAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); + QSGItemPrivate::get(rect)->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QSGItemPrivate::get(bottomGuideline)->horizontalCenter().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QSGItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QSGItemPrivate::get(leftGuideline)->verticalCenter().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QSGItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); delete rect; } @@ -786,16 +787,16 @@ void tst_qdeclarativestates::anchorChanges5() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QSGItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); QVERIFY(leftGuideline != 0); - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QSGItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); QVERIFY(bottomGuideline != 0); QDeclarativeListReference list(rect, "states"); @@ -803,11 +804,11 @@ void tst_qdeclarativestates::anchorChanges5() QVERIFY(state != 0); qmlExecuteDeferred(state); - QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QSGAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QSGItemPrivate::get(rect)->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); //QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); //QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); //QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item); @@ -816,12 +817,12 @@ void tst_qdeclarativestates::anchorChanges5() delete rect; } -void mirrorAnchors(QDeclarativeItem *item) { - QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); +void mirrorAnchors(QSGItem *item) { + QSGItemPrivate *itemPrivate = QSGItemPrivate::get(item); itemPrivate->setLayoutMirror(true); } -qreal offsetRTL(QDeclarativeItem *anchorItem, QDeclarativeItem *item) { +qreal offsetRTL(QSGItem *anchorItem, QSGItem *item) { return anchorItem->width()+2*anchorItem->x()-item->width(); } @@ -830,11 +831,11 @@ void tst_qdeclarativestates::anchorChangesRTL() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); mirrorAnchors(innerRect); @@ -843,15 +844,15 @@ void tst_qdeclarativestates::anchorChangesRTL() QVERIFY(state != 0); qmlExecuteDeferred(state); - QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QSGAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); rectPrivate->setState("right"); QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QSGAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); rectPrivate->setState(""); QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5)); @@ -864,11 +865,11 @@ void tst_qdeclarativestates::anchorChangesRTL2() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); mirrorAnchors(innerRect); @@ -886,18 +887,18 @@ void tst_qdeclarativestates::anchorChangesRTL3() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); - QDeclarativeRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QSGRectangle *innerRect = qobject_cast(rect->findChild("MyRect")); QVERIFY(innerRect != 0); mirrorAnchors(innerRect); - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QSGItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); QVERIFY(leftGuideline != 0); - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QSGItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); QVERIFY(bottomGuideline != 0); QDeclarativeListReference list(rect, "states"); @@ -905,19 +906,19 @@ void tst_qdeclarativestates::anchorChangesRTL3() QVERIFY(state != 0); qmlExecuteDeferred(state); - QDeclarativeAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QSGAnchorChanges *aChanges = qobject_cast(state->operationAt(0)); QVERIFY(aChanges != 0); rectPrivate->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->left().item, QSGItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QSGItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->bottom().item, QSGItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QSGItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QSGItemPrivate::get(bottomGuideline)->bottom().anchorLine); QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10)); QCOMPARE(innerRect->y(), qreal(0)); @@ -941,10 +942,10 @@ void tst_qdeclarativestates::anchorChangesCrash() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChangesCrash.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + QSGItemPrivate::get(rect)->setState("reanchored"); delete rect; } @@ -955,29 +956,29 @@ void tst_qdeclarativestates::anchorRewindBug() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItem * column = rect->findChild("column"); + QSGItem * column = rect->findChild("column"); QVERIFY(column != 0); - QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); - QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QVERIFY(!QSGItemPrivate::get(column)->heightValid); + QVERIFY(!QSGItemPrivate::get(column)->widthValid); QCOMPARE(column->height(), 200.0); - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + QSGItemPrivate::get(rect)->setState("reanchored"); // column height and width should stay implicit // and column's implicit resizing should still work - QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); - QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QVERIFY(!QSGItemPrivate::get(column)->heightValid); + QVERIFY(!QSGItemPrivate::get(column)->widthValid); QCOMPARE(column->height(), 100.0); - QDeclarativeItemPrivate::get(rect)->setState(""); + QSGItemPrivate::get(rect)->setState(""); // column height and width should stay implicit // and column's implicit resizing should still work - QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); - QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QVERIFY(!QSGItemPrivate::get(column)->heightValid); + QVERIFY(!QSGItemPrivate::get(column)->widthValid); QCOMPARE(column->height(), 200.0); delete rect; @@ -989,20 +990,20 @@ void tst_qdeclarativestates::anchorRewindBug2() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug2.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeRectangle *mover = rect->findChild("mover"); + QSGRectangle *mover = rect->findChild("mover"); QVERIFY(mover != 0); QCOMPARE(mover->y(), qreal(0.0)); QCOMPARE(mover->width(), qreal(50.0)); - QDeclarativeItemPrivate::get(rect)->setState("anchored"); + QSGItemPrivate::get(rect)->setState("anchored"); QCOMPARE(mover->y(), qreal(250.0)); QCOMPARE(mover->width(), qreal(200.0)); - QDeclarativeItemPrivate::get(rect)->setState(""); + QSGItemPrivate::get(rect)->setState(""); QCOMPARE(mover->y(), qreal(0.0)); QCOMPARE(mover->width(), qreal(50.0)); @@ -1015,9 +1016,9 @@ void tst_qdeclarativestates::script() { QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); rectPrivate->setState("blue"); @@ -1033,9 +1034,9 @@ void tst_qdeclarativestates::restoreEntryValues() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); rectPrivate->setState("blue"); @@ -1050,9 +1051,9 @@ void tst_qdeclarativestates::explicitChanges() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QDeclarativeListReference list(rect, "states"); QDeclarativeState *state = qobject_cast(list.at(0)); QVERIFY(state != 0); @@ -1083,14 +1084,14 @@ void tst_qdeclarativestates::propertyErrors() { QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); QCOMPARE(rect->color(),QColor("red")); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\""); - QDeclarativeItemPrivate::get(rect)->setState("blue"); + QSGItemPrivate::get(rect)->setState("blue"); } void tst_qdeclarativestates::incorrectRestoreBug() @@ -1098,9 +1099,9 @@ void tst_qdeclarativestates::incorrectRestoreBug() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QCOMPARE(rect->color(),QColor("red")); rectPrivate->setState("blue"); @@ -1141,9 +1142,9 @@ void tst_qdeclarativestates::deletingChange() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); rectPrivate->setState("blue"); QCOMPARE(rect->color(),QColor("blue")); QCOMPARE(rect->radius(),qreal(5)); @@ -1173,7 +1174,7 @@ void tst_qdeclarativestates::deletingState() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); QDeclarativeStateGroup *sg = rect->findChild(); @@ -1204,9 +1205,9 @@ void tst_qdeclarativestates::tempState() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QTest::ignoreMessage(QtDebugMsg, "entering placed"); QTest::ignoreMessage(QtDebugMsg, "entering idle"); rectPrivate->setState("placed"); @@ -1218,9 +1219,9 @@ void tst_qdeclarativestates::illegalTempState() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QTest::ignoreMessage(QtWarningMsg, ": QML StateGroup: Can't apply a state change as part of a state definition."); rectPrivate->setState("placed"); QCOMPARE(rectPrivate->state(), QLatin1String("placed")); @@ -1231,9 +1232,9 @@ void tst_qdeclarativestates::nonExistantProperty() QDeclarativeEngine engine; QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); - QDeclarativeRectangle *rect = qobject_cast(rectComponent.create()); + QSGRectangle *rect = qobject_cast(rectComponent.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); rectPrivate->setState("blue"); QCOMPARE(rectPrivate->state(), QLatin1String("blue")); @@ -1244,15 +1245,15 @@ void tst_qdeclarativestates::reset() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeImage *image = rect->findChild(); + QSGImage *image = rect->findChild(); QVERIFY(image != 0); QCOMPARE(image->width(), qreal(40.)); QCOMPARE(image->height(), qreal(20.)); - QDeclarativeItemPrivate::get(rect)->setState("state1"); + QSGItemPrivate::get(rect)->setState("state1"); QCOMPARE(image->width(), 20.0); QCOMPARE(image->height(), qreal(20.)); @@ -1276,9 +1277,9 @@ void tst_qdeclarativestates::whenOrdering() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QCOMPARE(rectPrivate->state(), QLatin1String("")); rect->setProperty("condition2", true); @@ -1299,16 +1300,16 @@ void tst_qdeclarativestates::urlResolution() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/urlResolution.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItem *myType = rect->findChild("MyType"); - QDeclarativeImage *image1 = rect->findChild("image1"); - QDeclarativeImage *image2 = rect->findChild("image2"); - QDeclarativeImage *image3 = rect->findChild("image3"); + QSGItem *myType = rect->findChild("MyType"); + QSGImage *image1 = rect->findChild("image1"); + QSGImage *image2 = rect->findChild("image2"); + QSGImage *image3 = rect->findChild("image3"); QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); - QDeclarativeItemPrivate::get(myType)->setState("SetImageState"); + QSGItemPrivate::get(myType)->setState("SetImageState"); QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png"); QCOMPARE(image1->source(), resolved); QCOMPARE(image2->source(), resolved); @@ -1320,9 +1321,9 @@ void tst_qdeclarativestates::unnamedWhen() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QCOMPARE(rectPrivate->state(), QLatin1String("")); QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); @@ -1339,9 +1340,9 @@ void tst_qdeclarativestates::returnToBase() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/returnToBase.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QCOMPARE(rectPrivate->state(), QLatin1String("")); QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); @@ -1359,10 +1360,10 @@ void tst_qdeclarativestates::extendsBug() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/extendsBug.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarativeRectangle *greenRect = rect->findChild("greenRect"); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); + QSGRectangle *greenRect = rect->findChild("greenRect"); rectPrivate->setState("b"); QCOMPARE(greenRect->x(), qreal(100)); @@ -1374,10 +1375,10 @@ void tst_qdeclarativestates::editProperties() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/editProperties.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QSGItemPrivate *rectPrivate = QSGItemPrivate::get(rect); QDeclarativeStateGroup *stateGroup = rectPrivate->_states(); QVERIFY(stateGroup != 0); @@ -1397,7 +1398,7 @@ void tst_qdeclarativestates::editProperties() QDeclarativePropertyChanges *propertyChangesGreen = qobject_cast(greenState->operationAt(0)); QVERIFY(propertyChangesGreen != 0); - QDeclarativeRectangle *childRect = rect->findChild("rect2"); + QSGRectangle *childRect = rect->findChild("rect2"); QVERIFY(childRect != 0); QCOMPARE(childRect->width(), qreal(402)); QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); @@ -1502,9 +1503,9 @@ void tst_qdeclarativestates::QTBUG_14830() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, SRCDIR "/data/QTBUG-14830.qml"); - QDeclarativeRectangle *rect = qobject_cast(c.create()); + QSGRectangle *rect = qobject_cast(c.create()); QVERIFY(rect != 0); - QDeclarativeItem *item = rect->findChild("area"); + QSGItem *item = rect->findChild("area"); QCOMPARE(item->width(), qreal(171)); } diff --git a/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp index b95c1196ee..993536f8b6 100644 --- a/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp +++ b/tests/auto/declarative/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include "../../../shared/util.h" @@ -75,7 +75,7 @@ tst_qdeclarativesystempalette::tst_qdeclarativesystempalette() void tst_qdeclarativesystempalette::activePalette() { - QString componentStr = "import QtQuick 1.0\nSystemPalette { }"; + QString componentStr = "import QtQuick 2.0\nSystemPalette { }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeSystemPalette *object = qobject_cast(component.create()); @@ -104,7 +104,7 @@ void tst_qdeclarativesystempalette::activePalette() void tst_qdeclarativesystempalette::inactivePalette() { - QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Inactive }"; + QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Inactive }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeSystemPalette *object = qobject_cast(component.create()); @@ -134,7 +134,7 @@ void tst_qdeclarativesystempalette::inactivePalette() void tst_qdeclarativesystempalette::disabledPalette() { - QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Disabled }"; + QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Disabled }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeSystemPalette *object = qobject_cast(component.create()); @@ -164,7 +164,7 @@ void tst_qdeclarativesystempalette::disabledPalette() void tst_qdeclarativesystempalette::paletteChanged() { - QString componentStr = "import QtQuick 1.0\nSystemPalette { }"; + QString componentStr = "import QtQuick 2.0\nSystemPalette { }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); QDeclarativeSystemPalette *object = qobject_cast(component.create()); diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro deleted file mode 100644 index 2cc9a8c05b..0000000000 --- a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro +++ /dev/null @@ -1,15 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui network -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativetextedit.cpp ../shared/testhttpserver.cpp -HEADERS += ../shared/testhttpserver.h - -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} -QT += core-private gui-private declarative-private diff --git a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp index f1a3c8fbf9..537c055f00 100644 --- a/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp +++ b/tests/auto/declarative/qdeclarativetimer/tst_qdeclarativetimer.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #ifdef Q_OS_SYMBIAN @@ -100,7 +100,7 @@ void tst_qdeclarativetimer::notRepeating() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile("")); QDeclarativeTimer *timer = qobject_cast(component.create()); QVERIFY(timer != 0); QVERIFY(timer->isRunning()); @@ -121,7 +121,7 @@ void tst_qdeclarativetimer::notRepeatingStart() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100 }"), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100 }"), QUrl::fromLocalFile("")); QDeclarativeTimer *timer = qobject_cast(component.create()); QVERIFY(timer != 0); QVERIFY(!timer->isRunning()); @@ -146,7 +146,7 @@ void tst_qdeclarativetimer::repeat() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile("")); QDeclarativeTimer *timer = qobject_cast(component.create()); QVERIFY(timer != 0); @@ -188,7 +188,7 @@ void tst_qdeclarativetimer::triggeredOnStart() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile("")); QDeclarativeTimer *timer = qobject_cast(component.create()); QVERIFY(timer != 0); QVERIFY(timer->triggeredOnStart()); @@ -223,7 +223,7 @@ void tst_qdeclarativetimer::triggeredOnStartRepeat() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile("")); QDeclarativeTimer *timer = qobject_cast(component.create()); QVERIFY(timer != 0); @@ -247,7 +247,7 @@ void tst_qdeclarativetimer::noTriggerIfNotRunning() QDeclarativeEngine engine; QDeclarativeComponent component(&engine); component.setData(QByteArray( - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "Item { property bool ok: true\n" "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }" "Timer { interval: 10; running: true; onTriggered: t1.running=false }" @@ -265,7 +265,7 @@ void tst_qdeclarativetimer::changeDuration() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile("")); QDeclarativeTimer *timer = qobject_cast(component.create()); QVERIFY(timer != 0); @@ -301,7 +301,7 @@ void tst_qdeclarativetimer::restart() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile("")); QDeclarativeTimer *timer = qobject_cast(component.create()); QVERIFY(timer != 0); @@ -328,8 +328,8 @@ void tst_qdeclarativetimer::parentProperty() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); + component.setData(QByteArray("import QtQuick 2.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile("")); + QSGItem *item = qobject_cast(component.create()); QVERIFY(item != 0); QDeclarativeTimer *timer = item->findChild("timer"); QVERIFY(timer != 0); diff --git a/tests/auto/declarative/qdeclarativev4/data/doubleBoolJump.qml b/tests/auto/declarative/qdeclarativev4/data/doubleBoolJump.qml index e7fb82ca36..2eea73b573 100644 --- a/tests/auto/declarative/qdeclarativev4/data/doubleBoolJump.qml +++ b/tests/auto/declarative/qdeclarativev4/data/doubleBoolJump.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { QtObject { diff --git a/tests/auto/declarative/qdeclarativev4/data/fetchException.qml b/tests/auto/declarative/qdeclarativev4/data/fetchException.qml index ece8e73199..6431fcfae8 100644 --- a/tests/auto/declarative/qdeclarativev4/data/fetchException.qml +++ b/tests/auto/declarative/qdeclarativev4/data/fetchException.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property Item data diff --git a/tests/auto/declarative/qdeclarativev4/data/nullQObject.qml b/tests/auto/declarative/qdeclarativev4/data/nullQObject.qml index 283c1a199b..00185b3988 100644 --- a/tests/auto/declarative/qdeclarativev4/data/nullQObject.qml +++ b/tests/auto/declarative/qdeclarativev4/data/nullQObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property QtObject obj diff --git a/tests/auto/declarative/qdeclarativev4/data/qrealToIntRounding.qml b/tests/auto/declarative/qdeclarativev4/data/qrealToIntRounding.qml index f961910f15..ee3d405073 100644 --- a/tests/auto/declarative/qdeclarativev4/data/qrealToIntRounding.qml +++ b/tests/auto/declarative/qdeclarativev4/data/qrealToIntRounding.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int data: 1 diff --git a/tests/auto/declarative/qdeclarativev4/data/subscriptionsInConditionalExpressions.qml b/tests/auto/declarative/qdeclarativev4/data/subscriptionsInConditionalExpressions.qml index 25483b207d..a8e05eeda1 100644 --- a/tests/auto/declarative/qdeclarativev4/data/subscriptionsInConditionalExpressions.qml +++ b/tests/auto/declarative/qdeclarativev4/data/subscriptionsInConditionalExpressions.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: thisTest diff --git a/tests/auto/declarative/qdeclarativev4/data/unaryMinus.qml b/tests/auto/declarative/qdeclarativev4/data/unaryMinus.qml index 3cfa0492c0..01fa515d6f 100644 --- a/tests/auto/declarative/qdeclarativev4/data/unaryMinus.qml +++ b/tests/auto/declarative/qdeclarativev4/data/unaryMinus.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { property real test1: -i1.p2 diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml index 70121435d4..2a1b936da6 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 BindingsSpliceCorrectlyType { property bool test: false diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml index 69dbcab9f2..84b465c565 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 BindingsSpliceCorrectlyType { property bool test: false diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml index 669feb99b2..f1212f8039 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 BindingsSpliceCorrectlyType { property bool test: false diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml index f28584f426..9c5e950660 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 BindingsSpliceCorrectlyType4 { property bool test: false diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml index 1214c83991..7d87ba1782 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 BindingsSpliceCorrectlyType5 { property bool test: false diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml index e2e696271b..923922c55a 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: root diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml index 0e09ff957b..9804af4df6 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: root diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml index 1f6646ea89..b5bb7f8ccc 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: root diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml index 391cabaf9c..4f7ad39db0 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 import "deletedObject.js" as JS MyTypeObject { diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml index 082aed1d41..cc7861a122 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyTypeObject { font.capitalization: Font.AllUppercase diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml index e5d9ab2b41..cf41c90b90 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 as MyQt +import QtQuick 2.0 as MyQt MyTypeObject { font.capitalization: MyQt.Font.AllUppercase diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml index 8ec508c9e3..de279dba6c 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 as MyQt +import QtQuick 2.0 as MyQt MyTypeObject { MyQt.Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml index 2fdfddb272..5297a8260d 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.0 Item { diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml index f1c185589c..1f9816f666 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyTypeObject { property bool test1: false; diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml index 9299c8b7f2..cbecb4379a 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.0 MyTypeObject { diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml index fc41ecf088..68b54b571e 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml @@ -1,5 +1,5 @@ import Test 1.0 -import QtQuick 1.0 +import QtQuick 2.0 MyTypeObject { Component.onCompleted: { diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml index ff80ff8408..9b56abbbed 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int x; diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml index b419c83073..0ac56d9b66 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 WorkerScript { id: worker diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml index 0c439c4916..b5a92bf1f5 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 BaseWorker { source: "script.js" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml index 90c4617f79..aa20783e76 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 BaseWorker { source: "script_error_onCall.js" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml index 0b9d21dc4b..8a33aeb44c 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 BaseWorker { source: "script_error_onLoad.js" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml index 595cb2b552..100b8d4551 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 BaseWorker { source: "script_include.js" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml index a8800ad0b5..7e313b3c42 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 BaseWorker { source: "script_pragma.js" diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index 2c85040f5f..cbf152bf8b 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -47,7 +47,6 @@ #include #include -#include #include #include diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml index 0196586bb7..9ba97fac4b 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string urlDummy diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml index aeea278967..d5bb84ddc0 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url: "testdocument.html" diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml index fffc3d9c09..4f58062a26 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url: "testdocument.html" diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml index 5d5dd12f54..b1c081c5fd 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool xmlTest: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml index ec6902dc45..ee1043f97f 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: obj diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml index be60664e03..f558fdadc6 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool xmlTest: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml index 0050f919d1..458066736e 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool calledAsConstructor diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml index 77b2b94e29..913fe59f99 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int readyState diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml index faf3af0acb..7695cd76a1 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool xmlTest: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml index 0f32a64a94..092db3443d 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int index_size_err: DOMException.INDEX_SIZE_ERR diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml index daec950343..9b190f3a43 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool xmlTest: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml index 686e7e5cf0..580688b835 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml index e8b7b770c1..84a0bf3015 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool exceptionThrown: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml index 1d4883ea7d..27edb4c4b7 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml index 360286d3e4..3d57348cc5 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml index f37545e1e6..203967e539 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml index 61ce9c6f67..dccc71dfc3 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool exceptionThrown: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml index 7cd91a2a1f..cff7af79e2 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml index 983ea1b82a..ad2ea0bd33 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml index 79e06d483b..b3a54e9b53 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int unsent diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml index 312292deaf..5a4093b9f1 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool readyState: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml index 4bb5b1d657..6e7681dfb4 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml index da6eb14273..61ef76d488 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool exceptionThrown: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml index f003292703..677759ccf3 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool exceptionThrown: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml index b87823d54c..0f29031e42 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool exceptionThrown: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml index 9f8f30982f..eafdda761f 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool exceptionThrown: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml index 2bec344726..4eaef536b3 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml index 70f2fa6227..b8ce5361f3 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml index f009ab78c0..e5c7b74553 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml index 86337c436c..0894573ecc 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml index cd125adf86..003d1954e9 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml index da229f6216..4b216d9c85 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml index 393ff09a01..e9265e09ef 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool xmlNull: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml index fd1c424786..4e0caa7171 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool dataOK: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml index 3dd851e591..6faac0242f 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml index fb1893627d..383a76e75e 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml index 9f2383e066..5cb8c926c2 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml index 410820e244..884661c8ce 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml index f56c51b8c3..c031b84418 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml index d44864ccee..42eb360d14 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml index 427d9f4312..5dc252f970 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml index 442932be26..336971c919 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string reqType diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml index badd7296e8..ef56517bf5 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml index 5afab091a9..4229584af2 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml index 4558f0e56a..1cef3e43da 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool exceptionThrown: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml index b15318c1e1..cd047cf8dd 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml index 3b9a91e257..49888fdac8 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml index 327fa7fb43..f528aa912c 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml index bc22d877f5..1b701e90ff 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int unsent: XMLHttpRequest.UNSENT diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml index 7aa08743ff..51964570d6 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml index d42e0cca0a..e7f658fc29 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property string url diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml index e8c8731240..b79e0bc7b1 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool xmlTest: false diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml index 0f9da30963..7c024bfda6 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool dataOK: false diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml index fdacb6c445..bf47f43567 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { source: "model.xml" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml index ed674ce36f..cc05b7c665 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { source: "model.xml" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml index 6345101d9a..3834cccf1d 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { source: "recipes.xml" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml index 492dad920f..50b8c0db49 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { id: model diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml index a0d846f188..c86a3720ad 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { source: "model.xml" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml index d90cd61096..74eca3edcf 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { query: "/data/item" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml index 4dbcc029e0..1f987e0781 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { query: "/data" diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml index dab8ffa78e..e4ed533d4e 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml +++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 XmlListModel { source: "model.xml" diff --git a/tests/auto/declarative/qsgflickable/data/disabledcontent.qml b/tests/auto/declarative/qsgflickable/data/disabledcontent.qml deleted file mode 100644 index f02f08e4ea..0000000000 --- a/tests/auto/declarative/qsgflickable/data/disabledcontent.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.0 - -Flickable { - width: 100; height: 100 - contentWidth: 200; contentHeight: 300 - - QGraphicsWidget { width: 200; height: 300; enabled: false } -} diff --git a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp index bbddbfe749..d1007819a4 100644 --- a/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp +++ b/tests/auto/declarative/qsgflickable/tst_qsgflickable.cpp @@ -72,7 +72,6 @@ private slots: void maximumFlickVelocity(); void flickDeceleration(); void pressDelay(); - void disabledContent(); void nestedPressDelay(); void flickableDirection(); void resizeContent(); @@ -260,44 +259,6 @@ void tst_qsgflickable::pressDelay() QCOMPARE(spy.count(),1); } -// QT-4677 -void tst_qsgflickable::disabledContent() -{ - QSGView *canvas = new QSGView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabledcontent.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QSGFlickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - QVERIFY(flickable->contentX() == 0); - QVERIFY(flickable->contentY() == 0); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 50)); - { - QMouseEvent mv(QEvent::MouseMove, QPoint(70,70), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas, &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, QPoint(90,90), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas, &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, QPoint(100,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas, &mv); - } - - QVERIFY(flickable->contentX() < 0); - QVERIFY(flickable->contentY() < 0); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(90, 90)); - - delete canvas; -} - - // QTBUG-17361 void tst_qsgflickable::nestedPressDelay() { diff --git a/tests/auto/declarative/qsglistview/data/displaylist.qml b/tests/auto/declarative/qsglistview/data/displaylist.qml index c083da5aa5..4e8fd32f6a 100644 --- a/tests/auto/declarative/qsglistview/data/displaylist.qml +++ b/tests/auto/declarative/qsglistview/data/displaylist.qml @@ -13,7 +13,7 @@ Rectangle { id: wrapper objectName: "wrapper" height: root.delegateHeight - Behavior on height { NumberAnimation {} } + Behavior on height { NumberAnimation { duration: 200} } width: 240 Text { text: index diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 22743b6f45..3abca71182 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -1761,7 +1761,7 @@ void tst_QSGListView::modelChanges() listView->setModel(QVariant()); QTRY_COMPARE(modelSpy.count(),2); -// delete canvas; + delete canvas; } void tst_QSGListView::QTBUG_9791() @@ -2232,12 +2232,12 @@ void tst_QSGListView::resizeDelegate() qApp->processEvents(); QSGListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); + QVERIFY(listview != 0); QSGItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); + QVERIFY(contentItem != 0); - QTRY_COMPARE(listview->count(), model.rowCount()); + QCOMPARE(listview->count(), model.rowCount()); listview->setCurrentIndex(25); listview->setContentY(0); @@ -2252,7 +2252,7 @@ void tst_QSGListView::resizeDelegate() QTRY_COMPARE(listview->highlightItem()->y(), 500.0); canvas->rootObject()->setProperty("delegateHeight", 30); - qApp->processEvents(); + QTest::qWait(300); for (int i = 0; i < 11; ++i) { QSGItem *item = findItem(contentItem, "wrapper", i); @@ -2277,7 +2277,7 @@ void tst_QSGListView::resizeDelegate() QTRY_COMPARE(listview->highlightItem()->y(), 30.0); canvas->rootObject()->setProperty("delegateHeight", 20); - qApp->processEvents(); + QTest::qWait(300); for (int i = 5; i < 11; ++i) { QSGItem *item = findItem(contentItem, "wrapper", i); diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h index 7e3e9e9eac..be8df86b90 100644 --- a/tests/auto/declarative/shared/debugutil_p.h +++ b/tests/auto/declarative/shared/debugutil_p.h @@ -49,7 +49,6 @@ #include #include -#include class QDeclarativeDebugTest { diff --git a/tests/auto/declarative/moduleqt47/data/importqt47.qml b/tests/auto/qtquick1/moduleqt47/data/importqt47.qml similarity index 100% rename from tests/auto/declarative/moduleqt47/data/importqt47.qml rename to tests/auto/qtquick1/moduleqt47/data/importqt47.qml diff --git a/tests/auto/declarative/moduleqt47/moduleqt47.pro b/tests/auto/qtquick1/moduleqt47/moduleqt47.pro similarity index 64% rename from tests/auto/declarative/moduleqt47/moduleqt47.pro rename to tests/auto/qtquick1/moduleqt47/moduleqt47.pro index 8c196d8097..2a3f08753d 100644 --- a/tests/auto/declarative/moduleqt47/moduleqt47.pro +++ b/tests/auto/qtquick1/moduleqt47/moduleqt47.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_moduleqt47.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/moduleqt47/tst_moduleqt47.cpp b/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp similarity index 94% rename from tests/auto/declarative/moduleqt47/tst_moduleqt47.cpp rename to tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp index 3b57a52638..cfacae2428 100644 --- a/tests/auto/declarative/moduleqt47/tst_moduleqt47.cpp +++ b/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -69,7 +70,7 @@ private slots: tst_moduleqt47::tst_moduleqt47() { - excludedFiles << "tests/auto/declarative/moduleqt47/data/importqt47.qml" + excludedFiles << "tests/auto/qtquick1/moduleqt47/data/importqt47.qml" << "doc/src/declarative/whatsnew.qdoc"; } @@ -78,6 +79,8 @@ void tst_moduleqt47::create() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/importqt47.qml")); QObject *obj = qobject_cast(c.create()); + if (!obj) + qWarning() << c.errorString(); QVERIFY(obj != 0); delete obj; @@ -128,6 +131,8 @@ void tst_moduleqt47::accidentalImport() return; QByteArray data = f.readAll(); + if (data.contains("import Qt 4")) + qDebug() << file; QVERIFY(!data.contains("import Qt 4")); } diff --git a/tests/auto/declarative/qdeclarativeanchors/data/anchors.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/anchors.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/anchorsqgraphicswidget.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/centerin.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/centerin.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/crash1.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/crash1.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/fill.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/fill.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/hvCenter.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/loop1.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/loop1.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/loop2.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/loop2.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/data/margins.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanchors/data/margins.qml rename to tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro similarity index 66% rename from tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro rename to tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro index ba2287d97c..12b545811d 100644 --- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro +++ b/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 SOURCES += tst_qdeclarativeanchors.cpp macx:CONFIG -= app_bundle @@ -13,4 +13,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp similarity index 77% rename from tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp rename to tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp index 388e115f00..795c91e9c4 100644 --- a/tests/auto/declarative/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ b/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp @@ -44,26 +44,25 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." #endif -Q_DECLARE_METATYPE(QDeclarativeAnchors::Anchor) -Q_DECLARE_METATYPE(QDeclarativeAnchorLine::AnchorLine) +Q_DECLARE_METATYPE(QDeclarative1Anchors::Anchor) +Q_DECLARE_METATYPE(QDeclarative1AnchorLine::AnchorLine) - -class tst_qdeclarativeanchors : public QObject +class tst_QDeclarative1Anchors : public QObject { Q_OBJECT public: - tst_qdeclarativeanchors() {} + tst_QDeclarative1Anchors() {} private slots: void basicAnchors(); @@ -130,7 +129,7 @@ QGraphicsObject *findObject(QGraphicsObject *parent, const QString &objectName) } -void tst_qdeclarativeanchors::basicAnchors() +void tst_QDeclarative1Anchors::basicAnchors() { QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); @@ -138,66 +137,66 @@ void tst_qdeclarativeanchors::basicAnchors() qApp->processEvents(); //sibling horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); //parent horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); //vertical - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); //stretch - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->width(), 96.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->width(), 192.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->width(), 192.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->width(), 96.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->width(), 192.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->width(), 192.0); //vertical stretch - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->height(), 40.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->height(), 40.0); //more parent horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); //centerIn - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); //margins - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->width(), 86.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->height(), 10.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->width(), 86.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->height(), 10.0); // offsets - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); //baseline - QDeclarativeText *text1 = findItem(view->rootObject(), QLatin1String("text1")); - QDeclarativeText *text2 = findItem(view->rootObject(), QLatin1String("text2")); + QDeclarative1Text *text1 = findItem(view->rootObject(), QLatin1String("text1")); + QDeclarative1Text *text2 = findItem(view->rootObject(), QLatin1String("text2")); QCOMPARE(text1->y(), text2->y()); delete view; } -void tst_qdeclarativeanchors::basicAnchorsQGraphicsWidget() +void tst_QDeclarative1Anchors::basicAnchorsQGraphicsWidget() { QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchorsqgraphicswidget.qml")); @@ -257,8 +256,8 @@ void tst_qdeclarativeanchors::basicAnchorsQGraphicsWidget() QCOMPARE(findObject(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); //baseline - QDeclarativeText *text1 = findItem(view->rootObject(), QLatin1String("text1")); - QDeclarativeText *text2 = findItem(view->rootObject(), QLatin1String("text2")); + QDeclarative1Text *text1 = findItem(view->rootObject(), QLatin1String("text1")); + QDeclarative1Text *text2 = findItem(view->rootObject(), QLatin1String("text2")); QCOMPARE(text1->y(), text2->y()); delete view; @@ -282,7 +281,7 @@ void mirrorAnchors(QDeclarativeItem *item) { itemPrivate->setLayoutMirror(true); } -void tst_qdeclarativeanchors::basicAnchorsRTL() +void tst_QDeclarative1Anchors::basicAnchorsRTL() { QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); @@ -356,15 +355,15 @@ void tst_qdeclarativeanchors::basicAnchorsRTL() QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0); //baseline - QDeclarativeText *text1 = findItem(rootItem, QLatin1String("text1")); - QDeclarativeText *text2 = findItem(rootItem, QLatin1String("text2")); + QDeclarative1Text *text1 = findItem(rootItem, QLatin1String("text1")); + QDeclarative1Text *text2 = findItem(rootItem, QLatin1String("text2")); QCOMPARE(text1->y(), text2->y()); delete view; } // mostly testing that we don't crash -void tst_qdeclarativeanchors::loops() +void tst_QDeclarative1Anchors::loops() { { QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); @@ -396,7 +395,7 @@ void tst_qdeclarativeanchors::loops() } } -void tst_qdeclarativeanchors::illegalSets() +void tst_QDeclarative1Anchors::illegalSets() { QFETCH(QString, qml); QFETCH(QString, warning); @@ -413,7 +412,7 @@ void tst_qdeclarativeanchors::illegalSets() delete o; } -void tst_qdeclarativeanchors::illegalSets_data() +void tst_QDeclarative1Anchors::illegalSets_data() { QTest::addColumn("qml"); QTest::addColumn("warning"); @@ -471,15 +470,15 @@ void tst_qdeclarativeanchors::illegalSets_data() << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; } -void tst_qdeclarativeanchors::reset() +void tst_QDeclarative1Anchors::reset() { QFETCH(QString, side); - QFETCH(QDeclarativeAnchorLine::AnchorLine, anchorLine); - QFETCH(QDeclarativeAnchors::Anchor, usedAnchor); + QFETCH(QDeclarative1AnchorLine::AnchorLine, anchorLine); + QFETCH(QDeclarative1Anchors::Anchor, usedAnchor); QDeclarativeItem *baseItem = new QDeclarativeItem; - QDeclarativeAnchorLine anchor; + QDeclarative1AnchorLine anchor; anchor.item = baseItem; anchor.anchorLine = anchorLine; @@ -499,23 +498,23 @@ void tst_qdeclarativeanchors::reset() delete baseItem; } -void tst_qdeclarativeanchors::reset_data() +void tst_QDeclarative1Anchors::reset_data() { QTest::addColumn("side"); - QTest::addColumn("anchorLine"); - QTest::addColumn("usedAnchor"); + QTest::addColumn("anchorLine"); + QTest::addColumn("usedAnchor"); - QTest::newRow("left") << "left" << QDeclarativeAnchorLine::Left << QDeclarativeAnchors::LeftAnchor; - QTest::newRow("top") << "top" << QDeclarativeAnchorLine::Top << QDeclarativeAnchors::TopAnchor; - QTest::newRow("right") << "right" << QDeclarativeAnchorLine::Right << QDeclarativeAnchors::RightAnchor; - QTest::newRow("bottom") << "bottom" << QDeclarativeAnchorLine::Bottom << QDeclarativeAnchors::BottomAnchor; + QTest::newRow("left") << "left" << QDeclarative1AnchorLine::Left << QDeclarative1Anchors::LeftAnchor; + QTest::newRow("top") << "top" << QDeclarative1AnchorLine::Top << QDeclarative1Anchors::TopAnchor; + QTest::newRow("right") << "right" << QDeclarative1AnchorLine::Right << QDeclarative1Anchors::RightAnchor; + QTest::newRow("bottom") << "bottom" << QDeclarative1AnchorLine::Bottom << QDeclarative1Anchors::BottomAnchor; - QTest::newRow("hcenter") << "horizontalCenter" << QDeclarativeAnchorLine::HCenter << QDeclarativeAnchors::HCenterAnchor; - QTest::newRow("vcenter") << "verticalCenter" << QDeclarativeAnchorLine::VCenter << QDeclarativeAnchors::VCenterAnchor; - QTest::newRow("baseline") << "baseline" << QDeclarativeAnchorLine::Baseline << QDeclarativeAnchors::BaselineAnchor; + QTest::newRow("hcenter") << "horizontalCenter" << QDeclarative1AnchorLine::HCenter << QDeclarative1Anchors::HCenterAnchor; + QTest::newRow("vcenter") << "verticalCenter" << QDeclarative1AnchorLine::VCenter << QDeclarative1Anchors::VCenterAnchor; + QTest::newRow("baseline") << "baseline" << QDeclarative1AnchorLine::Baseline << QDeclarative1Anchors::BaselineAnchor; } -void tst_qdeclarativeanchors::resetConvenience() +void tst_QDeclarative1Anchors::resetConvenience() { QDeclarativeItem *baseItem = new QDeclarativeItem; QDeclarativeItem *item = new QDeclarativeItem; @@ -537,11 +536,11 @@ void tst_qdeclarativeanchors::resetConvenience() delete baseItem; } -void tst_qdeclarativeanchors::nullItem() +void tst_QDeclarative1Anchors::nullItem() { QFETCH(QString, side); - QDeclarativeAnchorLine anchor; + QDeclarative1AnchorLine anchor; QDeclarativeItem *item = new QDeclarativeItem; QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); @@ -554,7 +553,7 @@ void tst_qdeclarativeanchors::nullItem() delete item; } -void tst_qdeclarativeanchors::nullItem_data() +void tst_QDeclarative1Anchors::nullItem_data() { QTest::addColumn("side"); @@ -568,7 +567,7 @@ void tst_qdeclarativeanchors::nullItem_data() QTest::newRow("baseline") << "baseline"; } -void tst_qdeclarativeanchors::crash1() +void tst_QDeclarative1Anchors::crash1() { QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); @@ -591,12 +590,12 @@ void tst_qdeclarativeanchors::crash1() delete view; } -void tst_qdeclarativeanchors::fill() +void tst_QDeclarative1Anchors::fill() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); qApp->processEvents(); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 0.0 + 10.0); QCOMPARE(rect->y(), 0.0 + 30.0); @@ -615,12 +614,12 @@ void tst_qdeclarativeanchors::fill() delete view; } -void tst_qdeclarativeanchors::fillRTL() +void tst_QDeclarative1Anchors::fillRTL() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); qApp->processEvents(); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); mirrorAnchors(rect); @@ -640,12 +639,12 @@ void tst_qdeclarativeanchors::fillRTL() delete view; } -void tst_qdeclarativeanchors::centerIn() +void tst_QDeclarative1Anchors::centerIn() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); qApp->processEvents(); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 75.0 + 10); @@ -660,12 +659,12 @@ void tst_qdeclarativeanchors::centerIn() } -void tst_qdeclarativeanchors::centerInRTL() +void tst_QDeclarative1Anchors::centerInRTL() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); qApp->processEvents(); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); mirrorAnchors(rect); @@ -680,12 +679,12 @@ void tst_qdeclarativeanchors::centerInRTL() delete view; } -void tst_qdeclarativeanchors::hvCenter() +void tst_QDeclarative1Anchors::hvCenter() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml")); qApp->processEvents(); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); // test QTBUG-10999 @@ -700,12 +699,12 @@ void tst_qdeclarativeanchors::hvCenter() delete view; } -void tst_qdeclarativeanchors::hvCenterRTL() +void tst_QDeclarative1Anchors::hvCenterRTL() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml")); qApp->processEvents(); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); mirrorAnchors(rect); @@ -720,12 +719,12 @@ void tst_qdeclarativeanchors::hvCenterRTL() delete view; } -void tst_qdeclarativeanchors::margins() +void tst_QDeclarative1Anchors::margins() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); qApp->processEvents(); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 6.0); @@ -743,11 +742,11 @@ void tst_qdeclarativeanchors::margins() delete view; } -void tst_qdeclarativeanchors::marginsRTL() +void tst_QDeclarative1Anchors::marginsRTL() { QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); - QDeclarativeRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); + QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); mirrorAnchors(rect); @@ -768,6 +767,6 @@ void tst_qdeclarativeanchors::marginsRTL() } -QTEST_MAIN(tst_qdeclarativeanchors) +QTEST_MAIN(tst_QDeclarative1Anchors) #include "tst_qdeclarativeanchors.moc" diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/colors.gif rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/colors.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/hearts.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/hearts.gif rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/hearts.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/hearts.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/qmldir b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/qmldir rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/qtbug-16520.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/qtbug-16520.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.gif rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/stickman.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanerror1.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanpause.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanscaled.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeanimatedimage/data/stickmanstopped.qml rename to tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro new file mode 100644 index 0000000000..a338a94ce1 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative network qtquick1 +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += tst_qdeclarativeanimatedimage.cpp ../../declarative/shared/testhttpserver.cpp +macx:CONFIG -= app_bundle + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp similarity index 86% rename from tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp rename to tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index e7121a58a6..1d2f5ad4de 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -41,14 +41,14 @@ #include #include #include -#include +#include #include #include #include #include #include -#include "../shared/testhttpserver.h" +#include "../../declarative/shared/testhttpserver.h" #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -96,7 +96,7 @@ void tst_qdeclarativeanimatedimage::play() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); @@ -107,7 +107,7 @@ void tst_qdeclarativeanimatedimage::pause() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); QVERIFY(anim->isPaused()); @@ -119,7 +119,7 @@ void tst_qdeclarativeanimatedimage::stopped() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(!anim->isPlaying()); QCOMPARE(anim->currentFrame(), 0); @@ -131,7 +131,7 @@ void tst_qdeclarativeanimatedimage::setFrame() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); QCOMPARE(anim->currentFrame(), 2); @@ -143,7 +143,7 @@ void tst_qdeclarativeanimatedimage::frameCount() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(anim->isPlaying()); QCOMPARE(anim->frameCount(), 3); @@ -157,7 +157,7 @@ void tst_qdeclarativeanimatedimage::mirror_running() QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/hearts.qml")); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QGraphicsScene scene; @@ -200,7 +200,7 @@ void tst_qdeclarativeanimatedimage::mirror_notRunning() QDeclarativeEngine engine; QDeclarativeComponent component(&engine, fileUrl); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QGraphicsScene scene; @@ -251,7 +251,7 @@ void tst_qdeclarativeanimatedimage::remote() QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); QTRY_VERIFY(component.isReady()); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QTRY_VERIFY(anim->isPlaying()); @@ -259,7 +259,7 @@ void tst_qdeclarativeanimatedimage::remote() QTRY_VERIFY(anim->isPaused()); QCOMPARE(anim->currentFrame(), 2); } - QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error); + QVERIFY(anim->status() != QDeclarative1AnimatedImage::Error); delete anim; } @@ -268,7 +268,7 @@ void tst_qdeclarativeanimatedimage::sourceSize() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml")); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QCOMPARE(anim->width(),240.0); QCOMPARE(anim->height(),180.0); @@ -303,7 +303,7 @@ void tst_qdeclarativeanimatedimage::invalidSource() QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif"); - QDeclarativeAnimatedImage *anim = qobject_cast(component.create()); + QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); QVERIFY(anim); QVERIFY(!anim->isPlaying()); @@ -323,9 +323,9 @@ void tst_qdeclarativeanimatedimage::qtbug_16520() QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug-16520.qml")); QTRY_VERIFY(component.isReady()); - QDeclarativeRectangle *root = qobject_cast(component.create()); + QDeclarative1Rectangle *root = qobject_cast(component.create()); QVERIFY(root); - QDeclarativeAnimatedImage *anim = root->findChild("anim"); + QDeclarative1AnimatedImage *anim = root->findChild("anim"); anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif"); @@ -347,18 +347,18 @@ void tst_qdeclarativeanimatedimage::progressAndStatusChanges() ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarativeImage::Ready); + QVERIFY(obj->status() == QDeclarative1Image::Ready); QTRY_VERIFY(obj->progress() == 1.0); QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarativeImageBase::Status))); + QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarative1ImageBase::Status))); // Loading local file ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.gif")); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 1); QTRY_COMPARE(progressSpy.count(), 0); @@ -366,16 +366,16 @@ void tst_qdeclarativeanimatedimage::progressAndStatusChanges() // Loading remote file ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif"); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 2); QTRY_VERIFY(progressSpy.count() > 1); QTRY_COMPARE(statusSpy.count(), 2); ctxt->setContextProperty("srcImage", ""); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Null); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Null); QTRY_VERIFY(obj->progress() == 0.0); QTRY_COMPARE(sourceSpy.count(), 3); QTRY_VERIFY(progressSpy.count() > 2); diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml new file mode 100644 index 0000000000..b247fcee5f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + id: container + property bool on: false + border.color: "#ffffff" + color: "green" + width: 50 + height: 50 + NumberAnimation on x { + objectName: "animation" + running: container.on; from: 0; to: 600; loops: Animation.Infinite; duration: 2000 + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml new file mode 100644 index 0000000000..c5d5535bb7 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml @@ -0,0 +1,34 @@ +import QtQuick 1.0 + +Rectangle { + width: 180; height: 200; + + Component { + id: delegate + Rectangle { + id: wrapper + width: 180; height: 200 + color: "blue" + + states: State { + name: "otherState" + PropertyChanges { target: wrapper; color: "green" } + } + + transitions: Transition { + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + ScriptAction { script: console.log(wrapper.ListView.delayRemove ? "on" : "off") } + } + + Component.onCompleted: { + console.log(ListView.delayRemove ? "on" : "off"); + wrapper.state = "otherState" + } + } + } + + ListView { + model: 1 + delegate: delegate + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml new file mode 100644 index 0000000000..3e7ebe7440 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml @@ -0,0 +1,21 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + states: State { + name: "state1" + PropertyChanges { target: myRect; border.color: "blue" } + } + transitions: Transition { + ColorAnimation { target: myRect; to: "red"; property: "border.colr"; duration: 1000 } + } + Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml new file mode 100644 index 0000000000..40235eee15 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml @@ -0,0 +1,21 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + states: State { + name: "state1" + PropertyChanges { target: myRect; border.color: "blue" } + } + transitions: Transition { + ColorAnimation { target: myRect; to: "red"; property: "border"; duration: 1000 } + } + Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml new file mode 100644 index 0000000000..0a8a7ea7f9 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + PropertyAnimation on x { from: "blue"; to: "green"; } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml new file mode 100644 index 0000000000..118bbbc889 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { from: "blue"; to: "green"; } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml new file mode 100644 index 0000000000..2599e70cc9 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + Rectangle { + color: "red" + ColorAnimation on color { from: 10; to: 15; } + width: 50; height: 50 + x: 100; y: 100 + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml new file mode 100644 index 0000000000..5dafb0e344 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml @@ -0,0 +1,27 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; x: 200; color: "blue" } + } + transitions: Transition { + //comment out each in turn to make sure each only animates the relevant property + ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml new file mode 100644 index 0000000000..e2ce07fbfc --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml @@ -0,0 +1,18 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + Behavior on x { + NumberAnimation { id: myAnim; objectName: "MyAnim"; target: redRect; property: "y"; to: 300; loops: Animation.Infinite} + } + + } + +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml new file mode 100644 index 0000000000..6b8031769f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml @@ -0,0 +1,19 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + SequentialAnimation on x { + running: false + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml new file mode 100644 index 0000000000..2563c01d4f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml @@ -0,0 +1,19 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + + transitions: Transition { + SequentialAnimation { + NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true } + } + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml new file mode 100644 index 0000000000..aff69e5c12 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; border.color: "blue" } + } + transitions: Transition { + ColorAnimation { properties: "border.color"; duration: 1000 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml new file mode 100644 index 0000000000..f0fdf9cfb5 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + + Double { id: dub; on: parent.width < 800 } + Component.onCompleted: dub.on = false +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml new file mode 100644 index 0000000000..a97b3fd5bf --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml @@ -0,0 +1,25 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; x: 200; border.width: 10 } + } + transitions: Transition { + PropertyAnimation { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml new file mode 100644 index 0000000000..9a77467820 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml @@ -0,0 +1,25 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 240 + height: 320 + Rectangle { + id: myRect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + MouseArea { + anchors.fill: parent + onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; + } + } + states: State { + name: "state1" + PropertyChanges { target: myRect; x: 200; color: "blue" } + } + transitions: Transition { + PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml new file mode 100644 index 0000000000..04741ff348 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 + +Rectangle { + id: root + width: 200 + height: 200 + + Rectangle { + id: mover + objectName: "mover" + } + + states: [ + State { + name: "free" + }, + State { + name: "left" + PropertyChanges { + restoreEntryValues: false + target: mover + x: 0 + } + } + ] + + transitions: Transition { + PropertyAnimation { properties: "x"; duration: 50 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml new file mode 100644 index 0000000000..e6af9acc93 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { to: 200 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml new file mode 100644 index 0000000000..60ec456c71 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { targets: theRect; properties: "x"; to: 200; } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml new file mode 100644 index 0000000000..e86eca1316 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { target: theRect; property: "x"; to: 300; } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml new file mode 100644 index 0000000000..04d41c64c1 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { target: theRect; property: "y"; to: 200; } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml new file mode 100644 index 0000000000..e139f8c6c0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { targets: theRect; properties: "y"; to: 200; } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml new file mode 100644 index 0000000000..8e2b41db6c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { targets: theRect; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml new file mode 100644 index 0000000000..6b846852ff --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { target: theRect; property: "y"; to: 200 } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml new file mode 100644 index 0000000000..c9d8e95bd3 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { targets: theRect; properties: "y" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml new file mode 100644 index 0000000000..61e8a96788 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { target: theRect; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml new file mode 100644 index 0000000000..b023943007 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { targets: theRect; property: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml new file mode 100644 index 0000000000..7c88a7f038 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + NumberAnimation { targets: theItem; properties: "x" } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml new file mode 100644 index 0000000000..fbef95e572 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: theRect + objectName: "TheRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + } + + states: State { + name: "moved" + PropertyChanges { + target: theRect + x: 200 + } + } + transitions: Transition { + SpringAnimation { targets: theRect; properties: "x"; velocity: 10000 } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "moved" + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml new file mode 100644 index 0000000000..7dc29f9315 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml @@ -0,0 +1,18 @@ +import QtQuick 1.0 + +Rectangle { + id: rect + width: 200 + height: 200 + + property bool animating: true + property int value: 0 + + NumberAnimation { + target: rect + property: "value" + running: rect.animating + to: 100 + duration: 50 + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml new file mode 100644 index 0000000000..ac158df719 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml @@ -0,0 +1,48 @@ +import QtQuick 1.0 + +Rectangle { + width: 600; height: 200 + + Row { + spacing: 5 + Rectangle { + id: rr + objectName: "rr" + color: "red" + width: 100; height: 100 + } + Rectangle { + id: rr2 + objectName: "rr2" + color: "red" + width: 100; height: 100 + } + Rectangle { + id: rr3 + objectName: "rr3" + color: "red" + width: 100; height: 100 + } + Rectangle { + id: rr4 + objectName: "rr4" + color: "red" + width: 100; height: 100 + } + } + + states: State { + name: "state1" + PropertyChanges { target: rr; rotation: 370 } + PropertyChanges { target: rr2; rotation: 370 } + PropertyChanges { target: rr3; rotation: 370 } + PropertyChanges { target: rr4; rotation: 370 } + } + + transitions: Transition { + RotationAnimation { target: rr; direction: RotationAnimation.Numerical; duration: 1000 } + RotationAnimation { target: rr2; direction: RotationAnimation.Clockwise; duration: 1000 } + RotationAnimation { target: rr3; direction: RotationAnimation.Counterclockwise; duration: 1000 } + RotationAnimation { target: rr4; direction: RotationAnimation.Shortest; duration: 1000 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml new file mode 100644 index 0000000000..7d33ed7175 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 +Rectangle { + color: "skyblue" + width: 500 + height: 200 + Rectangle { + objectName: "cloud" + color: "white" + y: 50 + width: 100 + height: 100 + + SequentialAnimation on x { + loops: Animation.Infinite + running: true + NumberAnimation { + id: firstAnimation + from: 0 + to: 500 + duration: 5000 + } + NumberAnimation { + id: secondAnimation + from: -100 + to: 0 + duration: 1000 + } + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml new file mode 100644 index 0000000000..fa9cd400ac --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { id: anim; objectName: "MyAnim"; to: 200 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml new file mode 100644 index 0000000000..f6343a1bff --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + color: "red" + width: 50; height: 50 + x: 100; y: 100 + NumberAnimation on x { id: anim; objectName: "MyAnim"; running: false; to: 200 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro new file mode 100644 index 0000000000..2daebc7a54 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro @@ -0,0 +1,16 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative qtquick1 +SOURCES += tst_qdeclarativeanimations.cpp +macx:CONFIG -= app_bundle + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp new file mode 100644 index 0000000000..6f75ce3d31 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -0,0 +1,855 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativeanimations : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativeanimations() {} + +private slots: + void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered + + void simpleProperty(); + void simpleNumber(); + void simpleColor(); + void simpleRotation(); + void alwaysRunToEnd(); + void complete(); + void resume(); + void dotProperty(); + void badTypes(); + void badProperties(); + void mixedTypes(); + void properties(); + void propertiesTransition(); + void invalidDuration(); + void attached(); + void propertyValueSourceDefaultStart(); + void dontStart(); + void easingProperties(); + void rotation(); + void runningTrueBug(); + void nonTransitionBug(); + void registrationBug(); + void doubleRegistrationBug(); + void alwaysRunToEndRestartBug(); +}; + +#define QTIMED_COMPARE(lhs, rhs) do { \ + for (int ii = 0; ii < 5; ++ii) { \ + if (lhs == rhs) \ + break; \ + QTest::qWait(50); \ + } \ + QCOMPARE(lhs, rhs); \ +} while (false) + +void tst_qdeclarativeanimations::simpleProperty() +{ + QDeclarative1Rectangle rect; + QDeclarative1PropertyAnimation animation; + animation.setTarget(&rect); + animation.setProperty("pos"); + animation.setTo(QPointF(200,200)); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "pos"); + QVERIFY(animation.to().toPointF() == QPointF(200,200)); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.pos(), QPointF(200,200)); + + rect.setPos(0,0); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.pos(), QPointF(100,100)); +} + +void tst_qdeclarativeanimations::simpleNumber() +{ + QDeclarative1Rectangle rect; + QDeclarative1NumberAnimation animation; + animation.setTarget(&rect); + animation.setProperty("x"); + animation.setTo(200); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "x"); + QVERIFY(animation.to() == 200); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.x(), qreal(200)); + + rect.setX(0); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.x(), qreal(100)); +} + +void tst_qdeclarativeanimations::simpleColor() +{ + QDeclarative1Rectangle rect; + QDeclarative1ColorAnimation animation; + animation.setTarget(&rect); + animation.setProperty("color"); + animation.setTo(QColor("red")); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "color"); + QVERIFY(animation.to() == QColor("red")); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.color(), QColor("red")); + + rect.setColor(QColor("blue")); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); + + rect.setColor(QColor("green")); + animation.setFrom(QColor("blue")); + QVERIFY(animation.from() == QColor("blue")); + animation.restart(); + QCOMPARE(rect.color(), QColor("blue")); + QVERIFY(animation.isRunning()); + animation.setCurrentTime(125); + QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); +} + +void tst_qdeclarativeanimations::simpleRotation() +{ + QDeclarative1Rectangle rect; + QDeclarative1RotationAnimation animation; + animation.setTarget(&rect); + animation.setProperty("rotation"); + animation.setTo(270); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "rotation"); + QVERIFY(animation.to() == 270); + QVERIFY(animation.direction() == QDeclarative1RotationAnimation::Numerical); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTIMED_COMPARE(rect.rotation(), qreal(270)); + + rect.setRotation(0); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.rotation(), qreal(135)); +} + +void tst_qdeclarativeanimations::alwaysRunToEnd() +{ + QDeclarative1Rectangle rect; + QDeclarative1PropertyAnimation animation; + animation.setTarget(&rect); + animation.setProperty("x"); + animation.setTo(200); + animation.setDuration(1000); + animation.setLoops(-1); + animation.setAlwaysRunToEnd(true); + QVERIFY(animation.loops() == -1); + QVERIFY(animation.alwaysRunToEnd() == true); + animation.start(); + QTest::qWait(1500); + animation.stop(); + QVERIFY(rect.x() != qreal(200)); + QTest::qWait(500); + QTIMED_COMPARE(rect.x(), qreal(200)); +} + +void tst_qdeclarativeanimations::complete() +{ + QDeclarative1Rectangle rect; + QDeclarative1PropertyAnimation animation; + animation.setTarget(&rect); + animation.setProperty("x"); + animation.setFrom(1); + animation.setTo(200); + animation.setDuration(500); + QVERIFY(animation.from() == 1); + animation.start(); + QTest::qWait(50); + animation.stop(); + QVERIFY(rect.x() != qreal(200)); + animation.start(); + QTest::qWait(50); + QVERIFY(animation.isRunning()); + animation.complete(); + QCOMPARE(rect.x(), qreal(200)); +} + +void tst_qdeclarativeanimations::resume() +{ + QDeclarative1Rectangle rect; + QDeclarative1PropertyAnimation animation; + animation.setTarget(&rect); + animation.setProperty("x"); + animation.setFrom(10); + animation.setTo(200); + animation.setDuration(1000); + QVERIFY(animation.from() == 10); + + animation.start(); + QTest::qWait(400); + animation.pause(); + qreal x = rect.x(); + QVERIFY(x != qreal(200) && x != qreal(10)); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + + animation.resume(); + QVERIFY(animation.isRunning()); + QVERIFY(!animation.isPaused()); + QTest::qWait(400); + animation.stop(); + QVERIFY(rect.x() > x); +} + +void tst_qdeclarativeanimations::dotProperty() +{ + QDeclarativeEngine engine; + QString componentStr = "import QtQuick 1.0\nRectangle{ id: rect; NumberAnimation{ objectName: \"anim\"; target: rect; property: \"border.width\"; to: 10 }}"; + QDeclarativeComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1Rectangle *rect = qobject_cast(animationComponent.create()); + QVERIFY(rect); + QDeclarative1NumberAnimation *animation = rect->findChild("anim"); + QVERIFY(animation); + + animation->start(); + QTest::qWait(animation->duration()+50); + QTIMED_COMPARE(rect->border()->width(), 10); + + rect->border()->setWidth(0); + animation->start(); + animation->pause(); + animation->setCurrentTime(125); + QVERIFY(animation->currentTime() == 125); + QCOMPARE(rect->border()->width(), 5); + + delete rect; +} + +void tst_qdeclarativeanimations::badTypes() +{ + //don't crash + { + QDeclarativeView *view = new QDeclarativeView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); + + qApp->processEvents(); + + delete view; + } + + //make sure we get a compiler error + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype2.qml")); + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected")); + } + + //make sure we get a compiler error + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype3.qml")); + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); + c.create(); + + QVERIFY(c.errors().count() == 1); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected")); + } + + //don't crash + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("state1"); + QTest::qWait(1000 + 50); + QDeclarative1Rectangle *myRect = rect->findChild("MyRect"); + QVERIFY(myRect); + QCOMPARE(myRect->x(),qreal(200)); + } +} + +void tst_qdeclarativeanimations::badProperties() +{ + //make sure we get a runtime error + { + QDeclarativeEngine engine; + + QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); + QByteArray message = QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; + QTest::ignoreMessage(QtWarningMsg, message); + QDeclarative1Rectangle *rect = qobject_cast(c1.create()); + QVERIFY(rect); + + QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml")); + message = QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; + QTest::ignoreMessage(QtWarningMsg, message); + rect = qobject_cast(c2.create()); + QVERIFY(rect); + + //### should we warn here are well? + //rect->setState("state1"); + } +} + +//test animating mixed types with property animation in a transition +//for example, int + real; color + real; etc +void tst_qdeclarativeanimations::mixedTypes() +{ + //assumes border.width stays a real -- not real robust + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("state1"); + QTest::qWait(500); + QDeclarative1Rectangle *myRect = rect->findChild("MyRect"); + QVERIFY(myRect); + + //rather inexact -- is there a better way? + QVERIFY(myRect->x() > 100 && myRect->x() < 200); + QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("state1"); + QTest::qWait(500); + QDeclarative1Rectangle *myRect = rect->findChild("MyRect"); + QVERIFY(myRect); + + //rather inexact -- is there a better way? + QVERIFY(myRect->x() > 100 && myRect->x() < 200); + QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue")); + } +} + +void tst_qdeclarativeanimations::properties() +{ + const int waitDuration = 300; + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(300)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->y(),qreal(200)); + QTIMED_COMPARE(myRect->x(),qreal(100)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(100)); + QTIMED_COMPARE(myRect->y(),qreal(200)); + } +} + +void tst_qdeclarativeanimations::propertiesTransition() +{ + const int waitDuration = 300; + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->y(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->y(),qreal(200)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->y(),qreal(100)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + + /*{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(100)); + }*/ + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition7.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); + } + +} + +void tst_qdeclarativeanimations::invalidDuration() +{ + QDeclarative1PropertyAnimation *animation = new QDeclarative1PropertyAnimation; + QTest::ignoreMessage(QtWarningMsg, ": QML PropertyAnimation: Cannot set a duration of < 0"); + animation->setDuration(-1); + QCOMPARE(animation->duration(), 250); + + QDeclarative1PauseAnimation *pauseAnimation = new QDeclarative1PauseAnimation; + QTest::ignoreMessage(QtWarningMsg, ": QML PauseAnimation: Cannot set a duration of < 0"); + pauseAnimation->setDuration(-1); + QCOMPARE(pauseAnimation->duration(), 250); +} + +void tst_qdeclarativeanimations::attached() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml")); + QTest::ignoreMessage(QtDebugMsg, "off"); + QTest::ignoreMessage(QtDebugMsg, "on"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); +} + +void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() +{ + { + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml")); + + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim); + QVERIFY(myAnim->isRunning()); + } + + { + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml")); + + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim); + QVERIFY(myAnim->isRunning() == false); + } + + { + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml")); + + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } +} + + +void tst_qdeclarativeanimations::dontStart() +{ + { + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } + + { + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml")); + + QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } +} + +void tst_qdeclarativeanimations::easingProperties() +{ + { + QDeclarativeEngine engine; + QString componentStr = "import QtQuick 1.0\nNumberAnimation { easing.type: \"InOutQuad\" }"; + QDeclarativeComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad); + } + + { + QDeclarativeEngine engine; + QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }"; + QDeclarativeComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce); + QCOMPARE(animObject->easing().amplitude(), 5.0); + } + + { + QDeclarativeEngine engine; + QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}"; + QDeclarativeComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic); + QCOMPARE(animObject->easing().amplitude(), 5.0); + QCOMPARE(animObject->easing().period(), 3.0); + } + + { + QDeclarativeEngine engine; + QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }"; + QDeclarativeComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack); + QCOMPARE(animObject->easing().overshoot(), 2.0); + } +} + +void tst_qdeclarativeanimations::rotation() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/rotation.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *rr = rect->findChild("rr"); + QDeclarative1Rectangle *rr2 = rect->findChild("rr2"); + QDeclarative1Rectangle *rr3 = rect->findChild("rr3"); + QDeclarative1Rectangle *rr4 = rect->findChild("rr4"); + + QDeclarativeItemPrivate::get(rect)->setState("state1"); + QTest::qWait(800); + qreal r1 = rr->rotation(); + qreal r2 = rr2->rotation(); + qreal r3 = rr3->rotation(); + qreal r4 = rr4->rotation(); + + QVERIFY(r1 > qreal(0) && r1 < qreal(370)); + QVERIFY(r2 > qreal(0) && r2 < qreal(370)); + QVERIFY(r3 < qreal(0) && r3 > qreal(-350)); + QVERIFY(r4 > qreal(0) && r4 < qreal(10)); + QCOMPARE(r1,r2); + QVERIFY(r4 < r2); + + QTest::qWait(800); + QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4)); +} + +void tst_qdeclarativeanimations::runningTrueBug() +{ + //ensure we start correctly when "running: true" is explicitly set + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrueBug.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *cloud = rect->findChild("cloud"); + QVERIFY(cloud); + QTest::qWait(1000); + QVERIFY(cloud->x() > qreal(0)); +} + +//QTBUG-12805 +void tst_qdeclarativeanimations::nonTransitionBug() +{ + //tests that the animation values from the previous transition are properly cleared + //in the case where an animation in the transition doesn't match anything (but previously did) + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/nonTransitionBug.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QDeclarative1Rectangle *mover = rect->findChild("mover"); + + mover->setX(100); + QCOMPARE(mover->x(), qreal(100)); + + rectPrivate->setState("left"); + QTRY_COMPARE(mover->x(), qreal(0)); + + mover->setX(100); + QCOMPARE(mover->x(), qreal(100)); + + //make sure we don't try to animate back to 0 + rectPrivate->setState("free"); + QTest::qWait(300); + QCOMPARE(mover->x(), qreal(100)); +} + +//QTBUG-14042 +void tst_qdeclarativeanimations::registrationBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/registrationBug.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QTRY_COMPARE(rect->property("value"), QVariant(int(100))); +} + +void tst_qdeclarativeanimations::doubleRegistrationBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/doubleRegistrationBug.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QDeclarative1AbstractAnimation *anim = rect->findChild("animation"); + QVERIFY(anim != 0); + QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Stopped); +} + +//QTBUG-16736 +void tst_qdeclarativeanimations::alwaysRunToEndRestartBug() +{ + QDeclarative1Rectangle rect; + QDeclarative1PropertyAnimation animation; + animation.setTarget(&rect); + animation.setProperty("x"); + animation.setTo(200); + animation.setDuration(1000); + animation.setLoops(-1); + animation.setAlwaysRunToEnd(true); + QVERIFY(animation.loops() == -1); + QVERIFY(animation.alwaysRunToEnd() == true); + animation.start(); + animation.stop(); + animation.start(); + animation.stop(); + QTest::qWait(500); + QVERIFY(rect.x() != qreal(200)); + QTest::qWait(800); + QTIMED_COMPARE(rect.x(), qreal(200)); + QCOMPARE(static_cast(&animation)->qtAnimation()->state(), QAbstractAnimation::Stopped); +} + +QTEST_MAIN(tst_qdeclarativeanimations) + +#include "tst_qdeclarativeanimations.moc" diff --git a/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro b/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro new file mode 100644 index 0000000000..96b3c0bffb --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeapplication.cpp +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp b/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp new file mode 100644 index 0000000000..dfb2329668 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "../../../shared/util.h" +#include +#include +#include +#include +#include + +class tst_qdeclarativeapplication : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativeapplication(); + +private slots: + void active(); + void layoutDirection(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativeapplication::tst_qdeclarativeapplication() +{ +} + +void tst_qdeclarativeapplication::active() +{ + QDeclarativeComponent component(&engine); + component.setData("import QtQuick 1.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile("")); + QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item); + QGraphicsScene scene; + QGraphicsView view(&scene); + scene.addItem(item); + + // not active + QVERIFY(!item->property("active").toBool()); + QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0); + + // active + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); + QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0); + + // not active again + // on mac, setActiveWindow(0) on mac does not deactivate the current application + // (you have to switch to a different app or hide the current app to trigger this) +#if !defined(Q_WS_MAC) + QApplication::setActiveWindow(0); + QVERIFY(!item->property("active").toBool()); + QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0); +#endif +} + +void tst_qdeclarativeapplication::layoutDirection() +{ + QDeclarativeComponent component(&engine); + component.setData("import QtQuick 1.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile("")); + QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item); + QGraphicsScene scene; + QGraphicsView view(&scene); + scene.addItem(item); + + // not mirrored + QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); + + // mirrored + QApplication::setLayoutDirection(Qt::RightToLeft); + QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft); + + // not mirrored again + QApplication::setLayoutDirection(Qt::LeftToRight); + QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); +} + +QTEST_MAIN(tst_qdeclarativeapplication) + +#include "tst_qdeclarativeapplication.moc" diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml new file mode 100644 index 0000000000..a452447f31 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + property real basex : 0 + property real movedx: 200 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: basex + Behavior on x { NumberAnimation { duration: 800; } } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: movedx + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml new file mode 100644 index 0000000000..c4b783a0f0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; + color: "green" + Behavior on color { ColorAnimation { duration: 500; } } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "red" + when: clicker.pressed + PropertyChanges { + target: rect + color: "red" + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml new file mode 100644 index 0000000000..88ddfaa1a7 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml @@ -0,0 +1,11 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { NumberAnimation { duration: 500; } } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml new file mode 100644 index 0000000000..aa384c335f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml @@ -0,0 +1,25 @@ +import QtQuick 1.0 + +Rectangle { + id: container + + width: 400; height: 400; + property Item myItem + + function doCreate() { + myItem = myComponent.createObject(container) + myItem.x = 100 + } + + Component { + id: myComponent + Rectangle { + width: 100 + height: 100 + color: "green" + Behavior on x { NumberAnimation { duration: 500 } } + } + } + + Component.onCompleted: doCreate() +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml new file mode 100644 index 0000000000..f6cfa5e33d --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml @@ -0,0 +1,27 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + enabled: false + NumberAnimation { duration: 200; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml new file mode 100644 index 0000000000..e318dd2567 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml @@ -0,0 +1,18 @@ +import QtQuick 1.0 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + Behavior on x { + NumberAnimation {id: myAnim; objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml new file mode 100644 index 0000000000..6c78a84540 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml @@ -0,0 +1,23 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x {} + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml new file mode 100644 index 0000000000..3baa1ac23a --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + NumberAnimation { target: rect; property: "x"; duration: 500; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml new file mode 100644 index 0000000000..ddb5bbd40c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml @@ -0,0 +1,23 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on pos { PropertyAnimation { duration: 500; } } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + pos: Qt.point(200,0); + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml new file mode 100644 index 0000000000..c0b71cdb04 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml @@ -0,0 +1,23 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on pos.x { NumberAnimation { duration: 500; } } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + pos.x: 200; + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml new file mode 100644 index 0000000000..8aa590bca1 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +Rectangle { + width: 200 + height: 200 + Text { + Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } } + text: "Hello World" + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml new file mode 100644 index 0000000000..76379c00a2 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml @@ -0,0 +1,19 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { NumberAnimation { duration: 200; } } + onXChanged: x = 100; + } + states: State { + name: "moved" + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml new file mode 100644 index 0000000000..c5c78d1aa2 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + NumberAnimation { targets: rect; properties: "y"; duration: 200; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml new file mode 100644 index 0000000000..d19da298b2 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml @@ -0,0 +1,28 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on parent { + SequentialAnimation { + PauseAnimation { duration: 500 } + PropertyAction {} + } + } + } + Item { + id: newParent + objectName: "NewParent" + x: 100 + } + states: State { + name: "reparented" + PropertyChanges { + target: rect + parent: newParent + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml new file mode 100644 index 0000000000..03b542164b --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml @@ -0,0 +1,17 @@ +import QtQuick 1.0 + +Rectangle { + width: 200 + height: 200 + color: "blue" + + Rectangle { + id: myRect + objectName: "myRect" + width: 100 + height: 100 + Behavior on x { + NumberAnimation { duration: 500 } + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml new file mode 100644 index 0000000000..56ac216c5a --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml @@ -0,0 +1,32 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + id: myBehavior + objectName: "MyBehavior" + NumberAnimation {id: na1; duration: 200 } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } + + NumberAnimation {id: na2; duration: 1000 } + Component.onCompleted: { + myBehavior.animation = na2; + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml new file mode 100644 index 0000000000..25cdf10acf --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml @@ -0,0 +1,20 @@ +import QtQuick 1.0 + +Rectangle { + id: root + width:200; height:200 + + property real myValue: 0 + + Rectangle { + anchors.centerIn: parent + width: 100 + height: 100 + color: "green" + smooth: true + rotation: myValue + Behavior on rotation { + RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest } + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml new file mode 100644 index 0000000000..c05cdaa940 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + + onColorChanged: { + rect.x = 200 + } + + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { NumberAnimation { duration: 800; } } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml new file mode 100644 index 0000000000..6ba0118660 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + Behavior on x { + objectName: "MyBehavior"; + NumberAnimation {id: na; duration: 500; } + } + } + MouseArea { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml new file mode 100644 index 0000000000..fca416c08c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml @@ -0,0 +1,17 @@ +import QtQuick 1.0 + +Rectangle { + width: 400 + height: 400 + + Rectangle { + objectName: "innerRect" + height: 100; width: 100; color: "green" + property real targetX: 100 + + x: targetX + Behavior on x { + NumberAnimation {} + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml new file mode 100644 index 0000000000..eb627613d4 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 + +Rectangle { + width: 800; + height: 480; + + Text { id:theText; text: "hello world" } + + Rectangle { + objectName: "innerRect" + color: "red" + x: theText.width + Behavior on x { NumberAnimation {} } + width: 100; height: 100 + } +} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro new file mode 100644 index 0000000000..4fd4ddd8b0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -0,0 +1,16 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative qtquick1 +SOURCES += tst_qdeclarativebehaviors.cpp +macx:CONFIG -= app_bundle + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp new file mode 100644 index 0000000000..773fc24148 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -0,0 +1,435 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativebehaviors : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativebehaviors() {} + +private slots: + void simpleBehavior(); + void scriptTriggered(); + void cppTriggered(); + void loop(); + void colorBehavior(); + void parentBehavior(); + void replaceBinding(); + //void transitionOverrides(); + void group(); + void emptyBehavior(); + void explicitSelection(); + void nonSelectingBehavior(); + void reassignedAnimation(); + void disabled(); + void dontStart(); + void startup(); + void groupedPropertyCrash(); + void runningTrue(); + void sameValue(); + void delayedRegistration(); +}; + +void tst_qdeclarativebehaviors::simpleBehavior() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + QTRY_VERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qdeclarativebehaviors::scriptTriggered() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + rect->setColor(QColor("red")); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qdeclarativebehaviors::cppTriggered() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QTRY_VERIFY(innerRect); + + innerRect->setProperty("x", 200); + QTRY_VERIFY(innerRect->x() > 0); + QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qdeclarativebehaviors::loop() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + //don't crash + QDeclarativeItemPrivate::get(rect)->setState("moved"); + + delete rect; +} + +void tst_qdeclarativebehaviors::colorBehavior() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("red"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("red")); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("green")); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qdeclarativebehaviors::parentBehavior() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QTRY_VERIFY(rect->findChild("MyRect")->parentItem() != rect->findChild("NewParent")); + QTRY_VERIFY(rect->findChild("MyRect")->parentItem() == rect->findChild("NewParent")); + + delete rect; +} + +void tst_qdeclarativebehaviors::replaceBinding() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QTRY_VERIFY(innerRect); + QTRY_VERIFY(innerRect->x() > 0); + QTRY_VERIFY(innerRect->x() < 200); + //i.e. the behavior has been triggered + QTRY_COMPARE(innerRect->x(), (qreal)200); + rect->setProperty("basex", 10); + QTRY_COMPARE(innerRect->x(), (qreal)200); + rect->setProperty("movedx", 210); + QTRY_COMPARE(innerRect->x(), (qreal)210); + + QDeclarativeItemPrivate::get(rect)->setState(""); + QTRY_VERIFY(innerRect->x() > 10); + QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered + QTRY_COMPARE(innerRect->x(), (qreal)10); + rect->setProperty("movedx", 200); + QTRY_COMPARE(innerRect->x(), (qreal)10); + rect->setProperty("basex", 20); + QTRY_COMPARE(innerRect->x(), (qreal)20); + + delete rect; +} + +void tst_qdeclarativebehaviors::group() +{ + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + //QTest::qWait(200); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QTRY_VERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; + } +} + +void tst_qdeclarativebehaviors::emptyBehavior() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; +} + +void tst_qdeclarativebehaviors::explicitSelection() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); + QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); + //i.e. the behavior has been triggered + + delete rect; +} + +void tst_qdeclarativebehaviors::nonSelectingBehavior() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; +} + +void tst_qdeclarativebehaviors::reassignedAnimation() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); + QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QCOMPARE(qobject_cast( + rect->findChild("MyBehavior")->animation())->duration(), 200); + + delete rect; +} + +void tst_qdeclarativebehaviors::disabled() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); + + QDeclarativeItemPrivate::get(rect)->setState("moved"); + qreal x = qobject_cast(rect->findChild("MyRect"))->x(); + QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; +} + +void tst_qdeclarativebehaviors::dontStart() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + + delete rect; +} + +void tst_qdeclarativebehaviors::startup() +{ + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *innerRect = rect->findChild("innerRect"); + QVERIFY(innerRect); + + QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately + + delete rect; + } + + { + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup2.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *innerRect = rect->findChild("innerRect"); + QVERIFY(innerRect); + + QDeclarative1Text *text = rect->findChild(); + QVERIFY(text); + + QCOMPARE(innerRect->x(), text->width()); //should be set immediately + + delete rect; + } +} + +//QTBUG-10799 +void tst_qdeclarativebehaviors::groupedPropertyCrash() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupedPropertyCrash.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); //don't crash +} + +//QTBUG-5491 +void tst_qdeclarativebehaviors::runningTrue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrue.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1AbstractAnimation *animation = rect->findChild("rotAnim"); + QVERIFY(animation); + + QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool))); + rect->setProperty("myValue", 180); + QTRY_VERIFY(runningSpy.count() > 0); +} + +//QTBUG-12295 +void tst_qdeclarativebehaviors::sameValue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *target = rect->findChild("myRect"); + QVERIFY(target); + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); + QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. + + target->setX(100); + QCOMPARE(target->x(), qreal(100)); + + //this is the main point of the test -- the behavior needs to be triggered again + //even though we set 0 twice in a row. + target->setProperty("x", 0); + QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); +} + +//QTBUG-18362 +void tst_qdeclarativebehaviors::delayedRegistration() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/delayedRegistration.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QDeclarativeItem *innerRect = rect->property("myItem").value(); + QVERIFY(innerRect != 0); + + QCOMPARE(innerRect->property("x").toInt(), int(0)); + + QTRY_COMPARE(innerRect->property("x").toInt(), int(100)); +} + +QTEST_MAIN(tst_qdeclarativebehaviors) + +#include "tst_qdeclarativebehaviors.moc" diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml new file mode 100644 index 0000000000..94497368a7 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 + +Rectangle { + id: screen + width: 320; height: 240 + property string text + property bool changeColor: false + + Text { id: s1; text: "Hello" } + Rectangle { id: r1; width: 1; height: 1; color: "yellow" } + Rectangle { id: r2; width: 1; height: 1; color: "red" } + + Binding { target: screen; property: "text"; value: s1.text; objectName: "binding1" } + Binding { target: screen; property: "color"; value: r1.color } + Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; objectName: "binding3" } +} diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml new file mode 100644 index 0000000000..3e99e2b5e6 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 + +Rectangle { + id: screen + width: 320; height: 240 + property string text + property bool changeColor: false + + Text { id: s1; text: "Hello" } + Rectangle { id: r1; width: 1; height: 1; color: "yellow" } + Rectangle { id: r2; width: 1; height: 1; color: "red" } + + Binding { target: screen; property: "text"; value: s1.text } + Binding { target: screen; property: "color"; value: r1.color } + Binding { target: screen; property: "color"; value: r2.color; when: screen.changeColor == true } +} diff --git a/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro new file mode 100644 index 0000000000..b335e1105c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativebinding.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp new file mode 100644 index 0000000000..776fa528cf --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativebinding : public QObject + +{ + Q_OBJECT +public: + tst_qdeclarativebinding(); + +private slots: + void binding(); + void whenAfterValue(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativebinding::tst_qdeclarativebinding() +{ +} + +void tst_qdeclarativebinding::binding() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QDeclarative1Bind *binding3 = qobject_cast(rect->findChild("binding3")); + QVERIFY(binding3 != 0); + + QCOMPARE(rect->color(), QColor("yellow")); + QCOMPARE(rect->property("text").toString(), QString("Hello")); + QCOMPARE(binding3->when(), false); + + rect->setProperty("changeColor", true); + QCOMPARE(rect->color(), QColor("red")); + + QCOMPARE(binding3->when(), true); + + QDeclarative1Bind *binding = qobject_cast(rect->findChild("binding1")); + QVERIFY(binding != 0); + QCOMPARE(binding->object(), qobject_cast(rect)); + QCOMPARE(binding->property(), QLatin1String("text")); + QCOMPARE(binding->value().toString(), QLatin1String("Hello")); + + delete rect; +} + +void tst_qdeclarativebinding::whenAfterValue() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml")); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + + QVERIFY(rect != 0); + QCOMPARE(rect->color(), QColor("yellow")); + QCOMPARE(rect->property("text").toString(), QString("Hello")); + + rect->setProperty("changeColor", true); + QCOMPARE(rect->color(), QColor("red")); + + delete rect; +} + +QTEST_MAIN(tst_qdeclarativebinding) + +#include "tst_qdeclarativebinding.moc" diff --git a/tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci similarity index 100% rename from tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci rename to tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci diff --git a/tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci similarity index 100% rename from tests/auto/declarative/qdeclarativeborderimage/data/colors-round.sci rename to tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci diff --git a/tests/auto/declarative/qdeclarativeborderimage/data/colors.png b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png similarity index 100% rename from tests/auto/declarative/qdeclarativeborderimage/data/colors.png rename to tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png diff --git a/tests/auto/declarative/qdeclarativeborderimage/data/heart200.png b/tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png similarity index 100% rename from tests/auto/declarative/qdeclarativeborderimage/data/heart200.png rename to tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png diff --git a/tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci similarity index 100% rename from tests/auto/declarative/qdeclarativeborderimage/data/invalid.sci rename to tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro new file mode 100644 index 0000000000..a6701ba8f9 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network qtquick1 +macx:CONFIG -= app_bundle + +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += tst_qdeclarativeborderimage.cpp ../../declarative/shared/testhttpserver.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp similarity index 79% rename from tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp rename to tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 444781801c..d5631469a5 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -54,7 +54,7 @@ #include #include -#include "../shared/testhttpserver.h" +#include "../../declarative/shared/testhttpserver.h" #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -102,13 +102,13 @@ void tst_qdeclarativeborderimage::noSource() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->source(), QUrl()); QCOMPARE(obj->width(), 0.); QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); delete obj; } @@ -146,24 +146,24 @@ void tst_qdeclarativeborderimage::imageSource() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); if (remote) - QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); if (error.isEmpty()) { - QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); QCOMPARE(obj->sourceSize().width(), 120); QCOMPARE(obj->sourceSize().height(), 120); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); } else { - QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error); + QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Error); } delete obj; @@ -177,15 +177,15 @@ void tst_qdeclarativeborderimage::clearSource() ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarativeBorderImage::Ready); + QVERIFY(obj->status() == QDeclarative1BorderImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); ctxt->setContextProperty("srcImage", ""); QVERIFY(obj->source().isEmpty()); - QVERIFY(obj->status() == QDeclarativeBorderImage::Null); + QVERIFY(obj->status() == QDeclarative1BorderImage::Null); QCOMPARE(obj->width(), 0.); QCOMPARE(obj->height(), 0.); } @@ -195,14 +195,14 @@ void tst_qdeclarativeborderimage::resized() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); QCOMPARE(obj->sourceSize().width(), 120); QCOMPARE(obj->sourceSize().height(), 120); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); delete obj; } @@ -212,13 +212,13 @@ void tst_qdeclarativeborderimage::smooth() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); QCOMPARE(obj->smooth(), true); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); delete obj; } @@ -228,7 +228,7 @@ void tst_qdeclarativeborderimage::mirror() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/heart200.png\"; smooth: true; width: 300; height: 300; border { top: 50; right: 50; bottom: 50; left: 50 } }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); int width = obj->property("width").toInt(); @@ -261,12 +261,12 @@ void tst_qdeclarativeborderimage::tileModes() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 100.); QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Repeat); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Repeat); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Repeat); delete obj; } @@ -274,12 +274,12 @@ void tst_qdeclarativeborderimage::tileModes() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 150.); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Round); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Round); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Round); delete obj; } @@ -301,26 +301,26 @@ void tst_qdeclarativeborderimage::sciSource() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); if (remote) - QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); if (valid) { - QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Ready); QCOMPARE(obj->border()->left(), 10); QCOMPARE(obj->border()->top(), 20); QCOMPARE(obj->border()->right(), 30); QCOMPARE(obj->border()->bottom(), 40); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Round); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Repeat); } else { - QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error); + QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Error); } delete obj; @@ -341,19 +341,19 @@ void tst_qdeclarativeborderimage::sciSource_data() void tst_qdeclarativeborderimage::invalidSciFile() { - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun" - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea" + QTest::ignoreMessage(QtWarningMsg, "QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun" + QTest::ignoreMessage(QtWarningMsg, "QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea" QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->status(), QDeclarativeImageBase::Error); - QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch); + QCOMPARE(obj->status(), QDeclarative1ImageBase::Error); + QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); + QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); delete obj; } @@ -365,9 +365,9 @@ void tst_qdeclarativeborderimage::pendingRemoteRequest() QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeBorderImage *obj = qobject_cast(component.create()); + QDeclarative1BorderImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - QCOMPARE(obj->status(), QDeclarativeBorderImage::Loading); + QCOMPARE(obj->status(), QDeclarative1BorderImage::Loading); // verify no crash // This will cause a delayed "QThread: Destroyed while thread is still running" warning diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml new file mode 100644 index 0000000000..dd92cb9c67 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml @@ -0,0 +1,25 @@ +import QtQuick 1.0 + +Item { + Component { + id: item1 + Item { + objectName: "item1" + } + } + Component { + id: item2 + Item { + objectName: "item2" + } + } + Loader { + id: loader + sourceComponent: item1 + } + Connections { + objectName: "connections" + target: loader.item + onWidthChanged: loader.sourceComponent = item2 + } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml new file mode 100644 index 0000000000..459c34617b --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +Item { + id: screen + + Connections { target: screen; onNotFooBar1: {} ignoreUnknownSignals: true } + Connections { objectName: "connections"; onNotFooBar2: {} ignoreUnknownSignals: true } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml new file mode 100644 index 0000000000..8eddf43fe6 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +Item { + id: screen + + Connections { objectName: "connections"; target: null; onNotFooBar: {} } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml new file mode 100644 index 0000000000..953347a3b2 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +Item { + id: screen + + Connections { objectName: "connections"; onFooBar: {} } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml new file mode 100644 index 0000000000..3702bdbe73 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +Item { + id: screen + + Connections { objectName: "connections"; target: screen; onFooBar: {} } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml new file mode 100644 index 0000000000..376a2182fe --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +Item { + Connections { + onClicked: Item {} + } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml new file mode 100644 index 0000000000..677af152ce --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 + +Item { + Connections { fakeProperty: {} } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml new file mode 100644 index 0000000000..127e58e657 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 + +Item { + Connections { onfakeProperty: {} } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml new file mode 100644 index 0000000000..6a82528e1a --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml @@ -0,0 +1,9 @@ +import QtQuick 1.0 + +Item { + Connections { + onClicked { + onPressed: {} + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml new file mode 100644 index 0000000000..c5990830cd --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +Item { + id: screen; width: 50 + + property bool tested: false + signal testMe + + Connections { target: screen; onWidthChanged: screen.tested = true } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml new file mode 100644 index 0000000000..f0dbaba5a6 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml @@ -0,0 +1,3 @@ +import QtQuick 1.0 + +Connections { id: connection; target: connection; onTargetChanged: 1 == 1 } diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml new file mode 100644 index 0000000000..94c9c7ca7f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml @@ -0,0 +1,3 @@ +import QtQuick 1.0 + +Connections {} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml new file mode 100644 index 0000000000..00507d919c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +Item { + id: screen; width: 50 + + property string tested + signal testMe(int param1, string param2) + + Connections { target: screen; onTestMe: screen.tested = param2 + param1 } +} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro new file mode 100644 index 0000000000..fb1ef04ee1 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeconnection.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp new file mode 100644 index 0000000000..96e2957fbe --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../../shared/util.h" +#include + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativeconnection : public QObject + +{ + Q_OBJECT +public: + tst_qdeclarativeconnection(); + +private slots: + void defaultValues(); + void properties(); + void connection(); + void trimming(); + void targetChanged(); + void unknownSignals_data(); + void unknownSignals(); + void errors_data(); + void errors(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativeconnection::tst_qdeclarativeconnection() +{ +} + +void tst_qdeclarativeconnection::defaultValues() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml")); + QDeclarative1Connections *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + QVERIFY(item->target() == 0); + + delete item; +} + +void tst_qdeclarativeconnection::properties() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml")); + QDeclarative1Connections *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QVERIFY(item != 0); + QVERIFY(item->target() == item); + + delete item; +} + +void tst_qdeclarativeconnection::connection() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml")); + QDeclarativeItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QCOMPARE(item->property("tested").toBool(), false); + QCOMPARE(item->width(), 50.); + emit item->setWidth(100.); + QCOMPARE(item->width(), 100.); + QCOMPARE(item->property("tested").toBool(), true); + + delete item; +} + +void tst_qdeclarativeconnection::trimming() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml")); + QDeclarativeItem *item = qobject_cast(c.create()); + + QVERIFY(item != 0); + + QCOMPARE(item->property("tested").toString(), QString("")); + int index = item->metaObject()->indexOfSignal("testMe(int,QString)"); + QMetaMethod method = item->metaObject()->method(index); + method.invoke(item, + Qt::DirectConnection, + Q_ARG(int, 5), + Q_ARG(QString, "worked")); + QCOMPARE(item->property("tested").toString(), QString("worked5")); + + delete item; +} + +// Confirm that target can be changed by one of our signal handlers +void tst_qdeclarativeconnection::targetChanged() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/connection-targetchange.qml")); + QDeclarativeItem *item = qobject_cast(c.create()); + QVERIFY(item != 0); + + QDeclarative1Connections *connections = item->findChild("connections"); + QVERIFY(connections); + + QDeclarativeItem *item1 = item->findChild("item1"); + QVERIFY(item1); + + item1->setWidth(200); + + QDeclarativeItem *item2 = item->findChild("item2"); + QVERIFY(item2); + QVERIFY(connections->target() == item2); + + // If we don't crash then we're OK + + delete item; +} + +void tst_qdeclarativeconnection::unknownSignals_data() +{ + QTest::addColumn("file"); + QTest::addColumn("error"); + + QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; + QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error + QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error +} + +void tst_qdeclarativeconnection::unknownSignals() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); + if (!error.isEmpty()) { + QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1()); + } else { + // QTest has no way to insist no message (i.e. fail) + } + + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, url); + QDeclarativeItem *item = qobject_cast(c.create()); + QVERIFY(item != 0); + + // check that connection is created (they are all runtime errors) + QDeclarative1Connections *connections = item->findChild("connections"); + QVERIFY(connections); + + if (file == "connection-unknownsignals-ignored.qml") + QVERIFY(connections->ignoreUnknownSignals()); + + delete item; +} + +void tst_qdeclarativeconnection::errors_data() +{ + QTest::addColumn("file"); + QTest::addColumn("error"); + + QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\""; + QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\""; + QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed"; + QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error"; +} + +void tst_qdeclarativeconnection::errors() +{ + QFETCH(QString, file); + QFETCH(QString, error); + + QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); + + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, url); + QVERIFY(c.isError() == true); + QList errors = c.errors(); + QVERIFY(errors.count() == 1); + QCOMPARE(errors.at(0).description(), error); +} + +QTEST_MAIN(tst_qdeclarativeconnection) + +#include "tst_qdeclarativeconnection.moc" diff --git a/tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/disabledcontent.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/flickableqgraphicswidget.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/nestedPressDelay.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/nestedPressDelay.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/resize.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/resize.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/data/wheel.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflickable/data/wheel.qml rename to tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro similarity index 79% rename from tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro rename to tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro index 83036f8347..79b61d81c4 100644 --- a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro +++ b/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflickable.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp similarity index 81% rename from tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp rename to tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp index b077fdc7ab..f74f02c8ff 100644 --- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -94,7 +94,7 @@ void tst_qdeclarativeflickable::create() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml")); - QDeclarativeFlickable *obj = qobject_cast(c.create()); + QDeclarative1Flickable *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QCOMPARE(obj->isAtXBeginning(), true); @@ -108,7 +108,7 @@ void tst_qdeclarativeflickable::create() QCOMPARE(obj->verticalVelocity(), 0.); QCOMPARE(obj->isInteractive(), true); - QCOMPARE(obj->boundsBehavior(), QDeclarativeFlickable::DragAndOvershootBounds); + QCOMPARE(obj->boundsBehavior(), QDeclarative1Flickable::DragAndOvershootBounds); QCOMPARE(obj->pressDelay(), 0); QCOMPARE(obj->maximumFlickVelocity(), 2500.); @@ -119,7 +119,7 @@ void tst_qdeclarativeflickable::horizontalViewportSize() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml")); - QDeclarativeFlickable *obj = qobject_cast(c.create()); + QDeclarative1Flickable *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QCOMPARE(obj->contentWidth(), 800.); @@ -136,7 +136,7 @@ void tst_qdeclarativeflickable::verticalViewportSize() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml")); - QDeclarativeFlickable *obj = qobject_cast(c.create()); + QDeclarative1Flickable *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QCOMPARE(obj->contentWidth(), 200.); @@ -153,11 +153,11 @@ void tst_qdeclarativeflickable::properties() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml")); - QDeclarativeFlickable *obj = qobject_cast(c.create()); + QDeclarative1Flickable *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QCOMPARE(obj->isInteractive(), false); - QCOMPARE(obj->boundsBehavior(), QDeclarativeFlickable::StopAtBounds); + QCOMPARE(obj->boundsBehavior(), QDeclarative1Flickable::StopAtBounds); QCOMPARE(obj->pressDelay(), 200); QCOMPARE(obj->maximumFlickVelocity(), 2000.); @@ -172,28 +172,28 @@ void tst_qdeclarativeflickable::boundsBehavior() { QDeclarativeComponent component(&engine); component.setData("import QtQuick 1.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile("")); - QDeclarativeFlickable *flickable = qobject_cast(component.create()); + QDeclarative1Flickable *flickable = qobject_cast(component.create()); QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged())); QVERIFY(flickable); - QVERIFY(flickable->boundsBehavior() == QDeclarativeFlickable::StopAtBounds); + QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::StopAtBounds); - flickable->setBoundsBehavior(QDeclarativeFlickable::DragAndOvershootBounds); - QVERIFY(flickable->boundsBehavior() == QDeclarativeFlickable::DragAndOvershootBounds); + flickable->setBoundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds); + QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::DragAndOvershootBounds); QCOMPARE(spy.count(),1); - flickable->setBoundsBehavior(QDeclarativeFlickable::DragAndOvershootBounds); + flickable->setBoundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds); QCOMPARE(spy.count(),1); - flickable->setBoundsBehavior(QDeclarativeFlickable::DragOverBounds); - QVERIFY(flickable->boundsBehavior() == QDeclarativeFlickable::DragOverBounds); + flickable->setBoundsBehavior(QDeclarative1Flickable::DragOverBounds); + QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::DragOverBounds); QCOMPARE(spy.count(),2); - flickable->setBoundsBehavior(QDeclarativeFlickable::DragOverBounds); + flickable->setBoundsBehavior(QDeclarative1Flickable::DragOverBounds); QCOMPARE(spy.count(),2); - flickable->setBoundsBehavior(QDeclarativeFlickable::StopAtBounds); - QVERIFY(flickable->boundsBehavior() == QDeclarativeFlickable::StopAtBounds); + flickable->setBoundsBehavior(QDeclarative1Flickable::StopAtBounds); + QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::StopAtBounds); QCOMPARE(spy.count(),3); - flickable->setBoundsBehavior(QDeclarativeFlickable::StopAtBounds); + flickable->setBoundsBehavior(QDeclarative1Flickable::StopAtBounds); QCOMPARE(spy.count(),3); } @@ -201,7 +201,7 @@ void tst_qdeclarativeflickable::maximumFlickVelocity() { QDeclarativeComponent component(&engine); component.setData("import QtQuick 1.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile("")); - QDeclarativeFlickable *flickable = qobject_cast(component.create()); + QDeclarative1Flickable *flickable = qobject_cast(component.create()); QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged())); QVERIFY(flickable); @@ -218,7 +218,7 @@ void tst_qdeclarativeflickable::flickDeceleration() { QDeclarativeComponent component(&engine); component.setData("import QtQuick 1.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile("")); - QDeclarativeFlickable *flickable = qobject_cast(component.create()); + QDeclarative1Flickable *flickable = qobject_cast(component.create()); QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged())); QVERIFY(flickable); @@ -235,7 +235,7 @@ void tst_qdeclarativeflickable::pressDelay() { QDeclarativeComponent component(&engine); component.setData("import QtQuick 1.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile("")); - QDeclarativeFlickable *flickable = qobject_cast(component.create()); + QDeclarative1Flickable *flickable = qobject_cast(component.create()); QSignalSpy spy(flickable, SIGNAL(pressDelayChanged())); QVERIFY(flickable); @@ -257,7 +257,7 @@ void tst_qdeclarativeflickable::disabledContent() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeFlickable *flickable = qobject_cast(canvas->rootObject()); + QDeclarative1Flickable *flickable = qobject_cast(canvas->rootObject()); QVERIFY(flickable != 0); QVERIFY(flickable->contentX() == 0); @@ -295,10 +295,10 @@ void tst_qdeclarativeflickable::nestedPressDelay() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeFlickable *outer = qobject_cast(canvas->rootObject()); + QDeclarative1Flickable *outer = qobject_cast(canvas->rootObject()); QVERIFY(outer != 0); - QDeclarativeFlickable *inner = canvas->rootObject()->findChild("innerFlickable"); + QDeclarative1Flickable *inner = canvas->rootObject()->findChild("innerFlickable"); QVERIFY(inner != 0); QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(150, 150))); @@ -318,26 +318,26 @@ void tst_qdeclarativeflickable::flickableDirection() { QDeclarativeComponent component(&engine); component.setData("import QtQuick 1.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile("")); - QDeclarativeFlickable *flickable = qobject_cast(component.create()); + QDeclarative1Flickable *flickable = qobject_cast(component.create()); QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged())); QVERIFY(flickable); - QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::VerticalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::VerticalFlick); - flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalAndVerticalFlick); - QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalAndVerticalFlick); + flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalAndVerticalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalAndVerticalFlick); QCOMPARE(spy.count(),1); - flickable->setFlickableDirection(QDeclarativeFlickable::AutoFlickDirection); - QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::AutoFlickDirection); + flickable->setFlickableDirection(QDeclarative1Flickable::AutoFlickDirection); + QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::AutoFlickDirection); QCOMPARE(spy.count(),2); - flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); - QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalFlick); + flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalFlick); QCOMPARE(spy.count(),3); - flickable->setFlickableDirection(QDeclarativeFlickable::HorizontalFlick); - QCOMPARE(flickable->flickableDirection(), QDeclarativeFlickable::HorizontalFlick); + flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalFlick); + QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalFlick); QCOMPARE(spy.count(),3); } @@ -345,7 +345,7 @@ void tst_qdeclarativeflickable::qgraphicswidget() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickableqgraphicswidget.qml")); - QDeclarativeFlickable *flickable = qobject_cast(c.create()); + QDeclarative1Flickable *flickable = qobject_cast(c.create()); QVERIFY(flickable != 0); QGraphicsWidget *widget = findItem(flickable->contentItem(), "widget1"); @@ -358,7 +358,7 @@ void tst_qdeclarativeflickable::resizeContent() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml")); QDeclarativeItem *root = qobject_cast(c.create()); - QDeclarativeFlickable *obj = findItem(root, "flick"); + QDeclarative1Flickable *obj = findItem(root, "flick"); QVERIFY(obj != 0); QCOMPARE(obj->contentX(), 0.); @@ -382,7 +382,7 @@ void tst_qdeclarativeflickable::returnToBounds() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml")); QDeclarativeItem *root = qobject_cast(c.create()); - QDeclarativeFlickable *obj = findItem(root, "flick"); + QDeclarative1Flickable *obj = findItem(root, "flick"); QVERIFY(obj != 0); QCOMPARE(obj->contentX(), 0.); @@ -451,7 +451,7 @@ void tst_qdeclarativeflickable::wheel() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeFlickable *flick = canvas->rootObject()->findChild("flick"); + QDeclarative1Flickable *flick = canvas->rootObject()->findChild("flick"); QVERIFY(flick != 0); QGraphicsScene *scene = canvas->scene(); diff --git a/tests/auto/declarative/qdeclarativeflipable/data/crash.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflipable/data/crash.qml rename to tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml diff --git a/tests/auto/declarative/qdeclarativeflipable/data/flipable-abort.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflipable/data/flipable-abort.qml rename to tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml diff --git a/tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeflipable/data/test-flipable.qml rename to tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro similarity index 79% rename from tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro rename to tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro index b5b10e73c0..e08611cbbd 100644 --- a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro +++ b/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeflipable.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp similarity index 89% rename from tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp rename to tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp index 1b3d818dd6..60d71253a5 100644 --- a/tests/auto/declarative/qdeclarativeflipable/tst_qdeclarativeflipable.cpp +++ b/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp @@ -41,11 +41,11 @@ #include #include #include -#include -#include +#include +#include #include #include -#include +#include #include #ifdef Q_OS_SYMBIAN @@ -80,7 +80,7 @@ void tst_qdeclarativeflipable::create() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml")); - QDeclarativeFlipable *obj = qobject_cast(c.create()); + QDeclarative1Flipable *obj = qobject_cast(c.create()); QVERIFY(obj != 0); delete obj; @@ -90,7 +90,7 @@ void tst_qdeclarativeflipable::checkFrontAndBack() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml")); - QDeclarativeFlipable *obj = qobject_cast(c.create()); + QDeclarative1Flipable *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QVERIFY(obj->front() != 0); @@ -102,7 +102,7 @@ void tst_qdeclarativeflipable::setFrontAndBack() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml")); - QDeclarativeFlipable *obj = qobject_cast(c.create()); + QDeclarative1Flipable *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QVERIFY(obj->front() != 0); @@ -110,11 +110,11 @@ void tst_qdeclarativeflipable::setFrontAndBack() QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); - obj->setFront(new QDeclarativeRectangle()); + obj->setFront(new QDeclarative1Rectangle()); message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property"; QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); - obj->setBack(new QDeclarativeRectangle()); + obj->setBack(new QDeclarative1Rectangle()); delete obj; } diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/chain.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/chain.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forceActiveFocus.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/forceActiveFocus.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/forcefocus.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/signalEmission.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/test.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test2.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/test2.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test3.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/test3.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test4.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/test4.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/test5.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml similarity index 100% rename from tests/auto/declarative/qdeclarativefocusscope/data/test5.qml rename to tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro similarity index 64% rename from tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro rename to tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro index f63f339e79..f532585b89 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro +++ b/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 SOURCES += tst_qdeclarativefocusscope.cpp macx:CONFIG -= app_bundle @@ -11,4 +11,4 @@ symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp similarity index 83% rename from tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp rename to tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index ab1e1940b9..50cca1d53d 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -42,11 +42,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -101,10 +101,10 @@ void tst_qdeclarativefocusscope::basic() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml")); - QDeclarativeFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarativeRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarativeRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarative1FocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QDeclarative1Rectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); QVERIFY(item0 != 0); QVERIFY(item1 != 0); QVERIFY(item2 != 0); @@ -146,11 +146,11 @@ void tst_qdeclarativefocusscope::nested() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test2.qml")); - QDeclarativeFocusScope *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarativeFocusScope *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarativeFocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QDeclarativeFocusScope *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QDeclarativeFocusScope *item5 = findItem(view->rootObject(), QLatin1String("item5")); + QDeclarative1FocusScope *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QDeclarative1FocusScope *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QDeclarative1FocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarative1FocusScope *item4 = findItem(view->rootObject(), QLatin1String("item4")); + QDeclarative1FocusScope *item5 = findItem(view->rootObject(), QLatin1String("item5")); QVERIFY(item1 != 0); QVERIFY(item2 != 0); QVERIFY(item3 != 0); @@ -182,10 +182,10 @@ void tst_qdeclarativefocusscope::noFocus() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test4.qml")); - QDeclarativeRectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarativeRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarativeRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarative1Rectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QDeclarative1Rectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); QVERIFY(item0 != 0); QVERIFY(item1 != 0); QVERIFY(item2 != 0); @@ -227,10 +227,10 @@ void tst_qdeclarativefocusscope::textEdit() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml")); - QDeclarativeFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarativeTextEdit *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarativeTextEdit *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarative1FocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QDeclarative1TextEdit *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QDeclarative1TextEdit *item3 = findItem(view->rootObject(), QLatin1String("item3")); QVERIFY(item0 != 0); QVERIFY(item1 != 0); QVERIFY(item2 != 0); @@ -282,12 +282,12 @@ void tst_qdeclarativefocusscope::forceFocus() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forcefocus.qml")); - QDeclarativeFocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarativeRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarativeFocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QDeclarativeRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QDeclarativeRectangle *item5 = findItem(view->rootObject(), QLatin1String("item5")); + QDeclarative1FocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); + QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QDeclarative1FocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarative1Rectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); + QDeclarative1Rectangle *item5 = findItem(view->rootObject(), QLatin1String("item5")); QVERIFY(item0 != 0); QVERIFY(item1 != 0); QVERIFY(item2 != 0); @@ -352,10 +352,10 @@ void tst_qdeclarativefocusscope::signalEmission() QDeclarativeView *view = new QDeclarativeView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/signalEmission.qml")); - QDeclarativeRectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarativeRectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarativeRectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QDeclarativeRectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); + QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); + QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); + QDeclarative1Rectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); + QDeclarative1Rectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); QVERIFY(item1 != 0); QVERIFY(item2 != 0); QVERIFY(item3 != 0); diff --git a/tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf similarity index 100% rename from tests/auto/declarative/qdeclarativefontloader/data/daniel.ttf rename to tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf diff --git a/tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf similarity index 100% rename from tests/auto/declarative/qdeclarativefontloader/data/dummy.ttf rename to tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf diff --git a/tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf similarity index 100% rename from tests/auto/declarative/qdeclarativefontloader/data/tarzeau_ocr_a.ttf rename to tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf diff --git a/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro new file mode 100644 index 0000000000..9bb0c8e3f2 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network qtquick1 +macx:CONFIG -= app_bundle + +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += tst_qdeclarativefontloader.cpp ../../declarative/shared/testhttpserver.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp similarity index 80% rename from tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp rename to tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp index 9b2704b076..cfd3087f77 100644 --- a/tests/auto/declarative/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ b/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp @@ -43,9 +43,9 @@ #include #include #include -#include +#include #include "../../../shared/util.h" -#include "../shared/testhttpserver.h" +#include "../../declarative/shared/testhttpserver.h" #define SERVER_PORT 14448 @@ -92,12 +92,12 @@ void tst_qdeclarativefontloader::noFont() QString componentStr = "import QtQuick 1.0\nFontLoader { }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QCOMPARE(fontObject->name(), QString("")); QCOMPARE(fontObject->source(), QUrl("")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Null); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Null); delete fontObject; } @@ -107,12 +107,12 @@ void tst_qdeclarativefontloader::namedFont() QString componentStr = "import QtQuick 1.0\nFontLoader { name: \"Helvetica\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QCOMPARE(fontObject->source(), QUrl("")); QCOMPARE(fontObject->name(), QString("Helvetica")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); } void tst_qdeclarativefontloader::localFont() @@ -120,12 +120,12 @@ void tst_qdeclarativefontloader::localFont() QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); } void tst_qdeclarativefontloader::failLocalFont() @@ -134,12 +134,12 @@ void tst_qdeclarativefontloader::failLocalFont() QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\"").toUtf8().constData()); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); QTRY_COMPARE(fontObject->name(), QString("")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Error); } void tst_qdeclarativefontloader::webFont() @@ -148,12 +148,12 @@ void tst_qdeclarativefontloader::webFont() QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); } void tst_qdeclarativefontloader::redirWebFont() @@ -164,12 +164,12 @@ void tst_qdeclarativefontloader::redirWebFont() QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); } void tst_qdeclarativefontloader::failWebFont() @@ -178,12 +178,12 @@ void tst_qdeclarativefontloader::failWebFont() QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\""); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QVERIFY(fontObject->source() != QUrl("")); QTRY_COMPARE(fontObject->name(), QString("")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Error); } void tst_qdeclarativefontloader::changeFont() @@ -193,33 +193,33 @@ void tst_qdeclarativefontloader::changeFont() ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeFontLoader *fontObject = qobject_cast(component.create()); + QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); QVERIFY(fontObject != 0); QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged())); QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged())); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); QCOMPARE(nameSpy.count(), 0); QCOMPARE(statusSpy.count(), 0); QTRY_COMPARE(fontObject->name(), QString("OCRA")); ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Loading); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Loading); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); QCOMPARE(nameSpy.count(), 1); QCOMPARE(statusSpy.count(), 2); QTRY_COMPARE(fontObject->name(), QString("Daniel")); ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf")); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); QCOMPARE(nameSpy.count(), 2); QCOMPARE(statusSpy.count(), 2); QTRY_COMPARE(fontObject->name(), QString("OCRA")); ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); - QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready); + QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); QCOMPARE(nameSpy.count(), 3); QCOMPARE(statusSpy.count(), 2); QTRY_COMPARE(fontObject->name(), QString("Daniel")); diff --git a/tests/auto/declarative/qdeclarativegridview/data/attachedSignals.qml b/tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/attachedSignals.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml b/tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/displaygrid.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/footer.qml b/tests/auto/qtquick1/qdeclarativegridview/data/footer.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/footer.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/footer.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/gridview-enforcerange.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-noCurrent.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/gridview-noCurrent.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview1.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/gridview1.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview2.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/gridview2.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview3.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/gridview3.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/header.qml b/tests/auto/qtquick1/qdeclarativegridview/data/header.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/header.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/header.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml b/tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/mirroring.qml b/tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/mirroring.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/propertychangestest.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml diff --git a/tests/auto/declarative/qdeclarativegridview/data/setindex.qml b/tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml similarity index 100% rename from tests/auto/declarative/qdeclarativegridview/data/setindex.qml rename to tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro similarity index 80% rename from tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro rename to tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro index 2a5fcffc85..bdff620e95 100644 --- a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro +++ b/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativegridview.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp similarity index 84% rename from tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp rename to tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp index 0bc964f206..606b5fcab8 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -41,16 +41,14 @@ #include #include -#include +#include #include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -58,11 +56,11 @@ #define SRCDIR "." #endif -class tst_QDeclarativeGridView : public QObject +class tst_QDeclarative1GridView : public QObject { Q_OBJECT public: - tst_QDeclarativeGridView(); + tst_QDeclarative1GridView(); private slots: void items(); @@ -190,11 +188,11 @@ class TestModel : public QAbstractListModel QList > list; }; -tst_QDeclarativeGridView::tst_QDeclarativeGridView() +tst_QDeclarative1GridView::tst_QDeclarative1GridView() { } -void tst_QDeclarativeGridView::items() +void tst_QDeclarative1GridView::items() { QDeclarativeView *canvas = createView(); @@ -215,7 +213,7 @@ void tst_QDeclarativeGridView::items() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -226,10 +224,10 @@ void tst_QDeclarativeGridView::items() QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item for (int i = 0; i < model.count(); ++i) { - QDeclarativeText *name = findItem(contentItem, "textName", i); + QDeclarative1Text *name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem(contentItem, "textNumber", i); + QDeclarative1Text *number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -244,7 +242,7 @@ void tst_QDeclarativeGridView::items() delete canvas; } -void tst_QDeclarativeGridView::changed() +void tst_QDeclarative1GridView::changed() { QDeclarativeView *canvas = createView(); @@ -265,24 +263,24 @@ void tst_QDeclarativeGridView::changed() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeFlickable *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1Flickable *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != 0); model.modifyItem(1, "Will", "9876"); - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); delete canvas; } -void tst_QDeclarativeGridView::inserted() +void tst_QDeclarative1GridView::inserted() { QDeclarativeView *canvas = createView(); @@ -299,7 +297,7 @@ void tst_QDeclarativeGridView::inserted() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -310,10 +308,10 @@ void tst_QDeclarativeGridView::inserted() QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -332,10 +330,10 @@ void tst_QDeclarativeGridView::inserted() QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - name = findItem(contentItem, "textName", 0); + name = findItem(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); + number = findItem(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -361,7 +359,7 @@ void tst_QDeclarativeGridView::inserted() delete canvas; } -void tst_QDeclarativeGridView::removed() +void tst_QDeclarative1GridView::removed() { QDeclarativeView *canvas = createView(); @@ -377,7 +375,7 @@ void tst_QDeclarativeGridView::removed() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -386,10 +384,10 @@ void tst_QDeclarativeGridView::removed() model.removeItem(1); QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -410,10 +408,10 @@ void tst_QDeclarativeGridView::removed() // Remove first item (which is the current item); model.removeItem(0); - name = findItem(contentItem, "textName", 0); + name = findItem(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); + number = findItem(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -506,7 +504,7 @@ void tst_QDeclarativeGridView::removed() delete canvas; } -void tst_QDeclarativeGridView::clear() +void tst_QDeclarative1GridView::clear() { QDeclarativeView *canvas = createView(); @@ -522,7 +520,7 @@ void tst_QDeclarativeGridView::clear() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -544,7 +542,7 @@ void tst_QDeclarativeGridView::clear() delete canvas; } -void tst_QDeclarativeGridView::moved() +void tst_QDeclarative1GridView::moved() { QDeclarativeView *canvas = createView(); @@ -560,7 +558,7 @@ void tst_QDeclarativeGridView::moved() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -568,17 +566,17 @@ void tst_QDeclarativeGridView::moved() model.moveItem(1, 8); - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); - name = findItem(contentItem, "textName", 8); + name = findItem(contentItem, "textName", 8); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(8)); - number = findItem(contentItem, "textNumber", 8); + number = findItem(contentItem, "textNumber", 8); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(8)); @@ -605,10 +603,10 @@ void tst_QDeclarativeGridView::moved() QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal((i%3)*80)); QTRY_COMPARE(item->y(), qreal((i/3)*60)); - name = findItem(contentItem, "textName", i); + name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); + number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -623,10 +621,10 @@ void tst_QDeclarativeGridView::moved() QTRY_VERIFY(item); QTRY_VERIFY(item->x() == (i%3)*80); QTRY_VERIFY(item->y() == (i/3)*60); - name = findItem(contentItem, "textName", i); + name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); + number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -639,7 +637,7 @@ void tst_QDeclarativeGridView::moved() delete canvas; } -void tst_QDeclarativeGridView::currentIndex() +void tst_QDeclarative1GridView::currentIndex() { TestModel model; for (int i = 0; i < 60; i++) @@ -656,7 +654,7 @@ void tst_QDeclarativeGridView::currentIndex() qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -731,7 +729,7 @@ void tst_QDeclarativeGridView::currentIndex() QTest::keyClick(canvas, Qt::Key_Up); QCOMPARE(gridview->currentIndex(), 0); - gridview->setFlow(QDeclarativeGridView::TopToBottom); + gridview->setFlow(QDeclarative1GridView::TopToBottom); qApp->setActiveWindow(canvas); #ifdef Q_WS_X11 @@ -780,7 +778,7 @@ void tst_QDeclarativeGridView::currentIndex() gridview->setHighlightFollowsCurrentItem(true); - gridview->setFlow(QDeclarativeGridView::LeftToRight); + gridview->setFlow(QDeclarative1GridView::LeftToRight); gridview->setLayoutDirection(Qt::RightToLeft); qApp->setActiveWindow(canvas); @@ -833,7 +831,7 @@ void tst_QDeclarativeGridView::currentIndex() delete canvas; } -void tst_QDeclarativeGridView::noCurrentIndex() +void tst_QDeclarative1GridView::noCurrentIndex() { TestModel model; for (int i = 0; i < 60; i++) @@ -850,7 +848,7 @@ void tst_QDeclarativeGridView::noCurrentIndex() qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -870,7 +868,7 @@ void tst_QDeclarativeGridView::noCurrentIndex() delete canvas; } -void tst_QDeclarativeGridView::changeFlow() +void tst_QDeclarative1GridView::changeFlow() { QDeclarativeView *canvas = createView(); @@ -886,7 +884,7 @@ void tst_QDeclarativeGridView::changeFlow() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -900,10 +898,10 @@ void tst_QDeclarativeGridView::changeFlow() QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal((i%3)*80)); QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QDeclarativeText *name = findItem(contentItem, "textName", i); + QDeclarative1Text *name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem(contentItem, "textNumber", i); + QDeclarative1Text *number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -918,10 +916,10 @@ void tst_QDeclarativeGridView::changeFlow() QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal((i/5)*80)); QTRY_COMPARE(item->y(), qreal((i%5)*60)); - QDeclarativeText *name = findItem(contentItem, "textName", i); + QDeclarative1Text *name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem(contentItem, "textNumber", i); + QDeclarative1Text *number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -936,10 +934,10 @@ void tst_QDeclarativeGridView::changeFlow() QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width())); QTRY_COMPARE(item->y(), qreal((i%5)*60)); - QDeclarativeText *name = findItem(contentItem, "textName", i); + QDeclarative1Text *name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem(contentItem, "textNumber", i); + QDeclarative1Text *number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -956,10 +954,10 @@ void tst_QDeclarativeGridView::changeFlow() QTRY_VERIFY(item); QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80)); QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QDeclarativeText *name = findItem(contentItem, "textName", i); + QDeclarative1Text *name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem(contentItem, "textNumber", i); + QDeclarative1Text *number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -967,11 +965,11 @@ void tst_QDeclarativeGridView::changeFlow() delete canvas; } -void tst_QDeclarativeGridView::defaultValues() +void tst_QDeclarative1GridView::defaultValues() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml")); - QDeclarativeGridView *obj = qobject_cast(c.create()); + QDeclarative1GridView *obj = qobject_cast(c.create()); QTRY_VERIFY(obj != 0); QTRY_VERIFY(obj->model() == QVariant()); @@ -990,11 +988,11 @@ void tst_QDeclarativeGridView::defaultValues() delete obj; } -void tst_QDeclarativeGridView::properties() +void tst_QDeclarative1GridView::properties() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml")); - QDeclarativeGridView *obj = qobject_cast(c.create()); + QDeclarative1GridView *obj = qobject_cast(c.create()); QTRY_VERIFY(obj != 0); QTRY_VERIFY(obj->model() != QVariant()); @@ -1013,13 +1011,13 @@ void tst_QDeclarativeGridView::properties() delete obj; } -void tst_QDeclarativeGridView::propertyChanges() +void tst_QDeclarative1GridView::propertyChanges() { QDeclarativeView *canvas = createView(); QTRY_VERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - QDeclarativeGridView *gridView = canvas->rootObject()->findChild("gridView"); + QDeclarative1GridView *gridView = canvas->rootObject()->findChild("gridView"); QTRY_VERIFY(gridView); QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged())); @@ -1029,15 +1027,15 @@ void tst_QDeclarativeGridView::propertyChanges() QTRY_COMPARE(gridView->isWrapEnabled(), true); QTRY_COMPARE(gridView->cacheBuffer(), 10); - QTRY_COMPARE(gridView->flow(), QDeclarativeGridView::LeftToRight); + QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::LeftToRight); gridView->setWrapEnabled(false); gridView->setCacheBuffer(3); - gridView->setFlow(QDeclarativeGridView::TopToBottom); + gridView->setFlow(QDeclarative1GridView::TopToBottom); QTRY_COMPARE(gridView->isWrapEnabled(), false); QTRY_COMPARE(gridView->cacheBuffer(), 3); - QTRY_COMPARE(gridView->flow(), QDeclarativeGridView::TopToBottom); + QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::TopToBottom); QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); QTRY_COMPARE(cacheBufferSpy.count(),1); @@ -1045,14 +1043,14 @@ void tst_QDeclarativeGridView::propertyChanges() gridView->setWrapEnabled(false); gridView->setCacheBuffer(3); - gridView->setFlow(QDeclarativeGridView::TopToBottom); + gridView->setFlow(QDeclarative1GridView::TopToBottom); QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); QTRY_COMPARE(cacheBufferSpy.count(),1); QTRY_COMPARE(flowSpy.count(),1); - gridView->setFlow(QDeclarativeGridView::LeftToRight); - QTRY_COMPARE(gridView->flow(), QDeclarativeGridView::LeftToRight); + gridView->setFlow(QDeclarative1GridView::LeftToRight); + QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::LeftToRight); gridView->setWrapEnabled(true); gridView->setCacheBuffer(5); @@ -1076,23 +1074,23 @@ void tst_QDeclarativeGridView::propertyChanges() QTRY_COMPARE(layoutSpy.count(),1); QTRY_COMPARE(flowSpy.count(),2); - gridView->setFlow(QDeclarativeGridView::TopToBottom); - QTRY_COMPARE(gridView->flow(), QDeclarativeGridView::TopToBottom); + gridView->setFlow(QDeclarative1GridView::TopToBottom); + QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::TopToBottom); QTRY_COMPARE(flowSpy.count(),3); - gridView->setFlow(QDeclarativeGridView::TopToBottom); + gridView->setFlow(QDeclarative1GridView::TopToBottom); QTRY_COMPARE(flowSpy.count(),3); delete canvas; } -void tst_QDeclarativeGridView::componentChanges() +void tst_QDeclarative1GridView::componentChanges() { QDeclarativeView *canvas = createView(); QTRY_VERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - QDeclarativeGridView *gridView = canvas->rootObject()->findChild("gridView"); + QDeclarative1GridView *gridView = canvas->rootObject()->findChild("gridView"); QTRY_VERIFY(gridView); QDeclarativeComponent component(canvas->engine()); @@ -1134,16 +1132,16 @@ void tst_QDeclarativeGridView::componentChanges() delete canvas; } -void tst_QDeclarativeGridView::modelChanges() +void tst_QDeclarative1GridView::modelChanges() { QDeclarativeView *canvas = createView(); QTRY_VERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - QDeclarativeGridView *gridView = canvas->rootObject()->findChild("gridView"); + QDeclarative1GridView *gridView = canvas->rootObject()->findChild("gridView"); QTRY_VERIFY(gridView); - QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); + QObject *alternateModel = canvas->rootObject()->findChild("alternateModel"); QTRY_VERIFY(alternateModel); QVariant modelVariant = QVariant::fromValue(alternateModel); QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); @@ -1160,7 +1158,7 @@ void tst_QDeclarativeGridView::modelChanges() delete canvas; } -void tst_QDeclarativeGridView::positionViewAtIndex() +void tst_QDeclarative1GridView::positionViewAtIndex() { QDeclarativeView *canvas = createView(); @@ -1176,7 +1174,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -1193,7 +1191,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position on a currently visible item - gridview->positionViewAtIndex(4, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(4, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->indexAt(120, 90), 4); QTRY_COMPARE(gridview->contentY(), 60.); @@ -1208,7 +1206,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position on an item beyond the visible items - gridview->positionViewAtIndex(21, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(21, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->indexAt(40, 450), 21); QTRY_COMPARE(gridview->contentY(), 420.); @@ -1223,7 +1221,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position on an item that would leave empty space if positioned at the top - gridview->positionViewAtIndex(31, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(31, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->indexAt(120, 630), 31); QTRY_COMPARE(gridview->contentY(), 520.); @@ -1238,7 +1236,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position at the beginning again - gridview->positionViewAtIndex(0, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(0, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->indexAt(0, 0), 0); QTRY_COMPARE(gridview->indexAt(40, 30), 0); QTRY_COMPARE(gridview->indexAt(80, 60), 4); @@ -1255,44 +1253,44 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position at End - gridview->positionViewAtIndex(30, QDeclarativeGridView::End); + gridview->positionViewAtIndex(30, QDeclarative1GridView::End); QTRY_COMPARE(gridview->contentY(), 340.); // Position in Center - gridview->positionViewAtIndex(15, QDeclarativeGridView::Center); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Center); QTRY_COMPARE(gridview->contentY(), 170.); // Ensure at least partially visible - gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentY(), 170.); gridview->setContentY(302); - gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentY(), 302.); gridview->setContentY(360); - gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentY(), 300.); gridview->setContentY(60); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentY(), 60.); gridview->setContentY(20); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentY(), 100.); // Ensure completely visible gridview->setContentY(120); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->contentY(), 120.); gridview->setContentY(302); - gridview->positionViewAtIndex(15, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->contentY(), 300.); gridview->setContentY(60); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->contentY(), 100.); // Test for Top To Bottom layout @@ -1309,27 +1307,27 @@ void tst_QDeclarativeGridView::positionViewAtIndex() } // Position at End - gridview->positionViewAtIndex(30, QDeclarativeGridView::End); + gridview->positionViewAtIndex(30, QDeclarative1GridView::End); QTRY_COMPARE(gridview->contentX(), 320.); QTRY_COMPARE(gridview->contentY(), 0.); // Position in Center - gridview->positionViewAtIndex(15, QDeclarativeGridView::Center); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Center); QTRY_COMPARE(gridview->contentX(), 160.); // Ensure at least partially visible - gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), 160.); gridview->setContentX(170); - gridview->positionViewAtIndex(25, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(25, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), 170.); - gridview->positionViewAtIndex(30, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(30, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), 320.); gridview->setContentX(170); - gridview->positionViewAtIndex(25, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(25, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->contentX(), 240.); // positionViewAtBeginning @@ -1353,7 +1351,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex() delete canvas; } -void tst_QDeclarativeGridView::snapping() +void tst_QDeclarative1GridView::snapping() { QDeclarativeView *canvas = createView(); @@ -1369,41 +1367,41 @@ void tst_QDeclarativeGridView::snapping() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); gridview->setHeight(220); QCOMPARE(gridview->height(), 220.); - gridview->positionViewAtIndex(12, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(12, QDeclarative1GridView::Visible); QCOMPARE(gridview->contentY(), 80.); gridview->setContentY(0); QCOMPARE(gridview->contentY(), 0.); - gridview->setSnapMode(QDeclarativeGridView::SnapToRow); - QCOMPARE(gridview->snapMode(), QDeclarativeGridView::SnapToRow); + gridview->setSnapMode(QDeclarative1GridView::SnapToRow); + QCOMPARE(gridview->snapMode(), QDeclarative1GridView::SnapToRow); - gridview->positionViewAtIndex(12, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(12, QDeclarative1GridView::Visible); QCOMPARE(gridview->contentY(), 60.); - gridview->positionViewAtIndex(15, QDeclarativeGridView::End); + gridview->positionViewAtIndex(15, QDeclarative1GridView::End); QCOMPARE(gridview->contentY(), 120.); delete canvas; } -void tst_QDeclarativeGridView::mirroring() +void tst_QDeclarative1GridView::mirroring() { QDeclarativeView *canvasA = createView(); canvasA->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirroring.qml")); - QDeclarativeGridView *gridviewA = findItem(canvasA->rootObject(), "view"); + QDeclarative1GridView *gridviewA = findItem(canvasA->rootObject(), "view"); QTRY_VERIFY(gridviewA != 0); QDeclarativeView *canvasB = createView(); canvasB->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirroring.qml")); - QDeclarativeGridView *gridviewB = findItem(canvasB->rootObject(), "view"); + QDeclarative1GridView *gridviewB = findItem(canvasB->rootObject(), "view"); QTRY_VERIFY(gridviewA != 0); qApp->processEvents(); @@ -1455,7 +1453,7 @@ void tst_QDeclarativeGridView::mirroring() delete canvasB; } -void tst_QDeclarativeGridView::positionViewAtIndex_rightToLeft() +void tst_QDeclarative1GridView::positionViewAtIndex_rightToLeft() { QDeclarativeView *canvas = createView(); @@ -1471,7 +1469,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex_rightToLeft() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -1488,7 +1486,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex_rightToLeft() } // Position on a currently visible item - gridview->positionViewAtIndex(6, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(6, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->contentX(), -320.); // Confirm items positioned correctly @@ -1502,7 +1500,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex_rightToLeft() } // Position on an item beyond the visible items - gridview->positionViewAtIndex(21, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(21, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->contentX(), -560.); // Confirm items positioned correctly @@ -1516,7 +1514,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex_rightToLeft() } // Position on an item that would leave empty space if positioned at the top - gridview->positionViewAtIndex(31, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(31, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->contentX(), -639.); // Confirm items positioned correctly @@ -1530,7 +1528,7 @@ void tst_QDeclarativeGridView::positionViewAtIndex_rightToLeft() } // Position at the beginning again - gridview->positionViewAtIndex(0, QDeclarativeGridView::Beginning); + gridview->positionViewAtIndex(0, QDeclarative1GridView::Beginning); QTRY_COMPARE(gridview->contentX(), -240.); // Confirm items positioned correctly @@ -1544,50 +1542,50 @@ void tst_QDeclarativeGridView::positionViewAtIndex_rightToLeft() } // Position at End - gridview->positionViewAtIndex(30, QDeclarativeGridView::End); + gridview->positionViewAtIndex(30, QDeclarative1GridView::End); QTRY_COMPARE(gridview->contentX(), -560.); // Position in Center - gridview->positionViewAtIndex(15, QDeclarativeGridView::Center); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Center); QTRY_COMPARE(gridview->contentX(), -400.); // Ensure at least partially visible - gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), -400.); gridview->setContentX(-555.); - gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), -555.); gridview->setContentX(-239); - gridview->positionViewAtIndex(15, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), -320.); gridview->setContentX(-239); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), -400.); gridview->setContentX(-640); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Visible); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); QTRY_COMPARE(gridview->contentX(), -560.); // Ensure completely visible gridview->setContentX(-400); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->contentX(), -400.); gridview->setContentX(-315); - gridview->positionViewAtIndex(15, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(15, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->contentX(), -320.); gridview->setContentX(-640); - gridview->positionViewAtIndex(20, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->contentX(), -560.); delete canvas; } -void tst_QDeclarativeGridView::resetModel() +void tst_QDeclarative1GridView::resetModel() { QDeclarativeView *canvas = createView(); @@ -1601,7 +1599,7 @@ void tst_QDeclarativeGridView::resetModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaygrid.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -1610,7 +1608,7 @@ void tst_QDeclarativeGridView::resetModel() QTRY_COMPARE(gridview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem(contentItem, "displayText", i); + QDeclarative1Text *display = findItem(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1622,7 +1620,7 @@ void tst_QDeclarativeGridView::resetModel() QTRY_COMPARE(gridview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem(contentItem, "displayText", i); + QDeclarative1Text *display = findItem(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1630,7 +1628,7 @@ void tst_QDeclarativeGridView::resetModel() delete canvas; } -void tst_QDeclarativeGridView::enforceRange() +void tst_QDeclarative1GridView::enforceRange() { QDeclarativeView *canvas = createView(); @@ -1647,12 +1645,12 @@ void tst_QDeclarativeGridView::enforceRange() qApp->processEvents(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange); + QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarative1GridView::StrictlyEnforceRange); QDeclarativeItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != 0); @@ -1662,10 +1660,10 @@ void tst_QDeclarativeGridView::enforceRange() QTRY_VERIFY(item); QTRY_COMPARE(gridview->contentY(), -100.0); - QDeclarativeText *name = findItem(contentItem, "textName", 0); + QDeclarative1Text *name = findItem(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 0); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -1686,7 +1684,7 @@ void tst_QDeclarativeGridView::enforceRange() delete canvas; } -void tst_QDeclarativeGridView::enforceRange_rightToLeft() +void tst_QDeclarative1GridView::enforceRange_rightToLeft() { QDeclarativeView *canvas = createView(); @@ -1703,12 +1701,12 @@ void tst_QDeclarativeGridView::enforceRange_rightToLeft() qApp->processEvents(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange); + QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarative1GridView::StrictlyEnforceRange); QDeclarativeItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != 0); @@ -1719,10 +1717,10 @@ void tst_QDeclarativeGridView::enforceRange_rightToLeft() QTRY_COMPARE(gridview->contentX(), -100.); QTRY_COMPARE(gridview->contentY(), 0.0); - QDeclarativeText *name = findItem(contentItem, "textName", 0); + QDeclarative1Text *name = findItem(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 0); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -1744,14 +1742,14 @@ void tst_QDeclarativeGridView::enforceRange_rightToLeft() delete canvas; } -void tst_QDeclarativeGridView::QTBUG_8456() +void tst_QDeclarative1GridView::QTBUG_8456() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/setindex.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QTRY_COMPARE(gridview->currentIndex(), 0); @@ -1759,7 +1757,7 @@ void tst_QDeclarativeGridView::QTBUG_8456() delete canvas; } -void tst_QDeclarativeGridView::manualHighlight() +void tst_QDeclarative1GridView::manualHighlight() { QDeclarativeView *canvas = createView(); @@ -1768,7 +1766,7 @@ void tst_QDeclarativeGridView::manualHighlight() qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -1786,15 +1784,15 @@ void tst_QDeclarativeGridView::manualHighlight() QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - gridview->positionViewAtIndex(8, QDeclarativeGridView::Contain); + gridview->positionViewAtIndex(8, QDeclarative1GridView::Contain); QTRY_COMPARE(gridview->currentIndex(), 2); QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 2)); QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - gridview->setFlow(QDeclarativeGridView::TopToBottom); - QTRY_COMPARE(gridview->flow(), QDeclarativeGridView::TopToBottom); + gridview->setFlow(QDeclarative1GridView::TopToBottom); + QTRY_COMPARE(gridview->flow(), QDeclarative1GridView::TopToBottom); gridview->setCurrentIndex(0); QTRY_COMPARE(gridview->currentIndex(), 0); @@ -1805,7 +1803,7 @@ void tst_QDeclarativeGridView::manualHighlight() delete canvas; } -void tst_QDeclarativeGridView::footer() +void tst_QDeclarative1GridView::footer() { QDeclarativeView *canvas = createView(); @@ -1819,13 +1817,13 @@ void tst_QDeclarativeGridView::footer() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != 0); - QDeclarativeText *footer = findItem(contentItem, "footer"); + QDeclarative1Text *footer = findItem(contentItem, "footer"); QVERIFY(footer); QCOMPARE(footer->y(), 180.0); @@ -1842,9 +1840,9 @@ void tst_QDeclarativeGridView::footer() QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); - footer = findItem(contentItem, "footer"); + footer = findItem(contentItem, "footer"); QVERIFY(!footer); - footer = findItem(contentItem, "footer2"); + footer = findItem(contentItem, "footer2"); QVERIFY(footer); QCOMPARE(footer->y(), 600.0); @@ -1854,7 +1852,7 @@ void tst_QDeclarativeGridView::footer() delete canvas; } -void tst_QDeclarativeGridView::header() +void tst_QDeclarative1GridView::header() { QDeclarativeView *canvas = createView(); @@ -1868,13 +1866,13 @@ void tst_QDeclarativeGridView::header() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != 0); - QDeclarativeText *header = findItem(contentItem, "header"); + QDeclarative1Text *header = findItem(contentItem, "header"); QVERIFY(header); QCOMPARE(header->y(), 0.0); @@ -1893,9 +1891,9 @@ void tst_QDeclarativeGridView::header() QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); - header = findItem(contentItem, "header"); + header = findItem(contentItem, "header"); QVERIFY(!header); - header = findItem(contentItem, "header2"); + header = findItem(contentItem, "header2"); QVERIFY(header); QCOMPARE(header->y(), 10.0); @@ -1905,7 +1903,7 @@ void tst_QDeclarativeGridView::header() delete canvas; } -void tst_QDeclarativeGridView::indexAt() +void tst_QDeclarative1GridView::indexAt() { QDeclarativeView *canvas = createView(); @@ -1926,7 +1924,7 @@ void tst_QDeclarativeGridView::indexAt() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -1943,7 +1941,7 @@ void tst_QDeclarativeGridView::indexAt() delete canvas; } -void tst_QDeclarativeGridView::onAdd() +void tst_QDeclarative1GridView::onAdd() { QFETCH(int, initialItemCount); QFETCH(int, itemsToAdd); @@ -1984,7 +1982,7 @@ void tst_QDeclarativeGridView::onAdd() delete canvas; } -void tst_QDeclarativeGridView::onAdd_data() +void tst_QDeclarative1GridView::onAdd_data() { QTest::addColumn("initialItemCount"); QTest::addColumn("itemsToAdd"); @@ -2002,7 +2000,7 @@ void tst_QDeclarativeGridView::onAdd_data() QTest::newRow("5, add 10") << 5 << 10; } -void tst_QDeclarativeGridView::onRemove() +void tst_QDeclarative1GridView::onRemove() { QFETCH(int, initialItemCount); QFETCH(int, indexToRemove); @@ -2031,7 +2029,7 @@ void tst_QDeclarativeGridView::onRemove() delete canvas; } -void tst_QDeclarativeGridView::onRemove_data() +void tst_QDeclarative1GridView::onRemove_data() { QTest::addColumn("initialItemCount"); QTest::addColumn("indexToRemove"); @@ -2054,7 +2052,7 @@ void tst_QDeclarativeGridView::onRemove_data() QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; } -void tst_QDeclarativeGridView::testQtQuick11Attributes() +void tst_QDeclarative1GridView::testQtQuick11Attributes() { QFETCH(QString, code); QFETCH(QString, warning); @@ -2078,7 +2076,7 @@ void tst_QDeclarativeGridView::testQtQuick11Attributes() delete obj; } -void tst_QDeclarativeGridView::testQtQuick11Attributes_data() +void tst_QDeclarative1GridView::testQtQuick11Attributes_data() { QTest::addColumn("code"); QTest::addColumn("warning"); @@ -2093,7 +2091,7 @@ void tst_QDeclarativeGridView::testQtQuick11Attributes_data() << ""; } -void tst_QDeclarativeGridView::contentPosJump() +void tst_QDeclarative1GridView::contentPosJump() { QDeclarativeView *canvas = createView(); @@ -2109,7 +2107,7 @@ void tst_QDeclarativeGridView::contentPosJump() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); qApp->processEvents(); - QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QDeclarativeItem *contentItem = gridview->contentItem(); @@ -2143,7 +2141,7 @@ void tst_QDeclarativeGridView::contentPosJump() delete canvas; } -QDeclarativeView *tst_QDeclarativeGridView::createView() +QDeclarativeView *tst_QDeclarative1GridView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); @@ -2156,7 +2154,7 @@ QDeclarativeView *tst_QDeclarativeGridView::createView() item must also evaluate the {index} expression equal to index */ template -T *tst_QDeclarativeGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index) +T *tst_QDeclarative1GridView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->childItems().count() << "children"; @@ -2186,7 +2184,7 @@ T *tst_QDeclarativeGridView::findItem(QGraphicsObject *parent, const QString &ob } template -QList tst_QDeclarativeGridView::findItems(QGraphicsObject *parent, const QString &objectName) +QList tst_QDeclarative1GridView::findItems(QGraphicsObject *parent, const QString &objectName) { QList items; const QMetaObject &mo = T::staticMetaObject; @@ -2206,7 +2204,7 @@ QList tst_QDeclarativeGridView::findItems(QGraphicsObject *parent, const QSt return items; } -void tst_QDeclarativeGridView::dumpTree(QDeclarativeItem *parent, int depth) +void tst_QDeclarative1GridView::dumpTree(QDeclarativeItem *parent, int depth) { static QString padding(" "); for (int i = 0; i < parent->childItems().count(); ++i) { @@ -2220,6 +2218,6 @@ void tst_QDeclarativeGridView::dumpTree(QDeclarativeItem *parent, int depth) } -QTEST_MAIN(tst_QDeclarativeGridView) +QTEST_MAIN(tst_QDeclarative1GridView) #include "tst_qdeclarativegridview.moc" diff --git a/tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml b/tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/aspectratio.qml rename to tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml diff --git a/tests/auto/declarative/qdeclarativeimage/data/big.jpeg b/tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/big.jpeg rename to tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg diff --git a/tests/auto/declarative/qdeclarativeimage/data/big256.png b/tests/auto/qtquick1/qdeclarativeimage/data/big256.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/big256.png rename to tests/auto/qtquick1/qdeclarativeimage/data/big256.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/colors.png b/tests/auto/qtquick1/qdeclarativeimage/data/colors.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/colors.png rename to tests/auto/qtquick1/qdeclarativeimage/data/colors.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/colors1.png b/tests/auto/qtquick1/qdeclarativeimage/data/colors1.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/colors1.png rename to tests/auto/qtquick1/qdeclarativeimage/data/colors1.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/green.png b/tests/auto/qtquick1/qdeclarativeimage/data/green.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/green.png rename to tests/auto/qtquick1/qdeclarativeimage/data/green.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/heart-win32.png rename to tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/heart.png rename to tests/auto/qtquick1/qdeclarativeimage/data/heart.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart.svg b/tests/auto/qtquick1/qdeclarativeimage/data/heart.svg similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/heart.svg rename to tests/auto/qtquick1/qdeclarativeimage/data/heart.svg diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png rename to tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart200.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/heart200.png rename to tests/auto/qtquick1/qdeclarativeimage/data/heart200.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml b/tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/qtbug_16389.qml rename to tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml diff --git a/tests/auto/declarative/qdeclarativeimage/data/rect.png b/tests/auto/qtquick1/qdeclarativeimage/data/rect.png similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/rect.png rename to tests/auto/qtquick1/qdeclarativeimage/data/rect.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/tiling.qml b/tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeimage/data/tiling.qml rename to tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml diff --git a/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro new file mode 100644 index 0000000000..dde8ed91b3 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network qtquick1 +macx:CONFIG -= app_bundle + +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += tst_qdeclarativeimage.cpp ../../declarative/shared/testhttpserver.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp similarity index 87% rename from tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp rename to tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp index b5aaa007e9..cd07b00d5d 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -46,16 +46,16 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include #include "../../../shared/util.h" -#include "../shared/testhttpserver.h" +#include "../../declarative/shared/testhttpserver.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -111,13 +111,13 @@ void tst_qdeclarativeimage::noSource() QString componentStr = "import QtQuick 1.0\nImage { source: \"\" }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->source(), QUrl()); - QVERIFY(obj->status() == QDeclarativeImage::Null); + QVERIFY(obj->status() == QDeclarative1Image::Null); QCOMPARE(obj->width(), 0.); QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); + QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); QCOMPARE(obj->progress(), 0.0); delete obj; @@ -173,7 +173,7 @@ void tst_qdeclarativeimage::imageSource() + (cache ? QLatin1String("true") : QLatin1String("false")) + " }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); if (async) @@ -187,18 +187,18 @@ void tst_qdeclarativeimage::imageSource() QVERIFY(obj->cache() == false); if (remote || async) - QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); if (error.isEmpty()) { - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); QCOMPARE(obj->width(), qreal(width)); QCOMPARE(obj->height(), qreal(height)); - QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); + QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); QCOMPARE(obj->progress(), 1.0); } else { - QTRY_VERIFY(obj->status() == QDeclarativeImage::Error); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Error); } delete obj; @@ -211,16 +211,16 @@ void tst_qdeclarativeimage::clearSource() ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarativeImage::Ready); + QVERIFY(obj->status() == QDeclarative1Image::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); QCOMPARE(obj->progress(), 1.0); ctxt->setContextProperty("srcImage", ""); QVERIFY(obj->source().isEmpty()); - QVERIFY(obj->status() == QDeclarativeImage::Null); + QVERIFY(obj->status() == QDeclarative1Image::Null); QCOMPARE(obj->width(), 0.); QCOMPARE(obj->height(), 0.); QCOMPARE(obj->progress(), 0.0); @@ -233,11 +233,11 @@ void tst_qdeclarativeimage::resized() QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); + QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); delete obj; } @@ -248,7 +248,7 @@ void tst_qdeclarativeimage::preserveAspectRatio() canvas->show(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml")); - QDeclarativeImage *image = qobject_cast(canvas->rootObject()); + QDeclarative1Image *image = qobject_cast(canvas->rootObject()); QVERIFY(image != 0); QCOMPARE(image->property("widthChange").toInt(), 1); QCOMPARE(image->property("heightChange").toInt(), 1); @@ -259,7 +259,7 @@ void tst_qdeclarativeimage::preserveAspectRatio() QCOMPARE(image->height(), 80.); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml")); - image = qobject_cast(canvas->rootObject()); + image = qobject_cast(canvas->rootObject()); QVERIFY(image != 0); QCOMPARE(image->property("widthChange").toInt(), 1); QCOMPARE(image->property("heightChange").toInt(), 1); @@ -276,12 +276,12 @@ void tst_qdeclarativeimage::smooth() QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); QCOMPARE(obj->smooth(), true); - QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); + QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); delete obj; } @@ -298,12 +298,12 @@ void tst_qdeclarativeimage::mirror() QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); obj->setProperty("width", width); obj->setProperty("height", height); - obj->setFillMode((QDeclarativeImage::FillMode)fillMode); + obj->setFillMode((QDeclarative1Image::FillMode)fillMode); obj->setProperty("mirror", true); QGraphicsScene scene; @@ -324,13 +324,14 @@ void tst_qdeclarativeimage::mirror() p_e.setTransform(transform); switch (fillMode) { - case QDeclarativeImage::Stretch: + case QDeclarative1Image::Stretch: p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); break; - case QDeclarativeImage::PreserveAspectFit: + case QDeclarative1Image::PreserveAspectFit: + QEXPECT_FAIL("", "QTBUG-19538", Continue); p_e.drawPixmap(QRect(25, 0, width / (width/height), height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); break; - case QDeclarativeImage::PreserveAspectCrop: + case QDeclarative1Image::PreserveAspectCrop: { qreal ratio = width/srcPixmap.width(); // width is the longer side QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio); @@ -338,15 +339,15 @@ void tst_qdeclarativeimage::mirror() p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); break; } - case QDeclarativeImage::Tile: + case QDeclarative1Image::Tile: p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); break; - case QDeclarativeImage::TileVertically: + case QDeclarative1Image::TileVertically: transform.scale(width / srcPixmap.width(), 1.0); p_e.setTransform(transform); p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); break; - case QDeclarativeImage::TileHorizontally: + case QDeclarative1Image::TileHorizontally: transform.scale(1.0, height / srcPixmap.height()); p_e.setTransform(transform); p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); @@ -362,12 +363,12 @@ void tst_qdeclarativeimage::mirror_data() { QTest::addColumn("fillMode"); - QTest::newRow("Stretch") << int(QDeclarativeImage::Stretch); - QTest::newRow("PreserveAspectFit") << int(QDeclarativeImage::PreserveAspectFit); - QTest::newRow("PreserveAspectCrop") << int(QDeclarativeImage::PreserveAspectCrop); - QTest::newRow("Tile") << int(QDeclarativeImage::Tile); - QTest::newRow("TileVertically") << int(QDeclarativeImage::TileVertically); - QTest::newRow("TileHorizontally") << int(QDeclarativeImage::TileHorizontally); + QTest::newRow("Stretch") << int(QDeclarative1Image::Stretch); + QTest::newRow("PreserveAspectFit") << int(QDeclarative1Image::PreserveAspectFit); + QTest::newRow("PreserveAspectCrop") << int(QDeclarative1Image::PreserveAspectCrop); + QTest::newRow("Tile") << int(QDeclarative1Image::Tile); + QTest::newRow("TileVertically") << int(QDeclarative1Image::TileVertically); + QTest::newRow("TileHorizontally") << int(QDeclarative1Image::TileHorizontally); } void tst_qdeclarativeimage::svg() @@ -376,7 +377,7 @@ void tst_qdeclarativeimage::svg() QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->pixmap().width(), 300); QCOMPARE(obj->pixmap().height(), 300); @@ -461,7 +462,7 @@ void tst_qdeclarativeimage::geometry() componentStr.append("}"); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), itemWidth); @@ -484,7 +485,7 @@ void tst_qdeclarativeimage::big() QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->pixmap().width(), 256); QCOMPARE(obj->pixmap().height(), 256); @@ -502,8 +503,8 @@ void tst_qdeclarativeimage::tiling_QTBUG_6716() canvas->show(); qApp->processEvents(); - QDeclarativeImage *vTiling = findItem(canvas->rootObject(), "vTiling"); - QDeclarativeImage *hTiling = findItem(canvas->rootObject(), "hTiling"); + QDeclarative1Image *vTiling = findItem(canvas->rootObject(), "vTiling"); + QDeclarative1Image *hTiling = findItem(canvas->rootObject(), "hTiling"); QVERIFY(vTiling != 0); QVERIFY(hTiling != 0); @@ -549,17 +550,17 @@ void tst_qdeclarativeimage::noLoading() ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarativeImage::Ready); + QVERIFY(obj->status() == QDeclarative1Image::Ready); QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarativeImageBase::Status))); + QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarative1ImageBase::Status))); // Loading local file ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/green.png")); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 1); QTRY_COMPARE(progressSpy.count(), 0); @@ -567,9 +568,9 @@ void tst_qdeclarativeimage::noLoading() // Loading remote file ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 2); QTRY_COMPARE(progressSpy.count(), 2); @@ -578,7 +579,7 @@ void tst_qdeclarativeimage::noLoading() // Loading remote file again - should not go through 'Loading' state. ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/green.png")); ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 4); QTRY_COMPARE(progressSpy.count(), 2); @@ -595,7 +596,7 @@ void tst_qdeclarativeimage::paintedWidthHeight() QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->pixmap().width(), 300); QCOMPARE(obj->pixmap().height(), 300); @@ -613,7 +614,7 @@ void tst_qdeclarativeimage::paintedWidthHeight() QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->pixmap().width(), 300); QCOMPARE(obj->pixmap().height(), 300); @@ -634,12 +635,12 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_14303() ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png")); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged())); QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); QTRY_COMPARE(obj->sourceSize().width(), 200); QTRY_COMPARE(obj->sourceSize().height(), 200); @@ -665,7 +666,7 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_16389() canvas->show(); qApp->processEvents(); - QDeclarativeImage *image = findItem(canvas->rootObject(), "iconImage"); + QDeclarative1Image *image = findItem(canvas->rootObject(), "iconImage"); QDeclarativeItem *handle = findItem(canvas->rootObject(), "blueHandle"); QCOMPARE(image->sourceSize().width(), 200); @@ -694,7 +695,7 @@ void tst_qdeclarativeimage::nullPixmapPaint() + SERVER_ADDR + QString("/no-such-file.png\" }"); QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *image = qobject_cast(component.create()); + QDeclarative1Image *image = qobject_cast(component.create()); QTRY_VERIFY(image != 0); @@ -717,7 +718,7 @@ void tst_qdeclarativeimage::resetSourceSize() QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeImage *obj = qobject_cast(component.create()); + QDeclarative1Image *obj = qobject_cast(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->pixmap().width(), 100); QCOMPARE(obj->pixmap().height(), 100); diff --git a/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro new file mode 100644 index 0000000000..1de026ea37 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative qtquick1 +QT += network +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeimageprovider.cpp + +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov + +!symbian: { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp new file mode 100644 index 0000000000..3190579949 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -0,0 +1,432 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +Q_DECLARE_METATYPE(QDeclarativeImageProvider*); + +class tst_qdeclarativeimageprovider : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativeimageprovider() + { + } + +private slots: + void requestImage_sync_data(); + void requestImage_sync(); + void requestImage_async_data(); + void requestImage_async(); + + void requestPixmap_sync_data(); + void requestPixmap_sync(); + void requestPixmap_async(); + + void removeProvider_data(); + void removeProvider(); + + void threadTest(); + +private: + QString newImageFileName() const; + void fillRequestTestsData(const QString &id); + void runTest(bool async, QDeclarativeImageProvider *provider); +}; + + +class TestQImageProvider : public QDeclarativeImageProvider +{ +public: + TestQImageProvider(bool *deleteWatch = 0) + : QDeclarativeImageProvider(Image), deleteWatch(deleteWatch) + { + } + + ~TestQImageProvider() + { + if (deleteWatch) + *deleteWatch = true; + } + + QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) + { + lastImageId = id; + + if (id == QLatin1String("no-such-file.png")) + return QImage(); + + int width = 100; + int height = 100; + QImage image(width, height, QImage::Format_RGB32); + if (size) + *size = QSize(width, height); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } + + bool *deleteWatch; + QString lastImageId; +}; +Q_DECLARE_METATYPE(TestQImageProvider*); + + +class TestQPixmapProvider : public QDeclarativeImageProvider +{ +public: + TestQPixmapProvider(bool *deleteWatch = 0) + : QDeclarativeImageProvider(Pixmap), deleteWatch(deleteWatch) + { + } + + ~TestQPixmapProvider() + { + if (deleteWatch) + *deleteWatch = true; + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) + { + lastImageId = id; + + if (id == QLatin1String("no-such-file.png")) + return QPixmap(); + + int width = 100; + int height = 100; + QPixmap image(width, height); + if (size) + *size = QSize(width, height); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } + + bool *deleteWatch; + QString lastImageId; +}; +Q_DECLARE_METATYPE(TestQPixmapProvider*); + + +QString tst_qdeclarativeimageprovider::newImageFileName() const +{ + // need to generate new filenames each time or else images are loaded + // from cache and we won't get loading status changes when testing + // async loading + static int count = 0; + return QString("image://test/image-%1.png").arg(count++); +} + +void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id) +{ + QTest::addColumn("source"); + QTest::addColumn("imageId"); + QTest::addColumn("properties"); + QTest::addColumn("size"); + QTest::addColumn("error"); + + QString fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " simple test")) + << "image://test/" + fileName << fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference + << "image://Test/" + fileName << fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with no id")) + << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with path")) + << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with fragment")) + << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with query")) + << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName + << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " scaled image")) + << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + + QTest::newRow(QTest::toString(id + " missing")) + << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100) + << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; + + QTest::newRow(QTest::toString(id + " unknown provider")) + << "image://bogus/exists.png" << "" << "" << QSize() + << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png"; +} + +void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider) +{ + QFETCH(QString, source); + QFETCH(QString, imageId); + QFETCH(QString, properties); + QFETCH(QSize, size); + QFETCH(QString, error); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + QDeclarativeEngine engine; + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); + + QString componentStr = "import QtQuick 1.0\nImage { source: \"" + source + "\"; " + + (async ? "asynchronous: true; " : "") + + properties + " }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1Image *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + if (async) + QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); + + QCOMPARE(obj->source(), QUrl(source)); + + if (error.isEmpty()) { + if (async) + QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); + else + QVERIFY(obj->status() == QDeclarative1Image::Ready); + if (QByteArray(QTest::currentDataTag()).startsWith("qimage")) + QCOMPARE(static_cast(provider)->lastImageId, imageId); + else + QCOMPARE(static_cast(provider)->lastImageId, imageId); + + QCOMPARE(obj->width(), qreal(size.width())); + QCOMPARE(obj->height(), qreal(size.height())); + QCOMPARE(obj->pixmap().width(), size.width()); + QCOMPARE(obj->pixmap().height(), size.height()); + QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); + QCOMPARE(obj->progress(), 1.0); + } else { + if (async) + QTRY_VERIFY(obj->status() == QDeclarative1Image::Error); + else + QVERIFY(obj->status() == QDeclarative1Image::Error); + } + + delete obj; +} + +void tst_qdeclarativeimageprovider::requestImage_sync_data() +{ + fillRequestTestsData("qimage|sync"); +} + +void tst_qdeclarativeimageprovider::requestImage_sync() +{ + bool deleteWatch = false; + runTest(false, new TestQImageProvider(&deleteWatch)); + QVERIFY(deleteWatch); +} + +void tst_qdeclarativeimageprovider::requestImage_async_data() +{ + fillRequestTestsData("qimage|async"); +} + +void tst_qdeclarativeimageprovider::requestImage_async() +{ + bool deleteWatch = false; + runTest(true, new TestQImageProvider(&deleteWatch)); + QVERIFY(deleteWatch); +} + +void tst_qdeclarativeimageprovider::requestPixmap_sync_data() +{ + fillRequestTestsData("qpixmap"); +} + +void tst_qdeclarativeimageprovider::requestPixmap_sync() +{ + bool deleteWatch = false; + runTest(false, new TestQPixmapProvider(&deleteWatch)); + QVERIFY(deleteWatch); +} + +void tst_qdeclarativeimageprovider::requestPixmap_async() +{ + QDeclarativeEngine engine; + QDeclarativeImageProvider *provider = new TestQPixmapProvider(); + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); + + // pixmaps are loaded synchronously regardless of 'asynchronous' value + QString componentStr = "import QtQuick 1.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1Image *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + delete obj; +} + +void tst_qdeclarativeimageprovider::removeProvider_data() +{ + QTest::addColumn("provider"); + + QTest::newRow("qimage") << static_cast(new TestQImageProvider); + QTest::newRow("qpixmap") << static_cast(new TestQPixmapProvider); +} + +void tst_qdeclarativeimageprovider::removeProvider() +{ + QFETCH(QDeclarativeImageProvider*, provider); + + QDeclarativeEngine engine; + + engine.addImageProvider("test", provider); + QVERIFY(engine.imageProvider("test") != 0); + + // add provider, confirm it works + QString componentStr = "import QtQuick 1.0\nImage { source: \"" + newImageFileName() + "\" }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1Image *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + QCOMPARE(obj->status(), QDeclarative1Image::Ready); + + // remove the provider and confirm + QString fileName = newImageFileName(); + QString error("file::2:1: QML Image: Failed to get image from provider: " + fileName); + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + engine.removeImageProvider("test"); + + obj->setSource(QUrl(fileName)); + QCOMPARE(obj->status(), QDeclarative1Image::Error); + + delete obj; +} + +class TestThreadProvider : public QDeclarativeImageProvider +{ + public: + TestThreadProvider() : QDeclarativeImageProvider(Image), ok(false) {} + + ~TestThreadProvider() {} + + QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) + { + mutex.lock(); + if (!ok) + cond.wait(&mutex); + mutex.unlock(); + QVector v; + for (int i = 0; i < 10000; i++) + v.prepend(i); //do some computation + QImage image(50,50, QImage::Format_RGB32); + image.fill(QColor(id).rgb()); + if (size) + *size = image.size(); + if (requestedSize.isValid()) + image = image.scaled(requestedSize); + return image; + } + + QWaitCondition cond; + QMutex mutex; + bool ok; +}; + + +void tst_qdeclarativeimageprovider::threadTest() +{ + QDeclarativeEngine engine; + + TestThreadProvider *provider = new TestThreadProvider; + + engine.addImageProvider("test_thread", provider); + QVERIFY(engine.imageProvider("test_thread") != 0); + + QString componentStr = "import QtQuick 1.0\nItem { \n" + "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n" + "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n" + " }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QObject *obj = component.create(); + //MUST not deadlock + QVERIFY(obj != 0); + QList images = obj->findChildren(); + QCOMPARE(images.count(), 4); + QTest::qWait(100); + foreach(QDeclarative1Image *img, images) { + QCOMPARE(img->status(), QDeclarative1Image::Loading); + } + provider->ok = true; + provider->cond.wakeAll(); + QTest::qWait(250); + foreach(QDeclarative1Image *img, images) { + QTRY_VERIFY(img->status() == QDeclarative1Image::Ready); + } +} + + +QTEST_MAIN(tst_qdeclarativeimageprovider) + +#include "tst_qdeclarativeimageprovider.moc" diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenProperty.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/childrenProperty.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/childrenRect.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/childrenRectBug.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug2.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/childrenRectBug2.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug3.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/childrenRectBug3.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/implicitsize.qml b/tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/implicitsize.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/keynavigationtest.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/keynavigationtest_implicit.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/keynavigationtest_implicit.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/keyspriority.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/keystest.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/keystest.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/layoutmirroring.qml b/tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/layoutmirroring.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/mapCoordinates.qml b/tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/mapCoordinates.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml b/tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/mouseFocus.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/propertychanges.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/qtbug_16871.qml b/tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/qtbug_16871.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/resourcesProperty.qml b/tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/resourcesProperty.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml diff --git a/tests/auto/declarative/qdeclarativeitem/data/transformCrash.qml b/tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeitem/data/transformCrash.qml rename to tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro similarity index 65% rename from tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro rename to tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro index 67133f65b2..0b87e3c9e7 100644 --- a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro +++ b/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeitem.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp similarity index 99% rename from tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp rename to tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp index c53e2c66fb..b244a24613 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -43,9 +43,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -1244,7 +1244,7 @@ void tst_QDeclarativeItem::childrenRectBug2() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug2.qml")); canvas->show(); - QDeclarativeRectangle *rect = qobject_cast(canvas->rootObject()); + QDeclarative1Rectangle *rect = qobject_cast(canvas->rootObject()); QVERIFY(rect); QDeclarativeItem *item = rect->findChild("theItem"); QCOMPARE(item->width(), qreal(100)); diff --git a/tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml b/tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelayoutitem/data/layoutItem.qml rename to tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml diff --git a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro b/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro similarity index 63% rename from tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro rename to tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro index 6c38af4da1..b248ee03b4 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro +++ b/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativelayoutitem.cpp @@ -11,4 +11,4 @@ symbian: { } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp similarity index 95% rename from tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp rename to tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp index 0db1f4398e..095ad2ba38 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp +++ b/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp @@ -41,8 +41,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -81,7 +81,7 @@ void tst_qdeclarativelayoutitem::test_resizing() //Add the QML snippet into the layout QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml")); - QDeclarativeLayoutItem* obj = static_cast(c.create()); + QDeclarative1LayoutItem* obj = static_cast(c.create()); QVERIFY(obj); QCOMPARE(obj->minimumSize(), QSizeF(100,100)); QCOMPARE(obj->preferredSize(), QSizeF(200,200)); diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml new file mode 100644 index 0000000000..93697f3307 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 + +Item { + property string result + + ListModel { + id: model + + ListElement { + val1: 1 + val2: 2 + val3: "str" + val4: false + val5: true + } + } + + Component.onCompleted: { + var element = model.get(0); + + for (var i in element) + result += i+"="+element[i]+(element[i] ? "Y" : "N")+":"; + } +} diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml new file mode 100644 index 0000000000..bfd547ed32 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml @@ -0,0 +1,22 @@ +import QtQuick 1.0 + +Item { + id: item + property variant model + property bool done: false + property variant result + + function evalExpressionViaWorker(commands) { + done = false + worker.sendMessage({'commands': commands, 'model': model}) + } + + WorkerScript { + id: worker + source: "script.js" + onMessage: { + item.result = messageObject.result + item.done = true + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml new file mode 100644 index 0000000000..cc6d9de8a0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml @@ -0,0 +1,25 @@ +import QtQuick 1.0 +ListView { + width: 100 + height: 250 + delegate: Rectangle { + width: 100 + height: 50 + color: black ? "black": "white" + } + model: ListModel { + objectName: "listModel" + ListElement { + black: false + rounded: false + } + ListElement { + black: true + rounded: false + } + ListElement { + black: true + rounded: false + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js b/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js new file mode 100644 index 0000000000..66a4acb8a8 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js @@ -0,0 +1,13 @@ +WorkerScript.onMessage = function(msg) { + var result = null + try { + for (var i=0; i +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QList) + +class tst_qdeclarativelistmodel : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativelistmodel() {} + +private: + int roleFromName(const QDeclarative1ListModel *model, const QString &roleName); + QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarative1ListModel *model); + void waitForWorker(QDeclarativeItem *item); + +private slots: + void static_types(); + void static_types_data(); + void static_i18n(); + void static_nestedElements(); + void static_nestedElements_data(); + void dynamic_data(); + void dynamic(); + void dynamic_worker_data(); + void dynamic_worker(); + void dynamic_worker_sync_data(); + void dynamic_worker_sync(); + void convertNestedToFlat_fail(); + void convertNestedToFlat_fail_data(); + void convertNestedToFlat_ok(); + void convertNestedToFlat_ok_data(); + void enumerate(); + void error_data(); + void error(); + void syncError(); + void set(); + void get(); + void get_data(); + void get_worker(); + void get_worker_data(); + void get_nested(); + void get_nested_data(); + void crash_model_with_multiple_roles(); + void set_model_cache(); + void property_changes(); + void property_changes_data(); + void property_changes_worker(); + void property_changes_worker_data(); + void clear(); +}; + +int tst_qdeclarativelistmodel::roleFromName(const QDeclarative1ListModel *model, const QString &roleName) +{ + QList roles = model->roles(); + for (int i=0; itoString(roles[i]) == roleName) + return roles[i]; + } + return -1; +} + +QDeclarativeItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarative1ListModel *model) +{ + QDeclarativeItem *item = qobject_cast(component->create()); + QDeclarativeEngine::setContextForObject(model, eng->rootContext()); + if (item) + item->setProperty("model", qVariantFromValue(model)); + return item; +} + +void tst_qdeclarativelistmodel::waitForWorker(QDeclarativeItem *item) +{ + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + + QDeclarativeProperty prop(item, "done"); + QVERIFY(prop.isValid()); + QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit()))); + timer.start(10000); + loop.exec(); + QVERIFY(timer.isActive()); +} + +void tst_qdeclarativelistmodel::static_types_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("value"); + + QTest::newRow("string") + << "ListElement { foo: \"bar\" }" + << QVariant(QString("bar")); + + QTest::newRow("real") + << "ListElement { foo: 10.5 }" + << QVariant(10.5); + + QTest::newRow("real0") + << "ListElement { foo: 0 }" + << QVariant(double(0)); + + QTest::newRow("bool") + << "ListElement { foo: false }" + << QVariant(false); + + QTest::newRow("bool") + << "ListElement { foo: true }" + << QVariant(true); + + QTest::newRow("enum") + << "ListElement { foo: Text.AlignHCenter }" + << QVariant(double(QDeclarativeText::AlignHCenter)); +} + +void tst_qdeclarativelistmodel::static_types() +{ + QFETCH(QString, qml); + QFETCH(QVariant, value); + + qml = "import QtQuick 1.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }"; + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + + QVERIFY(!component.isError()); + + QObject *obj = component.create(); + QVERIFY(obj != 0); + + QVariant actual = obj->property("test"); + + QCOMPARE(actual, value); + QCOMPARE(actual.toString(), value.toString()); + + delete obj; +} + +void tst_qdeclarativelistmodel::static_i18n() +{ + QString expect = QString::fromUtf8("na\303\257ve"); + + QString componentStr = "import QtQuick 1.0\nItem { property string prop1: model.get(0).prop1; property string prop2: model.get(0).prop2; ListModel { id: model; ListElement { prop1: \""+expect+"\"; prop2: QT_TR_NOOP(\""+expect+"\") } } }"; + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toUtf8(), QUrl::fromLocalFile("")); + QObject *obj = component.create(); + QVERIFY(obj != 0); + QString prop1 = obj->property("prop1").toString(); + QCOMPARE(prop1,expect); + QString prop2 = obj->property("prop2").toString(); + QCOMPARE(prop2,expect); // (no, not translated, QT_TR_NOOP is a no-op) + delete obj; +} + +void tst_qdeclarativelistmodel::static_nestedElements() +{ + QFETCH(int, elementCount); + + QStringList elements; + for (int i=0; i(component.create()); + QVERIFY(obj != 0); + + QVariant count = obj->property("count"); + QCOMPARE(count.type(), QVariant::Int); + QCOMPARE(count.toInt(), elementCount); + + delete obj; +} + +void tst_qdeclarativelistmodel::static_nestedElements_data() +{ + QTest::addColumn("elementCount"); + + QTest::newRow("0 items") << 0; + QTest::newRow("1 item") << 1; + QTest::newRow("2 items") << 2; + QTest::newRow("many items") << 5; +} + +void tst_qdeclarativelistmodel::dynamic_data() +{ + QTest::addColumn("script"); + QTest::addColumn("result"); + QTest::addColumn("warning"); + + // Simple flat model + + QTest::newRow("count") << "count" << 0 << ""; + + QTest::newRow("get1") << "{get(0) === undefined}" << 1 << ""; + QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << ""; + QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << ""; + QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << ""; + + QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << ""; + QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << ""; + + QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; + QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; + QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << ""; + QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << ""; + QTest::newRow("append4a") << "{append(123)}" << 0 << ": QML ListModel: append: value is not an object"; + QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << ": QML ListModel: append: value is not an object"; + + QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << ""; + QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << ""; + QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << ""; + + QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << ""; + QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << ""; + QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; + QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; + QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << ""; + QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << ": QML ListModel: remove: index -1 out of range"; + QTest::newRow("remove4a") << "{remove(0)}" << 0 << ": QML ListModel: remove: index 0 out of range"; + QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << ": QML ListModel: remove: index 0 out of range"; + QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << ": QML ListModel: remove: index 1 out of range"; + + QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << ""; + QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << ": QML ListModel: insert: index 1 out of range"; + QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << ""; + QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << ""; + QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << ""; + QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << ""; + QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << ""; + QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << ": QML ListModel: insert: index -1 out of range"; + QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << ": QML ListModel: insert: value is not an object"; + QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << ": QML ListModel: insert: value is not an object"; + + QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << ""; + QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << ""; + QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << ""; + QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; + QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << ""; + QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << ": QML ListModel: set: index -1 out of range"; + QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << ": QML ListModel: set: value is not an object"; + QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << ": QML ListModel: set: value is not an object"; + QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; + + QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << ""; + QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << ""; + QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << ""; + QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << ""; + QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << ": QML ListModel: set: index 0 out of range"; + QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << ": QML ListModel: set: index -1 out of range"; + QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << ": QML ListModel: set: index 1 out of range"; + QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << ""; + + QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; + QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << ""; + QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << ""; + QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << ""; + QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << ""; + QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << ""; + QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << ""; + QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << ""; + QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << ""; + QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << ": QML ListModel: move: out of range"; + QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << ": QML ListModel: move: out of range"; + QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << ": QML ListModel: move: out of range"; + QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << ": QML ListModel: move: out of range"; + + // Nested models + + QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << ""; + QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << ""; + QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << ""; + + QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << ""; + QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << ""; + + QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << ""; + QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << ""; +} + +void tst_qdeclarativelistmodel::dynamic() +{ + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + + QDeclarativeEngine engine; + QDeclarative1ListModel model; + QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); + engine.rootContext()->setContextObject(&model); + QDeclarativeExpression e(engine.rootContext(), &model, script); + if (!warning.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + QSignalSpy spyCount(&model, SIGNAL(countChanged())); + + int actual = e.evaluate().toInt(); + if (e.hasError()) + qDebug() << e.error(); // errors not expected + + QCOMPARE(actual,result); + + if (model.count() > 0) + QVERIFY(spyCount.count() > 0); +} + +void tst_qdeclarativelistmodel::dynamic_worker_data() +{ + dynamic_data(); +} + +void tst_qdeclarativelistmodel::dynamic_worker() +{ + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + + if (QByteArray(QTest::currentDataTag()).startsWith("nested")) + return; + + // This is same as dynamic() except it applies the test to a ListModel called + // from a WorkerScript (i.e. testing the internal FlatListModel that is created + // by the WorkerListModelAgent) + + QDeclarative1ListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + QSignalSpy spyCount(&model, SIGNAL(countChanged())); + + if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) + script = script.mid(1, script.length() - 2); + QVariantList operations; + foreach (const QString &s, script.split(';')) { + if (!s.isEmpty()) + operations << s; + } + + if (!warning.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, operations))); + waitForWorker(item); + QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result); + + if (model.count() > 0) + QVERIFY(spyCount.count() > 0); + + delete item; + qApp->processEvents(); +} + +void tst_qdeclarativelistmodel::dynamic_worker_sync_data() +{ + dynamic_data(); +} + +void tst_qdeclarativelistmodel::dynamic_worker_sync() +{ + QFETCH(QString, script); + QFETCH(int, result); + QFETCH(QString, warning); + + // This is the same as dynamic_worker() except that it executes a set of list operations + // from the worker script, calls sync(), and tests the changes are reflected in the + // list in the main thread + + QDeclarative1ListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) + script = script.mid(1, script.length() - 2); + QVariantList operations; + foreach (const QString &s, script.split(';')) { + if (!s.isEmpty()) + operations << s; + } + + if (!warning.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + + // execute a set of commands on the worker list model, then check the + // changes are reflected in the list model in the main thread + if (QByteArray(QTest::currentDataTag()).startsWith("nested")) + QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"); + + if (QByteArray(QTest::currentDataTag()).startsWith("nested-set")) + QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"); + + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); + waitForWorker(item); + + QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString()); + if (!QByteArray(QTest::currentDataTag()).startsWith("nested")) + QCOMPARE(e.evaluate().toInt(), result); + + delete item; + qApp->processEvents(); +} + +#define RUNEVAL(object, string) \ + QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string)))); + +inline QVariant runexpr(QDeclarativeEngine *engine, const QString &str) +{ + QDeclarativeExpression expr(engine->rootContext(), 0, str); + return expr.evaluate(); +} + +#define RUNEXPR(string) runexpr(&engine, QString(string)) + +void tst_qdeclarativelistmodel::convertNestedToFlat_fail() +{ + // If a model has nested data, it cannot be used at all from a worker script + + QFETCH(QString, script); + + QDeclarative1ListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + RUNEVAL(item, "model.append({foo: 123})"); + RUNEVAL(item, "model.append({foo: [{}, {}]})"); + + QCOMPARE(model.count(), 2); + + QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: List contains list-type data and cannot be used from a worker script"); + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script))); + waitForWorker(item); + + QCOMPARE(model.count(), 2); + + delete item; + qApp->processEvents(); +} + +void tst_qdeclarativelistmodel::convertNestedToFlat_fail_data() +{ + QTest::addColumn("script"); + + QTest::newRow("clear") << "clear()"; + QTest::newRow("remove") << "remove(0)"; + QTest::newRow("append") << "append({'x':1})"; + QTest::newRow("insert") << "insert(0, {'x':1})"; + QTest::newRow("set") << "set(0, {'foo':1})"; + QTest::newRow("setProperty") << "setProperty(0, 'foo', 1})"; + QTest::newRow("move") << "move(0, 1, 1})"; + QTest::newRow("get") << "get(0)"; +} + +void tst_qdeclarativelistmodel::convertNestedToFlat_ok() + +{ + // If a model only has plain data, it can be modified from a worker script. However, + // once the model is used from a worker script, it no longer accepts nested data + + QFETCH(QString, script); + + QDeclarative1ListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + RUNEVAL(item, "model.append({foo: 123})"); + + QCOMPARE(model.count(), 1); + + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script))); + waitForWorker(item); + + // can still add plain data + int count = model.count(); + + RUNEVAL(item, "model.append({foo: 123})"); + + QCOMPARE(model.count(), count+1); + + const char *warning = ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"; + + QTest::ignoreMessage(QtWarningMsg, warning); + RUNEVAL(item, "model.append({foo: [{}, {}]})"); + + QTest::ignoreMessage(QtWarningMsg, warning); + RUNEVAL(item, "model.insert(0, {foo: [{}, {}]})"); + + QTest::ignoreMessage(QtWarningMsg, warning); + RUNEVAL(item, "model.set(0, {foo: [{}, {}]})"); + + QCOMPARE(model.count(), count+1); + + delete item; + qApp->processEvents(); +} + +void tst_qdeclarativelistmodel::convertNestedToFlat_ok_data() +{ + convertNestedToFlat_fail_data(); +} + +void tst_qdeclarativelistmodel::enumerate() +{ + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/enumerate.qml")); + QVERIFY(!component.isError()); + QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + QStringList r = item->property("result").toString().split(":"); + QCOMPARE(r[0],QLatin1String("val1=1Y")); + QCOMPARE(r[1],QLatin1String("val2=2Y")); + QCOMPARE(r[2],QLatin1String("val3=strY")); + QCOMPARE(r[3],QLatin1String("val4=falseN")); + QCOMPARE(r[4],QLatin1String("val5=trueY")); + delete item; +} + +void tst_qdeclarativelistmodel::error_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("error"); + + QTest::newRow("id not allowed in ListElement") + << "import QtQuick 1.0\nListModel { ListElement { id: fred } }" + << "ListElement: cannot use reserved \"id\" property"; + + QTest::newRow("id allowed in ListModel") + << "import QtQuick 1.0\nListModel { id:model }" + << ""; + + QTest::newRow("random properties not allowed in ListModel") + << "import QtQuick 1.0\nListModel { foo:123 }" + << "ListModel: undefined property 'foo'"; + + QTest::newRow("random properties allowed in ListElement") + << "import QtQuick 1.0\nListModel { ListElement { foo:123 } }" + << ""; + + QTest::newRow("bindings not allowed in ListElement") + << "import QtQuick 1.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" + << "ListElement: cannot use script for property value"; + + QTest::newRow("random object list properties allowed in ListElement") + << "import QtQuick 1.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" + << ""; + + QTest::newRow("default properties not allowed in ListElement") + << "import QtQuick 1.0\nListModel { ListElement { Item { } } }" + << "ListElement: cannot contain nested elements"; + + QTest::newRow("QML elements not allowed in ListElement") + << "import QtQuick 1.0\nListModel { ListElement { a: Item { } } }" + << "ListElement: cannot contain nested elements"; + + QTest::newRow("qualified ListElement supported") + << "import QtQuick 1.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }" + << ""; + + QTest::newRow("qualified ListElement required") + << "import QtQuick 1.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }" + << "ListElement is not a type"; + + QTest::newRow("unknown qualified ListElement not allowed") + << "import QtQuick 1.0\nListModel { Foo.ListElement { a: 123 } }" + << "Foo.ListElement - Foo is not a namespace"; +} + +void tst_qdeclarativelistmodel::error() +{ + QFETCH(QString, qml); + QFETCH(QString, error); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + if (error.isEmpty()) { + QVERIFY(!component.isError()); + } else { + QVERIFY(component.isError()); + QList errors = component.errors(); + QCOMPARE(errors.count(),1); + QCOMPARE(errors.at(0).description(),error); + } +} + +void tst_qdeclarativelistmodel::syncError() +{ + QString qml = "import QtQuick 1.0\nListModel { id: lm; Component.onCompleted: lm.sync() }"; + QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript"; + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + QTest::ignoreMessage(QtWarningMsg,error.toUtf8()); + QObject *obj = component.create(); + QVERIFY(obj); + delete obj; +} + +/* + Test model changes from set() are available to the view +*/ +void tst_qdeclarativelistmodel::set() +{ + QDeclarativeEngine engine; + QDeclarative1ListModel model; + QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); + engine.rootContext()->setContextProperty("model", &model); + + RUNEXPR("model.append({test:false})"); + RUNEXPR("model.set(0, {test:true})"); + + QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache + QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true)); + + RUNEXPR("model.set(0, {test:false})"); + QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated + QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false)); +} + +/* + Test model changes on values returned by get() are available to the view +*/ +void tst_qdeclarativelistmodel::get() +{ + QFETCH(QString, expression); + QFETCH(int, index); + QFETCH(QString, roleName); + QFETCH(QVariant, roleValue); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData( + "import QtQuick 1.0\n" + "ListModel { \n" + "ListElement { roleA: 100 }\n" + "ListElement { roleA: 200; roleB: 400 } \n" + "ListElement { roleA: 200; roleB: 400 } \n" + "}", QUrl()); + QDeclarative1ListModel *model = qobject_cast(component.create()); + int role = roleFromName(model, roleName); + QVERIFY(role >= 0); + + QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList))); + QDeclarativeExpression expr(engine.rootContext(), model, expression); + expr.evaluate(); + QVERIFY(!expr.hasError()); + + QCOMPARE(model->data(index, role), roleValue); + QCOMPARE(spy.count(), 1); + + QList spyResult = spy.takeFirst(); + QCOMPARE(spyResult.at(0).toInt(), index); + QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time + QCOMPARE(spyResult.at(2).value >(), (QList() << role)); + + delete model; +} + +void tst_qdeclarativelistmodel::get_data() +{ + QTest::addColumn("expression"); + QTest::addColumn("index"); + QTest::addColumn("roleName"); + QTest::addColumn("roleValue"); + + QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500); + QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500); + + QVariantMap map; + map["zzz"] = 123; + QTest::newRow("object value") << "get(1).roleB = {'zzz':123}" << 1 << "roleB" << QVariant::fromValue(map); + + QVariantList list; + map.clear(); map["a"] = 50; map["b"] = 500; + list << map; + map.clear(); map["c"] = 1000; + list << map; + QTest::newRow("list of objects") << "get(2).roleB = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleB" << QVariant::fromValue(list); +} + +void tst_qdeclarativelistmodel::get_worker() +{ + QFETCH(QString, expression); + QFETCH(int, index); + QFETCH(QString, roleName); + QFETCH(QVariant, roleValue); + + QDeclarative1ListModel model; + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); + QVERIFY(item != 0); + + // Add some values like get() test + RUNEVAL(item, "model.append({roleA: 100})"); + RUNEVAL(item, "model.append({roleA: 200, roleB: 400})"); + RUNEVAL(item, "model.append({roleA: 200, roleB: 400})"); + + int role = roleFromName(&model, roleName); + QVERIFY(role >= 0); + + const char *warning = ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"; + if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) + QTest::ignoreMessage(QtWarningMsg, warning); + QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList))); + + // in the worker thread, change the model data and call sync() + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, QStringList(expression)))); + waitForWorker(item); + + // see if we receive the model changes in the main thread's model + if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) { + QVERIFY(model.data(index, role) != roleValue); + QCOMPARE(spy.count(), 0); + } else { + QCOMPARE(model.data(index, role), roleValue); + QCOMPARE(spy.count(), 1); + + QList spyResult = spy.takeFirst(); + QCOMPARE(spyResult.at(0).toInt(), index); + QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time + QVERIFY(spyResult.at(2).value >().contains(role)); + } +} + +void tst_qdeclarativelistmodel::get_worker_data() +{ + get_data(); +} + +/* + Test that the tests run in get() also work for nested list data +*/ +void tst_qdeclarativelistmodel::get_nested() +{ + QFETCH(QString, expression); + QFETCH(int, index); + QFETCH(QString, roleName); + QFETCH(QVariant, roleValue); + + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng); + component.setData( + "import QtQuick 1.0\n" + "ListModel { \n" + "ListElement {\n" + "listRoleA: [\n" + "ListElement { roleA: 100 },\n" + "ListElement { roleA: 200; roleB: 400 },\n" + "ListElement { roleA: 200; roleB: 400 } \n" + "]\n" + "}\n" + "ListElement {\n" + "listRoleA: [\n" + "ListElement { roleA: 100 },\n" + "ListElement { roleA: 200; roleB: 400 },\n" + "ListElement { roleA: 200; roleB: 400 } \n" + "]\n" + "listRoleB: [\n" + "ListElement { roleA: 100 },\n" + "ListElement { roleA: 200; roleB: 400 },\n" + "ListElement { roleA: 200; roleB: 400 } \n" + "]\n" + "listRoleC: [\n" + "ListElement { roleA: 100 },\n" + "ListElement { roleA: 200; roleB: 400 },\n" + "ListElement { roleA: 200; roleB: 400 } \n" + "]\n" + "}\n" + "}", QUrl()); + QDeclarative1ListModel *model = qobject_cast(component.create()); + QVERIFY(component.errorString().isEmpty()); + QDeclarative1ListModel *childModel; + + // Test setting the inner list data for: + // get(0).listRoleA + // get(1).listRoleA + // get(1).listRoleB + // get(1).listRoleC + + QList > testData; + testData << qMakePair(0, QString("listRoleA")); + testData << qMakePair(1, QString("listRoleA")); + testData << qMakePair(1, QString("listRoleB")); + testData << qMakePair(1, QString("listRoleC")); + + for (int i=0; i= 0); + + childModel = qobject_cast(model->data(outerListIndex, outerListRole).value()); + QVERIFY(childModel); + + QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression); + QDeclarativeExpression expr(eng.rootContext(), model, extendedExpression); + + QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList))); + expr.evaluate(); + QVERIFY(!expr.hasError()); + + int role = roleFromName(childModel, roleName); + QVERIFY(role >= 0); + QCOMPARE(childModel->data(index, role), roleValue); + QCOMPARE(spy.count(), 1); + + QList spyResult = spy.takeFirst(); + QCOMPARE(spyResult.at(0).toInt(), index); + QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time + QCOMPARE(spyResult.at(2).value >(), (QList() << role)); + } + + delete model; +} + +void tst_qdeclarativelistmodel::get_nested_data() +{ + get_data(); +} + +//QTBUG-13754 +void tst_qdeclarativelistmodel::crash_model_with_multiple_roles() +{ + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/multipleroles.qml")); + QObject *rootItem = component.create(); + QVERIFY(component.errorString().isEmpty()); + QVERIFY(rootItem != 0); + QDeclarative1ListModel *model = rootItem->findChild("listModel"); + QVERIFY(model != 0); + + // used to cause a crash in QDeclarativeVisualDataModel + model->setProperty(0, "black", true); + + delete rootItem; +} + +//QTBUG-15190 +void tst_qdeclarativelistmodel::set_model_cache() +{ + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/setmodelcachelist.qml")); + QObject *model = component.create(); + QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); + QVERIFY(model != 0); + QVERIFY(model->property("ok").toBool()); + + delete model; +} + +void tst_qdeclarativelistmodel::property_changes() +{ + QFETCH(QString, script_setup); + QFETCH(QString, script_change); + QFETCH(QString, roleName); + QFETCH(int, listIndex); + QFETCH(bool, itemsChanged); + QFETCH(QString, testExpression); + + QDeclarativeEngine engine; + QDeclarative1ListModel model; + QDeclarativeEngine::setContextForObject(&model, engine.rootContext()); + engine.rootContext()->setContextObject(&model); + + QDeclarativeExpression expr(engine.rootContext(), &model, script_setup); + expr.evaluate(); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); + + QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:"; + QString qml = "import QtQuick 1.0\n" + "Connections {\n" + "property bool gotSignal: false\n" + "target: model.get(0)\n" + + signalHandler + " gotSignal = true\n" + "}\n"; + QDeclarativeComponent component(&engine); + component.setData(qml.toUtf8(), QUrl::fromLocalFile("")); + engine.rootContext()->setContextProperty("model", &model); + QObject *connectionsObject = component.create(); + QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); + + QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList))); + + expr.setExpression(script_change); + expr.evaluate(); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error())); + + // test the object returned by get() emits the correct signals + QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged); + + // test itemsChanged() is emitted correctly + if (itemsChanged) { + QCOMPARE(spyItemsChanged.count(), 1); + QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); + QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); + } else { + QCOMPARE(spyItemsChanged.count(), 0); + } + + expr.setExpression(testExpression); + QCOMPARE(expr.evaluate().toBool(), true); + + delete connectionsObject; +} + +void tst_qdeclarativelistmodel::property_changes_data() +{ + QTest::addColumn("script_setup"); + QTest::addColumn("script_change"); + QTest::addColumn("roleName"); + QTest::addColumn("listIndex"); + QTest::addColumn("itemsChanged"); + QTest::addColumn("testExpression"); + + QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});" + << "b" << 0 << true << "get(0).b == 123"; + QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);" + << "b" << 0 << true << "get(0).b == 123"; + + QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});" + << "b" << 0 << false << "get(0).b == 456"; + QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);" + << "b" << 0 << false << "get(0).b == 456"; + + // Following tests only call set() since setProperty() only allows plain + // values, not lists, as the argument. + // Note that when a list is changed, itemsChanged() is currently always + // emitted regardless of whether it actually changed or not. + + QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2"; + + QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3"; + + QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});" + << "b" << 0 << true << "get(0).b.count == 0"; + + QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3"; + + QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});" + << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3"; + + QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});" + << "b" << 0 << true << "get(0).b.count == 0"; +} + +void tst_qdeclarativelistmodel::property_changes_worker() +{ + // nested models are not supported when WorkerScript is involved + if (QByteArray(QTest::currentDataTag()).startsWith("nested-")) + return; + + QFETCH(QString, script_setup); + QFETCH(QString, script_change); + QFETCH(QString, roleName); + QFETCH(int, listIndex); + QFETCH(bool, itemsChanged); + + QDeclarative1ListModel model; + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); + QDeclarativeItem *item = createWorkerTest(&engine, &component, &model); + QVERIFY(item != 0); + + QDeclarativeExpression expr(engine.rootContext(), &model, script_setup); + expr.evaluate(); + QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); + + QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList))); + + QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", + Q_ARG(QVariant, QStringList(script_change)))); + waitForWorker(item); + + // test itemsChanged() is emitted correctly + if (itemsChanged) { + QCOMPARE(spyItemsChanged.count(), 1); + QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); + QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); + } else { + QCOMPARE(spyItemsChanged.count(), 0); + } + + delete item; + qApp->processEvents(); +} + +void tst_qdeclarativelistmodel::property_changes_worker_data() +{ + property_changes_data(); +} + +void tst_qdeclarativelistmodel::clear() +{ + QDeclarativeEngine engine; + QDeclarative1ListModel model; + QDeclarativeEngine::setContextForObject(&model, engine.rootContext()); + engine.rootContext()->setContextProperty("model", &model); + + model.clear(); + QCOMPARE(model.count(), 0); + + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); + QCOMPARE(model.count(), 1); + + model.clear(); + QCOMPARE(model.count(), 0); + + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); + QCOMPARE(model.count(), 2); + + model.clear(); + QCOMPARE(model.count(), 0); + + // clearing does not remove the roles + RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})"); + QList roles = model.roles(); + model.clear(); + QCOMPARE(model.count(), 0); + QCOMPARE(model.roles(), roles); + QCOMPARE(model.toString(roles[0]), QString("propertyA")); + QCOMPARE(model.toString(roles[1]), QString("propertyB")); + QCOMPARE(model.toString(roles[2]), QString("propertyC")); +} + +QTEST_MAIN(tst_qdeclarativelistmodel) + +#include "tst_qdeclarativelistmodel.moc" diff --git a/tests/auto/declarative/qdeclarativelistview/data/attachedSignals.qml b/tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/attachedSignals.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/displaylist.qml b/tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/displaylist.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/footer.qml b/tests/auto/qtquick1/qdeclarativelistview/data/footer.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/footer.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/footer.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/header.qml b/tests/auto/qtquick1/qdeclarativelistview/data/header.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/header.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/header.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/header1.qml b/tests/auto/qtquick1/qdeclarativelistview/data/header1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/header1.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/header1.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/headerfooter.qml b/tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/headerfooter.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/itemlist.qml b/tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/itemlist.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/listview-enforcerange.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-noCurrent.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/listview-noCurrent.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/listview-sections.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-sections_delegate.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/listview-sections_delegate.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/listviewtest.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml b/tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/orientchange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/orientchange.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/propertychangestest.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/qtbug14821.qml b/tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/qtbug14821.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml b/tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/qtbug16037.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/rightToLeft.qml b/tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/rightToLeft.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml b/tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/sizelessthan1.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml diff --git a/tests/auto/declarative/qdeclarativelistview/data/strictlyenforcerange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/data/strictlyenforcerange.qml rename to tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml diff --git a/tests/auto/declarative/qdeclarativelistview/incrementalmodel.cpp b/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/incrementalmodel.cpp rename to tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp diff --git a/tests/auto/declarative/qdeclarativelistview/incrementalmodel.h b/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h similarity index 100% rename from tests/auto/declarative/qdeclarativelistview/incrementalmodel.h rename to tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro similarity index 82% rename from tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro rename to tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro index 77e6261c2a..0454d4476a 100644 --- a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro +++ b/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 macx:CONFIG -= app_bundle HEADERS += incrementalmodel.h @@ -14,4 +14,4 @@ symbian: { } CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp similarity index 86% rename from tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp rename to tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp index 7bb15c5ce8..d55a851ede 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -41,15 +41,14 @@ #include #include -#include +#include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include "../../../shared/util.h" #include "incrementalmodel.h" @@ -59,11 +58,11 @@ #define SRCDIR "." #endif -class tst_QDeclarativeListView : public QObject +class tst_QDeclarative1ListView : public QObject { Q_OBJECT public: - tst_QDeclarativeListView(); + tst_QDeclarative1ListView(); private slots: // Test both QListModelInterface and QAbstractItemModel model types @@ -355,12 +354,12 @@ class TestModel2 : public QAbstractListModel QList > list; }; -tst_QDeclarativeListView::tst_QDeclarativeListView() +tst_QDeclarative1ListView::tst_QDeclarative1ListView() { } template -void tst_QDeclarativeListView::items() +void tst_QDeclarative1ListView::items() { QDeclarativeView *canvas = createView(); @@ -378,7 +377,7 @@ void tst_QDeclarativeListView::items() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -396,10 +395,10 @@ void tst_QDeclarativeListView::items() QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 0)); for (int i = 0; i < model.count(); ++i) { - QDeclarativeText *name = findItem(contentItem, "textName", i); + QDeclarative1Text *name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem(contentItem, "textNumber", i); + QDeclarative1Text *number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -440,7 +439,7 @@ void tst_QDeclarativeListView::items() template -void tst_QDeclarativeListView::changed() +void tst_QDeclarative1ListView::changed() { QDeclarativeView *canvas = createView(); @@ -458,17 +457,17 @@ void tst_QDeclarativeListView::changed() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeFlickable *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1Flickable *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); model.modifyItem(1, "Will", "9876"); - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -477,7 +476,7 @@ void tst_QDeclarativeListView::changed() } template -void tst_QDeclarativeListView::inserted() +void tst_QDeclarative1ListView::inserted() { QDeclarativeView *canvas = createView(); @@ -495,7 +494,7 @@ void tst_QDeclarativeListView::inserted() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -505,10 +504,10 @@ void tst_QDeclarativeListView::inserted() QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -523,10 +522,10 @@ void tst_QDeclarativeListView::inserted() QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - name = findItem(contentItem, "textName", 0); + name = findItem(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); + number = findItem(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -563,7 +562,7 @@ void tst_QDeclarativeListView::inserted() } template -void tst_QDeclarativeListView::removed(bool animated) +void tst_QDeclarative1ListView::removed(bool animated) { QDeclarativeView *canvas = createView(); @@ -581,7 +580,7 @@ void tst_QDeclarativeListView::removed(bool animated) canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -590,10 +589,10 @@ void tst_QDeclarativeListView::removed(bool animated) model.removeItem(1); QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); @@ -611,10 +610,10 @@ void tst_QDeclarativeListView::removed(bool animated) QTest::qWait(300); - name = findItem(contentItem, "textName", 0); + name = findItem(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); + number = findItem(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -714,7 +713,7 @@ void tst_QDeclarativeListView::removed(bool animated) model.removeItems(2, 1); model.addItem("New", "1"); - QTRY_VERIFY(name = findItem(contentItem, "textName", model.count()-1)); + QTRY_VERIFY(name = findItem(contentItem, "textName", model.count()-1)); QCOMPARE(name->text(), QString("New")); // Add some more items so that we don't run out @@ -732,7 +731,7 @@ void tst_QDeclarativeListView::removed(bool animated) } template -void tst_QDeclarativeListView::clear() +void tst_QDeclarative1ListView::clear() { QDeclarativeView *canvas = createView(); @@ -749,7 +748,7 @@ void tst_QDeclarativeListView::clear() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -774,7 +773,7 @@ void tst_QDeclarativeListView::clear() template -void tst_QDeclarativeListView::moved() +void tst_QDeclarative1ListView::moved() { QDeclarativeView *canvas = createView(); @@ -791,7 +790,7 @@ void tst_QDeclarativeListView::moved() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -799,17 +798,17 @@ void tst_QDeclarativeListView::moved() model.moveItem(1, 4); - QDeclarativeText *name = findItem(contentItem, "textName", 1); + QDeclarative1Text *name = findItem(contentItem, "textName", 1); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(1)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 1); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(1)); - name = findItem(contentItem, "textName", 4); + name = findItem(contentItem, "textName", 4); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(4)); - number = findItem(contentItem, "textNumber", 4); + number = findItem(contentItem, "textNumber", 4); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(4)); @@ -833,10 +832,10 @@ void tst_QDeclarativeListView::moved() if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.0 + 20); - name = findItem(contentItem, "textName", i); + name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); + number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -850,10 +849,10 @@ void tst_QDeclarativeListView::moved() if (!item) qWarning() << "Item" << i << "not found"; QTRY_VERIFY(item); QTRY_COMPARE(item->y(), i*20.0 + 20); - name = findItem(contentItem, "textName", i); + name = findItem(contentItem, "textName", i); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); + number = findItem(contentItem, "textNumber", i); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(i)); } @@ -862,7 +861,7 @@ void tst_QDeclarativeListView::moved() delete testObject; } -void tst_QDeclarativeListView::enforceRange() +void tst_QDeclarative1ListView::enforceRange() { QDeclarativeView *canvas = createView(); @@ -876,12 +875,12 @@ void tst_QDeclarativeListView::enforceRange() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-enforcerange.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0); QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange); + QTRY_COMPARE(listview->highlightRangeMode(), QDeclarative1ListView::StrictlyEnforceRange); QDeclarativeItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); @@ -891,10 +890,10 @@ void tst_QDeclarativeListView::enforceRange() QTRY_VERIFY(item); QTRY_COMPARE(listview->contentY(), -100.0); - QDeclarativeText *name = findItem(contentItem, "textName", 0); + QDeclarative1Text *name = findItem(contentItem, "textName", 0); QTRY_VERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(0)); - QDeclarativeText *number = findItem(contentItem, "textNumber", 0); + QDeclarative1Text *number = findItem(contentItem, "textNumber", 0); QTRY_VERIFY(number != 0); QTRY_COMPARE(number->text(), model.number(0)); @@ -914,7 +913,7 @@ void tst_QDeclarativeListView::enforceRange() delete canvas; } -void tst_QDeclarativeListView::spacing() +void tst_QDeclarative1ListView::spacing() { QDeclarativeView *canvas = createView(); @@ -931,7 +930,7 @@ void tst_QDeclarativeListView::spacing() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -973,7 +972,7 @@ void tst_QDeclarativeListView::spacing() delete testObject; } -void tst_QDeclarativeListView::sections() +void tst_QDeclarative1ListView::sections() { QDeclarativeView *canvas = createView(); @@ -987,7 +986,7 @@ void tst_QDeclarativeListView::sections() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -999,7 +998,7 @@ void tst_QDeclarativeListView::sections() QDeclarativeItem *item = findItem(contentItem, "wrapper", i); QTRY_VERIFY(item); QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20)); - QDeclarativeText *next = findItem(item, "nextSection"); + QDeclarative1Text *next = findItem(item, "nextSection"); QCOMPARE(next->text().toInt(), (i+1)/5); } @@ -1062,7 +1061,7 @@ void tst_QDeclarativeListView::sections() delete canvas; } -void tst_QDeclarativeListView::sectionsDelegate() +void tst_QDeclarative1ListView::sectionsDelegate() { QDeclarativeView *canvas = createView(); @@ -1076,7 +1075,7 @@ void tst_QDeclarativeListView::sectionsDelegate() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections_delegate.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1088,7 +1087,7 @@ void tst_QDeclarativeListView::sectionsDelegate() QDeclarativeItem *item = findItem(contentItem, "wrapper", i); QTRY_VERIFY(item); QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20)); - QDeclarativeText *next = findItem(item, "nextSection"); + QDeclarative1Text *next = findItem(item, "nextSection"); QCOMPARE(next->text().toInt(), (i+1)/5); } @@ -1173,7 +1172,7 @@ void tst_QDeclarativeListView::sectionsDelegate() delete canvas; } -void tst_QDeclarativeListView::currentIndex() +void tst_QDeclarative1ListView::currentIndex() { TestModel model; for (int i = 0; i < 30; i++) @@ -1191,7 +1190,7 @@ void tst_QDeclarativeListView::currentIndex() qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1274,7 +1273,7 @@ void tst_QDeclarativeListView::currentIndex() delete canvas; } -void tst_QDeclarativeListView::noCurrentIndex() +void tst_QDeclarative1ListView::noCurrentIndex() { TestModel model; for (int i = 0; i < 30; i++) @@ -1291,7 +1290,7 @@ void tst_QDeclarativeListView::noCurrentIndex() qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1312,20 +1311,20 @@ void tst_QDeclarativeListView::noCurrentIndex() delete canvas; } -void tst_QDeclarativeListView::itemList() +void tst_QDeclarative1ListView::itemList() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "view"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "view"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild("itemModel"); + QDeclarative1VisualItemModel *model = canvas->rootObject()->findChild("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); @@ -1336,7 +1335,7 @@ void tst_QDeclarativeListView::itemList() QTRY_COMPARE(item->x(), 0.0); QCOMPARE(item->height(), listview->height()); - QDeclarativeText *text = findItem(contentItem, "text1"); + QDeclarative1Text *text = findItem(contentItem, "text1"); QTRY_VERIFY(text); QTRY_COMPARE(text->text(), QLatin1String("index: 0")); @@ -1346,14 +1345,14 @@ void tst_QDeclarativeListView::itemList() QTRY_VERIFY(item); QTRY_COMPARE(item->x(), 480.0); - text = findItem(contentItem, "text3"); + text = findItem(contentItem, "text3"); QTRY_VERIFY(text); QTRY_COMPARE(text->text(), QLatin1String("index: 2")); delete canvas; } -void tst_QDeclarativeListView::cacheBuffer() +void tst_QDeclarative1ListView::cacheBuffer() { QDeclarativeView *canvas = createView(); @@ -1370,7 +1369,7 @@ void tst_QDeclarativeListView::cacheBuffer() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1406,7 +1405,7 @@ void tst_QDeclarativeListView::cacheBuffer() delete testObject; } -void tst_QDeclarativeListView::positionViewAtIndex() +void tst_QDeclarative1ListView::positionViewAtIndex() { QDeclarativeView *canvas = createView(); @@ -1423,7 +1422,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1439,7 +1438,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position on a currently visible item - listview->positionViewAtIndex(3, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(3, QDeclarative1ListView::Beginning); QTRY_COMPARE(listview->contentY(), 60.); // Confirm items positioned correctly @@ -1452,7 +1451,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position on an item beyond the visible items - listview->positionViewAtIndex(22, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(22, QDeclarative1ListView::Beginning); QTRY_COMPARE(listview->contentY(), 440.); // Confirm items positioned correctly @@ -1465,7 +1464,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position on an item that would leave empty space if positioned at the top - listview->positionViewAtIndex(28, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(28, QDeclarative1ListView::Beginning); QTRY_COMPARE(listview->contentY(), 480.); // Confirm items positioned correctly @@ -1478,7 +1477,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position at the beginning again - listview->positionViewAtIndex(0, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(0, QDeclarative1ListView::Beginning); QTRY_COMPARE(listview->contentY(), 0.); // Confirm items positioned correctly @@ -1491,7 +1490,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position at End using last index - listview->positionViewAtIndex(model.count()-1, QDeclarativeListView::End); + listview->positionViewAtIndex(model.count()-1, QDeclarative1ListView::End); QTRY_COMPARE(listview->contentY(), 480.); // Confirm items positioned correctly @@ -1504,44 +1503,44 @@ void tst_QDeclarativeListView::positionViewAtIndex() } // Position at End - listview->positionViewAtIndex(20, QDeclarativeListView::End); + listview->positionViewAtIndex(20, QDeclarative1ListView::End); QTRY_COMPARE(listview->contentY(), 100.); // Position in Center - listview->positionViewAtIndex(15, QDeclarativeListView::Center); + listview->positionViewAtIndex(15, QDeclarative1ListView::Center); QTRY_COMPARE(listview->contentY(), 150.); // Ensure at least partially visible - listview->positionViewAtIndex(15, QDeclarativeListView::Visible); + listview->positionViewAtIndex(15, QDeclarative1ListView::Visible); QTRY_COMPARE(listview->contentY(), 150.); listview->setContentY(302); - listview->positionViewAtIndex(15, QDeclarativeListView::Visible); + listview->positionViewAtIndex(15, QDeclarative1ListView::Visible); QTRY_COMPARE(listview->contentY(), 302.); listview->setContentY(320); - listview->positionViewAtIndex(15, QDeclarativeListView::Visible); + listview->positionViewAtIndex(15, QDeclarative1ListView::Visible); QTRY_COMPARE(listview->contentY(), 300.); listview->setContentY(85); - listview->positionViewAtIndex(20, QDeclarativeListView::Visible); + listview->positionViewAtIndex(20, QDeclarative1ListView::Visible); QTRY_COMPARE(listview->contentY(), 85.); listview->setContentY(75); - listview->positionViewAtIndex(20, QDeclarativeListView::Visible); + listview->positionViewAtIndex(20, QDeclarative1ListView::Visible); QTRY_COMPARE(listview->contentY(), 100.); // Ensure completely visible listview->setContentY(120); - listview->positionViewAtIndex(20, QDeclarativeListView::Contain); + listview->positionViewAtIndex(20, QDeclarative1ListView::Contain); QTRY_COMPARE(listview->contentY(), 120.); listview->setContentY(302); - listview->positionViewAtIndex(15, QDeclarativeListView::Contain); + listview->positionViewAtIndex(15, QDeclarative1ListView::Contain); QTRY_COMPARE(listview->contentY(), 300.); listview->setContentY(85); - listview->positionViewAtIndex(20, QDeclarativeListView::Contain); + listview->positionViewAtIndex(20, QDeclarative1ListView::Contain); QTRY_COMPARE(listview->contentY(), 100.); // positionAtBeginnging @@ -1566,7 +1565,7 @@ void tst_QDeclarativeListView::positionViewAtIndex() delete testObject; } -void tst_QDeclarativeListView::resetModel() +void tst_QDeclarative1ListView::resetModel() { QDeclarativeView *canvas = createView(); @@ -1580,7 +1579,7 @@ void tst_QDeclarativeListView::resetModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1589,7 +1588,7 @@ void tst_QDeclarativeListView::resetModel() QTRY_COMPARE(listview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem(contentItem, "displayText", i); + QDeclarative1Text *display = findItem(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1601,7 +1600,7 @@ void tst_QDeclarativeListView::resetModel() QTRY_COMPARE(listview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem(contentItem, "displayText", i); + QDeclarative1Text *display = findItem(contentItem, "displayText", i); QTRY_VERIFY(display != 0); QTRY_COMPARE(display->text(), strings.at(i)); } @@ -1609,13 +1608,13 @@ void tst_QDeclarativeListView::resetModel() delete canvas; } -void tst_QDeclarativeListView::propertyChanges() +void tst_QDeclarative1ListView::propertyChanges() { QDeclarativeView *canvas = createView(); QTRY_VERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - QDeclarativeListView *listView = canvas->rootObject()->findChild("listView"); + QDeclarative1ListView *listView = canvas->rootObject()->findChild("listView"); QTRY_VERIFY(listView); QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged())); @@ -1629,26 +1628,26 @@ void tst_QDeclarativeListView::propertyChanges() QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true); QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0); QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0); - QTRY_COMPARE(listView->highlightRangeMode(), QDeclarativeListView::ApplyRange); + QTRY_COMPARE(listView->highlightRangeMode(), QDeclarative1ListView::ApplyRange); QTRY_COMPARE(listView->isWrapEnabled(), true); QTRY_COMPARE(listView->cacheBuffer(), 10); - QTRY_COMPARE(listView->snapMode(), QDeclarativeListView::SnapToItem); + QTRY_COMPARE(listView->snapMode(), QDeclarative1ListView::SnapToItem); listView->setHighlightFollowsCurrentItem(false); listView->setPreferredHighlightBegin(1.0); listView->setPreferredHighlightEnd(1.0); - listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange); + listView->setHighlightRangeMode(QDeclarative1ListView::StrictlyEnforceRange); listView->setWrapEnabled(false); listView->setCacheBuffer(3); - listView->setSnapMode(QDeclarativeListView::SnapOneItem); + listView->setSnapMode(QDeclarative1ListView::SnapOneItem); QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false); QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0); QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0); - QTRY_COMPARE(listView->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange); + QTRY_COMPARE(listView->highlightRangeMode(), QDeclarative1ListView::StrictlyEnforceRange); QTRY_COMPARE(listView->isWrapEnabled(), false); QTRY_COMPARE(listView->cacheBuffer(), 3); - QTRY_COMPARE(listView->snapMode(), QDeclarativeListView::SnapOneItem); + QTRY_COMPARE(listView->snapMode(), QDeclarative1ListView::SnapOneItem); QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); @@ -1661,10 +1660,10 @@ void tst_QDeclarativeListView::propertyChanges() listView->setHighlightFollowsCurrentItem(false); listView->setPreferredHighlightBegin(1.0); listView->setPreferredHighlightEnd(1.0); - listView->setHighlightRangeMode(QDeclarativeListView::StrictlyEnforceRange); + listView->setHighlightRangeMode(QDeclarative1ListView::StrictlyEnforceRange); listView->setWrapEnabled(false); listView->setCacheBuffer(3); - listView->setSnapMode(QDeclarativeListView::SnapOneItem); + listView->setSnapMode(QDeclarative1ListView::SnapOneItem); QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); @@ -1677,13 +1676,13 @@ void tst_QDeclarativeListView::propertyChanges() delete canvas; } -void tst_QDeclarativeListView::componentChanges() +void tst_QDeclarative1ListView::componentChanges() { QDeclarativeView *canvas = createView(); QTRY_VERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - QDeclarativeListView *listView = canvas->rootObject()->findChild("listView"); + QDeclarative1ListView *listView = canvas->rootObject()->findChild("listView"); QTRY_VERIFY(listView); QDeclarativeComponent component(canvas->engine()); @@ -1725,16 +1724,16 @@ void tst_QDeclarativeListView::componentChanges() delete canvas; } -void tst_QDeclarativeListView::modelChanges() +void tst_QDeclarative1ListView::modelChanges() { QDeclarativeView *canvas = createView(); QTRY_VERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - QDeclarativeListView *listView = canvas->rootObject()->findChild("listView"); + QDeclarative1ListView *listView = canvas->rootObject()->findChild("listView"); QTRY_VERIFY(listView); - QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); + QObject *alternateModel = canvas->rootObject()->findChild("alternateModel"); QTRY_VERIFY(alternateModel); QVariant modelVariant = QVariant::fromValue(alternateModel); QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); @@ -1752,14 +1751,14 @@ void tst_QDeclarativeListView::modelChanges() delete canvas; } -void tst_QDeclarativeListView::QTBUG_9791() +void tst_QDeclarative1ListView::QTBUG_9791() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/strictlyenforcerange.qml")); qApp->processEvents(); - QDeclarativeListView *listview = qobject_cast(canvas->rootObject()); + QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1787,7 +1786,7 @@ void tst_QDeclarativeListView::QTBUG_9791() delete canvas; } -void tst_QDeclarativeListView::manualHighlight() +void tst_QDeclarative1ListView::manualHighlight() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); @@ -1797,7 +1796,7 @@ void tst_QDeclarativeListView::manualHighlight() qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1814,7 +1813,7 @@ void tst_QDeclarativeListView::manualHighlight() QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); // QTBUG-15972 - listview->positionViewAtIndex(3, QDeclarativeListView::Contain); + listview->positionViewAtIndex(3, QDeclarative1ListView::Contain); QTRY_COMPARE(listview->currentIndex(), 2); QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 2)); @@ -1823,7 +1822,7 @@ void tst_QDeclarativeListView::manualHighlight() delete canvas; } -void tst_QDeclarativeListView::QTBUG_11105() +void tst_QDeclarative1ListView::QTBUG_11105() { QDeclarativeView *canvas = createView(); @@ -1840,7 +1839,7 @@ void tst_QDeclarativeListView::QTBUG_11105() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -1855,7 +1854,7 @@ void tst_QDeclarativeListView::QTBUG_11105() QTRY_VERIFY(item->y() == i*20); } - listview->positionViewAtIndex(20, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(20, QDeclarative1ListView::Beginning); QCOMPARE(listview->contentY(), 280.); TestModel model2; @@ -1871,7 +1870,7 @@ void tst_QDeclarativeListView::QTBUG_11105() delete testObject; } -void tst_QDeclarativeListView::header() +void tst_QDeclarative1ListView::header() { { QDeclarativeView *canvas = createView(); @@ -1886,13 +1885,13 @@ void tst_QDeclarativeListView::header() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QDeclarativeText *header = findItem(contentItem, "header"); + QDeclarative1Text *header = findItem(contentItem, "header"); QVERIFY(header); QCOMPARE(header->y(), 0.0); QCOMPARE(header->height(), 20.0); @@ -1907,9 +1906,9 @@ void tst_QDeclarativeListView::header() QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); - header = findItem(contentItem, "header"); + header = findItem(contentItem, "header"); QVERIFY(!header); - header = findItem(contentItem, "header2"); + header = findItem(contentItem, "header2"); QVERIFY(header); QCOMPARE(header->y(), 10.0); @@ -1926,13 +1925,13 @@ void tst_QDeclarativeListView::header() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header1.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QDeclarativeText *header = findItem(contentItem, "header"); + QDeclarative1Text *header = findItem(contentItem, "header"); QVERIFY(header); QCOMPARE(header->y(), 0.0); @@ -1945,7 +1944,7 @@ void tst_QDeclarativeListView::header() } } -void tst_QDeclarativeListView::footer() +void tst_QDeclarative1ListView::footer() { QDeclarativeView *canvas = createView(); @@ -1959,13 +1958,13 @@ void tst_QDeclarativeListView::footer() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QDeclarativeText *footer = findItem(contentItem, "footer"); + QDeclarative1Text *footer = findItem(contentItem, "footer"); QVERIFY(footer); QCOMPARE(footer->y(), 60.0); QCOMPARE(footer->height(), 30.0); @@ -1981,9 +1980,9 @@ void tst_QDeclarativeListView::footer() QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); - footer = findItem(contentItem, "footer"); + footer = findItem(contentItem, "footer"); QVERIFY(!footer); - footer = findItem(contentItem, "footer2"); + footer = findItem(contentItem, "footer2"); QVERIFY(footer); QCOMPARE(footer->y(), 600.0); @@ -1993,7 +1992,7 @@ void tst_QDeclarativeListView::footer() delete canvas; } -class LVAccessor : public QDeclarativeListView +class LVAccessor : public QDeclarative1ListView { public: qreal minY() const { return minYExtent(); } @@ -2002,7 +2001,7 @@ class LVAccessor : public QDeclarativeListView qreal maxX() const { return maxXExtent(); } }; -void tst_QDeclarativeListView::headerFooter() +void tst_QDeclarative1ListView::headerFooter() { { // Vertical @@ -2015,7 +2014,7 @@ void tst_QDeclarativeListView::headerFooter() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/headerfooter.qml")); qApp->processEvents(); - QDeclarativeListView *listview = qobject_cast(canvas->rootObject()); + QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2046,7 +2045,7 @@ void tst_QDeclarativeListView::headerFooter() canvas->rootObject()->setProperty("horizontal", true); qApp->processEvents(); - QDeclarativeListView *listview = qobject_cast(canvas->rootObject()); + QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2078,7 +2077,7 @@ void tst_QDeclarativeListView::headerFooter() canvas->rootObject()->setProperty("rtl", true); qApp->processEvents(); - QDeclarativeListView *listview = qobject_cast(canvas->rootObject()); + QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2099,7 +2098,7 @@ void tst_QDeclarativeListView::headerFooter() } } -void tst_QDeclarativeListView::resizeView() +void tst_QDeclarative1ListView::resizeView() { QDeclarativeView *canvas = createView(); @@ -2116,7 +2115,7 @@ void tst_QDeclarativeListView::resizeView() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2144,7 +2143,7 @@ void tst_QDeclarativeListView::resizeView() delete testObject; } -void tst_QDeclarativeListView::sizeLessThan1() +void tst_QDeclarative1ListView::sizeLessThan1() { QDeclarativeView *canvas = createView(); @@ -2161,7 +2160,7 @@ void tst_QDeclarativeListView::sizeLessThan1() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/sizelessthan1.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2180,14 +2179,14 @@ void tst_QDeclarativeListView::sizeLessThan1() delete testObject; } -void tst_QDeclarativeListView::QTBUG_14821() +void tst_QDeclarative1ListView::QTBUG_14821() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug14821.qml")); qApp->processEvents(); - QDeclarativeListView *listview = qobject_cast(canvas->rootObject()); + QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2202,7 +2201,7 @@ void tst_QDeclarativeListView::QTBUG_14821() delete canvas; } -void tst_QDeclarativeListView::resizeDelegate() +void tst_QDeclarative1ListView::resizeDelegate() { QDeclarativeView *canvas = createView(); @@ -2217,7 +2216,7 @@ void tst_QDeclarativeListView::resizeDelegate() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2250,8 +2249,8 @@ void tst_QDeclarativeListView::resizeDelegate() QTRY_COMPARE(listview->highlightItem()->y(), 750.0); listview->setCurrentIndex(1); - listview->positionViewAtIndex(25, QDeclarativeListView::Beginning); - listview->positionViewAtIndex(5, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(25, QDeclarative1ListView::Beginning); + listview->positionViewAtIndex(5, QDeclarative1ListView::Beginning); for (int i = 5; i < 16; ++i) { QDeclarativeItem *item = findItem(contentItem, "wrapper", i); @@ -2277,14 +2276,14 @@ void tst_QDeclarativeListView::resizeDelegate() delete canvas; } -void tst_QDeclarativeListView::QTBUG_16037() +void tst_QDeclarative1ListView::QTBUG_16037() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug16037.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "listview"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "listview"); QTRY_VERIFY(listview != 0); QVERIFY(listview->contentHeight() <= 0.0); @@ -2296,7 +2295,7 @@ void tst_QDeclarativeListView::QTBUG_16037() delete canvas; } -void tst_QDeclarativeListView::indexAt() +void tst_QDeclarative1ListView::indexAt() { QDeclarativeView *canvas = createView(); @@ -2313,7 +2312,7 @@ void tst_QDeclarativeListView::indexAt() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2329,7 +2328,7 @@ void tst_QDeclarativeListView::indexAt() delete testObject; } -void tst_QDeclarativeListView::incrementalModel() +void tst_QDeclarative1ListView::incrementalModel() { QDeclarativeView *canvas = createView(); @@ -2340,7 +2339,7 @@ void tst_QDeclarativeListView::incrementalModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2348,14 +2347,14 @@ void tst_QDeclarativeListView::incrementalModel() QTRY_COMPARE(listview->count(), 20); - listview->positionViewAtIndex(10, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(10, QDeclarative1ListView::Beginning); QTRY_COMPARE(listview->count(), 25); delete canvas; } -void tst_QDeclarativeListView::onAdd() +void tst_QDeclarative1ListView::onAdd() { QFETCH(int, initialItemCount); QFETCH(int, itemsToAdd); @@ -2394,7 +2393,7 @@ void tst_QDeclarativeListView::onAdd() delete canvas; } -void tst_QDeclarativeListView::onAdd_data() +void tst_QDeclarative1ListView::onAdd_data() { QTest::addColumn("initialItemCount"); QTest::addColumn("itemsToAdd"); @@ -2412,7 +2411,7 @@ void tst_QDeclarativeListView::onAdd_data() QTest::newRow("5, add 10") << 5 << 10; } -void tst_QDeclarativeListView::onRemove() +void tst_QDeclarative1ListView::onRemove() { QFETCH(int, initialItemCount); QFETCH(int, indexToRemove); @@ -2439,7 +2438,7 @@ void tst_QDeclarativeListView::onRemove() delete canvas; } -void tst_QDeclarativeListView::onRemove_data() +void tst_QDeclarative1ListView::onRemove_data() { QTest::addColumn("initialItemCount"); QTest::addColumn("indexToRemove"); @@ -2462,7 +2461,7 @@ void tst_QDeclarativeListView::onRemove_data() QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; } -void tst_QDeclarativeListView::testQtQuick11Attributes() +void tst_QDeclarative1ListView::testQtQuick11Attributes() { QFETCH(QString, code); QFETCH(QString, warning); @@ -2486,7 +2485,7 @@ void tst_QDeclarativeListView::testQtQuick11Attributes() delete obj; } -void tst_QDeclarativeListView::testQtQuick11Attributes_data() +void tst_QDeclarative1ListView::testQtQuick11Attributes_data() { QTest::addColumn("code"); QTest::addColumn("warning"); @@ -2501,7 +2500,7 @@ void tst_QDeclarativeListView::testQtQuick11Attributes_data() << ""; } -void tst_QDeclarativeListView::rightToLeft() +void tst_QDeclarative1ListView::rightToLeft() { QDeclarativeView *canvas = createView(); canvas->setFixedSize(640,320); @@ -2509,13 +2508,13 @@ void tst_QDeclarativeListView::rightToLeft() qApp->processEvents(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "view"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "view"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != 0); - QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild("itemModel"); + QDeclarative1VisualItemModel *model = canvas->rootObject()->findChild("itemModel"); QTRY_VERIFY(model != 0); QTRY_VERIFY(model->count() == 3); @@ -2529,7 +2528,7 @@ void tst_QDeclarativeListView::rightToLeft() QTRY_COMPARE(item->x(), -100.0); QCOMPARE(item->height(), listview->height()); - QDeclarativeText *text = findItem(contentItem, "text1"); + QDeclarative1Text *text = findItem(contentItem, "text1"); QTRY_VERIFY(text); QTRY_COMPARE(text->text(), QLatin1String("index: 0")); @@ -2539,7 +2538,7 @@ void tst_QDeclarativeListView::rightToLeft() QTRY_VERIFY(item); QTRY_COMPARE(item->x(), -540.0); - text = findItem(contentItem, "text3"); + text = findItem(contentItem, "text3"); QTRY_VERIFY(text); QTRY_COMPARE(text->text(), QLatin1String("index: 2")); @@ -2552,16 +2551,16 @@ void tst_QDeclarativeListView::rightToLeft() delete canvas; } -void tst_QDeclarativeListView::test_mirroring() +void tst_QDeclarative1ListView::test_mirroring() { QDeclarativeView *canvasA = createView(); canvasA->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml")); - QDeclarativeListView *listviewA = findItem(canvasA->rootObject(), "view"); + QDeclarative1ListView *listviewA = findItem(canvasA->rootObject(), "view"); QTRY_VERIFY(listviewA != 0); QDeclarativeView *canvasB = createView(); canvasB->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml")); - QDeclarativeListView *listviewB = findItem(canvasB->rootObject(), "view"); + QDeclarative1ListView *listviewB = findItem(canvasB->rootObject(), "view"); QTRY_VERIFY(listviewA != 0); qApp->processEvents(); @@ -2613,20 +2612,20 @@ void tst_QDeclarativeListView::test_mirroring() delete canvasB; } -void tst_QDeclarativeListView::orientationChange() +void tst_QDeclarative1ListView::orientationChange() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/orientchange.qml")); qApp->processEvents(); - QDeclarativeListView *listview = qobject_cast(canvas->rootObject()); + QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - listview->positionViewAtIndex(50, QDeclarativeListView::Beginning); + listview->positionViewAtIndex(50, QDeclarative1ListView::Beginning); // Confirm items positioned correctly for (int i = 50; i < 54; ++i) { @@ -2635,7 +2634,7 @@ void tst_QDeclarativeListView::orientationChange() QCOMPARE(item->y(), i*80.0); } - listview->setOrientation(QDeclarativeListView::Horizontal); + listview->setOrientation(QDeclarative1ListView::Horizontal); QCOMPARE(listview->contentY(), 0.); // Confirm items positioned correctly @@ -2645,8 +2644,8 @@ void tst_QDeclarativeListView::orientationChange() QCOMPARE(item->x(), i*80.0); } - listview->positionViewAtIndex(50, QDeclarativeListView::Beginning); - listview->setOrientation(QDeclarativeListView::Vertical); + listview->positionViewAtIndex(50, QDeclarative1ListView::Beginning); + listview->setOrientation(QDeclarative1ListView::Vertical); QCOMPARE(listview->contentX(), 0.); // // Confirm items positioned correctly @@ -2659,7 +2658,7 @@ void tst_QDeclarativeListView::orientationChange() delete canvas; } -void tst_QDeclarativeListView::contentPosJump() +void tst_QDeclarative1ListView::contentPosJump() { QDeclarativeView *canvas = createView(); @@ -2676,7 +2675,7 @@ void tst_QDeclarativeListView::contentPosJump() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); qApp->processEvents(); - QDeclarativeListView *listview = findItem(canvas->rootObject(), "list"); + QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -2714,69 +2713,69 @@ void tst_QDeclarativeListView::contentPosJump() delete canvas; } -void tst_QDeclarativeListView::qListModelInterface_items() +void tst_QDeclarative1ListView::qListModelInterface_items() { items(); } -void tst_QDeclarativeListView::qAbstractItemModel_items() +void tst_QDeclarative1ListView::qAbstractItemModel_items() { items(); } -void tst_QDeclarativeListView::qListModelInterface_changed() +void tst_QDeclarative1ListView::qListModelInterface_changed() { changed(); } -void tst_QDeclarativeListView::qAbstractItemModel_changed() +void tst_QDeclarative1ListView::qAbstractItemModel_changed() { changed(); } -void tst_QDeclarativeListView::qListModelInterface_inserted() +void tst_QDeclarative1ListView::qListModelInterface_inserted() { inserted(); } -void tst_QDeclarativeListView::qAbstractItemModel_inserted() +void tst_QDeclarative1ListView::qAbstractItemModel_inserted() { inserted(); } -void tst_QDeclarativeListView::qListModelInterface_removed() +void tst_QDeclarative1ListView::qListModelInterface_removed() { removed(false); removed(true); } -void tst_QDeclarativeListView::qAbstractItemModel_removed() +void tst_QDeclarative1ListView::qAbstractItemModel_removed() { removed(false); removed(true); } -void tst_QDeclarativeListView::qListModelInterface_moved() +void tst_QDeclarative1ListView::qListModelInterface_moved() { moved(); } -void tst_QDeclarativeListView::qAbstractItemModel_moved() +void tst_QDeclarative1ListView::qAbstractItemModel_moved() { moved(); } -void tst_QDeclarativeListView::qListModelInterface_clear() +void tst_QDeclarative1ListView::qListModelInterface_clear() { clear(); } -void tst_QDeclarativeListView::qAbstractItemModel_clear() +void tst_QDeclarative1ListView::qAbstractItemModel_clear() { clear(); } -QDeclarativeView *tst_QDeclarativeListView::createView() +QDeclarativeView *tst_QDeclarative1ListView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); @@ -2789,7 +2788,7 @@ QDeclarativeView *tst_QDeclarativeListView::createView() item must also evaluate the {index} expression equal to index */ template -T *tst_QDeclarativeListView::findItem(QGraphicsObject *parent, const QString &objectName, int index) +T *tst_QDeclarative1ListView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->childItems().count() << "children"; @@ -2816,7 +2815,7 @@ T *tst_QDeclarativeListView::findItem(QGraphicsObject *parent, const QString &ob } template -QList tst_QDeclarativeListView::findItems(QGraphicsObject *parent, const QString &objectName) +QList tst_QDeclarative1ListView::findItems(QGraphicsObject *parent, const QString &objectName) { QList items; const QMetaObject &mo = T::staticMetaObject; @@ -2834,7 +2833,7 @@ QList tst_QDeclarativeListView::findItems(QGraphicsObject *parent, const QSt return items; } -void tst_QDeclarativeListView::dumpTree(QDeclarativeItem *parent, int depth) +void tst_QDeclarative1ListView::dumpTree(QDeclarativeItem *parent, int depth) { static QString padding(" "); for (int i = 0; i < parent->childItems().count(); ++i) { @@ -2847,6 +2846,6 @@ void tst_QDeclarativeListView::dumpTree(QDeclarativeItem *parent, int depth) } -QTEST_MAIN(tst_QDeclarativeListView) +QTEST_MAIN(tst_QDeclarative1ListView) #include "tst_qdeclarativelistview.moc" diff --git a/tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/BlueRect.qml b/tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/BlueRect.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/CreationContextLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/CreationContextLoader.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/GraphicsWidget250x250.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/GreenRect.qml b/tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/GreenRect.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/NoResize.qml b/tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/NoResize.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml b/tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/NoResizeGraphicsWidget.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/QTBUG_16928.qml b/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/QTBUG_16928.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/QTBUG_17114.qml b/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/QTBUG_17114.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml b/tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/Rect120x60.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/SetSourceComponent.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/SizeToItem.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/SizeToLoader.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/VmeError.qml b/tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/VmeError.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/crash.qml b/tests/auto/qtquick1/qdeclarativeloader/data/crash.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/crash.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/crash.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/creationContext.qml b/tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/creationContext.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/differentorigin.qml b/tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/differentorigin.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/implicitSize.qml b/tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/implicitSize.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/nonItem.qml b/tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/nonItem.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/qmldir b/tests/auto/qtquick1/qdeclarativeloader/data/qmldir similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/qmldir rename to tests/auto/qtquick1/qdeclarativeloader/data/qmldir diff --git a/tests/auto/declarative/qdeclarativeloader/data/sameorigin-load.qml b/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/sameorigin-load.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/sameorigin.qml b/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/sameorigin.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml diff --git a/tests/auto/declarative/qdeclarativeloader/data/vmeErrors.qml b/tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeloader/data/vmeErrors.qml rename to tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml diff --git a/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro new file mode 100644 index 0000000000..980e58461c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro @@ -0,0 +1,20 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network qtquick1 +macx:CONFIG -= app_bundle + +INCLUDEPATH += ../../declarative/shared/ +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += tst_qdeclarativeloader.cpp \ + ../../declarative/shared/testhttpserver.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp similarity index 84% rename from tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp rename to tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp index 0d96efebbd..baed4973dc 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "testhttpserver.h" #include "../../../shared/util.h" @@ -61,12 +61,12 @@ inline QUrl TEST_FILE(const QString &filename) return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); } -class tst_QDeclarativeLoader : public QObject +class tst_QDeclarative1Loader : public QObject { Q_OBJECT public: - tst_QDeclarativeLoader(); + tst_QDeclarative1Loader(); private slots: void sourceOrComponent(); @@ -98,11 +98,11 @@ private slots: }; -tst_QDeclarativeLoader::tst_QDeclarativeLoader() +tst_QDeclarative1Loader::tst_QDeclarative1Loader() { } -void tst_QDeclarativeLoader::sourceOrComponent() +void tst_QDeclarative1Loader::sourceOrComponent() { QFETCH(QString, sourceDefinition); QFETCH(QUrl, sourceUrl); @@ -131,13 +131,13 @@ void tst_QDeclarativeLoader::sourceOrComponent() "}") , TEST_FILE("")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->item() == 0, error); QCOMPARE(loader->source(), sourceUrl); QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), error ? QDeclarativeLoader::Error : QDeclarativeLoader::Ready); + QCOMPARE(loader->status(), error ? QDeclarative1Loader::Error : QDeclarative1Loader::Ready); QCOMPARE(static_cast(loader)->children().count(), error ? 0: 1); if (!error) { @@ -156,7 +156,7 @@ void tst_QDeclarativeLoader::sourceOrComponent() delete loader; } -void tst_QDeclarativeLoader::sourceOrComponent_data() +void tst_QDeclarative1Loader::sourceOrComponent_data() { QTest::addColumn("sourceDefinition"); QTest::addColumn("sourceUrl"); @@ -169,7 +169,7 @@ void tst_QDeclarativeLoader::sourceOrComponent_data() << QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found"); } -void tst_QDeclarativeLoader::clear() +void tst_QDeclarative1Loader::clear() { { QDeclarativeComponent component(&engine); @@ -180,7 +180,7 @@ void tst_QDeclarativeLoader::clear() " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" " }") , TEST_FILE("")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -188,7 +188,7 @@ void tst_QDeclarativeLoader::clear() QTRY_VERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QDeclarativeLoader::Null); + QCOMPARE(loader->status(), QDeclarative1Loader::Null); QCOMPARE(static_cast(loader)->children().count(), 0); delete loader; @@ -198,7 +198,7 @@ void tst_QDeclarativeLoader::clear() QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); - QDeclarativeLoader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); + QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); QVERIFY(loader); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -208,7 +208,7 @@ void tst_QDeclarativeLoader::clear() QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QDeclarativeLoader::Null); + QCOMPARE(loader->status(), QDeclarative1Loader::Null); QCOMPARE(static_cast(loader)->children().count(), 0); delete item; @@ -218,7 +218,7 @@ void tst_QDeclarativeLoader::clear() QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); - QDeclarativeLoader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); + QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); QVERIFY(loader); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -228,14 +228,14 @@ void tst_QDeclarativeLoader::clear() QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QDeclarativeLoader::Null); + QCOMPARE(loader->status(), QDeclarative1Loader::Null); QCOMPARE(static_cast(loader)->children().count(), 0); delete item; } } -void tst_QDeclarativeLoader::urlToComponent() +void tst_QDeclarative1Loader::urlToComponent() { QDeclarativeComponent component(&engine); component.setData(QByteArray("import QtQuick 1.0\n" @@ -246,7 +246,7 @@ void tst_QDeclarativeLoader::urlToComponent() " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" "}" ) , TEST_FILE("")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QTest::qWait(200); QTRY_VERIFY(loader != 0); QVERIFY(loader->item()); @@ -258,13 +258,13 @@ void tst_QDeclarativeLoader::urlToComponent() delete loader; } -void tst_QDeclarativeLoader::componentToUrl() +void tst_QDeclarative1Loader::componentToUrl() { QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); - QDeclarativeLoader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); + QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); QVERIFY(loader); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -280,7 +280,7 @@ void tst_QDeclarativeLoader::componentToUrl() delete item; } -void tst_QDeclarativeLoader::anchoredLoader() +void tst_QDeclarative1Loader::anchoredLoader() { QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml")); QDeclarativeItem *rootItem = qobject_cast(component.create()); @@ -301,10 +301,10 @@ void tst_QDeclarativeLoader::anchoredLoader() QCOMPARE(sourceElement->height(), 200.0); } -void tst_QDeclarativeLoader::sizeLoaderToItem() +void tst_QDeclarative1Loader::sizeLoaderToItem() { QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->width(), 120.0); QCOMPARE(loader->height(), 60.0); @@ -342,10 +342,10 @@ void tst_QDeclarativeLoader::sizeLoaderToItem() delete loader; } -void tst_QDeclarativeLoader::sizeItemToLoader() +void tst_QDeclarative1Loader::sizeItemToLoader() { QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->width(), 200.0); QCOMPARE(loader->height(), 80.0); @@ -372,7 +372,7 @@ void tst_QDeclarativeLoader::sizeItemToLoader() delete loader; } -void tst_QDeclarativeLoader::noResize() +void tst_QDeclarative1Loader::noResize() { QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml")); QDeclarativeItem* item = qobject_cast(component.create()); @@ -383,10 +383,10 @@ void tst_QDeclarativeLoader::noResize() delete item; } -void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() +void tst_QDeclarative1Loader::sizeLoaderToGraphicsWidget() { QDeclarativeComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QGraphicsScene scene; scene.addItem(loader); @@ -410,10 +410,10 @@ void tst_QDeclarativeLoader::sizeLoaderToGraphicsWidget() delete loader; } -void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() +void tst_QDeclarative1Loader::sizeGraphicsWidgetToLoader() { QDeclarativeComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QGraphicsScene scene; scene.addItem(loader); @@ -442,7 +442,7 @@ void tst_QDeclarativeLoader::sizeGraphicsWidgetToLoader() delete loader; } -void tst_QDeclarativeLoader::noResizeGraphicsWidget() +void tst_QDeclarative1Loader::noResizeGraphicsWidget() { QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml")); QDeclarativeItem *item = qobject_cast(component.create()); @@ -456,7 +456,7 @@ void tst_QDeclarativeLoader::noResizeGraphicsWidget() delete item; } -void tst_QDeclarativeLoader::networkRequestUrl() +void tst_QDeclarative1Loader::networkRequestUrl() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -466,10 +466,10 @@ void tst_QDeclarativeLoader::networkRequestUrl() component.setData(QByteArray("import QtQuick 1.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); if (component.isError()) qDebug() << component.errors(); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); - QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready); + QTRY_VERIFY(loader->status() == QDeclarative1Loader::Ready); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -480,7 +480,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() } /* XXX Component waits until all dependencies are loaded. Is this actually possible? -void tst_QDeclarativeLoader::networkComponent() +void tst_QDeclarative1Loader::networkComponent() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -498,20 +498,20 @@ void tst_QDeclarativeLoader::networkComponent() QDeclarativeItem *item = qobject_cast(component.create()); QVERIFY(item); - QDeclarativeLoader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); + QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); QVERIFY(loader); - QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready); + QTRY_VERIFY(loader->status() == QDeclarative1Loader::Ready); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(loader->status(), QDeclarative1Loader::Ready); QCOMPARE(static_cast(loader)->children().count(), 1); delete loader; } */ -void tst_QDeclarativeLoader::failNetworkRequest() +void tst_QDeclarative1Loader::failNetworkRequest() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -521,10 +521,10 @@ void tst_QDeclarativeLoader::failNetworkRequest() QDeclarativeComponent component(&engine); component.setData(QByteArray("import QtQuick 1.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader != 0); - QTRY_VERIFY(loader->status() == QDeclarativeLoader::Error); + QTRY_VERIFY(loader->status() == QDeclarative1Loader::Error); QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); @@ -535,7 +535,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() } // QTBUG-9241 -void tst_QDeclarativeLoader::deleteComponentCrash() +void tst_QDeclarative1Loader::deleteComponentCrash() { QDeclarativeComponent component(&engine, TEST_FILE("crash.qml")); QDeclarativeItem *item = qobject_cast(component.create()); @@ -543,37 +543,37 @@ void tst_QDeclarativeLoader::deleteComponentCrash() item->metaObject()->invokeMethod(item, "setLoaderSource"); - QDeclarativeLoader *loader = qobject_cast(item->QGraphicsObject::children().at(0)); + QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(0)); QVERIFY(loader); QVERIFY(loader->item()); QCOMPARE(loader->item()->objectName(), QLatin1String("blue")); QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(loader->status(), QDeclarative1Loader::Ready); QCOMPARE(static_cast(loader)->children().count(), 1); QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/BlueRect.qml")); delete item; } -void tst_QDeclarativeLoader::nonItem() +void tst_QDeclarative1Loader::nonItem() { QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml")); QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/nonItem.qml:3:1: QML Loader: Loader does not support loading non-visual elements."; QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader); QVERIFY(loader->item() == 0); delete loader; } -void tst_QDeclarativeLoader::vmeErrors() +void tst_QDeclarative1Loader::vmeErrors() { QDeclarativeComponent component(&engine, TEST_FILE("vmeErrors.qml")); QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/VmeError.qml:6: Cannot assign object type QObject with no default method"; QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); - QDeclarativeLoader *loader = qobject_cast(component.create()); + QDeclarative1Loader *loader = qobject_cast(component.create()); QVERIFY(loader); QVERIFY(loader->item() == 0); @@ -581,7 +581,7 @@ void tst_QDeclarativeLoader::vmeErrors() } // QTBUG-13481 -void tst_QDeclarativeLoader::creationContext() +void tst_QDeclarative1Loader::creationContext() { QDeclarativeComponent component(&engine, TEST_FILE("creationContext.qml")); @@ -593,7 +593,7 @@ void tst_QDeclarativeLoader::creationContext() delete o; } -void tst_QDeclarativeLoader::QTBUG_16928() +void tst_QDeclarative1Loader::QTBUG_16928() { QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_16928.qml")); QDeclarativeItem *item = qobject_cast(component.create()); @@ -605,7 +605,7 @@ void tst_QDeclarativeLoader::QTBUG_16928() delete item; } -void tst_QDeclarativeLoader::implicitSize() +void tst_QDeclarative1Loader::implicitSize() { QDeclarativeComponent component(&engine, TEST_FILE("implicitSize.qml")); QDeclarativeItem *item = qobject_cast(component.create()); @@ -620,7 +620,7 @@ void tst_QDeclarativeLoader::implicitSize() delete item; } -void tst_QDeclarativeLoader::QTBUG_17114() +void tst_QDeclarative1Loader::QTBUG_17114() { QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_17114.qml")); QDeclarativeItem *item = qobject_cast(component.create()); @@ -632,6 +632,6 @@ void tst_QDeclarativeLoader::QTBUG_17114() delete item; } -QTEST_MAIN(tst_QDeclarativeLoader) +QTEST_MAIN(tst_QDeclarative1Loader) #include "tst_qdeclarativeloader.moc" diff --git a/tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/clickandhold.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/clicktwice.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/clicktwice.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/dragging.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/dragging.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/dragproperties.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/dragreset.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/dragreset.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/pressedOrdering.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/pressedOrdering.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/preventContextMenu.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/preventstealing.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/preventstealing.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/rejectEvent.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnClick.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnClick.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml diff --git a/tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnResize.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml similarity index 100% rename from tests/auto/declarative/qdeclarativemousearea/data/updateMousePosOnResize.qml rename to tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml diff --git a/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro new file mode 100644 index 0000000000..bc717ee521 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro @@ -0,0 +1,18 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network qtquick1 +macx:CONFIG -= app_bundle + +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += tst_qdeclarativemousearea.cpp ../../declarative/shared/testhttpserver.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp similarity index 90% rename from tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp rename to tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 7548ee0e9c..a84071045a 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -41,10 +41,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -54,7 +54,7 @@ #define SRCDIR "." #endif -class tst_QDeclarativeMouseArea: public QObject +class tst_QDeclarative1MouseArea: public QObject { Q_OBJECT private slots: @@ -79,7 +79,7 @@ private slots: QDeclarativeView *createView(); }; -void tst_QDeclarativeMouseArea::dragProperties() +void tst_QDeclarative1MouseArea::dragProperties() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragproperties.qml")); @@ -87,8 +87,8 @@ void tst_QDeclarativeMouseArea::dragProperties() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QDeclarativeDrag *drag = mouseRegion->drag(); + QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QDeclarative1Drag *drag = mouseRegion->drag(); QVERIFY(mouseRegion != 0); QVERIFY(drag != 0); @@ -105,12 +105,12 @@ void tst_QDeclarativeMouseArea::dragProperties() QCOMPARE(targetSpy.count(),1); // axis - QCOMPARE(drag->axis(), QDeclarativeDrag::XandYAxis); + QCOMPARE(drag->axis(), QDeclarative1Drag::XandYAxis); QSignalSpy axisSpy(drag, SIGNAL(axisChanged())); - drag->setAxis(QDeclarativeDrag::XAxis); - QCOMPARE(drag->axis(), QDeclarativeDrag::XAxis); + drag->setAxis(QDeclarative1Drag::XAxis); + QCOMPARE(drag->axis(), QDeclarative1Drag::XAxis); QCOMPARE(axisSpy.count(),1); - drag->setAxis(QDeclarativeDrag::XAxis); + drag->setAxis(QDeclarative1Drag::XAxis); QCOMPARE(axisSpy.count(),1); // minimum and maximum properties @@ -163,7 +163,7 @@ void tst_QDeclarativeMouseArea::dragProperties() delete canvas; } -void tst_QDeclarativeMouseArea::resetDrag() +void tst_QDeclarative1MouseArea::resetDrag() { QDeclarativeView *canvas = createView(); @@ -173,8 +173,8 @@ void tst_QDeclarativeMouseArea::resetDrag() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QDeclarativeDrag *drag = mouseRegion->drag(); + QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QDeclarative1Drag *drag = mouseRegion->drag(); QVERIFY(mouseRegion != 0); QVERIFY(drag != 0); @@ -194,7 +194,7 @@ void tst_QDeclarativeMouseArea::resetDrag() } -void tst_QDeclarativeMouseArea::dragging() +void tst_QDeclarative1MouseArea::dragging() { QDeclarativeView *canvas = createView(); @@ -203,8 +203,8 @@ void tst_QDeclarativeMouseArea::dragging() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QDeclarativeDrag *drag = mouseRegion->drag(); + QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QDeclarative1Drag *drag = mouseRegion->drag(); QVERIFY(mouseRegion != 0); QVERIFY(drag != 0); @@ -256,7 +256,7 @@ void tst_QDeclarativeMouseArea::dragging() delete canvas; } -QDeclarativeView *tst_QDeclarativeMouseArea::createView() +QDeclarativeView *tst_QDeclarative1MouseArea::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); @@ -264,7 +264,7 @@ QDeclarativeView *tst_QDeclarativeMouseArea::createView() return canvas; } -void tst_QDeclarativeMouseArea::updateMouseAreaPosOnClick() +void tst_QDeclarative1MouseArea::updateMouseAreaPosOnClick() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/updateMousePosOnClick.qml")); @@ -272,10 +272,10 @@ void tst_QDeclarativeMouseArea::updateMouseAreaPosOnClick() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); QVERIFY(mouseRegion != 0); - QDeclarativeRectangle *rect = canvas->rootObject()->findChild("ball"); + QDeclarative1Rectangle *rect = canvas->rootObject()->findChild("ball"); QVERIFY(rect != 0); QCOMPARE(mouseRegion->mouseX(), rect->x()); @@ -297,7 +297,7 @@ void tst_QDeclarativeMouseArea::updateMouseAreaPosOnClick() delete canvas; } -void tst_QDeclarativeMouseArea::updateMouseAreaPosOnResize() +void tst_QDeclarative1MouseArea::updateMouseAreaPosOnResize() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/updateMousePosOnResize.qml")); @@ -305,10 +305,10 @@ void tst_QDeclarativeMouseArea::updateMouseAreaPosOnResize() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeMouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); + QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); QVERIFY(mouseRegion != 0); - QDeclarativeRectangle *rect = canvas->rootObject()->findChild("brother"); + QDeclarative1Rectangle *rect = canvas->rootObject()->findChild("brother"); QVERIFY(rect != 0); QCOMPARE(mouseRegion->mouseX(), 0.0); @@ -337,7 +337,7 @@ void tst_QDeclarativeMouseArea::updateMouseAreaPosOnResize() delete canvas; } -void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() +void tst_QDeclarative1MouseArea::noOnClickedWithPressAndHold() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clickandhold.qml")); @@ -369,7 +369,7 @@ void tst_QDeclarativeMouseArea::noOnClickedWithPressAndHold() delete canvas; } -void tst_QDeclarativeMouseArea::onMousePressRejected() +void tst_QDeclarative1MouseArea::onMousePressRejected() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rejectEvent.qml")); @@ -414,7 +414,7 @@ void tst_QDeclarativeMouseArea::onMousePressRejected() delete canvas; } -void tst_QDeclarativeMouseArea::doubleClick() +void tst_QDeclarative1MouseArea::doubleClick() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/doubleclick.qml")); @@ -453,7 +453,7 @@ void tst_QDeclarativeMouseArea::doubleClick() } // QTBUG-14832 -void tst_QDeclarativeMouseArea::clickTwice() +void tst_QDeclarative1MouseArea::clickTwice() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clicktwice.qml")); @@ -494,7 +494,7 @@ void tst_QDeclarativeMouseArea::clickTwice() delete canvas; } -void tst_QDeclarativeMouseArea::pressedOrdering() +void tst_QDeclarative1MouseArea::pressedOrdering() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pressedOrdering.qml")); @@ -528,7 +528,7 @@ void tst_QDeclarativeMouseArea::pressedOrdering() delete canvas; } -void tst_QDeclarativeMouseArea::preventStealing() +void tst_QDeclarative1MouseArea::preventStealing() { QDeclarativeView *canvas = createView(); @@ -537,13 +537,13 @@ void tst_QDeclarativeMouseArea::preventStealing() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeFlickable *flickable = qobject_cast(canvas->rootObject()); + QDeclarative1Flickable *flickable = qobject_cast(canvas->rootObject()); QVERIFY(flickable != 0); - QDeclarativeMouseArea *mouseArea = canvas->rootObject()->findChild("mousearea"); + QDeclarative1MouseArea *mouseArea = canvas->rootObject()->findChild("mousearea"); QVERIFY(mouseArea != 0); - QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QDeclarativeMouseEvent*))); + QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QDeclarative1MouseEvent*))); QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(80, 80))); @@ -606,7 +606,7 @@ void tst_QDeclarativeMouseArea::preventStealing() delete canvas; } -void tst_QDeclarativeMouseArea::testQtQuick11Attributes() +void tst_QDeclarative1MouseArea::testQtQuick11Attributes() { QFETCH(QString, code); QFETCH(QString, warning); @@ -630,7 +630,7 @@ void tst_QDeclarativeMouseArea::testQtQuick11Attributes() delete obj; } -void tst_QDeclarativeMouseArea::testQtQuick11Attributes_data() +void tst_QDeclarative1MouseArea::testQtQuick11Attributes_data() { QTest::addColumn("code"); QTest::addColumn("warning"); @@ -662,7 +662,7 @@ class ContextMenuEventReceiver : public QDeclarativeItem int m_eventCount; }; -void tst_QDeclarativeMouseArea::preventContextMenu() +void tst_QDeclarative1MouseArea::preventContextMenu() { // A MouseArea accepting Left, Middle and Right buttons should prevent context menu // events with "Mouse" reason to hit the Item below. @@ -700,6 +700,6 @@ void tst_QDeclarativeMouseArea::preventContextMenu() } #endif // QT_NO_CONTEXTMENU -QTEST_MAIN(tst_QDeclarativeMouseArea) +QTEST_MAIN(tst_QDeclarative1MouseArea) #include "tst_qdeclarativemousearea.moc" diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particle.png b/tests/auto/qtquick1/qdeclarativeparticles/data/particle.png similarity index 100% rename from tests/auto/declarative/qdeclarativeparticles/data/particle.png rename to tests/auto/qtquick1/qdeclarativeparticles/data/particle.png diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particlemotiontest.qml b/tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeparticles/data/particlemotiontest.qml rename to tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml diff --git a/tests/auto/declarative/qdeclarativeparticles/data/particlestest.qml b/tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeparticles/data/particlestest.qml rename to tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml diff --git a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro similarity index 67% rename from tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro rename to tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro index 57bd1163cc..44bc1a9b30 100644 --- a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro +++ b/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeparticles.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1 diff --git a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp similarity index 99% rename from tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp rename to tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp index a724ac678e..a321c284c4 100644 --- a/tests/auto/declarative/qdeclarativeparticles/tst_qdeclarativeparticles.cpp +++ b/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include #include -#include +#include #include #ifdef Q_OS_SYMBIAN diff --git a/tests/auto/declarative/qdeclarativepathview/data/closedPath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/closedPath.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/datamodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/datamodel.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/displaypath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/displaypath.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/dragpath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/dragpath.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/emptymodel.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/openPath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/openPath.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathUpdate.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathUpdateOnStartChanged.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathtest.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathtest.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview0.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathview0.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview1.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathview1.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview2.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathview2.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview3.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathview3.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/propertychanges.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/treemodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/treemodel.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/undefinedpath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/undefinedpath.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml diff --git a/tests/auto/declarative/qdeclarativepathview/data/vdm.qml b/tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepathview/data/vdm.qml rename to tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro similarity index 80% rename from tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro rename to tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro index 8c5ef972a6..251277ef57 100644 --- a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro +++ b/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativepathview.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp similarity index 79% rename from tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp rename to tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp index 2d91b53ebb..194d42130d 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -40,16 +40,15 @@ ****************************************************************************/ #include -#include +#include #include #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -82,11 +81,11 @@ static void initStandardTreeModel(QStandardItemModel *model) } -class tst_QDeclarativePathView : public QObject +class tst_QDeclarative1PathView : public QObject { Q_OBJECT public: - tst_QDeclarativePathView(); + tst_QDeclarative1PathView(); private slots: void initValues(); @@ -212,15 +211,15 @@ class TestModel : public QAbstractListModel }; -tst_QDeclarativePathView::tst_QDeclarativePathView() +tst_QDeclarative1PathView::tst_QDeclarative1PathView() { } -void tst_QDeclarativePathView::initValues() +void tst_QDeclarative1PathView::initValues() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview1.qml")); - QDeclarativePathView *obj = qobject_cast(c.create()); + QDeclarative1PathView *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QVERIFY(obj->path() == 0); @@ -234,7 +233,7 @@ void tst_QDeclarativePathView::initValues() QCOMPARE(obj->pathItemCount(), -1); } -void tst_QDeclarativePathView::items() +void tst_QDeclarative1PathView::items() { QDeclarativeView *canvas = createView(); @@ -250,7 +249,7 @@ void tst_QDeclarativePathView::items() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); qApp->processEvents(); - QDeclarativePathView *pathview = findItem(canvas->rootObject(), "view"); + QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); QCOMPARE(pathview->count(), model.count()); @@ -258,15 +257,15 @@ void tst_QDeclarativePathView::items() QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight for (int i = 0; i < model.count(); ++i) { - QDeclarativeText *name = findItem(pathview, "textName", i); + QDeclarative1Text *name = findItem(pathview, "textName", i); QVERIFY(name != 0); QCOMPARE(name->text(), model.name(i)); - QDeclarativeText *number = findItem(pathview, "textNumber", i); + QDeclarative1Text *number = findItem(pathview, "textNumber", i); QVERIFY(number != 0); QCOMPARE(number->text(), model.number(i)); } - QDeclarativePath *path = qobject_cast(pathview->path()); + QDeclarative1Path *path = qobject_cast(pathview->path()); QVERIFY(path); QVERIFY(pathview->highlightItem()); @@ -279,11 +278,11 @@ void tst_QDeclarativePathView::items() delete canvas; } -void tst_QDeclarativePathView::pathview2() +void tst_QDeclarative1PathView::pathview2() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview2.qml")); - QDeclarativePathView *obj = qobject_cast(c.create()); + QDeclarative1PathView *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QVERIFY(obj->path() != 0); @@ -297,11 +296,11 @@ void tst_QDeclarativePathView::pathview2() QCOMPARE(obj->pathItemCount(), 10); } -void tst_QDeclarativePathView::pathview3() +void tst_QDeclarative1PathView::pathview3() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview3.qml")); - QDeclarativePathView *obj = qobject_cast(c.create()); + QDeclarative1PathView *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QVERIFY(obj->path() != 0); @@ -315,11 +314,11 @@ void tst_QDeclarativePathView::pathview3() QCOMPARE(obj->pathItemCount(), 4); } -void tst_QDeclarativePathView::path() +void tst_QDeclarative1PathView::path() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathtest.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); + QDeclarative1Path *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QCOMPARE(obj->startX(), 120.); @@ -329,28 +328,28 @@ void tst_QDeclarativePathView::path() QDeclarativeListReference list(obj, "pathElements"); QCOMPARE(list.count(), 5); - QDeclarativePathAttribute* attr = qobject_cast(list.at(0)); + QDeclarative1PathAttribute* attr = qobject_cast(list.at(0)); QVERIFY(attr != 0); QCOMPARE(attr->name(), QString("scale")); QCOMPARE(attr->value(), 1.0); - QDeclarativePathQuad* quad = qobject_cast(list.at(1)); + QDeclarative1PathQuad* quad = qobject_cast(list.at(1)); QVERIFY(quad != 0); QCOMPARE(quad->x(), 120.); QCOMPARE(quad->y(), 25.); QCOMPARE(quad->controlX(), 260.); QCOMPARE(quad->controlY(), 75.); - QDeclarativePathPercent* perc = qobject_cast(list.at(2)); + QDeclarative1PathPercent* perc = qobject_cast(list.at(2)); QVERIFY(perc != 0); QCOMPARE(perc->value(), 0.3); - QDeclarativePathLine* line = qobject_cast(list.at(3)); + QDeclarative1PathLine* line = qobject_cast(list.at(3)); QVERIFY(line != 0); QCOMPARE(line->x(), 120.); QCOMPARE(line->y(), 100.); - QDeclarativePathCubic* cubic = qobject_cast(list.at(4)); + QDeclarative1PathCubic* cubic = qobject_cast(list.at(4)); QVERIFY(cubic != 0); QCOMPARE(cubic->x(), 180.); QCOMPARE(cubic->y(), 0.); @@ -360,7 +359,7 @@ void tst_QDeclarativePathView::path() QCOMPARE(cubic->control2Y(), 90.); } -void tst_QDeclarativePathView::dataModel() +void tst_QDeclarative1PathView::dataModel() { QDeclarativeView *canvas = createView(); @@ -388,7 +387,7 @@ void tst_QDeclarativePathView::dataModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/datamodel.qml")); qApp->processEvents(); - QDeclarativePathView *pathview = qobject_cast(canvas->rootObject()); + QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); QVERIFY(pathview != 0); QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); @@ -407,13 +406,13 @@ void tst_QDeclarativePathView::dataModel() QVERIFY(pathview->currentIndex() == 0); - QDeclarativeText *text = findItem(pathview, "myText", 4); + QDeclarative1Text *text = findItem(pathview, "myText", 4); QVERIFY(text); QCOMPARE(text->text(), model.name(4)); model.removeItem(2); QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); - text = findItem(pathview, "myText", 2); + text = findItem(pathview, "myText", 2); QVERIFY(text); QCOMPARE(text->text(), model.name(2)); @@ -423,9 +422,9 @@ void tst_QDeclarativePathView::dataModel() QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - QDeclarativeRectangle *testItem = findItem(pathview, "wrapper", 4); + QDeclarative1Rectangle *testItem = findItem(pathview, "wrapper", 4); QVERIFY(testItem != 0); - testItem = findItem(pathview, "wrapper", 5); + testItem = findItem(pathview, "wrapper", 5); QVERIFY(testItem == 0); pathview->setCurrentIndex(1); @@ -436,13 +435,13 @@ void tst_QDeclarativePathView::dataModel() QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); QVERIFY(pathview->currentIndex() == 1); - text = findItem(pathview, "myText", 2); + text = findItem(pathview, "myText", 2); QVERIFY(text); QCOMPARE(text->text(), model.name(2)); model.removeItem(3); QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - text = findItem(pathview, "myText", 3); + text = findItem(pathview, "myText", 3); QVERIFY(text); QCOMPARE(text->text(), model.name(3)); @@ -476,7 +475,7 @@ void tst_QDeclarativePathView::dataModel() delete testObject; } -void tst_QDeclarativePathView::pathMoved() +void tst_QDeclarative1PathView::pathMoved() { QDeclarativeView *canvas = createView(); @@ -492,12 +491,12 @@ void tst_QDeclarativePathView::pathMoved() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); qApp->processEvents(); - QDeclarativePathView *pathview = findItem(canvas->rootObject(), "view"); + QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); - QDeclarativeRectangle *firstItem = findItem(pathview, "wrapper", 0); + QDeclarative1Rectangle *firstItem = findItem(pathview, "wrapper", 0); QVERIFY(firstItem); - QDeclarativePath *path = qobject_cast(pathview->path()); + QDeclarative1Path *path = qobject_cast(pathview->path()); QVERIFY(path); QPointF start = path->pointAt(0.0); QPointF offset;//Center of item is at point, but pos is from corner @@ -507,7 +506,7 @@ void tst_QDeclarativePathView::pathMoved() pathview->setOffset(1.0); for(int i=0; i(pathview, "wrapper", i); + QDeclarative1Rectangle *curItem = findItem(pathview, "wrapper", i); QPointF itemPos(path->pointAt(0.25 + i*0.25)); QCOMPARE(curItem->pos() + offset, QPointF(qRound(itemPos.x()), qRound(itemPos.y()))); } @@ -532,7 +531,7 @@ void tst_QDeclarativePathView::pathMoved() delete canvas; } -void tst_QDeclarativePathView::setCurrentIndex() +void tst_QDeclarative1PathView::setCurrentIndex() { QDeclarativeView *canvas = createView(); @@ -548,12 +547,12 @@ void tst_QDeclarativePathView::setCurrentIndex() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); qApp->processEvents(); - QDeclarativePathView *pathview = findItem(canvas->rootObject(), "view"); + QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); - QDeclarativeRectangle *firstItem = findItem(pathview, "wrapper", 0); + QDeclarative1Rectangle *firstItem = findItem(pathview, "wrapper", 0); QVERIFY(firstItem); - QDeclarativePath *path = qobject_cast(pathview->path()); + QDeclarative1Path *path = qobject_cast(pathview->path()); QVERIFY(path); QPointF start = path->pointAt(0.0); QPointF offset;//Center of item is at point, but pos is from corner @@ -565,39 +564,39 @@ void tst_QDeclarativePathView::setCurrentIndex() pathview->setCurrentIndex(2); - firstItem = findItem(pathview, "wrapper", 2); + firstItem = findItem(pathview, "wrapper", 2); QTRY_COMPARE(firstItem->pos() + offset, start); QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2); QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2); pathview->decrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 1); - firstItem = findItem(pathview, "wrapper", 1); + firstItem = findItem(pathview, "wrapper", 1); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); pathview->decrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); + firstItem = findItem(pathview, "wrapper", 0); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); pathview->decrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 3); - firstItem = findItem(pathview, "wrapper", 3); + firstItem = findItem(pathview, "wrapper", 3); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); pathview->incrementCurrentIndex(); QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); + firstItem = findItem(pathview, "wrapper", 0); QVERIFY(firstItem); QTRY_COMPARE(firstItem->pos() + offset, start); delete canvas; } -void tst_QDeclarativePathView::resetModel() +void tst_QDeclarative1PathView::resetModel() { QDeclarativeView *canvas = createView(); @@ -611,13 +610,13 @@ void tst_QDeclarativePathView::resetModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaypath.qml")); qApp->processEvents(); - QDeclarativePathView *pathview = findItem(canvas->rootObject(), "view"); + QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); QCOMPARE(pathview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem(pathview, "displayText", i); + QDeclarative1Text *display = findItem(pathview, "displayText", i); QVERIFY(display != 0); QCOMPARE(display->text(), strings.at(i)); } @@ -629,7 +628,7 @@ void tst_QDeclarativePathView::resetModel() QCOMPARE(pathview->count(), model.rowCount()); for (int i = 0; i < model.rowCount(); ++i) { - QDeclarativeText *display = findItem(pathview, "displayText", i); + QDeclarative1Text *display = findItem(pathview, "displayText", i); QVERIFY(display != 0); QCOMPARE(display->text(), strings.at(i)); } @@ -637,13 +636,13 @@ void tst_QDeclarativePathView::resetModel() delete canvas; } -void tst_QDeclarativePathView::propertyChanges() +void tst_QDeclarative1PathView::propertyChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); + QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); QVERIFY(pathView); QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged())); @@ -672,16 +671,16 @@ void tst_QDeclarativePathView::propertyChanges() delete canvas; } -void tst_QDeclarativePathView::pathChanges() +void tst_QDeclarative1PathView::pathChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); + QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); QVERIFY(pathView); - QDeclarativePath *path = canvas->rootObject()->findChild("path"); + QDeclarative1Path *path = canvas->rootObject()->findChild("path"); QVERIFY(path); QSignalSpy startXSpy(path, SIGNAL(startXChanged())); @@ -705,7 +704,7 @@ void tst_QDeclarativePathView::pathChanges() QCOMPARE(startXSpy.count(),1); QCOMPARE(startYSpy.count(),1); - QDeclarativePath *alternatePath = canvas->rootObject()->findChild("alternatePath"); + QDeclarative1Path *alternatePath = canvas->rootObject()->findChild("alternatePath"); QVERIFY(alternatePath); QSignalSpy pathSpy(pathView, SIGNAL(pathChanged())); @@ -719,7 +718,7 @@ void tst_QDeclarativePathView::pathChanges() pathView->setPath(alternatePath); QCOMPARE(pathSpy.count(),1); - QDeclarativePathAttribute *pathAttribute = canvas->rootObject()->findChild("pathAttribute"); + QDeclarative1PathAttribute *pathAttribute = canvas->rootObject()->findChild("pathAttribute"); QVERIFY(pathAttribute); QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged())); @@ -734,13 +733,13 @@ void tst_QDeclarativePathView::pathChanges() delete canvas; } -void tst_QDeclarativePathView::componentChanges() +void tst_QDeclarative1PathView::componentChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); + QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); QVERIFY(pathView); QDeclarativeComponent delegateComponent(canvas->engine()); @@ -757,16 +756,17 @@ void tst_QDeclarativePathView::componentChanges() delete canvas; } -void tst_QDeclarativePathView::modelChanges() +void tst_QDeclarative1PathView::modelChanges() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); + QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); QVERIFY(pathView); - QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); +// QDeclarative1ListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); + QObject *alternateModel = canvas->rootObject()->findChild("alternateModel"); QVERIFY(alternateModel); QVariant modelVariant = QVariant::fromValue(alternateModel); QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); @@ -784,16 +784,16 @@ void tst_QDeclarativePathView::modelChanges() delete canvas; } -void tst_QDeclarativePathView::pathUpdateOnStartChanged() +void tst_QDeclarative1PathView::pathUpdateOnStartChanged() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdateOnStartChanged.qml")); - QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); + QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); QVERIFY(pathView); - QDeclarativePath *path = canvas->rootObject()->findChild("path"); + QDeclarative1Path *path = canvas->rootObject()->findChild("path"); QVERIFY(path); QCOMPARE(path->startX(), 400.0); QCOMPARE(path->startY(), 300.0); @@ -806,13 +806,13 @@ void tst_QDeclarativePathView::pathUpdateOnStartChanged() delete canvas; } -void tst_QDeclarativePathView::package() +void tst_QDeclarative1PathView::package() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview_package.qml")); - QDeclarativePathView *pathView = canvas->rootObject()->findChild("photoPathView"); + QDeclarative1PathView *pathView = canvas->rootObject()->findChild("photoPathView"); QVERIFY(pathView); QDeclarativeItem *item = findItem(pathView, "pathItem"); @@ -823,7 +823,7 @@ void tst_QDeclarativePathView::package() } //QTBUG-13017 -void tst_QDeclarativePathView::emptyModel() +void tst_QDeclarative1PathView::emptyModel() { QDeclarativeView *canvas = createView(); @@ -835,7 +835,7 @@ void tst_QDeclarativePathView::emptyModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/emptymodel.qml")); qApp->processEvents(); - QDeclarativePathView *pathview = qobject_cast(canvas->rootObject()); + QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); QVERIFY(pathview != 0); QCOMPARE(pathview->offset(), qreal(0.0)); @@ -843,13 +843,13 @@ void tst_QDeclarativePathView::emptyModel() delete canvas; } -void tst_QDeclarativePathView::closed() +void tst_QDeclarative1PathView::closed() { QDeclarativeEngine engine; { QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/openPath.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); + QDeclarative1Path *obj = qobject_cast(c.create()); QVERIFY(obj); QCOMPARE(obj->isClosed(), false); delete obj; @@ -857,7 +857,7 @@ void tst_QDeclarativePathView::closed() { QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/closedPath.qml")); - QDeclarativePath *obj = qobject_cast(c.create()); + QDeclarative1Path *obj = qobject_cast(c.create()); QVERIFY(obj); QCOMPARE(obj->isClosed(), true); delete obj; @@ -865,13 +865,13 @@ void tst_QDeclarativePathView::closed() } // QTBUG-14239 -void tst_QDeclarativePathView::pathUpdate() +void tst_QDeclarative1PathView::pathUpdate() { QDeclarativeView *canvas = createView(); QVERIFY(canvas); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdate.qml")); - QDeclarativePathView *pathView = canvas->rootObject()->findChild("pathView"); + QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); QVERIFY(pathView); QDeclarativeItem *item = findItem(pathView, "wrapper", 0); @@ -881,12 +881,12 @@ void tst_QDeclarativePathView::pathUpdate() delete canvas; } -void tst_QDeclarativePathView::visualDataModel() +void tst_QDeclarative1PathView::visualDataModel() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/vdm.qml")); - QDeclarativePathView *obj = qobject_cast(c.create()); + QDeclarative1PathView *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QCOMPARE(obj->count(), 3); @@ -894,12 +894,12 @@ void tst_QDeclarativePathView::visualDataModel() delete obj; } -void tst_QDeclarativePathView::undefinedPath() +void tst_QDeclarative1PathView::undefinedPath() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/undefinedpath.qml")); - QDeclarativePathView *obj = qobject_cast(c.create()); + QDeclarative1PathView *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QCOMPARE(obj->count(), 3); @@ -907,7 +907,7 @@ void tst_QDeclarativePathView::undefinedPath() delete obj; } -void tst_QDeclarativePathView::mouseDrag() +void tst_QDeclarative1PathView::mouseDrag() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml")); @@ -916,7 +916,7 @@ void tst_QDeclarativePathView::mouseDrag() QTest::qWaitForWindowShown(canvas); QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - QDeclarativePathView *pathview = qobject_cast(canvas->rootObject()); + QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); QVERIFY(pathview != 0); int current = pathview->currentIndex(); @@ -939,7 +939,7 @@ void tst_QDeclarativePathView::mouseDrag() delete canvas; } -void tst_QDeclarativePathView::treeModel() +void tst_QDeclarative1PathView::treeModel() { QDeclarativeView *canvas = createView(); @@ -949,24 +949,24 @@ void tst_QDeclarativePathView::treeModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/treemodel.qml")); - QDeclarativePathView *pathview = qobject_cast(canvas->rootObject()); + QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); QVERIFY(pathview != 0); QCOMPARE(pathview->count(), 3); - QDeclarativeText *item = findItem(pathview, "wrapper", 0); + QDeclarative1Text *item = findItem(pathview, "wrapper", 0); QVERIFY(item); QCOMPARE(item->text(), QLatin1String("Row 1 Item")); QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1))); QCOMPARE(pathview->count(), 1); - QTRY_VERIFY(item = findItem(pathview, "wrapper", 0)); + QTRY_VERIFY(item = findItem(pathview, "wrapper", 0)); QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item")); delete canvas; } -void tst_QDeclarativePathView::changePreferredHighlight() +void tst_QDeclarative1PathView::changePreferredHighlight() { QDeclarativeView *canvas = createView(); canvas->setFixedSize(400,200); @@ -976,15 +976,15 @@ void tst_QDeclarativePathView::changePreferredHighlight() QTest::qWaitForWindowShown(canvas); QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - QDeclarativePathView *pathview = qobject_cast(canvas->rootObject()); + QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); QVERIFY(pathview != 0); int current = pathview->currentIndex(); QCOMPARE(current, 0); - QDeclarativeRectangle *firstItem = findItem(pathview, "wrapper", 0); + QDeclarative1Rectangle *firstItem = findItem(pathview, "wrapper", 0); QVERIFY(firstItem); - QDeclarativePath *path = qobject_cast(pathview->path()); + QDeclarative1Path *path = qobject_cast(pathview->path()); QVERIFY(path); QPointF start = path->pointAt(0.5); start.setX(qRound(start.x())); @@ -1005,7 +1005,7 @@ void tst_QDeclarativePathView::changePreferredHighlight() delete canvas; } -QDeclarativeView *tst_QDeclarativePathView::createView() +QDeclarativeView *tst_QDeclarative1PathView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); @@ -1018,7 +1018,7 @@ QDeclarativeView *tst_QDeclarativePathView::createView() item must also evaluate the {index} expression equal to index */ template -T *tst_QDeclarativePathView::findItem(QGraphicsObject *parent, const QString &objectName, int index) +T *tst_QDeclarative1PathView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->childItems().count() << "children"; @@ -1045,7 +1045,7 @@ T *tst_QDeclarativePathView::findItem(QGraphicsObject *parent, const QString &ob } template -QList tst_QDeclarativePathView::findItems(QGraphicsObject *parent, const QString &objectName) +QList tst_QDeclarative1PathView::findItems(QGraphicsObject *parent, const QString &objectName) { QList items; const QMetaObject &mo = T::staticMetaObject; @@ -1063,6 +1063,6 @@ QList tst_QDeclarativePathView::findItems(QGraphicsObject *parent, const QSt return items; } -QTEST_MAIN(tst_QDeclarativePathView) +QTEST_MAIN(tst_QDeclarative1PathView) #include "tst_qdeclarativepathview.moc" diff --git a/tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml b/tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepincharea/data/flickresize.qml rename to tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml diff --git a/tests/auto/declarative/qdeclarativepincharea/data/pinchproperties.qml b/tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepincharea/data/pinchproperties.qml rename to tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml diff --git a/tests/auto/declarative/qdeclarativepincharea/qdeclarativepincharea.pro b/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro similarity index 65% rename from tests/auto/declarative/qdeclarativepincharea/qdeclarativepincharea.pro rename to tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro index dba87ec011..e0eb3b50f9 100644 --- a/tests/auto/declarative/qdeclarativepincharea/qdeclarativepincharea.pro +++ b/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativepincharea.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp b/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp similarity index 88% rename from tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp rename to tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp index 220612081c..5f4795e07c 100644 --- a/tests/auto/declarative/qdeclarativepincharea/tst_qdeclarativepincharea.cpp +++ b/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp @@ -41,10 +41,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #ifdef Q_OS_SYMBIAN @@ -52,7 +52,7 @@ #define SRCDIR "." #endif -class tst_QDeclarativePinchArea: public QObject +class tst_QDeclarative1PinchArea: public QObject { Q_OBJECT private slots: @@ -65,7 +65,7 @@ private slots: QDeclarativeView *createView(); }; -void tst_QDeclarativePinchArea::pinchProperties() +void tst_QDeclarative1PinchArea::pinchProperties() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml")); @@ -73,8 +73,8 @@ void tst_QDeclarativePinchArea::pinchProperties() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativePinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarativePinch *pinch = pinchArea->pinch(); + QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QDeclarative1Pinch *pinch = pinchArea->pinch(); QVERIFY(pinchArea != 0); QVERIFY(pinch != 0); @@ -91,12 +91,12 @@ void tst_QDeclarativePinchArea::pinchProperties() QCOMPARE(targetSpy.count(),1); // axis - QCOMPARE(pinch->axis(), QDeclarativePinch::XandYAxis); + QCOMPARE(pinch->axis(), QDeclarative1Pinch::XandYAxis); QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged())); - pinch->setAxis(QDeclarativePinch::XAxis); - QCOMPARE(pinch->axis(), QDeclarativePinch::XAxis); + pinch->setAxis(QDeclarative1Pinch::XAxis); + QCOMPARE(pinch->axis(), QDeclarative1Pinch::XAxis); QCOMPARE(axisSpy.count(),1); - pinch->setAxis(QDeclarativePinch::XAxis); + pinch->setAxis(QDeclarative1Pinch::XAxis); QCOMPARE(axisSpy.count(),1); // minimum and maximum drag properties @@ -191,7 +191,7 @@ QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QGraphicsView *v, QGrap return touchPoint; } -void tst_QDeclarativePinchArea::scale() +void tst_QDeclarative1PinchArea::scale() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml")); @@ -201,8 +201,8 @@ void tst_QDeclarativePinchArea::scale() QVERIFY(canvas->rootObject() != 0); qApp->processEvents(); - QDeclarativePinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarativePinch *pinch = pinchArea->pinch(); + QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QDeclarative1Pinch *pinch = pinchArea->pinch(); QVERIFY(pinchArea != 0); QVERIFY(pinch != 0); @@ -246,7 +246,7 @@ void tst_QDeclarativePinchArea::scale() delete canvas; } -void tst_QDeclarativePinchArea::pan() +void tst_QDeclarative1PinchArea::pan() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml")); @@ -256,8 +256,8 @@ void tst_QDeclarativePinchArea::pan() QVERIFY(canvas->rootObject() != 0); qApp->processEvents(); - QDeclarativePinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarativePinch *pinch = pinchArea->pinch(); + QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QDeclarative1Pinch *pinch = pinchArea->pinch(); QVERIFY(pinchArea != 0); QVERIFY(pinch != 0); @@ -303,7 +303,7 @@ void tst_QDeclarativePinchArea::pan() delete canvas; } -void tst_QDeclarativePinchArea::flickable() +void tst_QDeclarative1PinchArea::flickable() { QDeclarativeView *canvas = createView(); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickresize.qml")); @@ -313,12 +313,12 @@ void tst_QDeclarativePinchArea::flickable() QVERIFY(canvas->rootObject() != 0); qApp->processEvents(); - QDeclarativePinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarativePinch *pinch = pinchArea->pinch(); + QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); + QDeclarative1Pinch *pinch = pinchArea->pinch(); QVERIFY(pinchArea != 0); QVERIFY(pinch != 0); - QDeclarativeFlickable *root = qobject_cast(canvas->rootObject()); + QDeclarative1Flickable *root = qobject_cast(canvas->rootObject()); QVERIFY(root != 0); QWidget *vp = canvas->viewport(); @@ -374,7 +374,7 @@ void tst_QDeclarativePinchArea::flickable() delete canvas; } -QDeclarativeView *tst_QDeclarativePinchArea::createView() +QDeclarativeView *tst_QDeclarative1PinchArea::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); @@ -383,6 +383,6 @@ QDeclarativeView *tst_QDeclarativePinchArea::createView() return canvas; } -QTEST_MAIN(tst_QDeclarativePinchArea) +QTEST_MAIN(tst_QDeclarative1PinchArea) #include "tst_qdeclarativepincharea.moc" diff --git a/tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/flow-testimplicitsize.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/flowtest-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/flowtest-toptobottom.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/flowtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/flowtest.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/grid-animated.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/grid-spacing.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/gridtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/gridtest.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/gridzerocolumns.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/horizontal-animated.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/horizontal-spacing.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/horizontal.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/propertychangestest.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/vertical-animated.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/vertical-spacing.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/vertical.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/vertical.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml similarity index 100% rename from tests/auto/declarative/qdeclarativepositioners/data/verticalqgraphicswidget.qml rename to tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro similarity index 66% rename from tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro rename to tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro index 235543a240..cf4ebfbf39 100644 --- a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro +++ b/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 SOURCES += tst_qdeclarativepositioners.cpp macx:CONFIG -= app_bundle @@ -13,4 +13,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp similarity index 78% rename from tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp rename to tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 0f3f540423..60ad1033fe 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -39,13 +39,12 @@ ** ****************************************************************************/ #include -#include -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include "../../../shared/util.h" @@ -105,13 +104,13 @@ void tst_QDeclarativePositioners::test_horizontal() canvas->rootObject()->setProperty("testRightToLeft", false); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -134,13 +133,13 @@ void tst_QDeclarativePositioners::test_horizontal_rtl() canvas->rootObject()->setProperty("testRightToLeft", true); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 60.0); @@ -172,13 +171,13 @@ void tst_QDeclarativePositioners::test_horizontal_spacing() canvas->rootObject()->setProperty("testRightToLeft", false); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -201,13 +200,13 @@ void tst_QDeclarativePositioners::test_horizontal_spacing_rightToLeft() canvas->rootObject()->setProperty("testRightToLeft", true); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 80.0); @@ -230,13 +229,13 @@ void tst_QDeclarativePositioners::test_horizontal_animated() canvas->rootObject()->setProperty("testRightToLeft", false); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); //Note that they animate in @@ -284,13 +283,13 @@ void tst_QDeclarativePositioners::test_horizontal_animated_rightToLeft() canvas->rootObject()->setProperty("testRightToLeft", true); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); //Note that they animate in @@ -336,13 +335,13 @@ void tst_QDeclarativePositioners::test_vertical() { QDeclarativeView *canvas = createView(SRCDIR "/data/vertical.qml"); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -364,13 +363,13 @@ void tst_QDeclarativePositioners::test_vertical_spacing() { QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-spacing.qml"); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -392,15 +391,15 @@ void tst_QDeclarativePositioners::test_vertical_animated() QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-animated.qml"); //Note that they animate in - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); QCOMPARE(one->y(), -100.0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); QCOMPARE(two->y(), -100.0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(three->y(), -100.0); @@ -439,15 +438,15 @@ void tst_QDeclarativePositioners::test_grid() { QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml"); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -461,8 +460,8 @@ void tst_QDeclarativePositioners::test_grid() QCOMPARE(five->x(), 50.0); QCOMPARE(five->y(), 50.0); - QDeclarativeGrid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->flow(), QDeclarativeGrid::LeftToRight); + QDeclarative1Grid *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->flow(), QDeclarative1Grid::LeftToRight); QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 100.0); @@ -473,15 +472,15 @@ void tst_QDeclarativePositioners::test_grid_topToBottom() { QDeclarativeView *canvas = createView(SRCDIR "/data/grid-toptobottom.qml"); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -495,8 +494,8 @@ void tst_QDeclarativePositioners::test_grid_topToBottom() QCOMPARE(five->x(), 50.0); QCOMPARE(five->y(), 50.0); - QDeclarativeGrid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->flow(), QDeclarativeGrid::TopToBottom); + QDeclarative1Grid *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->flow(), QDeclarative1Grid::TopToBottom); QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 120.0); @@ -509,15 +508,15 @@ void tst_QDeclarativePositioners::test_grid_rightToLeft() canvas->rootObject()->setProperty("testRightToLeft", true); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 50.0); @@ -531,7 +530,7 @@ void tst_QDeclarativePositioners::test_grid_rightToLeft() QCOMPARE(five->x(), 40.0); QCOMPARE(five->y(), 50.0); - QDeclarativeGrid *grid = canvas->rootObject()->findChild("grid"); + QDeclarative1Grid *grid = canvas->rootObject()->findChild("grid"); QCOMPARE(grid->layoutDirection(), Qt::RightToLeft); QCOMPARE(grid->width(), 100.0); QCOMPARE(grid->height(), 100.0); @@ -556,15 +555,15 @@ void tst_QDeclarativePositioners::test_grid_spacing() { QDeclarativeView *canvas = createView(SRCDIR "/data/grid-spacing.qml"); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -592,27 +591,27 @@ void tst_QDeclarativePositioners::test_grid_animated() canvas->rootObject()->setProperty("testRightToLeft", false); //Note that all animate in - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); QCOMPARE(one->x(), -100.0); QCOMPARE(one->y(), -100.0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); QCOMPARE(two->x(), -100.0); QCOMPARE(two->y(), -100.0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(three->x(), -100.0); QCOMPARE(three->y(), -100.0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); QCOMPARE(four->x(), -100.0); QCOMPARE(four->y(), -100.0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); @@ -675,27 +674,27 @@ void tst_QDeclarativePositioners::test_grid_animated_rightToLeft() canvas->rootObject()->setProperty("testRightToLeft", true); //Note that all animate in - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); QCOMPARE(one->x(), -100.0); QCOMPARE(one->y(), -100.0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); QCOMPARE(two->x(), -100.0); QCOMPARE(two->y(), -100.0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(three->x(), -100.0); QCOMPARE(three->y(), -100.0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); QCOMPARE(four->x(), -100.0); QCOMPARE(four->y(), -100.0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); @@ -755,15 +754,15 @@ void tst_QDeclarativePositioners::test_grid_zero_columns() { QDeclarativeView *canvas = createView(SRCDIR "/data/gridzerocolumns.qml"); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -788,10 +787,10 @@ void tst_QDeclarativePositioners::test_propertychanges() { QDeclarativeView *canvas = createView(SRCDIR "/data/propertychangestest.qml"); - QDeclarativeGrid *grid = qobject_cast(canvas->rootObject()); + QDeclarative1Grid *grid = qobject_cast(canvas->rootObject()); QVERIFY(grid != 0); - QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild("rowTransition"); - QDeclarativeTransition *columnTransition = canvas->rootObject()->findChild("columnTransition"); + QDeclarative1Transition *rowTransition = canvas->rootObject()->findChild("rowTransition"); + QDeclarative1Transition *columnTransition = canvas->rootObject()->findChild("columnTransition"); QSignalSpy addSpy(grid, SIGNAL(addChanged())); QSignalSpy moveSpy(grid, SIGNAL(moveChanged())); @@ -847,13 +846,13 @@ void tst_QDeclarativePositioners::test_repeater() { QDeclarativeView *canvas = createView(SRCDIR "/data/repeatertest.qml"); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -872,15 +871,15 @@ void tst_QDeclarativePositioners::test_flow() canvas->rootObject()->setProperty("testRightToLeft", false); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -908,15 +907,15 @@ void tst_QDeclarativePositioners::test_flow_rightToLeft() canvas->rootObject()->setProperty("testRightToLeft", true); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 40.0); @@ -944,15 +943,15 @@ void tst_QDeclarativePositioners::test_flow_topToBottom() canvas->rootObject()->setProperty("testRightToLeft", false); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -1000,15 +999,15 @@ void tst_QDeclarativePositioners::test_flow_resize() root->setWidth(125); root->setProperty("testRightToLeft", false); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -1034,15 +1033,15 @@ void tst_QDeclarativePositioners::test_flow_resize_rightToLeft() root->setWidth(125); root->setProperty("testRightToLeft", true); - QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 75.0); @@ -1064,19 +1063,19 @@ void tst_QDeclarativePositioners::test_flow_implicit_resize() QDeclarativeView *canvas = createView(SRCDIR "/data/flow-testimplicitsize.qml"); QVERIFY(canvas->rootObject() != 0); - QDeclarativeFlow *flow = canvas->rootObject()->findChild("flow"); + QDeclarative1Flow *flow = canvas->rootObject()->findChild("flow"); QVERIFY(flow != 0); QCOMPARE(flow->width(), 100.0); QCOMPARE(flow->height(), 120.0); canvas->rootObject()->setProperty("flowLayout", 0); - QCOMPARE(flow->flow(), QDeclarativeFlow::LeftToRight); + QCOMPARE(flow->flow(), QDeclarative1Flow::LeftToRight); QCOMPARE(flow->width(), 220.0); QCOMPARE(flow->height(), 50.0); canvas->rootObject()->setProperty("flowLayout", 1); - QCOMPARE(flow->flow(), QDeclarativeFlow::TopToBottom); + QCOMPARE(flow->flow(), QDeclarative1Flow::TopToBottom); QCOMPARE(flow->width(), 100.0); QCOMPARE(flow->height(), 120.0); diff --git a/tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml similarity index 100% rename from tests/auto/declarative/qdeclarativerepeater/data/intmodel.qml rename to tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml similarity index 100% rename from tests/auto/declarative/qdeclarativerepeater/data/itemlist.qml rename to tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/data/modelChanged.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml similarity index 100% rename from tests/auto/declarative/qdeclarativerepeater/data/modelChanged.qml rename to tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/data/objlist.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/objlist.qml similarity index 100% rename from tests/auto/declarative/qdeclarativerepeater/data/objlist.qml rename to tests/auto/qtquick1/qdeclarativerepeater/data/objlist.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/data/properties.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/properties.qml similarity index 100% rename from tests/auto/declarative/qdeclarativerepeater/data/properties.qml rename to tests/auto/qtquick1/qdeclarativerepeater/data/properties.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/data/repeater1.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/repeater1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativerepeater/data/repeater1.qml rename to tests/auto/qtquick1/qdeclarativerepeater/data/repeater1.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/repeater2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativerepeater/data/repeater2.qml rename to tests/auto/qtquick1/qdeclarativerepeater/data/repeater2.qml diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/qtquick1/qdeclarativerepeater/qdeclarativerepeater.pro similarity index 66% rename from tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro rename to tests/auto/qtquick1/qdeclarativerepeater/qdeclarativerepeater.pro index 30d8b615bf..dd5fa976cf 100644 --- a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro +++ b/tests/auto/qtquick1/qdeclarativerepeater/qdeclarativerepeater.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative +contains(QT_CONFIG,declarative): QT += declarative qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativerepeater.cpp @@ -13,4 +13,4 @@ symbian: { } CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp b/tests/auto/qtquick1/qdeclarativerepeater/tst_qdeclarativerepeater.cpp similarity index 88% rename from tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp rename to tests/auto/qtquick1/qdeclarativerepeater/tst_qdeclarativerepeater.cpp index 2938a5fb52..de9ed67275 100644 --- a/tests/auto/declarative/qdeclarativerepeater/tst_qdeclarativerepeater.cpp +++ b/tests/auto/qtquick1/qdeclarativerepeater/tst_qdeclarativerepeater.cpp @@ -41,13 +41,12 @@ #include #include -#include #include -#include +#include #include #include -#include -#include +#include +#include #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -59,11 +58,11 @@ inline QUrl TEST_FILE(const QString &filename) return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); } -class tst_QDeclarativeRepeater : public QObject +class tst_QDeclarative1Repeater : public QObject { Q_OBJECT public: - tst_QDeclarativeRepeater(); + tst_QDeclarative1Repeater(); private slots: void numberModel(); @@ -172,11 +171,11 @@ class TestModel : public QAbstractListModel }; -tst_QDeclarativeRepeater::tst_QDeclarativeRepeater() +tst_QDeclarative1Repeater::tst_QDeclarative1Repeater() { } -void tst_QDeclarativeRepeater::numberModel() +void tst_QDeclarative1Repeater::numberModel() { QDeclarativeView *canvas = createView(); @@ -188,7 +187,7 @@ void tst_QDeclarativeRepeater::numberModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/intmodel.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QCOMPARE(repeater->parentItem()->childItems().count(), 5+1); @@ -216,7 +215,7 @@ class MyObject : public QObject int m_idx; }; -void tst_QDeclarativeRepeater::objectList() +void tst_QDeclarative1Repeater::objectList() { QDeclarativeView *canvas = createView(); QObjectList data; @@ -229,7 +228,7 @@ void tst_QDeclarativeRepeater::objectList() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/objlist.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data QCOMPARE(repeater->property("instantiated").toInt(), 100); @@ -254,7 +253,7 @@ The Repeater element creates children at its own position in its parent's stacking order. In this test we insert a repeater between two other Text elements to test this. */ -void tst_QDeclarativeRepeater::stringList() +void tst_QDeclarative1Repeater::stringList() { QDeclarativeView *canvas = createView(); @@ -270,7 +269,7 @@ void tst_QDeclarativeRepeater::stringList() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); @@ -282,21 +281,21 @@ void tst_QDeclarativeRepeater::stringList() for (int i = 0; i < container->childItems().count(); ++i) { if (i == 0) { - QDeclarativeText *name = qobject_cast(container->childItems().at(i)); + QDeclarative1Text *name = qobject_cast(container->childItems().at(i)); QVERIFY(name != 0); QCOMPARE(name->text(), QLatin1String("Zero")); } else if (i == container->childItems().count() - 2) { // The repeater itself - QDeclarativeRepeater *rep = qobject_cast(container->childItems().at(i)); + QDeclarative1Repeater *rep = qobject_cast(container->childItems().at(i)); QCOMPARE(rep, repeater); saw_repeater = true; continue; } else if (i == container->childItems().count() - 1) { - QDeclarativeText *name = qobject_cast(container->childItems().at(i)); + QDeclarative1Text *name = qobject_cast(container->childItems().at(i)); QVERIFY(name != 0); QCOMPARE(name->text(), QLatin1String("Last")); } else { - QDeclarativeText *name = qobject_cast(container->childItems().at(i)); + QDeclarative1Text *name = qobject_cast(container->childItems().at(i)); QVERIFY(name != 0); QCOMPARE(name->text(), data.at(i-1)); } @@ -306,7 +305,7 @@ void tst_QDeclarativeRepeater::stringList() delete canvas; } -void tst_QDeclarativeRepeater::dataModel_adding() +void tst_QDeclarative1Repeater::dataModel_adding() { QDeclarativeView *canvas = createView(); QDeclarativeContext *ctxt = canvas->rootContext(); @@ -318,7 +317,7 @@ void tst_QDeclarativeRepeater::dataModel_adding() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); QVERIFY(container != 0); @@ -368,7 +367,7 @@ void tst_QDeclarativeRepeater::dataModel_adding() delete canvas; } -void tst_QDeclarativeRepeater::dataModel_removing() +void tst_QDeclarative1Repeater::dataModel_removing() { QDeclarativeView *canvas = createView(); QDeclarativeContext *ctxt = canvas->rootContext(); @@ -386,7 +385,7 @@ void tst_QDeclarativeRepeater::dataModel_removing() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); QVERIFY(container != 0); @@ -436,7 +435,7 @@ void tst_QDeclarativeRepeater::dataModel_removing() delete canvas; } -void tst_QDeclarativeRepeater::dataModel_changes() +void tst_QDeclarative1Repeater::dataModel_changes() { QDeclarativeView *canvas = createView(); QDeclarativeContext *ctxt = canvas->rootContext(); @@ -452,23 +451,23 @@ void tst_QDeclarativeRepeater::dataModel_changes() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); QVERIFY(container != 0); QCOMPARE(container->childItems().count(), repeater->count()+1); // Check that model changes are propagated - QDeclarativeText *text = findItem(canvas->rootObject(), "myName", 1); + QDeclarative1Text *text = findItem(canvas->rootObject(), "myName", 1); QVERIFY(text); QCOMPARE(text->text(), QString("two")); testModel.modifyItem(1, "Item two", "_2"); - text = findItem(canvas->rootObject(), "myName", 1); + text = findItem(canvas->rootObject(), "myName", 1); QVERIFY(text); QCOMPARE(text->text(), QString("Item two")); - text = findItem(canvas->rootObject(), "myNumber", 1); + text = findItem(canvas->rootObject(), "myNumber", 1); QVERIFY(text); QCOMPARE(text->text(), QString("_2")); @@ -476,7 +475,7 @@ void tst_QDeclarativeRepeater::dataModel_changes() delete canvas; } -void tst_QDeclarativeRepeater::itemModel() +void tst_QDeclarative1Repeater::itemModel() { QDeclarativeView *canvas = createView(); QDeclarativeContext *ctxt = canvas->rootContext(); @@ -486,7 +485,7 @@ void tst_QDeclarativeRepeater::itemModel() canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); @@ -517,7 +516,7 @@ void tst_QDeclarativeRepeater::itemModel() delete canvas; } -void tst_QDeclarativeRepeater::resetModel() +void tst_QDeclarative1Repeater::resetModel() { QDeclarativeView *canvas = createView(); @@ -529,7 +528,7 @@ void tst_QDeclarativeRepeater::resetModel() ctxt->setContextProperty("testData", dataA); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml")); qApp->processEvents(); - QDeclarativeRepeater *repeater = findItem(canvas->rootObject(), "repeater"); + QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); QVERIFY(container != 0); @@ -581,14 +580,14 @@ void tst_QDeclarativeRepeater::resetModel() } // QTBUG-17156 -void tst_QDeclarativeRepeater::modelChanged() +void tst_QDeclarative1Repeater::modelChanged() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, TEST_FILE("/modelChanged.qml")); QDeclarativeItem *rootObject = qobject_cast(component.create()); QVERIFY(rootObject); - QDeclarativeRepeater *repeater = findItem(rootObject, "repeater"); + QDeclarative1Repeater *repeater = findItem(rootObject, "repeater"); QVERIFY(repeater); repeater->setModel(4); @@ -604,7 +603,7 @@ void tst_QDeclarativeRepeater::modelChanged() delete rootObject; } -void tst_QDeclarativeRepeater::properties() +void tst_QDeclarative1Repeater::properties() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, TEST_FILE("/properties.qml")); @@ -612,7 +611,7 @@ void tst_QDeclarativeRepeater::properties() QDeclarativeItem *rootObject = qobject_cast(component.create()); QVERIFY(rootObject); - QDeclarativeRepeater *repeater = findItem(rootObject, "repeater"); + QDeclarative1Repeater *repeater = findItem(rootObject, "repeater"); QVERIFY(repeater); QSignalSpy modelSpy(repeater, SIGNAL(modelChanged())); @@ -634,7 +633,7 @@ void tst_QDeclarativeRepeater::properties() delete rootObject; } -void tst_QDeclarativeRepeater::testQtQuick11Attributes() +void tst_QDeclarative1Repeater::testQtQuick11Attributes() { QFETCH(QString, code); QFETCH(QString, warning); @@ -658,7 +657,7 @@ void tst_QDeclarativeRepeater::testQtQuick11Attributes() delete obj; } -void tst_QDeclarativeRepeater::testQtQuick11Attributes_data() +void tst_QDeclarative1Repeater::testQtQuick11Attributes_data() { QTest::addColumn("code"); QTest::addColumn("warning"); @@ -678,7 +677,7 @@ void tst_QDeclarativeRepeater::testQtQuick11Attributes_data() } -QDeclarativeView *tst_QDeclarativeRepeater::createView() +QDeclarativeView *tst_QDeclarative1Repeater::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); canvas->setFixedSize(240,320); @@ -687,7 +686,7 @@ QDeclarativeView *tst_QDeclarativeRepeater::createView() } template -T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName, int index) +T *tst_QDeclarative1Repeater::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->childItems().count() << "children"; @@ -714,7 +713,7 @@ T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &ob } template -T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &objectName) +T *tst_QDeclarative1Repeater::findItem(QGraphicsObject *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName)) @@ -731,6 +730,6 @@ T *tst_QDeclarativeRepeater::findItem(QGraphicsObject *parent, const QString &ob return 0; } -QTEST_MAIN(tst_QDeclarativeRepeater) +QTEST_MAIN(tst_QDeclarative1Repeater) #include "tst_qdeclarativerepeater.moc" diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml new file mode 100644 index 0000000000..3a2c4e386b --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml @@ -0,0 +1,3 @@ +import QtQuick 1.0 + +SmoothedAnimation {} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml new file mode 100644 index 0000000000..47935d48f0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 + +SmoothedAnimation { + to: 10; duration: 300; reversingMode: SmoothedAnimation.Immediate +} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml new file mode 100644 index 0000000000..fe44cce14b --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml @@ -0,0 +1,6 @@ +import QtQuick 1.0 + +SmoothedAnimation { + to: 10; velocity: 250; reversingMode: SmoothedAnimation.Sync + maximumEasingTime: 150 +} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml new file mode 100644 index 0000000000..65611227d0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400; color: "blue" + + Rectangle { + id: rect1 + color: "red" + width: 60; height: 60; + x: 100; y: 100; + SmoothedAnimation on x { to: 200; velocity: 500 } + SmoothedAnimation on y { to: 200; velocity: 500 } + } + + Rectangle { + objectName: "theRect" + color: "green" + width: 60; height: 60; + x: rect1.x; y: rect1.y; + // id are needed for SmoothedAnimation in order to avoid deferred creation + Behavior on x { SmoothedAnimation { id: anim1; objectName: "easeX"; velocity: 400 } } + Behavior on y { SmoothedAnimation { id: anim2; objectName: "easeY"; velocity: 400 } } + } + } diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml new file mode 100644 index 0000000000..5036d5f225 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml @@ -0,0 +1,13 @@ +import QtQuick 1.0 + +Rectangle { + width: 300; height: 300; + Rectangle { + objectName: "theRect" + color: "red" + width: 60; height: 60; + x: 100; y: 100; + SmoothedAnimation on x { objectName: "easeX"; to: 200; velocity: 500 } + SmoothedAnimation on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro new file mode 100644 index 0000000000..f9a0b17f81 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativesmoothedanimation.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp new file mode 100644 index 0000000000..0b1c46d20c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativesmoothedanimation : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativesmoothedanimation(); + +private slots: + void defaultValues(); + void values(); + void disabled(); + void simpleAnimation(); + void valueSource(); + void behavior(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativesmoothedanimation::tst_qdeclarativesmoothedanimation() +{ +} + +void tst_qdeclarativesmoothedanimation::defaultValues() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation1.qml")); + QDeclarative1SmoothedAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 0.); + QCOMPARE(obj->velocity(), 200.); + QCOMPARE(obj->duration(), -1); + QCOMPARE(obj->maximumEasingTime(), -1); + QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Eased); + + delete obj; +} + +void tst_qdeclarativesmoothedanimation::values() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation2.qml")); + QDeclarative1SmoothedAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 10.); + QCOMPARE(obj->velocity(), 200.); + QCOMPARE(obj->duration(), 300); + QCOMPARE(obj->maximumEasingTime(), -1); + QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Immediate); + + delete obj; +} + +void tst_qdeclarativesmoothedanimation::disabled() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation3.qml")); + QDeclarative1SmoothedAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 10.); + QCOMPARE(obj->velocity(), 250.); + QCOMPARE(obj->maximumEasingTime(), 150); + QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Sync); + + delete obj; +} + +void tst_qdeclarativesmoothedanimation::simpleAnimation() +{ + QDeclarative1Rectangle rect; + QDeclarative1SmoothedAnimation animation; + animation.setTarget(&rect); + animation.setProperty("x"); + animation.setTo(200); + animation.setDuration(250); + QVERIFY(animation.target() == &rect); + QVERIFY(animation.property() == "x"); + QVERIFY(animation.to() == 200); + animation.start(); + QVERIFY(animation.isRunning()); + QTest::qWait(animation.duration()); + QTRY_COMPARE(rect.x(), qreal(200)); + + rect.setX(0); + animation.start(); + animation.pause(); + QVERIFY(animation.isRunning()); + QVERIFY(animation.isPaused()); + animation.setCurrentTime(125); + QVERIFY(animation.currentTime() == 125); + QCOMPARE(rect.x(), qreal(100)); +} + +void tst_qdeclarativesmoothedanimation::valueSource() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationValueSource.qml")); + + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *theRect = rect->findChild("theRect"); + QVERIFY(theRect); + + QDeclarative1SmoothedAnimation *easeX = rect->findChild("easeX"); + QVERIFY(easeX); + QVERIFY(easeX->isRunning()); + + QDeclarative1SmoothedAnimation *easeY = rect->findChild("easeY"); + QVERIFY(easeY); + QVERIFY(easeY->isRunning()); + + // XXX get the proper duration + QTest::qWait(100); + + QTRY_VERIFY(!easeX->isRunning()); + QTRY_VERIFY(!easeY->isRunning()); + + QTRY_COMPARE(theRect->x(), qreal(200)); + QTRY_COMPARE(theRect->y(), qreal(200)); + + delete rect; +} + +void tst_qdeclarativesmoothedanimation::behavior() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationBehavior.qml")); + + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QDeclarative1Rectangle *theRect = rect->findChild("theRect"); + QVERIFY(theRect); + + QDeclarative1SmoothedAnimation *easeX = rect->findChild("easeX"); + QVERIFY(easeX); + + QDeclarative1SmoothedAnimation *easeY = rect->findChild("easeY"); + QVERIFY(easeY); + + // XXX get the proper duration + QTest::qWait(400); + + QTRY_VERIFY(!easeX->isRunning()); + QTRY_VERIFY(!easeY->isRunning()); + + QTRY_COMPARE(theRect->x(), qreal(200)); + QTRY_COMPARE(theRect->y(), qreal(200)); + + delete rect; +} + +QTEST_MAIN(tst_qdeclarativesmoothedanimation) + +#include "tst_qdeclarativesmoothedanimation.moc" diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml new file mode 100644 index 0000000000..8890a78fdb --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml @@ -0,0 +1,4 @@ +import QtQuick 1.0 + +SpringAnimation { +} diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml new file mode 100644 index 0000000000..de75bb06cb --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml @@ -0,0 +1,9 @@ +import QtQuick 1.0 + +SpringAnimation { + to: 1.44; velocity: 0.9 + spring: 1.0; damping: 0.5 + epsilon: 0.25; modulus: 360.0 + mass: 2.0; + running: true; +} diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml new file mode 100644 index 0000000000..b68d769f01 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +SpringAnimation { + to: 1.44; velocity: 0.9 + spring: 1.0; damping: 0.5 + epsilon: 0.25; modulus: 360.0 + mass: 2.0; running: false +} diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro new file mode 100644 index 0000000000..10132374e2 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativespringanimation.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp b/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp new file mode 100644 index 0000000000..8c22f97acb --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativespringanimation : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativespringanimation(); + +private slots: + void defaultValues(); + void values(); + void disabled(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativespringanimation::tst_qdeclarativespringanimation() +{ +} + +void tst_qdeclarativespringanimation::defaultValues() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation1.qml")); + QDeclarative1SpringAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 0.); + QCOMPARE(obj->velocity(), 0.); + QCOMPARE(obj->spring(), 0.); + QCOMPARE(obj->damping(), 0.); + QCOMPARE(obj->epsilon(), 0.01); + QCOMPARE(obj->modulus(), 0.); + QCOMPARE(obj->mass(), 1.); + QCOMPARE(obj->isRunning(), false); + + delete obj; +} + +void tst_qdeclarativespringanimation::values() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation2.qml")); + QDeclarative1SpringAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 1.44); + QCOMPARE(obj->velocity(), 0.9); + QCOMPARE(obj->spring(), 1.0); + QCOMPARE(obj->damping(), 0.5); + QCOMPARE(obj->epsilon(), 0.25); + QCOMPARE(obj->modulus(), 360.0); + QCOMPARE(obj->mass(), 2.0); + QCOMPARE(obj->isRunning(), true); + + QTRY_COMPARE(obj->isRunning(), false); + + delete obj; +} + +void tst_qdeclarativespringanimation::disabled() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation3.qml")); + QDeclarative1SpringAnimation *obj = qobject_cast(c.create()); + + QVERIFY(obj != 0); + + QCOMPARE(obj->to(), 1.44); + QCOMPARE(obj->velocity(), 0.9); + QCOMPARE(obj->spring(), 1.0); + QCOMPARE(obj->damping(), 0.5); + QCOMPARE(obj->epsilon(), 0.25); + QCOMPARE(obj->modulus(), 360.0); + QCOMPARE(obj->mass(), 2.0); + QCOMPARE(obj->isRunning(), false); + + delete obj; +} + +QTEST_MAIN(tst_qdeclarativespringanimation) + +#include "tst_qdeclarativespringanimation.moc" diff --git a/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml b/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml new file mode 100644 index 0000000000..d91f504455 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml @@ -0,0 +1,19 @@ +import QtQuick 1.0 +Rectangle { + id: extendedRect + objectName: "extendedRect" + property color extendedColor: "orange" + + width: 100; height: 100 + color: "red" + states: State { + name: "green" + PropertyChanges { + target: rect + onDidSomething: { + extendedRect.color = "green" + extendedColor = "green" + } + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml new file mode 100644 index 0000000000..6ad3b4a6ba --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml @@ -0,0 +1,32 @@ +import QtQuick 1.0 + +Item { + Column { + anchors.centerIn: parent + Image { id: image1; objectName: "image1" } + Image { id: image2; objectName: "image2" } + Image { id: image3; objectName: "image3" } + } + + states: State { + name: "SetImageState" + PropertyChanges { + target: image1 + source: "images/qt-logo.png" + } + PropertyChanges { + target: image2 + source: "images/" + "qt-logo.png" + } + PropertyChanges { + target: image3 + source: "images/" + (true ? "qt-logo.png" : "") + } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.state = "SetImageState" + } + +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png differ diff --git a/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml b/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml new file mode 100644 index 0000000000..7f9ddbfa2d --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + width: 1024 + height: 768 + + Item { + id: area + objectName: "area" + property int numx: 6 + property int cellwidth: 1024/numx + + onWidthChanged: { + width = width>1024?1024:width; + } + + state: 'minimal' + states: [ + State { + name: 'minimal' + PropertyChanges { + target: area + width: cellwidth + } + } + ] + + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml new file mode 100644 index 0000000000..fad27080fe --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml @@ -0,0 +1,23 @@ +import QtQuick 1.0 + +Rectangle { + id: container + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + width: 50; height: 50 + color: "green"; + anchors.left: parent.left + anchors.leftMargin: 5 + } + states: State { + name: "right" + AnchorChanges { + id: ancCh + target: myRect; + anchors.left: undefined + anchors.right: container.right + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml new file mode 100644 index 0000000000..e1d4d66abd --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml @@ -0,0 +1,21 @@ +import QtQuick 1.0 + +Rectangle { + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + width: 50; height: 50 + color: "green"; + anchors.left: parent.left + anchors.leftMargin: 5 + } + states: State { + name: "right" + AnchorChanges { + target: myRect; + anchors.left: undefined + anchors.right: parent.right + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml new file mode 100644 index 0000000000..116b844489 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml @@ -0,0 +1,29 @@ +import QtQuick 1.0 + +Rectangle { + id: container + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + color: "green"; + anchors.left: parent.left + anchors.right: rightGuideline.left + anchors.top: topGuideline.top + anchors.bottom: container.bottom + } + Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } + Item { id: rightGuideline; x: 150 } + Item { id: topGuideline; y: 10 } + Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } + states: State { + name: "reanchored" + AnchorChanges { + target: myRect; + anchors.left: leftGuideline.left + anchors.right: container.right + anchors.top: container.top + anchors.bottom: bottomGuideline.bottom + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml new file mode 100644 index 0000000000..eaff37345b --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml @@ -0,0 +1,22 @@ +import QtQuick 1.0 + +Rectangle { + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + color: "green"; + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + } + Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } + Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } + states: State { + name: "reanchored" + AnchorChanges { + target: myRect; + anchors.horizontalCenter: bottomGuideline.horizontalCenter + anchors.verticalCenter: leftGuideline.verticalCenter + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml new file mode 100644 index 0000000000..ea7b251151 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml @@ -0,0 +1,22 @@ +import QtQuick 1.0 + +Rectangle { + width: 200; height: 200 + Rectangle { + id: myRect + objectName: "MyRect" + color: "green"; + anchors.horizontalCenter: parent.horizontalCenter + anchors.baseline: parent.baseline + } + Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } + Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } + states: State { + name: "reanchored" + AnchorChanges { + target: myRect; + anchors.horizontalCenter: bottomGuideline.horizontalCenter + anchors.baseline: leftGuideline.baseline + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml new file mode 100644 index 0000000000..ca96da8855 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + id: container + width: 400 + height: 400 + + states: State { + name: "reanchored" + AnchorChanges { + anchors.top: container.top + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml new file mode 100644 index 0000000000..6277111e68 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml @@ -0,0 +1,37 @@ +import QtQuick 1.0 +Rectangle { + id: container + color: "red" + height: 200 + width: 200 + Column { + id: column + objectName: "column" + anchors.left: container.right + anchors.bottom: container.bottom + + Rectangle { + id: rectangle + color: "blue" + height: 100 + width: 200 + } + Rectangle { + color: "blue" + height: 100 + width: 200 + } + } + states: State { + name: "reanchored" + AnchorChanges { + target: column + anchors.left: undefined + anchors.right: container.right + } + PropertyChanges { + target: rectangle + opacity: 0 + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml new file mode 100644 index 0000000000..d8b02e9b32 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml @@ -0,0 +1,25 @@ +import QtQuick 1.0 + +Rectangle { + id: root + width:200; height:300 + + Rectangle { + id: rectangle + objectName: "mover" + color: "green" + width:50; height:50 + } + + states: [ + State { + name: "anchored" + AnchorChanges { + target: rectangle + anchors.left: root.left + anchors.right: root.right + anchors.bottom: root.bottom + } + } + ] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml new file mode 100644 index 0000000000..2cad0504b2 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml @@ -0,0 +1,20 @@ +import Qt.test 1.0 +import QtQuick 1.0 + +Item { + id: item + width: 100; height: 100 + MyRectangle.foo: 0 + + states: State { + name: "foo1" + PropertyChanges { + target: item + MyRectangle.foo: 1 + width: 50 + } + } + + Component.onCompleted: item.state = "foo1" +} + diff --git a/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml new file mode 100644 index 0000000000..ccd126f6a7 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml @@ -0,0 +1,18 @@ +import QtQuick 1.0 + +Item { + id: root + property int input: 1 + property int test: 9 + + states: [ + State { + name: "portrait" + when: root.input == 1 + PropertyChanges { + target: root + test: 3 + } + } + ] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml new file mode 100644 index 0000000000..2060f03009 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: sourceColor } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml new file mode 100644 index 0000000000..a329da33dd --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + + property color sourceColor: "red" + width: 100; height: 100 + color: sourceColor + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml new file mode 100644 index 0000000000..cb054d214d --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml @@ -0,0 +1,13 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + + property color sourceColor: "red" + property color sourceColor2: "blue" + width: 100; height: 100 + color: sourceColor + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: sourceColor2 } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml new file mode 100644 index 0000000000..7a740e570c --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml @@ -0,0 +1,17 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: sourceColor } + }, + State { + name: "green" + PropertyChanges { target: myRectangle; color: "green" } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml new file mode 100644 index 0000000000..08ce7875f0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml new file mode 100644 index 0000000000..ab97ba18b5 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml @@ -0,0 +1,15 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "green" + PropertyChanges { target: myRectangle; color: "green" } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml new file mode 100644 index 0000000000..73ac34d7ff --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml @@ -0,0 +1,15 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "bordered" + PropertyChanges { target: myRectangle; border.width: 2 } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml new file mode 100644 index 0000000000..b5df922190 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml @@ -0,0 +1,19 @@ +import Qt.test 1.0 +import QtQuick 1.0 + +MyRectangle { + id: rect + width: 100; height: 100 + color: "red" + + states: State { + name: "aBlueDay" + PropertyChanges { + target: rect + onPropertyWithNotifyChanged: { rect.color = "blue"; } + } + } + + Component.onCompleted: rect.state = "aBlueDay" +} + diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml new file mode 100644 index 0000000000..58c9fbe231 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "bordered" + extend: "blue" + PropertyChanges { target: myRectangle; border.width: 2 } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml b/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml new file mode 100644 index 0000000000..d1b3fd3a10 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml @@ -0,0 +1,11 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue"; objectName: "pc1" } + PropertyChanges { target: myRectangle; radius: 5; objectName: "pc2" } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml b/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml new file mode 100644 index 0000000000..654e09cb2e --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml @@ -0,0 +1,13 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + StateGroup { + id: stateGroup + states: State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml b/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml new file mode 100644 index 0000000000..08d0209615 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml @@ -0,0 +1,34 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + + property color sourceColor: "blue" + width: 400; height: 400 + color: "red" + + Rectangle { + id: rect2 + objectName: "rect2" + width: parent.width + 2 + height: 200 + color: "yellow" + } + + states: [ + State { + name: "blue" + PropertyChanges { + target: rect2 + width:50 + height: 40 + } + }, + State { + name: "green" + PropertyChanges { + target: rect2 + width: myRectangle.width / 2 + height: myRectangle.width / 4 + } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml b/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml new file mode 100644 index 0000000000..426731914f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml @@ -0,0 +1,15 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + property color sourceColor: "blue" + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { + objectName: "changes" + target: myRectangle; explicit: true + color: sourceColor + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml new file mode 100644 index 0000000000..a4b77b122e --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 + +Rectangle { + width: 200 + height: 200 + + Rectangle { + id: rect + objectName: "greenRect" + width: 100 + height: 100 + color: "green" + } + + states:[ + State { + name: "a" + PropertyChanges { target: rect; x: 100 } + }, + State { + name: "b" + extend:"a" + PropertyChanges { target: rect; y: 100 } + } + ] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml b/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml new file mode 100644 index 0000000000..a98c96bedc --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: [ + State { + name: "blue" + PropertyChanges { target: myRectangle; color: "blue" } + }, + State { + name: "green" + extend: "blue" + PropertyChanges { target: myRectangle; color: "green" } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml b/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml new file mode 100644 index 0000000000..e6444325a3 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 + +Rectangle { + id: myItem + + states : State { + PropertyChanges { + target: myItem + children: Item { id: newItem } + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml b/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml new file mode 100644 index 0000000000..c04b03c94b --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml @@ -0,0 +1,21 @@ +import QtQuick 1.0 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + PropertyChanges { target: card; state: "idle" } + }, + State { + name: "idle" + } + ] + + MouseArea { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/image.png b/tests/auto/qtquick1/qdeclarativestates/data/image.png new file mode 100644 index 0000000000..ed1833c95b Binary files /dev/null and b/tests/auto/qtquick1/qdeclarativestates/data/image.png differ diff --git a/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml b/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml new file mode 100644 index 0000000000..4d500d9e05 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml @@ -0,0 +1,23 @@ +import QtQuick 1.0 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + onCompleted: card.state = "idle" + StateChangeScript { script: console.log("entering placed") } + }, + State { + name: "idle" + StateChangeScript { script: console.log("entering idle") } + } + ] + + MouseArea { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml b/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml new file mode 100644 index 0000000000..4973b82c3f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml @@ -0,0 +1,11 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; colr: "blue" } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml new file mode 100644 index 0000000000..2f7e80eb08 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml @@ -0,0 +1,37 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + Item { + x: 10; y: 10 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5 + width: 100; height: 100 + color: "red" + } + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + x: -100; y: -50 + Item { + id: newParent + objectName: "NewParent" + x: 248; y: 360 + } + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml new file mode 100644 index 0000000000..bdd0c6c282 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml @@ -0,0 +1,31 @@ +import QtQuick 1.0 + +Rectangle { + id: newParent + width: 400; height: 400 + Item { + scale: .5 + rotation: 15 + x: 10; y: 10 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5 + width: 100; height: 100 + color: "red" + } + } + MouseArea { + id: clickable + anchors.fill: parent + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml new file mode 100644 index 0000000000..55f3ead7c6 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml @@ -0,0 +1,42 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + Item { + scale: .5 + rotation: 15 + transformOrigin: "Center" + x: 10; y: 10 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5 + width: 100; height: 100 + transformOrigin: "BottomLeft" + color: "red" + } + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + x: 200; y: 200 + rotation: 52; + scale: 2 + Item { + id: newParent + x: 100; y: 100 + } + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml new file mode 100644 index 0000000000..ae05b05072 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + transform: Scale { xScale: .5; yScale: .7} + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml new file mode 100644 index 0000000000..32a0b91cd9 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + transform: Rotation { angle: 30; axis { x: 0; y: 1; z: 0 } } + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml new file mode 100644 index 0000000000..70ad894ffc --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml @@ -0,0 +1,30 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + Rectangle { + id: myRect + objectName: "MyRect" + x: 5; y: 5 + width: 100; height: 100 + color: "red" + } + MouseArea { + id: clickable + anchors.fill: parent + } + + Item { + id: newParent + rotation: 180 + } + + states: State { + name: "reparented" + when: clickable.pressed + ParentChange { + target: myRect + parent: newParent + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml b/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml new file mode 100644 index 0000000000..3ab3c3252e --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/reset.qml b/tests/auto/qtquick1/qdeclarativestates/data/reset.qml new file mode 100644 index 0000000000..a140ffab4d --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/reset.qml @@ -0,0 +1,19 @@ +import QtQuick 1.0 + +Rectangle { + width: 640 + height: 480 + Image { + id: image + width: 40 + source: "image.png" + } + + states: State { + name: "state1" + PropertyChanges { + target: image + width: undefined + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml b/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml new file mode 100644 index 0000000000..dfd7c1794a --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + PropertyChanges { + target: myRectangle + restoreEntryValues: false + color: "blue" + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml b/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml new file mode 100644 index 0000000000..a0d053cf03 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml @@ -0,0 +1,21 @@ +import QtQuick 1.0 + +Rectangle { + id: theRect + property bool triggerState: false + property string stateString: "" + states: [ State { + when: triggerState + PropertyChanges { + target: theRect + stateString: "inState" + } + }, + State { + name: "" + PropertyChanges { + target: theRect + stateString: "originalState" + } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/script.qml b/tests/auto/qtquick1/qdeclarativestates/data/script.qml new file mode 100644 index 0000000000..630aaf0ffa --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/script.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 +Rectangle { + id: myRectangle + width: 100; height: 100 + color: "red" + states: State { + name: "blue" + StateChangeScript { script: myRectangle.color = "blue"; } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml new file mode 100644 index 0000000000..0eaf547644 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml @@ -0,0 +1,18 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +MyRectangle { + id: rect + + onDidSomething: color = "blue" + + width: 100; height: 100 + color: "red" + states: State { + name: "green" + PropertyChanges { + target: rect + onDidSomething: color = "green" + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml new file mode 100644 index 0000000000..ef26ff14e7 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml @@ -0,0 +1,9 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +MyRectangle { + id: rect + onDidSomething: color = "blue" + width: 100; height: 100 + ExtendedRectangle {} +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml new file mode 100644 index 0000000000..8e9b698383 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml @@ -0,0 +1,15 @@ +import QtQuick 1.0 +import Qt.test 1.0 + +MyRectangle { + id: rect + + width: 100; height: 100 + states: State { + name: "overridden" + PropertyChanges { + target: rect + onDidSomething: rect.state = "" + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml new file mode 100644 index 0000000000..74df9430c3 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 + +Rectangle { + id: myRect + width: 400 + height: 400 + + states: [ + State { + name: "state1" + PropertyChanges { + target: myRect + onHeightChanged: console.log("Hello World") + color: "green" + } + }, + State { + name: "state2"; extend: "state1" + PropertyChanges { + target: myRect + color: "red" + } + }] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml new file mode 100644 index 0000000000..4425b4dd49 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml @@ -0,0 +1,14 @@ +import QtQuick 1.0 + +Rectangle { + id: theRect + property bool triggerState: false + property string stateString: "" + states: State { + when: triggerState + PropertyChanges { + target: theRect + stateString: "inState" + } + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml b/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml new file mode 100644 index 0000000000..743f5404b0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml @@ -0,0 +1,12 @@ +import QtQuick 1.0 +import "Implementation" + +Rectangle { + width: 100 + height: 200 + + MyType { + objectName: "MyType" + anchors.fill: parent + } +} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml b/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml new file mode 100644 index 0000000000..48aef5a6ce --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml @@ -0,0 +1,11 @@ +import QtQuick 1.0 + +Rectangle { + property bool condition1: false + property bool condition2: false + + states: [ + State { name: "state1"; when: condition1 }, + State { name: "state2"; when: condition2 } + ] +} diff --git a/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro b/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro new file mode 100644 index 0000000000..79990aa31a --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro @@ -0,0 +1,16 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativestates.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp new file mode 100644 index 0000000000..8da3abf614 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp @@ -0,0 +1,1514 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class MyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo WRITE setFoo) +public: + MyAttached(QObject *parent) : QObject(parent), m_foo(13) {} + + int foo() const { return m_foo; } + void setFoo(int f) { m_foo = f; } + +private: + int m_foo; +}; + +class MyRect : public QDeclarative1Rectangle +{ + Q_OBJECT + Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) +public: + MyRect() {} + + void doSomething() { emit didSomething(); } + + int propertyWithNotify() const { return m_prop; } + void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); } + + static MyAttached *qmlAttachedProperties(QObject *o) { + return new MyAttached(o); + } +Q_SIGNALS: + void didSomething(); + void oddlyNamedNotifySignal(); + +private: + int m_prop; +}; + +QML_DECLARE_TYPE(MyRect) +QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES) + +class tst_qdeclarativestates : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativestates() {} + +private: + static QByteArray fullDataPath(const QString &path); + +private slots: + void initTestCase(); + + void basicChanges(); + void attachedPropertyChanges(); + void basicExtension(); + void basicBinding(); + void signalOverride(); + void signalOverrideCrash(); + void signalOverrideCrash2(); + void parentChange(); + void parentChangeErrors(); + void anchorChanges(); + void anchorChanges2(); + void anchorChanges3(); + void anchorChanges4(); + void anchorChanges5(); + void anchorChangesRTL(); + void anchorChangesRTL2(); + void anchorChangesRTL3(); + void anchorChangesCrash(); + void anchorRewindBug(); + void anchorRewindBug2(); + void script(); + void restoreEntryValues(); + void explicitChanges(); + void propertyErrors(); + void incorrectRestoreBug(); + void autoStateAtStartupRestoreBug(); + void deletingChange(); + void deletingState(); + void tempState(); + void illegalTempState(); + void nonExistantProperty(); + void reset(); + void illegalObjectCreation(); + void whenOrdering(); + void urlResolution(); + void unnamedWhen(); + void returnToBase(); + void extendsBug(); + void editProperties(); + void QTBUG_14830(); +}; + +void tst_qdeclarativestates::initTestCase() +{ + qmlRegisterType("Qt.test", 1, 0, "MyRectangle"); +} + +QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) +{ + return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8(); +} + +void tst_qdeclarativestates::basicChanges() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),2); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),2); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + } + + { + // Test basicChanges4.qml can magically connect to propertyWithNotify's notify + // signal using 'onPropertyWithNotifyChanged' even though the signal name is + // actually 'oddlyNamedNotifySignal' + + QDeclarativeComponent component(&engine, SRCDIR "/data/basicChanges4.qml"); + QVERIFY(component.isReady()); + + MyRect *rect = qobject_cast(component.create()); + QVERIFY(rect != 0); + + QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify")); + QVERIFY(prop.hasNotifySignal()); + QString notifySignal = QByteArray(prop.notifySignal().signature()); + QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged(")); + + QCOMPARE(rect->color(), QColor(Qt::red)); + + rect->setPropertyWithNotify(100); + QCOMPARE(rect->color(), QColor(Qt::blue)); + } +} + +void tst_qdeclarativestates::attachedPropertyChanges() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent component(&engine, SRCDIR "/data/attachedPropertyChanges.qml"); + QVERIFY(component.isReady()); + + QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + QCOMPARE(item->width(), 50.0); + + // Ensure attached property has been changed + QObject *attObj = qmlAttachedPropertiesObject(item, false); + QVERIFY(attObj); + + MyAttached *att = qobject_cast(attObj); + QVERIFY(att); + + QCOMPARE(att->foo(), 1); +} + +void tst_qdeclarativestates::basicExtension() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),2); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),1); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + + rectPrivate->setState("bordered"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->border()->width(),2); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->border()->width(),1); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + } +} + +void tst_qdeclarativestates::basicBinding() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("green")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("red")); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor2", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor2", QColor("green")); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("yellow")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + rect->setProperty("sourceColor", QColor("purple")); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("purple")); + + rectPrivate->setState("green"); + QCOMPARE(rect->color(),QColor("green")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + } +} + +void tst_qdeclarativestates::signalOverride() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml"); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + + QDeclarativeItemPrivate::get(rect)->setState("green"); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("green")); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml"); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("white")); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); + QDeclarativeItemPrivate::get(innerRect)->setState("green"); + rect->doSomething(); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(innerRect->color(),QColor("green")); + QCOMPARE(innerRect->property("extendedColor").value(),QColor("green")); + } +} + +void tst_qdeclarativestates::signalOverrideCrash() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml"); + MyRect *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeItemPrivate::get(rect)->setState("overridden"); + rect->doSomething(); +} + +void tst_qdeclarativestates::signalOverrideCrash2() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash2.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeItemPrivate::get(rect)->setState("state1"); + QDeclarativeItemPrivate::get(rect)->setState("state2"); + QDeclarativeItemPrivate::get(rect)->setState("state1"); + + delete rect; +} + +void tst_qdeclarativestates::parentChange() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange1.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1ParentChange *pChange = qobject_cast(state->operationAt(0)); + QVERIFY(pChange != 0); + QDeclarativeItem *nParent = qobject_cast(rect->findChild("NewParent")); + QVERIFY(nParent != 0); + + QCOMPARE(pChange->parent(), nParent); + + QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(-133)); + QCOMPARE(innerRect->y(), qreal(-300)); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + rectPrivate->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(15)); + QCOMPARE(innerRect->scale(), qreal(.5)); + QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075)); + QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433)); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + rectPrivate->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(-37)); + QCOMPARE(innerRect->scale(), qreal(.25)); + QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305)); + QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(5)); + //do a non-qFuzzyCompare fuzzy compare + QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001)); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange6.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(180)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(-105)); + QCOMPARE(innerRect->y(), qreal(-105)); + } +} + +void tst_qdeclarativestates::parentChangeErrors() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(5)); + QCOMPARE(innerRect->y(), qreal(5)); + } + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange5.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); + QDeclarativeItemPrivate::get(rect)->setState("reparented"); + QCOMPARE(innerRect->rotation(), qreal(0)); + QCOMPARE(innerRect->scale(), qreal(1)); + QCOMPARE(innerRect->x(), qreal(5)); + QCOMPARE(innerRect->y(), qreal(5)); + } +} + +void tst_qdeclarativestates::anchorChanges() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), qreal(150)); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarative1AnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), qreal(5)); + + delete rect; +} + +void tst_qdeclarativestates::anchorChanges2() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), qreal(5)); + + delete rect; +} + +void tst_qdeclarativestates::anchorChanges3() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + rectPrivate->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); + + QCOMPARE(innerRect->x(), qreal(10)); + QCOMPARE(innerRect->y(), qreal(0)); + QCOMPARE(innerRect->width(), qreal(190)); + QCOMPARE(innerRect->height(), qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), qreal(0)); + QCOMPARE(innerRect->y(), qreal(10)); + QCOMPARE(innerRect->width(), qreal(150)); + QCOMPARE(innerRect->height(), qreal(190)); + + delete rect; +} + +void tst_qdeclarativestates::anchorChanges4() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); + + delete rect; +} + +void tst_qdeclarativestates::anchorChanges5() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + + QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + //QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); + //QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); + //QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item); + //QCOMPARE(aChanges->anchors()->baseline().anchorLine, leftGuideline->baseline().anchorLine); + + delete rect; +} + +void mirrorAnchors(QDeclarativeItem *item) { + QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); + itemPrivate->setLayoutMirror(true); +} + +qreal offsetRTL(QDeclarativeItem *anchorItem, QDeclarativeItem *item) { + return anchorItem->width()+2*anchorItem->x()-item->width(); +} + +void tst_qdeclarativestates::anchorChangesRTL() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + mirrorAnchors(innerRect); + + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarative1AnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5)); + + delete rect; +} + +void tst_qdeclarativestates::anchorChangesRTL2() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + mirrorAnchors(innerRect); + + rectPrivate->setState("right"); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5)); + + delete rect; +} + +void tst_qdeclarativestates::anchorChangesRTL3() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); + QVERIFY(innerRect != 0); + mirrorAnchors(innerRect); + + QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); + QVERIFY(leftGuideline != 0); + + QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); + QVERIFY(bottomGuideline != 0); + + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); + QVERIFY(aChanges != 0); + + rectPrivate->setState("reanchored"); + QCOMPARE(aChanges->object(), qobject_cast(innerRect)); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); + QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); + + QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10)); + QCOMPARE(innerRect->y(), qreal(0)); + // between left side of parent and leftGuideline.x: 10, which has width 0 + QCOMPARE(innerRect->width(), qreal(10)); + QCOMPARE(innerRect->height(), qreal(150)); + + rectPrivate->setState(""); + QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0)); + QCOMPARE(innerRect->y(), qreal(10)); + // between right side of parent and left side of rightGuideline.x: 150, which has width 0 + QCOMPARE(innerRect->width(), qreal(50)); + QCOMPARE(innerRect->height(), qreal(190)); + + delete rect; +} + +//QTBUG-9609 +void tst_qdeclarativestates::anchorChangesCrash() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChangesCrash.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + + delete rect; +} + +// QTBUG-12273 +void tst_qdeclarativestates::anchorRewindBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeItem * column = rect->findChild("column"); + + QVERIFY(column != 0); + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 200.0); + QDeclarativeItemPrivate::get(rect)->setState("reanchored"); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 100.0); + + QDeclarativeItemPrivate::get(rect)->setState(""); + + // column height and width should stay implicit + // and column's implicit resizing should still work + QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); + QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); + QCOMPARE(column->height(), 200.0); + + delete rect; +} + +// QTBUG-11834 +void tst_qdeclarativestates::anchorRewindBug2() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug2.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1Rectangle *mover = rect->findChild("mover"); + + QVERIFY(mover != 0); + QCOMPARE(mover->y(), qreal(0.0)); + QCOMPARE(mover->width(), qreal(50.0)); + + QDeclarativeItemPrivate::get(rect)->setState("anchored"); + QCOMPARE(mover->y(), qreal(250.0)); + QCOMPARE(mover->width(), qreal(200.0)); + + QDeclarativeItemPrivate::get(rect)->setState(""); + QCOMPARE(mover->y(), qreal(0.0)); + QCOMPARE(mover->width(), qreal(50.0)); + + delete rect; +} + +void tst_qdeclarativestates::script() +{ + QDeclarativeEngine engine; + + { + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted + } +} + +void tst_qdeclarativestates::restoreEntryValues() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("blue")); +} + +void tst_qdeclarativestates::explicitChanges() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QDeclarativeListReference list(rect, "states"); + QDeclarative1State *state = qobject_cast(list.at(0)); + QVERIFY(state != 0); + + qmlExecuteDeferred(state); + QDeclarative1PropertyChanges *changes = qobject_cast(rect->findChild("changes")); + QVERIFY(changes != 0); + QVERIFY(changes->isExplicit()); + + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rect->setProperty("sourceColor", QColor("green")); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + rect->setProperty("sourceColor", QColor("yellow")); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("yellow")); +} + +void tst_qdeclarativestates::propertyErrors() +{ + QDeclarativeEngine engine; + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QCOMPARE(rect->color(),QColor("red")); + + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\""); + QDeclarativeItemPrivate::get(rect)->setState("blue"); +} + +void tst_qdeclarativestates::incorrectRestoreBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QCOMPARE(rect->color(),QColor("red")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + // make sure if we change the base state value, we then restore to it correctly + rect->setColor(QColor("green")); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("green")); +} + +void tst_qdeclarativestates::autoStateAtStartupRestoreBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent component(&engine, SRCDIR "/data/autoStateAtStartupRestoreBug.qml"); + QObject *obj = component.create(); + + QVERIFY(obj != 0); + QCOMPARE(obj->property("test").toInt(), 3); + + obj->setProperty("input", 2); + + QCOMPARE(obj->property("test").toInt(), 9); + + delete obj; +} + +void tst_qdeclarativestates::deletingChange() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + QCOMPARE(rect->radius(),qreal(5)); + + rectPrivate->setState(""); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->radius(),qreal(0)); + + QDeclarative1PropertyChanges *pc = rect->findChild("pc1"); + QVERIFY(pc != 0); + delete pc; + + QDeclarative1State *state = rect->findChild(); + QVERIFY(state != 0); + qmlExecuteDeferred(state); + QCOMPARE(state->operationCount(), 1); + + rectPrivate->setState("blue"); + QCOMPARE(rect->color(),QColor("red")); + QCOMPARE(rect->radius(),qreal(5)); + + delete rect; +} + +void tst_qdeclarativestates::deletingState() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarative1StateGroup *sg = rect->findChild(); + QVERIFY(sg != 0); + QVERIFY(sg->findState("blue") != 0); + + sg->setState("blue"); + QCOMPARE(rect->color(),QColor("blue")); + + sg->setState(""); + QCOMPARE(rect->color(),QColor("red")); + + QDeclarative1State *state = rect->findChild(); + QVERIFY(state != 0); + delete state; + + QVERIFY(sg->findState("blue") == 0); + + //### should we warn that state doesn't exist + sg->setState("blue"); + QCOMPARE(rect->color(),QColor("red")); + + delete rect; +} + +void tst_qdeclarativestates::tempState() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QTest::ignoreMessage(QtDebugMsg, "entering placed"); + QTest::ignoreMessage(QtDebugMsg, "entering idle"); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("idle")); +} + +void tst_qdeclarativestates::illegalTempState() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QTest::ignoreMessage(QtWarningMsg, ": QML StateGroup: Can't apply a state change as part of a state definition."); + rectPrivate->setState("placed"); + QCOMPARE(rectPrivate->state(), QLatin1String("placed")); +} + +void tst_qdeclarativestates::nonExistantProperty() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); + QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); + rectPrivate->setState("blue"); + QCOMPARE(rectPrivate->state(), QLatin1String("blue")); +} + +void tst_qdeclarativestates::reset() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QDeclarative1Image *image = rect->findChild(); + QVERIFY(image != 0); + QCOMPARE(image->width(), qreal(40.)); + QCOMPARE(image->height(), qreal(20.)); + + QDeclarativeItemPrivate::get(rect)->setState("state1"); + + QCOMPARE(image->width(), 20.0); + QCOMPARE(image->height(), qreal(20.)); +} + +void tst_qdeclarativestates::illegalObjectCreation() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent component(&engine, SRCDIR "/data/illegalObj.qml"); + QList errors = component.errors(); + QVERIFY(errors.count() == 1); + const QDeclarativeError &error = errors.at(0); + QCOMPARE(error.line(), 9); + QCOMPARE(error.column(), 23); + QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects."); +} + +void tst_qdeclarativestates::whenOrdering() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + rect->setProperty("condition2", true); + QCOMPARE(rectPrivate->state(), QLatin1String("state2")); + rect->setProperty("condition1", true); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); + rect->setProperty("condition2", false); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); + rect->setProperty("condition2", true); + QCOMPARE(rectPrivate->state(), QLatin1String("state1")); + rect->setProperty("condition1", false); + rect->setProperty("condition2", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); +} + +void tst_qdeclarativestates::urlResolution() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/urlResolution.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QDeclarativeItem *myType = rect->findChild("MyType"); + QDeclarative1Image *image1 = rect->findChild("image1"); + QDeclarative1Image *image2 = rect->findChild("image2"); + QDeclarative1Image *image3 = rect->findChild("image3"); + QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); + + QDeclarativeItemPrivate::get(myType)->setState("SetImageState"); + QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png"); + QCOMPARE(image1->source(), resolved); + QCOMPARE(image2->source(), resolved); + QCOMPARE(image3->source(), resolved); +} + +void tst_qdeclarativestates::unnamedWhen() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); + rect->setProperty("triggerState", true); + QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); + rect->setProperty("triggerState", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); +} + +void tst_qdeclarativestates::returnToBase() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/returnToBase.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); + rect->setProperty("triggerState", true); + QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); + rect->setProperty("triggerState", false); + QCOMPARE(rectPrivate->state(), QLatin1String("")); + QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState")); +} + +//QTBUG-12559 +void tst_qdeclarativestates::extendsBug() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/extendsBug.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + QDeclarative1Rectangle *greenRect = rect->findChild("greenRect"); + + rectPrivate->setState("b"); + QCOMPARE(greenRect->x(), qreal(100)); + QCOMPARE(greenRect->y(), qreal(100)); +} + +void tst_qdeclarativestates::editProperties() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/editProperties.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + + QDeclarative1StateGroup *stateGroup = rectPrivate->_states(); + QVERIFY(stateGroup != 0); + qmlExecuteDeferred(stateGroup); + + QDeclarative1State *blueState = stateGroup->findState("blue"); + QVERIFY(blueState != 0); + qmlExecuteDeferred(blueState); + + QDeclarative1PropertyChanges *propertyChangesBlue = qobject_cast(blueState->operationAt(0)); + QVERIFY(propertyChangesBlue != 0); + + QDeclarative1State *greenState = stateGroup->findState("green"); + QVERIFY(greenState != 0); + qmlExecuteDeferred(greenState); + + QDeclarative1PropertyChanges *propertyChangesGreen = qobject_cast(greenState->operationAt(0)); + QVERIFY(propertyChangesGreen != 0); + + QDeclarative1Rectangle *childRect = rect->findChild("rect2"); + QVERIFY(childRect != 0); + QCOMPARE(childRect->width(), qreal(402)); + QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + QCOMPARE(childRect->height(), qreal(200)); + + rectPrivate->setState("blue"); + QCOMPARE(childRect->width(), qreal(50)); + QCOMPARE(childRect->height(), qreal(40)); + QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + QVERIFY(blueState->bindingInRevertList(childRect, "width")); + + + rectPrivate->setState("green"); + QCOMPARE(childRect->width(), qreal(200)); + QCOMPARE(childRect->height(), qreal(100)); + QVERIFY(greenState->bindingInRevertList(childRect, "width")); + + + rectPrivate->setState(""); + + + QCOMPARE(propertyChangesBlue->actions().length(), 2); + QVERIFY(propertyChangesBlue->containsValue("width")); + QVERIFY(!propertyChangesBlue->containsProperty("x")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); + QVERIFY(!propertyChangesBlue->value("x").isValid()); + + propertyChangesBlue->changeValue("width", 60); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + + + propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); + QVERIFY(!propertyChangesBlue->containsValue("width")); + QVERIFY(propertyChangesBlue->containsExpression("width")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + + propertyChangesBlue->changeValue("width", 50); + QVERIFY(propertyChangesBlue->containsValue("width")); + QVERIFY(!propertyChangesBlue->containsExpression("width")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + + QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + rectPrivate->setState("blue"); + QCOMPARE(childRect->width(), qreal(50)); + QCOMPARE(childRect->height(), qreal(40)); + + propertyChangesBlue->changeValue("width", 60); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + QCOMPARE(childRect->width(), qreal(60)); + QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + + propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); + QVERIFY(!propertyChangesBlue->containsValue("width")); + QVERIFY(propertyChangesBlue->containsExpression("width")); + QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); + QCOMPARE(propertyChangesBlue->actions().length(), 2); + QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + QCOMPARE(childRect->width(), qreal(200)); + + propertyChangesBlue->changeValue("width", 50); + QCOMPARE(childRect->width(), qreal(50)); + + rectPrivate->setState(""); + QCOMPARE(childRect->width(), qreal(402)); + QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + + QCOMPARE(propertyChangesGreen->actions().length(), 2); + rectPrivate->setState("green"); + QCOMPARE(childRect->width(), qreal(200)); + QCOMPARE(childRect->height(), qreal(100)); + QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + QVERIFY(greenState->bindingInRevertList(childRect, "width")); + QCOMPARE(propertyChangesGreen->actions().length(), 2); + + + propertyChangesGreen->removeProperty("height"); + QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "height"))); + QCOMPARE(childRect->height(), qreal(200)); + + QVERIFY(greenState->bindingInRevertList(childRect, "width")); + QVERIFY(greenState->containsPropertyInRevertList(childRect, "width")); + propertyChangesGreen->removeProperty("width"); + QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); + QCOMPARE(childRect->width(), qreal(402)); + QVERIFY(!greenState->bindingInRevertList(childRect, "width")); + QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width")); + + propertyChangesBlue->removeProperty("width"); + QCOMPARE(childRect->width(), qreal(402)); + + rectPrivate->setState("blue"); + QCOMPARE(childRect->width(), qreal(402)); + QCOMPARE(childRect->height(), qreal(40)); +} + +void tst_qdeclarativestates::QTBUG_14830() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent c(&engine, SRCDIR "/data/QTBUG-14830.qml"); + QDeclarative1Rectangle *rect = qobject_cast(c.create()); + QVERIFY(rect != 0); + QDeclarativeItem *item = rect->findChild("area"); + + QCOMPARE(item->width(), qreal(171)); +} + +QTEST_MAIN(tst_qdeclarativestates) + +#include "tst_qdeclarativestates.moc" diff --git a/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro new file mode 100644 index 0000000000..eb1ff6ac58 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativesystempalette.cpp + +!symbian: { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp new file mode 100644 index 0000000000..0c44e9f833 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp @@ -0,0 +1,192 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativesystempalette : public QObject + +{ + Q_OBJECT +public: + tst_qdeclarativesystempalette(); + +private slots: + void activePalette(); + void inactivePalette(); + void disabledPalette(); + void paletteChanged(); + +private: + QDeclarativeEngine engine; +}; + +tst_qdeclarativesystempalette::tst_qdeclarativesystempalette() +{ +} + +void tst_qdeclarativesystempalette::activePalette() +{ + QString componentStr = "import QtQuick 1.0\nSystemPalette { }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1SystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Active); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qdeclarativesystempalette::inactivePalette() +{ + QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Inactive }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1SystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + QVERIFY(object->colorGroup() == QDeclarative1SystemPalette::Inactive); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Inactive); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qdeclarativesystempalette::disabledPalette() +{ + QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Disabled }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1SystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + QVERIFY(object->colorGroup() == QDeclarative1SystemPalette::Disabled); + + QPalette palette; + palette.setCurrentColorGroup(QPalette::Disabled); + QCOMPARE(palette.window().color(), object->window()); + QCOMPARE(palette.windowText().color(), object->windowText()); + QCOMPARE(palette.base().color(), object->base()); + QCOMPARE(palette.text().color(), object->text()); + QCOMPARE(palette.alternateBase().color(), object->alternateBase()); + QCOMPARE(palette.button().color(), object->button()); + QCOMPARE(palette.buttonText().color(), object->buttonText()); + QCOMPARE(palette.light().color(), object->light()); + QCOMPARE(palette.midlight().color(), object->midlight()); + QCOMPARE(palette.dark().color(), object->dark()); + QCOMPARE(palette.mid().color(), object->mid()); + QCOMPARE(palette.shadow().color(), object->shadow()); + QCOMPARE(palette.highlight().color(), object->highlight()); + QCOMPARE(palette.highlightedText().color(), object->highlightedText()); + + delete object; +} + +void tst_qdeclarativesystempalette::paletteChanged() +{ + QString componentStr = "import QtQuick 1.0\nSystemPalette { }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarative1SystemPalette *object = qobject_cast(component.create()); + + QVERIFY(object != 0); + + QPalette p; + p.setCurrentColorGroup(QPalette::Active); + p.setColor(QPalette::Active, QPalette::Text, QColor("red")); + p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green")); + p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue")); + + qApp->setPalette(p); + + object->setColorGroup(QDeclarative1SystemPalette::Active); + QTRY_COMPARE(QColor("red"), object->text()); + QTRY_COMPARE(QColor("green"), object->buttonText()); + QTRY_COMPARE(QColor("blue"), object->windowText()); + + delete object; +} + +QTEST_MAIN(tst_qdeclarativesystempalette) + +#include "tst_qdeclarativesystempalette.moc" diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/qtquick1/qdeclarativetext/data/alignments.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments.qml rename to tests/auto/qtquick1/qdeclarativetext/data/alignments.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_cb.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_cc.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_ct.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_lb.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_lc.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_lt.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_rb.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_rc.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/alignments_rt.png rename to tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png diff --git a/tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml b/tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/elideimplicitwidth.qml rename to tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml rename to tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml rename to tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml rename to tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml rename to tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml rename to tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/http/exists.png b/tests/auto/qtquick1/qdeclarativetext/data/http/exists.png similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/http/exists.png rename to tests/auto/qtquick1/qdeclarativetext/data/http/exists.png diff --git a/tests/auto/declarative/qdeclarativetext/data/lineCount.qml b/tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/lineCount.qml rename to tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/lineHeight.qml b/tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/lineHeight.qml rename to tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/qtbug_14734.qml b/tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/qtbug_14734.qml rename to tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml diff --git a/tests/auto/declarative/qdeclarativetext/data/rotated.qml b/tests/auto/qtquick1/qdeclarativetext/data/rotated.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetext/data/rotated.qml rename to tests/auto/qtquick1/qdeclarativetext/data/rotated.qml diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro similarity index 58% rename from tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro rename to tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro index 5a043e0a05..fbb88ae1fa 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro @@ -1,13 +1,13 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 QT += network macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetext.cpp -INCLUDEPATH += ../shared/ -HEADERS += ../shared/testhttpserver.h -SOURCES += ../shared/testhttpserver.cpp +INCLUDEPATH += ../../declarative/shared/ +HEADERS += ../../declarative/shared/testhttpserver.h +SOURCES += ../../declarative/shared/testhttpserver.cpp symbian: { importFiles.files = data @@ -19,4 +19,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp similarity index 83% rename from tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp rename to tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp index 118303ea56..d6984cb98a 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp @@ -42,13 +42,13 @@ #include #include #include -#include -#include +#include +#include #include #include #include #include -#include +#include #include #include @@ -121,7 +121,7 @@ private slots: QList horizontalAlignmentments; QStringList styleStrings; - QList styles; + QList styles; QStringList colorStrings; @@ -159,10 +159,10 @@ tst_qdeclarativetext::tst_qdeclarativetext() << "Raised" << "Sunken"; - styles << QDeclarativeText::Normal - << QDeclarativeText::Outline - << QDeclarativeText::Raised - << QDeclarativeText::Sunken; + styles << QDeclarative1Text::Normal + << QDeclarative1Text::Outline + << QDeclarative1Text::Raised + << QDeclarative1Text::Sunken; colorStrings << "aliceblue" << "antiquewhite" @@ -196,7 +196,7 @@ void tst_qdeclarativetext::text() { QDeclarativeComponent textComponent(&engine); textComponent.setData("import QtQuick 1.0\nText { text: \"\" }", QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->text(), QString("")); @@ -211,7 +211,7 @@ void tst_qdeclarativetext::text() QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->text(), standard.at(i)); @@ -225,7 +225,7 @@ void tst_qdeclarativetext::text() QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QString expected = richText.at(i); @@ -242,7 +242,7 @@ void tst_qdeclarativetext::width() { QDeclarativeComponent textComponent(&engine); textComponent.setData("import QtQuick 1.0\nText { text: \"\" }", QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->width(), 0.); @@ -262,12 +262,12 @@ void tst_qdeclarativetext::width() QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QVERIFY(textObject->boundingRect().width() > 0); QCOMPARE(textObject->width(), qreal(metricWidth)); - QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format + QVERIFY(textObject->textFormat() == QDeclarative1Text::AutoText); // setting text doesn't change format delete textObject; } @@ -285,11 +285,11 @@ void tst_qdeclarativetext::width() QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->width(), qreal(documentWidth)); - QVERIFY(textObject->textFormat() == QDeclarativeText::AutoText); // setting text doesn't change format + QVERIFY(textObject->textFormat() == QDeclarative1Text::AutoText); // setting text doesn't change format delete textObject; } @@ -302,11 +302,11 @@ void tst_qdeclarativetext::wrap() { QDeclarativeComponent textComponent(&engine); textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); textHeight = textObject->height(); QVERIFY(textObject != 0); - QVERIFY(textObject->wrapMode() == QDeclarativeText::WordWrap); + QVERIFY(textObject->wrapMode() == QDeclarative1Text::WordWrap); QCOMPARE(textObject->width(), 300.); delete textObject; @@ -317,7 +317,7 @@ void tst_qdeclarativetext::wrap() QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->width(), 30.); @@ -335,7 +335,7 @@ void tst_qdeclarativetext::wrap() QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->width(), 30.); @@ -354,7 +354,7 @@ void tst_qdeclarativetext::wrap() QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->width(), 30.); @@ -370,7 +370,7 @@ void tst_qdeclarativetext::wrap() void tst_qdeclarativetext::elide() { - for (QDeclarativeText::TextElideMode m = QDeclarativeText::ElideLeft; m<=QDeclarativeText::ElideNone; m=QDeclarativeText::TextElideMode(int(m)+1)) { + for (QDeclarative1Text::TextElideMode m = QDeclarative1Text::ElideLeft; m<=QDeclarative1Text::ElideNone; m=QDeclarative1Text::TextElideMode(int(m)+1)) { const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"}; QString elide = "elide: Text." + QString(elidename[int(m)]) + ";"; @@ -379,7 +379,7 @@ void tst_qdeclarativetext::elide() { QDeclarativeComponent textComponent(&engine); textComponent.setData(("import QtQuick 1.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->elideMode(), m); QCOMPARE(textObject->width(), 100.); @@ -392,7 +392,7 @@ void tst_qdeclarativetext::elide() QString componentStr = "import QtQuick 1.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->elideMode(), m); QCOMPARE(textObject->width(), 100.); @@ -406,7 +406,7 @@ void tst_qdeclarativetext::elide() QString componentStr = "import QtQuick 1.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->elideMode(), m); QCOMPARE(textObject->width(), 100.); @@ -428,20 +428,20 @@ void tst_qdeclarativetext::textFormat() { QDeclarativeComponent textComponent(&engine); textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarativeText::RichText); + QVERIFY(textObject->textFormat() == QDeclarative1Text::RichText); delete textObject; } { QDeclarativeComponent textComponent(&engine); textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarativeText::PlainText); + QVERIFY(textObject->textFormat() == QDeclarative1Text::PlainText); delete textObject; } @@ -522,7 +522,7 @@ void tst_qdeclarativetext::horizontalAlignment() QString componentStr = "import QtQuick 1.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); @@ -537,7 +537,7 @@ void tst_qdeclarativetext::horizontalAlignment() QString componentStr = "import QtQuick 1.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); @@ -550,86 +550,86 @@ void tst_qdeclarativetext::horizontalAlignment() void tst_qdeclarativetext::horizontalAlignment_RightToLeft() { QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml"); - QDeclarativeText *text = canvas->rootObject()->findChild("text"); + QDeclarative1Text *text = canvas->rootObject()->findChild("text"); QVERIFY(text != 0); canvas->show(); - QDeclarativeTextPrivate *textPrivate = QDeclarativeTextPrivate::get(text); + QDeclarative1TextPrivate *textPrivate = QDeclarative1TextPrivate::get(text); QVERIFY(textPrivate != 0); // implicit alignment should follow the reading direction of RTL text - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); // explicitly left aligned text - text->setHAlign(QDeclarativeText::AlignLeft); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignLeft); + text->setHAlign(QDeclarative1Text::AlignLeft); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); QCOMPARE(text->effectiveHAlign(), text->hAlign()); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); // explicitly right aligned text - text->setHAlign(QDeclarativeText::AlignRight); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); + text->setHAlign(QDeclarative1Text::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); // change to rich text QString textString = text->text(); text->setText(QString("") + textString + QString("")); - text->setTextFormat(QDeclarativeText::RichText); + text->setTextFormat(QDeclarative1Text::RichText); text->resetHAlign(); // implicitly aligned rich text should follow the reading direction of text - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); // explicitly left aligned rich text - text->setHAlign(QDeclarativeText::AlignLeft); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignLeft); + text->setHAlign(QDeclarative1Text::AlignLeft); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); QCOMPARE(text->effectiveHAlign(), text->hAlign()); QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight); // explicitly right aligned rich text - text->setHAlign(QDeclarativeText::AlignRight); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); + text->setHAlign(QDeclarative1Text::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); text->setText(textString); - text->setTextFormat(QDeclarativeText::PlainText); + text->setTextFormat(QDeclarative1Text::PlainText); // explicitly center aligned - text->setHAlign(QDeclarativeText::AlignHCenter); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignHCenter); + text->setHAlign(QDeclarative1Text::AlignHCenter); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignHCenter); QCOMPARE(text->effectiveHAlign(), text->hAlign()); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2); // reseted alignment should go back to following the text reading direction text->resetHAlign(); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); // mirror the text item QDeclarativeItemPrivate::get(text)->setLayoutMirror(true); // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); - QCOMPARE(text->effectiveHAlign(), QDeclarativeText::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); + QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignRight); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); // mirrored explicitly right aligned behaves as left aligned - text->setHAlign(QDeclarativeText::AlignRight); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); - QCOMPARE(text->effectiveHAlign(), QDeclarativeText::AlignLeft); + text->setHAlign(QDeclarative1Text::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); + QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignLeft); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); // mirrored explicitly left aligned behaves as right aligned - text->setHAlign(QDeclarativeText::AlignLeft); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignLeft); - QCOMPARE(text->effectiveHAlign(), QDeclarativeText::AlignRight); + text->setHAlign(QDeclarative1Text::AlignLeft); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); + QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignRight); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); // disable mirroring @@ -638,7 +638,7 @@ void tst_qdeclarativetext::horizontalAlignment_RightToLeft() // English text should be implicitly left aligned text->setText("Hello world!"); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignLeft); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); #ifndef Q_OS_MAC // QTBUG-18040 @@ -646,9 +646,9 @@ void tst_qdeclarativetext::horizontalAlignment_RightToLeft() // keyboard input direction from QApplication::keyboardInputDirection text->setText(""); QCOMPARE(text->hAlign(), QApplication::keyboardInputDirection() == Qt::LeftToRight ? - QDeclarativeText::AlignLeft : QDeclarativeText::AlignRight); - text->setHAlign(QDeclarativeText::AlignRight); - QCOMPARE(text->hAlign(), QDeclarativeText::AlignRight); + QDeclarative1Text::AlignLeft : QDeclarative1Text::AlignRight); + text->setHAlign(QDeclarative1Text::AlignRight); + QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); #endif delete canvas; @@ -658,9 +658,9 @@ void tst_qdeclarativetext::horizontalAlignment_RightToLeft() QString componentStr = "import QtQuick 1.0\nText {}"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->hAlign(), QApplication::keyboardInputDirection() == Qt::LeftToRight ? - QDeclarativeText::AlignLeft : QDeclarativeText::AlignRight); + QDeclarative1Text::AlignLeft : QDeclarative1Text::AlignRight); delete textObject; #endif } @@ -676,7 +676,7 @@ void tst_qdeclarativetext::verticalAlignment() QString componentStr = "import QtQuick 1.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); @@ -692,7 +692,7 @@ void tst_qdeclarativetext::verticalAlignment() QString componentStr = "import QtQuick 1.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); @@ -705,16 +705,16 @@ void tst_qdeclarativetext::verticalAlignment() QString componentStr = "import QtQuick 1.0\nText { height: 80; text: \"Hello\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QRectF br = textObject->boundingRect(); QVERIFY(br.y() == 0); - textObject->setVAlign(QDeclarativeText::AlignVCenter); + textObject->setVAlign(QDeclarative1Text::AlignVCenter); br = textObject->boundingRect(); QCOMPARE(qFloor(br.y()), qFloor((80.0 - br.height())/2)); - textObject->setVAlign(QDeclarativeText::AlignBottom); + textObject->setVAlign(QDeclarative1Text::AlignBottom); br = textObject->boundingRect(); QCOMPARE(qFloor(br.y()), qFloor(80.0 - br.height())); @@ -728,7 +728,7 @@ void tst_qdeclarativetext::font() QString componentStr = "import QtQuick 1.0\nText { font.pointSize: 40; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->font().pointSize(), 40); QCOMPARE(textObject->font().bold(), false); @@ -741,7 +741,7 @@ void tst_qdeclarativetext::font() QString componentStr = "import QtQuick 1.0\nText { font.pixelSize: 40; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->font().pixelSize(), 40); QCOMPARE(textObject->font().bold(), false); @@ -754,7 +754,7 @@ void tst_qdeclarativetext::font() QString componentStr = "import QtQuick 1.0\nText { font.bold: true; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->font().bold(), true); QCOMPARE(textObject->font().italic(), false); @@ -766,7 +766,7 @@ void tst_qdeclarativetext::font() QString componentStr = "import QtQuick 1.0\nText { font.italic: true; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->font().italic(), true); QCOMPARE(textObject->font().bold(), false); @@ -778,7 +778,7 @@ void tst_qdeclarativetext::font() QString componentStr = "import QtQuick 1.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->font().family(), QString("Helvetica")); QCOMPARE(textObject->font().bold(), false); @@ -791,7 +791,7 @@ void tst_qdeclarativetext::font() QString componentStr = "import QtQuick 1.0\nText { font.family: \"\"; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->font().family(), QString("")); @@ -807,7 +807,7 @@ void tst_qdeclarativetext::style() QString componentStr = "import QtQuick 1.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE((int)textObject->style(), (int)styles.at(i)); QCOMPARE(textObject->styleColor(), QColor("white")); @@ -817,10 +817,10 @@ void tst_qdeclarativetext::style() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QRectF brPre = textObject->boundingRect(); - textObject->setStyle(QDeclarativeText::Outline); + textObject->setStyle(QDeclarative1Text::Outline); QRectF brPost = textObject->boundingRect(); QVERIFY(brPre.width() < brPost.width()); @@ -837,7 +837,7 @@ void tst_qdeclarativetext::color() QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); QCOMPARE(textObject->styleColor(), QColor()); @@ -850,7 +850,7 @@ void tst_qdeclarativetext::color() QString componentStr = "import QtQuick 1.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i))); // default color to black? @@ -866,7 +866,7 @@ void tst_qdeclarativetext::color() QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j))); @@ -882,7 +882,7 @@ void tst_qdeclarativetext::color() QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->color(), testColor); @@ -898,7 +898,7 @@ void tst_qdeclarativetext::smooth() QString componentStr = "import QtQuick 1.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->smooth(), true); delete textObject; @@ -907,7 +907,7 @@ void tst_qdeclarativetext::smooth() QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->smooth(), false); delete textObject; @@ -919,7 +919,7 @@ void tst_qdeclarativetext::smooth() QString componentStr = "import QtQuick 1.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->smooth(), true); delete textObject; @@ -928,7 +928,7 @@ void tst_qdeclarativetext::smooth() QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->smooth(), false); delete textObject; @@ -942,7 +942,7 @@ void tst_qdeclarativetext::weight() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal); @@ -953,7 +953,7 @@ void tst_qdeclarativetext::weight() QString componentStr = "import QtQuick 1.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold); @@ -968,7 +968,7 @@ void tst_qdeclarativetext::underline() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().underline(), false); @@ -979,7 +979,7 @@ void tst_qdeclarativetext::underline() QString componentStr = "import QtQuick 1.0\nText { font.underline: true; text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().underline(), true); @@ -994,7 +994,7 @@ void tst_qdeclarativetext::overline() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().overline(), false); @@ -1005,7 +1005,7 @@ void tst_qdeclarativetext::overline() QString componentStr = "import QtQuick 1.0\nText { font.overline: true; text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().overline(), true); @@ -1020,7 +1020,7 @@ void tst_qdeclarativetext::strikeout() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().strikeOut(), false); @@ -1031,7 +1031,7 @@ void tst_qdeclarativetext::strikeout() QString componentStr = "import QtQuick 1.0\nText { font.strikeout: true; text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().strikeOut(), true); @@ -1046,7 +1046,7 @@ void tst_qdeclarativetext::capitalization() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase); @@ -1057,7 +1057,7 @@ void tst_qdeclarativetext::capitalization() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase); @@ -1068,7 +1068,7 @@ void tst_qdeclarativetext::capitalization() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase); @@ -1079,7 +1079,7 @@ void tst_qdeclarativetext::capitalization() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps); @@ -1090,7 +1090,7 @@ void tst_qdeclarativetext::capitalization() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize); @@ -1105,7 +1105,7 @@ void tst_qdeclarativetext::letterSpacing() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().letterSpacing(), 0.0); @@ -1116,7 +1116,7 @@ void tst_qdeclarativetext::letterSpacing() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().letterSpacing(), -2.); @@ -1127,7 +1127,7 @@ void tst_qdeclarativetext::letterSpacing() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().letterSpacing(), 3.); @@ -1142,7 +1142,7 @@ void tst_qdeclarativetext::wordSpacing() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().wordSpacing(), 0.0); @@ -1153,7 +1153,7 @@ void tst_qdeclarativetext::wordSpacing() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().wordSpacing(), -50.); @@ -1164,7 +1164,7 @@ void tst_qdeclarativetext::wordSpacing() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); QCOMPARE(textObject->font().wordSpacing(), 200.); @@ -1185,7 +1185,7 @@ void tst_qdeclarativetext::QTBUG_12291() QObject *ob = canvas->rootObject(); QVERIFY(ob != 0); - QDeclarativeText *text = ob->findChild("text"); + QDeclarative1Text *text = ob->findChild("text"); QVERIFY(text); QVERIFY(text->boundingRect().isValid()); @@ -1216,7 +1216,7 @@ void tst_qdeclarativetext::clickLink() QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); @@ -1269,7 +1269,7 @@ void tst_qdeclarativetext::embeddedImages() QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); QDeclarativeComponent textComponent(&engine, qmlfile); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); @@ -1292,7 +1292,7 @@ void tst_qdeclarativetext::lineCount() { QDeclarativeView *canvas = createView(SRCDIR "/data/lineCount.qml"); - QDeclarativeText *myText = canvas->rootObject()->findChild("myText"); + QDeclarative1Text *myText = canvas->rootObject()->findChild("myText"); QVERIFY(myText != 0); QVERIFY(myText->lineCount() > 1); @@ -1308,7 +1308,7 @@ void tst_qdeclarativetext::lineCount() QCOMPARE(myText->maximumLineCount(), INT_MAX); QCOMPARE(myText->truncated(), false); - myText->setElideMode(QDeclarativeText::ElideRight); + myText->setElideMode(QDeclarative1Text::ElideRight); myText->setMaximumLineCount(2); QCOMPARE(myText->lineCount(), 2); QCOMPARE(myText->truncated(), true); @@ -1321,22 +1321,22 @@ void tst_qdeclarativetext::lineHeight() { QDeclarativeView *canvas = createView(SRCDIR "/data/lineHeight.qml"); - QDeclarativeText *myText = canvas->rootObject()->findChild("myText"); + QDeclarative1Text *myText = canvas->rootObject()->findChild("myText"); QVERIFY(myText != 0); QVERIFY(myText->lineHeight() == 1); - QVERIFY(myText->lineHeightMode() == QDeclarativeText::ProportionalHeight); + QVERIFY(myText->lineHeightMode() == QDeclarative1Text::ProportionalHeight); qreal h = myText->height(); myText->setLineHeight(1.5); QVERIFY(myText->height() == h * 1.5); - myText->setLineHeightMode(QDeclarativeText::FixedHeight); + myText->setLineHeightMode(QDeclarative1Text::FixedHeight); myText->setLineHeight(20); QCOMPARE(myText->height(), myText->lineCount() * 20.0); myText->setText("Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum."); - myText->setLineHeightMode(QDeclarativeText::ProportionalHeight); + myText->setLineHeightMode(QDeclarative1Text::ProportionalHeight); myText->setLineHeight(1.0); qreal h2 = myText->height(); @@ -1344,7 +1344,7 @@ void tst_qdeclarativetext::lineHeight() QEXPECT_FAIL("", "QTBUG-17325", Continue); QVERIFY(myText->height() == h2 * 2.0); - myText->setLineHeightMode(QDeclarativeText::FixedHeight); + myText->setLineHeightMode(QDeclarative1Text::FixedHeight); myText->setLineHeight(10); QEXPECT_FAIL("", "QTBUG-17325", Continue); QCOMPARE(myText->height(), myText->lineCount() * 10.0); @@ -1369,7 +1369,7 @@ void tst_qdeclarativetext::implicitSize() QString componentStr = "import QtQuick 1.1\nText { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeText *textObject = qobject_cast(textComponent.create()); + QDeclarative1Text *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject->width() < textObject->implicitWidth()); QVERIFY(textObject->height() == textObject->implicitHeight()); diff --git a/tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/CursorRect.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png rename to tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png diff --git a/tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/cursorTest.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/geometrySignals.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/http/ErrItem.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/http/NormItem.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTest.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/http/cursorHttpTestPass.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/http/qmldir b/tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/http/qmldir rename to tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir diff --git a/tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/httpfail/FailItem.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/httpslow/WaitItem.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/inputmethodhints.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_default.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_readonly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_readonly.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_false_words.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_multiline.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_readonly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_readonly.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselection_true_words.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_characters.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_characters.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_default.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_default.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/mouseselectionmode_words.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/navigation.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/navigation.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/positionAt.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/positionAt.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml diff --git a/tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextedit/data/readOnly.qml rename to tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml diff --git a/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro new file mode 100644 index 0000000000..2d5461ffc1 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro @@ -0,0 +1,15 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativetextedit.cpp ../../declarative/shared/testhttpserver.cpp +HEADERS += ../../declarative/shared/testhttpserver.h + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp similarity index 85% rename from tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp rename to tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 8530c7f6ee..94378e96c3 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -41,7 +41,7 @@ #include #include #include "../../../shared/util.h" -#include "../shared/testhttpserver.h" +#include "../../declarative/shared/testhttpserver.h" #include #include #include @@ -49,10 +49,10 @@ #include #include #include -#include -#include +#include +#include #include -#include +#include #include #include #include @@ -66,7 +66,7 @@ #define SRCDIR "." #endif -Q_DECLARE_METATYPE(QDeclarativeTextEdit::SelectionMode) +Q_DECLARE_METATYPE(QDeclarative1TextEdit::SelectionMode) QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) { @@ -223,7 +223,7 @@ void tst_qdeclarativetextedit::text() { QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\" }", QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->text(), QString("")); @@ -234,7 +234,7 @@ void tst_qdeclarativetextedit::text() QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->text(), standard.at(i)); @@ -245,7 +245,7 @@ void tst_qdeclarativetextedit::text() QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QString actual = textEditObject->text(); @@ -263,7 +263,7 @@ void tst_qdeclarativetextedit::width() { QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\" }", QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->width(), 0.0); @@ -279,7 +279,7 @@ void tst_qdeclarativetextedit::width() QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->width(), qreal(metricWidth)); @@ -296,7 +296,7 @@ void tst_qdeclarativetextedit::width() QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->width(), qreal(documentWidth)); @@ -309,7 +309,7 @@ void tst_qdeclarativetextedit::wrap() { QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->width(), 300.); @@ -320,7 +320,7 @@ void tst_qdeclarativetextedit::wrap() QString componentStr = "import QtQuick 1.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->width(), 300.); @@ -331,7 +331,7 @@ void tst_qdeclarativetextedit::wrap() QString componentStr = "import QtQuick 1.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->width(), 300.); @@ -344,18 +344,18 @@ void tst_qdeclarativetextedit::textFormat() { QDeclarativeComponent textComponent(&engine); textComponent.setData("import QtQuick 1.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); - QDeclarativeTextEdit *textObject = qobject_cast(textComponent.create()); + QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarativeTextEdit::RichText); + QVERIFY(textObject->textFormat() == QDeclarative1TextEdit::RichText); } { QDeclarativeComponent textComponent(&engine); textComponent.setData("import QtQuick 1.0\nTextEdit { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); - QDeclarativeTextEdit *textObject = qobject_cast(textComponent.create()); + QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarativeTextEdit::PlainText); + QVERIFY(textObject->textFormat() == QDeclarative1TextEdit::PlainText); } } @@ -424,7 +424,7 @@ void tst_qdeclarativetextedit::hAlign() QString componentStr = "import QtQuick 1.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); @@ -438,7 +438,7 @@ void tst_qdeclarativetextedit::hAlign() QString componentStr = "import QtQuick 1.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); @@ -450,22 +450,22 @@ void tst_qdeclarativetextedit::hAlign() void tst_qdeclarativetextedit::hAlign_RightToLeft() { QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml"); - QDeclarativeTextEdit *textEdit = canvas->rootObject()->findChild("text"); + QDeclarative1TextEdit *textEdit = canvas->rootObject()->findChild("text"); QVERIFY(textEdit != 0); canvas->show(); // implicit alignment should follow the reading direction of text - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); // explicitly left aligned - textEdit->setHAlign(QDeclarativeTextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft); + textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); // explicitly right aligned - textEdit->setHAlign(QDeclarativeTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); + textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); QString textString = textEdit->text(); @@ -473,52 +473,52 @@ void tst_qdeclarativetextedit::hAlign_RightToLeft() textEdit->resetHAlign(); // implicitly aligned rich text should follow the reading direction of RTL text - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); // explicitly left aligned rich text - textEdit->setHAlign(QDeclarativeTextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft); + textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); // explicitly right aligned rich text - textEdit->setHAlign(QDeclarativeTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); + textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); textEdit->setText(textString); // explicitly center aligned - textEdit->setHAlign(QDeclarativeTextEdit::AlignHCenter); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignHCenter); + textEdit->setHAlign(QDeclarative1TextEdit::AlignHCenter); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignHCenter); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); // reseted alignment should go back to following the text reading direction textEdit->resetHAlign(); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); // mirror the text item QDeclarativeItemPrivate::get(textEdit)->setLayoutMirror(true); // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), QDeclarativeTextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); + QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignRight); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); // mirrored explicitly right aligned behaves as left aligned - textEdit->setHAlign(QDeclarativeTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), QDeclarativeTextEdit::AlignLeft); + textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); + QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignLeft); QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); // mirrored explicitly left aligned behaves as right aligned - textEdit->setHAlign(QDeclarativeTextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft); - QCOMPARE(textEdit->effectiveHAlign(), QDeclarativeTextEdit::AlignRight); + textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); + QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignRight); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); // disable mirroring @@ -527,7 +527,7 @@ void tst_qdeclarativetextedit::hAlign_RightToLeft() // English text should be implicitly left aligned textEdit->setText("Hello world!"); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignLeft); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); #ifndef Q_OS_MAC // QTBUG-18040 @@ -535,13 +535,13 @@ void tst_qdeclarativetextedit::hAlign_RightToLeft() // keyboard input direction from QApplication::keyboardInputDirection textEdit->setText(""); QCOMPARE(textEdit->hAlign(), QApplication::keyboardInputDirection() == Qt::LeftToRight ? - QDeclarativeTextEdit::AlignLeft : QDeclarativeTextEdit::AlignRight); + QDeclarative1TextEdit::AlignLeft : QDeclarative1TextEdit::AlignRight); if (QApplication::keyboardInputDirection() == Qt::LeftToRight) QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); else QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - textEdit->setHAlign(QDeclarativeTextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarativeTextEdit::AlignRight); + textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); + QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); #endif @@ -552,9 +552,9 @@ void tst_qdeclarativetextedit::hAlign_RightToLeft() QString componentStr = "import QtQuick 1.0\nTextEdit {}"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeTextEdit *textObject = qobject_cast(textComponent.create()); + QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->hAlign(), QApplication::keyboardInputDirection() == Qt::LeftToRight ? - QDeclarativeTextEdit::AlignLeft : QDeclarativeTextEdit::AlignRight); + QDeclarative1TextEdit::AlignLeft : QDeclarative1TextEdit::AlignRight); delete textObject; #endif } @@ -570,7 +570,7 @@ void tst_qdeclarativetextedit::vAlign() QString componentStr = "import QtQuick 1.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); @@ -584,7 +584,7 @@ void tst_qdeclarativetextedit::vAlign() QString componentStr = "import QtQuick 1.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); @@ -600,7 +600,7 @@ void tst_qdeclarativetextedit::font() QString componentStr = "import QtQuick 1.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->font().pointSize(), 40); @@ -612,7 +612,7 @@ void tst_qdeclarativetextedit::font() QString componentStr = "import QtQuick 1.0\nTextEdit { font.bold: true; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->font().bold(), true); @@ -623,7 +623,7 @@ void tst_qdeclarativetextedit::font() QString componentStr = "import QtQuick 1.0\nTextEdit { font.italic: true; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->font().italic(), true); @@ -634,7 +634,7 @@ void tst_qdeclarativetextedit::font() QString componentStr = "import QtQuick 1.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->font().family(), QString("Helvetica")); @@ -646,7 +646,7 @@ void tst_qdeclarativetextedit::font() QString componentStr = "import QtQuick 1.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->font().family(), QString("")); @@ -660,9 +660,9 @@ void tst_qdeclarativetextedit::color() QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QDeclarativeTextEditPrivate *textEditPrivate = static_cast(QDeclarativeItemPrivate::get(textEditObject)); + QDeclarative1TextEditPrivate *textEditPrivate = static_cast(QDeclarativeItemPrivate::get(textEditObject)); QVERIFY(textEditObject); QVERIFY(textEditPrivate); @@ -678,7 +678,7 @@ void tst_qdeclarativetextedit::color() QString componentStr = "import QtQuick 1.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i)); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i))); @@ -690,7 +690,7 @@ void tst_qdeclarativetextedit::color() QString componentStr = "import QtQuick 1.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i))); } @@ -701,7 +701,7 @@ void tst_qdeclarativetextedit::color() QString componentStr = "import QtQuick 1.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i))); } @@ -714,7 +714,7 @@ void tst_qdeclarativetextedit::color() QString componentStr = "import QtQuick 1.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->color(), testColor); @@ -727,7 +727,7 @@ void tst_qdeclarativetextedit::textMargin() QString componentStr = "import QtQuick 1.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->textMargin(), i); } @@ -739,7 +739,7 @@ void tst_qdeclarativetextedit::persistentSelection() QString componentStr = "import QtQuick 1.0\nTextEdit { persistentSelection: true; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->persistentSelection(), true); } @@ -748,7 +748,7 @@ void tst_qdeclarativetextedit::persistentSelection() QString componentStr = "import QtQuick 1.0\nTextEdit { persistentSelection: false; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->persistentSelection(), false); } @@ -760,7 +760,7 @@ void tst_qdeclarativetextedit::focusOnPress() QString componentStr = "import QtQuick 1.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->focusOnPress(), true); } @@ -769,7 +769,7 @@ void tst_qdeclarativetextedit::focusOnPress() QString componentStr = "import QtQuick 1.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->focusOnPress(), false); } @@ -781,7 +781,7 @@ void tst_qdeclarativetextedit::selection() QString componentStr = "import QtQuick 1.0\nTextEdit { text: \""+ testStr +"\"; }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -900,7 +900,7 @@ void tst_qdeclarativetextedit::isRightToLeft() QFETCH(bool, midString); QFETCH(bool, endString); - QDeclarativeTextEdit textEdit; + QDeclarative1TextEdit textEdit; textEdit.setText(text); // first test that the right string is delivered to the QString::isRightToLeft() @@ -937,7 +937,7 @@ void tst_qdeclarativetextedit::keySelection() QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); + QDeclarative1TextEdit *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasActiveFocus() == true); @@ -981,146 +981,146 @@ void tst_qdeclarativetextedit::moveCursorSelection_data() QTest::addColumn("testStr"); QTest::addColumn("cursorPosition"); QTest::addColumn("movePosition"); - QTest::addColumn("mode"); + QTest::addColumn("mode"); QTest::addColumn("selectionStart"); QTest::addColumn("selectionEnd"); QTest::addColumn("reversible"); QTest::newRow("(t)he|characters") - << standard[0] << 0 << 1 << QDeclarativeTextEdit::SelectCharacters << 0 << 1 << true; + << standard[0] << 0 << 1 << QDeclarative1TextEdit::SelectCharacters << 0 << 1 << true; QTest::newRow("do(g)|characters") - << standard[0] << 43 << 44 << QDeclarativeTextEdit::SelectCharacters << 43 << 44 << true; + << standard[0] << 43 << 44 << QDeclarative1TextEdit::SelectCharacters << 43 << 44 << true; QTest::newRow("jum(p)ed|characters") - << standard[0] << 23 << 24 << QDeclarativeTextEdit::SelectCharacters << 23 << 24 << true; + << standard[0] << 23 << 24 << QDeclarative1TextEdit::SelectCharacters << 23 << 24 << true; QTest::newRow("jumped( )over|characters") - << standard[0] << 26 << 27 << QDeclarativeTextEdit::SelectCharacters << 26 << 27 << true; + << standard[0] << 26 << 27 << QDeclarative1TextEdit::SelectCharacters << 26 << 27 << true; QTest::newRow("(the )|characters") - << standard[0] << 0 << 4 << QDeclarativeTextEdit::SelectCharacters << 0 << 4 << true; + << standard[0] << 0 << 4 << QDeclarative1TextEdit::SelectCharacters << 0 << 4 << true; QTest::newRow("( dog)|characters") - << standard[0] << 40 << 44 << QDeclarativeTextEdit::SelectCharacters << 40 << 44 << true; + << standard[0] << 40 << 44 << QDeclarative1TextEdit::SelectCharacters << 40 << 44 << true; QTest::newRow("( jumped )|characters") - << standard[0] << 19 << 27 << QDeclarativeTextEdit::SelectCharacters << 19 << 27 << true; + << standard[0] << 19 << 27 << QDeclarative1TextEdit::SelectCharacters << 19 << 27 << true; QTest::newRow("th(e qu)ick|characters") - << standard[0] << 2 << 6 << QDeclarativeTextEdit::SelectCharacters << 2 << 6 << true; + << standard[0] << 2 << 6 << QDeclarative1TextEdit::SelectCharacters << 2 << 6 << true; QTest::newRow("la(zy d)og|characters") - << standard[0] << 38 << 42 << QDeclarativeTextEdit::SelectCharacters << 38 << 42 << true; + << standard[0] << 38 << 42 << QDeclarative1TextEdit::SelectCharacters << 38 << 42 << true; QTest::newRow("jum(ped ov)er|characters") - << standard[0] << 23 << 29 << QDeclarativeTextEdit::SelectCharacters << 23 << 29 << true; + << standard[0] << 23 << 29 << QDeclarative1TextEdit::SelectCharacters << 23 << 29 << true; QTest::newRow("()the|characters") - << standard[0] << 0 << 0 << QDeclarativeTextEdit::SelectCharacters << 0 << 0 << true; + << standard[0] << 0 << 0 << QDeclarative1TextEdit::SelectCharacters << 0 << 0 << true; QTest::newRow("dog()|characters") - << standard[0] << 44 << 44 << QDeclarativeTextEdit::SelectCharacters << 44 << 44 << true; + << standard[0] << 44 << 44 << QDeclarative1TextEdit::SelectCharacters << 44 << 44 << true; QTest::newRow("jum()ped|characters") - << standard[0] << 23 << 23 << QDeclarativeTextEdit::SelectCharacters << 23 << 23 << true; + << standard[0] << 23 << 23 << QDeclarative1TextEdit::SelectCharacters << 23 << 23 << true; QTest::newRow("<(t)he>|words") - << standard[0] << 0 << 1 << QDeclarativeTextEdit::SelectWords << 0 << 3 << true; + << standard[0] << 0 << 1 << QDeclarative1TextEdit::SelectWords << 0 << 3 << true; QTest::newRow("|words") - << standard[0] << 43 << 44 << QDeclarativeTextEdit::SelectWords << 41 << 44 << true; + << standard[0] << 43 << 44 << QDeclarative1TextEdit::SelectWords << 41 << 44 << true; QTest::newRow("|words") - << standard[0] << 23 << 24 << QDeclarativeTextEdit::SelectWords << 20 << 26 << true; + << standard[0] << 23 << 24 << QDeclarative1TextEdit::SelectWords << 20 << 26 << true; QTest::newRow("over|words") - << standard[0] << 26 << 27 << QDeclarativeTextEdit::SelectWords << 20 << 27 << false; + << standard[0] << 26 << 27 << QDeclarative1TextEdit::SelectWords << 20 << 27 << false; QTest::newRow("jumped<( )over>|words,reversed") - << standard[0] << 27 << 26 << QDeclarativeTextEdit::SelectWords << 26 << 31 << false; + << standard[0] << 27 << 26 << QDeclarative1TextEdit::SelectWords << 26 << 31 << false; QTest::newRow("<(the )>quick|words") - << standard[0] << 0 << 4 << QDeclarativeTextEdit::SelectWords << 0 << 4 << false; + << standard[0] << 0 << 4 << QDeclarative1TextEdit::SelectWords << 0 << 4 << false; QTest::newRow("<(the )quick>|words,reversed") - << standard[0] << 4 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 9 << false; + << standard[0] << 4 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 9 << false; QTest::newRow("|words") - << standard[0] << 40 << 44 << QDeclarativeTextEdit::SelectWords << 36 << 44 << false; + << standard[0] << 40 << 44 << QDeclarative1TextEdit::SelectWords << 36 << 44 << false; QTest::newRow("lazy<( dog)>|words,reversed") - << standard[0] << 44 << 40 << QDeclarativeTextEdit::SelectWords << 40 << 44 << false; + << standard[0] << 44 << 40 << QDeclarative1TextEdit::SelectWords << 40 << 44 << false; QTest::newRow("over|words") - << standard[0] << 19 << 27 << QDeclarativeTextEdit::SelectWords << 16 << 27 << false; + << standard[0] << 19 << 27 << QDeclarative1TextEdit::SelectWords << 16 << 27 << false; QTest::newRow("fox<( jumped )over>|words,reversed") - << standard[0] << 27 << 19 << QDeclarativeTextEdit::SelectWords << 19 << 31 << false; + << standard[0] << 27 << 19 << QDeclarative1TextEdit::SelectWords << 19 << 31 << false; QTest::newRow("|words") - << standard[0] << 2 << 6 << QDeclarativeTextEdit::SelectWords << 0 << 9 << true; + << standard[0] << 2 << 6 << QDeclarative1TextEdit::SelectWords << 0 << 9 << true; QTest::newRow("") - << standard[0] << 38 << 42 << QDeclarativeTextEdit::SelectWords << 36 << 44 << true; + << standard[0] << 38 << 42 << QDeclarative1TextEdit::SelectWords << 36 << 44 << true; QTest::newRow("|words") - << standard[0] << 23 << 29 << QDeclarativeTextEdit::SelectWords << 20 << 31 << true; + << standard[0] << 23 << 29 << QDeclarative1TextEdit::SelectWords << 20 << 31 << true; QTest::newRow("<()>the|words") - << standard[0] << 0 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 0 << true; + << standard[0] << 0 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 0 << true; QTest::newRow("dog<()>|words") - << standard[0] << 44 << 44 << QDeclarativeTextEdit::SelectWords << 44 << 44 << true; + << standard[0] << 44 << 44 << QDeclarative1TextEdit::SelectWords << 44 << 44 << true; QTest::newRow("jum<()>ped|words") - << standard[0] << 23 << 23 << QDeclarativeTextEdit::SelectWords << 23 << 23 << true; + << standard[0] << 23 << 23 << QDeclarative1TextEdit::SelectWords << 23 << 23 << true; QTest::newRow("Hello<(,)> |words") - << standard[2] << 5 << 6 << QDeclarativeTextEdit::SelectWords << 5 << 6 << true; + << standard[2] << 5 << 6 << QDeclarative1TextEdit::SelectWords << 5 << 6 << true; QTest::newRow("Hello<(, )>world|words") - << standard[2] << 5 << 7 << QDeclarativeTextEdit::SelectWords << 5 << 7 << false; + << standard[2] << 5 << 7 << QDeclarative1TextEdit::SelectWords << 5 << 7 << false; QTest::newRow("Hello<(, )world>|words,reversed") - << standard[2] << 7 << 5 << QDeclarativeTextEdit::SelectWords << 5 << 12 << false; + << standard[2] << 7 << 5 << QDeclarative1TextEdit::SelectWords << 5 << 12 << false; QTest::newRow("world|words") - << standard[2] << 3 << 7 << QDeclarativeTextEdit::SelectWords << 0 << 7 << false; + << standard[2] << 3 << 7 << QDeclarative1TextEdit::SelectWords << 0 << 7 << false; QTest::newRow("|words,reversed") - << standard[2] << 7 << 3 << QDeclarativeTextEdit::SelectWords << 0 << 12 << false; + << standard[2] << 7 << 3 << QDeclarative1TextEdit::SelectWords << 0 << 12 << false; QTest::newRow(",|words") - << standard[2] << 3 << 5 << QDeclarativeTextEdit::SelectWords << 0 << 5 << true; + << standard[2] << 3 << 5 << QDeclarative1TextEdit::SelectWords << 0 << 5 << true; QTest::newRow("Hello<()>,|words") - << standard[2] << 5 << 5 << QDeclarativeTextEdit::SelectWords << 5 << 5 << true; + << standard[2] << 5 << 5 << QDeclarative1TextEdit::SelectWords << 5 << 5 << true; QTest::newRow("Hello,<()>|words") - << standard[2] << 6 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 6 << true; + << standard[2] << 6 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 6 << true; QTest::newRow("Hello<,( )>world|words") - << standard[2] << 6 << 7 << QDeclarativeTextEdit::SelectWords << 5 << 7 << false; + << standard[2] << 6 << 7 << QDeclarative1TextEdit::SelectWords << 5 << 7 << false; QTest::newRow("Hello,<( )world>|words,reversed") - << standard[2] << 7 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 12 << false; + << standard[2] << 7 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 12 << false; QTest::newRow("Hello<,( world)>|words") - << standard[2] << 6 << 12 << QDeclarativeTextEdit::SelectWords << 5 << 12 << false; + << standard[2] << 6 << 12 << QDeclarative1TextEdit::SelectWords << 5 << 12 << false; QTest::newRow("Hello,<( world)>|words,reversed") - << standard[2] << 12 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 12 << false; + << standard[2] << 12 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 12 << false; QTest::newRow("Hello<,( world!)>|words") - << standard[2] << 6 << 13 << QDeclarativeTextEdit::SelectWords << 5 << 13 << false; + << standard[2] << 6 << 13 << QDeclarative1TextEdit::SelectWords << 5 << 13 << false; QTest::newRow("Hello,<( world!)>|words,reversed") - << standard[2] << 13 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 13 << false; + << standard[2] << 13 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 13 << false; QTest::newRow("Hello<(, world!)>|words") - << standard[2] << 5 << 13 << QDeclarativeTextEdit::SelectWords << 5 << 13 << true; + << standard[2] << 5 << 13 << QDeclarative1TextEdit::SelectWords << 5 << 13 << true; QTest::newRow("world<(!)>|words") - << standard[2] << 12 << 13 << QDeclarativeTextEdit::SelectWords << 12 << 13 << true; + << standard[2] << 12 << 13 << QDeclarative1TextEdit::SelectWords << 12 << 13 << true; QTest::newRow("world!<()>)|words") - << standard[2] << 13 << 13 << QDeclarativeTextEdit::SelectWords << 13 << 13 << true; + << standard[2] << 13 << 13 << QDeclarative1TextEdit::SelectWords << 13 << 13 << true; QTest::newRow("world<()>!)|words") - << standard[2] << 12 << 12 << QDeclarativeTextEdit::SelectWords << 12 << 12 << true; + << standard[2] << 12 << 12 << QDeclarative1TextEdit::SelectWords << 12 << 12 << true; QTest::newRow("<(,)>olleH |words") - << standard[3] << 7 << 8 << QDeclarativeTextEdit::SelectWords << 7 << 8 << true; + << standard[3] << 7 << 8 << QDeclarative1TextEdit::SelectWords << 7 << 8 << true; QTest::newRow("olleH|words") - << standard[3] << 6 << 8 << QDeclarativeTextEdit::SelectWords << 1 << 8 << false; + << standard[3] << 6 << 8 << QDeclarative1TextEdit::SelectWords << 1 << 8 << false; QTest::newRow("dlrow<( ,)>olleH|words,reversed") - << standard[3] << 8 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 8 << false; + << standard[3] << 8 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 8 << false; QTest::newRow("|words") - << standard[3] << 6 << 10 << QDeclarativeTextEdit::SelectWords << 1 << 13 << false; + << standard[3] << 6 << 10 << QDeclarative1TextEdit::SelectWords << 1 << 13 << false; QTest::newRow("dlrow<( ,ol)leH>|words,reversed") - << standard[3] << 10 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 13 << false; + << standard[3] << 10 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 13 << false; QTest::newRow(",<(ol)leH>,|words") - << standard[3] << 8 << 10 << QDeclarativeTextEdit::SelectWords << 8 << 13 << true; + << standard[3] << 8 << 10 << QDeclarative1TextEdit::SelectWords << 8 << 13 << true; QTest::newRow(",<()>olleH|words") - << standard[3] << 8 << 8 << QDeclarativeTextEdit::SelectWords << 8 << 8 << true; + << standard[3] << 8 << 8 << QDeclarative1TextEdit::SelectWords << 8 << 8 << true; QTest::newRow("<()>,olleH|words") - << standard[3] << 7 << 7 << QDeclarativeTextEdit::SelectWords << 7 << 7 << true; + << standard[3] << 7 << 7 << QDeclarative1TextEdit::SelectWords << 7 << 7 << true; QTest::newRow(",olleH|words") - << standard[3] << 6 << 7 << QDeclarativeTextEdit::SelectWords << 1 << 7 << false; + << standard[3] << 6 << 7 << QDeclarative1TextEdit::SelectWords << 1 << 7 << false; QTest::newRow("dlrow<( ),>olleH|words,reversed") - << standard[3] << 7 << 6 << QDeclarativeTextEdit::SelectWords << 6 << 8 << false; + << standard[3] << 7 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 8 << false; QTest::newRow("<(dlrow )>,olleH|words") - << standard[3] << 1 << 7 << QDeclarativeTextEdit::SelectWords << 1 << 7 << false; + << standard[3] << 1 << 7 << QDeclarative1TextEdit::SelectWords << 1 << 7 << false; QTest::newRow("<(dlrow ),>olleH|words,reversed") - << standard[3] << 7 << 1 << QDeclarativeTextEdit::SelectWords << 1 << 8 << false; + << standard[3] << 7 << 1 << QDeclarative1TextEdit::SelectWords << 1 << 8 << false; QTest::newRow("<(!dlrow )>,olleH|words") - << standard[3] << 0 << 7 << QDeclarativeTextEdit::SelectWords << 0 << 7 << false; + << standard[3] << 0 << 7 << QDeclarative1TextEdit::SelectWords << 0 << 7 << false; QTest::newRow("<(!dlrow ),>olleH|words,reversed") - << standard[3] << 7 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 8 << false; + << standard[3] << 7 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 8 << false; QTest::newRow("(!dlrow ,)olleH|words") - << standard[3] << 0 << 8 << QDeclarativeTextEdit::SelectWords << 0 << 8 << true; + << standard[3] << 0 << 8 << QDeclarative1TextEdit::SelectWords << 0 << 8 << true; QTest::newRow("<(!)>dlrow|words") - << standard[3] << 0 << 1 << QDeclarativeTextEdit::SelectWords << 0 << 1 << true; + << standard[3] << 0 << 1 << QDeclarative1TextEdit::SelectWords << 0 << 1 << true; QTest::newRow("<()>!dlrow|words") - << standard[3] << 0 << 0 << QDeclarativeTextEdit::SelectWords << 0 << 0 << true; + << standard[3] << 0 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 0 << true; QTest::newRow("!<()>dlrow|words") - << standard[3] << 1 << 1 << QDeclarativeTextEdit::SelectWords << 1 << 1 << true; + << standard[3] << 1 << 1 << QDeclarative1TextEdit::SelectWords << 1 << 1 << true; } void tst_qdeclarativetextedit::moveCursorSelection() @@ -1128,7 +1128,7 @@ void tst_qdeclarativetextedit::moveCursorSelection() QFETCH(QString, testStr); QFETCH(int, cursorPosition); QFETCH(int, movePosition); - QFETCH(QDeclarativeTextEdit::SelectionMode, mode); + QFETCH(QDeclarative1TextEdit::SelectionMode, mode); QFETCH(int, selectionStart); QFETCH(int, selectionEnd); QFETCH(bool, reversible); @@ -1136,7 +1136,7 @@ void tst_qdeclarativetextedit::moveCursorSelection() QString componentStr = "import QtQuick 1.1\nTextEdit { text: \""+ testStr +"\"; }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *texteditObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextEdit *texteditObject = qobject_cast(textinputComponent.create()); QVERIFY(texteditObject != 0); texteditObject->setCursorPosition(cursorPosition); @@ -1295,17 +1295,17 @@ void tst_qdeclarativetextedit::moveCursorSelectionSequence() QString componentStr = "import QtQuick 1.1\nTextEdit { text: \""+ testStr +"\"; }"; QDeclarativeComponent texteditComponent(&engine); texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *texteditObject = qobject_cast(texteditComponent.create()); + QDeclarative1TextEdit *texteditObject = qobject_cast(texteditComponent.create()); QVERIFY(texteditObject != 0); texteditObject->setCursorPosition(cursorPosition); - texteditObject->moveCursorSelection(movePosition1, QDeclarativeTextEdit::SelectWords); + texteditObject->moveCursorSelection(movePosition1, QDeclarative1TextEdit::SelectWords); QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); QCOMPARE(texteditObject->selectionStart(), selection1Start); QCOMPARE(texteditObject->selectionEnd(), selection1End); - texteditObject->moveCursorSelection(movePosition2, QDeclarativeTextEdit::SelectWords); + texteditObject->moveCursorSelection(movePosition2, QDeclarative1TextEdit::SelectWords); QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); QCOMPARE(texteditObject->selectionStart(), selection2Start); QCOMPARE(texteditObject->selectionEnd(), selection2End); @@ -1338,7 +1338,7 @@ void tst_qdeclarativetextedit::mouseSelection() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *textEditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1375,7 +1375,7 @@ void tst_qdeclarativetextedit::multilineMouseSelection() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *textEditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); // press-and-drag from x1,y1 to x2,y1 @@ -1421,7 +1421,7 @@ void tst_qdeclarativetextedit::deferEnableSelectByMouse() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *textEditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1461,7 +1461,7 @@ void tst_qdeclarativetextedit::deferDisableSelectByMouse() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *textEditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1492,7 +1492,7 @@ void tst_qdeclarativetextedit::dragMouseSelection() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *textEditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); textEditObject->setAcceptDrops(true); @@ -1553,7 +1553,7 @@ void tst_qdeclarativetextedit::mouseSelectionMode() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *textEditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1589,7 +1589,7 @@ void tst_qdeclarativetextedit::inputMethodHints() canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *textEditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText); textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); @@ -1607,7 +1607,7 @@ void tst_qdeclarativetextedit::positionAt() QApplication::setActiveWindow(canvas); QTest::qWaitForWindowShown(canvas); - QDeclarativeTextEdit *texteditObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *texteditObject = qobject_cast(canvas->rootObject()); QVERIFY(texteditObject != 0); QFontMetrics fm(texteditObject->font()); @@ -1653,7 +1653,7 @@ void tst_qdeclarativetextedit::cursorDelegate() QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); view->show(); view->setFocus(); - QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); + QDeclarative1TextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); QVERIFY(textEditObject != 0); QVERIFY(textEditObject->findChild("cursorInstance")); //Test Delegate gets created @@ -1700,12 +1700,12 @@ void tst_qdeclarativetextedit::cursorDelegate() QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); QVERIFY(textEditObject->cursorRectangle().y() >= 0); QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->cursorRectangle().height()); - textEditObject->setVAlign(QDeclarativeTextEdit::AlignVCenter); + textEditObject->setVAlign(QDeclarative1TextEdit::AlignVCenter); QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); QVERIFY(textEditObject->cursorRectangle().y() > (textEditObject->height() / 2) - textEditObject->cursorRectangle().height()); QVERIFY(textEditObject->cursorRectangle().y() < (textEditObject->height() / 2) + textEditObject->cursorRectangle().height()); - textEditObject->setVAlign(QDeclarativeTextEdit::AlignBottom); + textEditObject->setVAlign(QDeclarative1TextEdit::AlignBottom); QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); QVERIFY(textEditObject->cursorRectangle().y() > textEditObject->height() - (textEditObject->cursorRectangle().height() * 2)); @@ -1728,7 +1728,7 @@ void tst_qdeclarativetextedit::cursorVisible() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); view.setFocus(); - QDeclarativeTextEdit edit; + QDeclarative1TextEdit edit; QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); QCOMPARE(edit.isCursorVisible(), false); @@ -1821,7 +1821,7 @@ void tst_qdeclarativetextedit::delegateLoading() QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test } else { QTRY_VERIFY(view->rootObject());//Wait for loading to finish. - QDeclarativeTextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); + QDeclarative1TextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); // view->rootObject()->dumpObjectTree(); QVERIFY(textEditObject != 0); textEditObject->setFocus(true); @@ -1836,7 +1836,7 @@ void tst_qdeclarativetextedit::delegateLoading() //A test should be added here with a component which is ready but component.create() returns null - //Not sure how to accomplish this with QDeclarativeTextEdits cursor delegate + //Not sure how to accomplish this with QDeclarative1TextEdits cursor delegate //###This was only needed for code coverage, and could be a case of overzealous defensive programming //delegate = view->rootObject()->findChild("delegateErrorB"); //QVERIFY(!delegate); @@ -1891,7 +1891,7 @@ void tst_qdeclarativetextedit::copyAndPaste() { QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; QDeclarativeComponent textEditComponent(&engine); textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QDeclarative1TextEdit *textEdit = qobject_cast(textEditComponent.create()); QVERIFY(textEdit != 0); // copy and paste @@ -1916,7 +1916,7 @@ void tst_qdeclarativetextedit::copyAndPaste() { // QTBUG-12339 // test that document and internal text attribute are in sync QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(textEdit); - QDeclarativeTextEditPrivate *editPrivate = static_cast(pri); + QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); QCOMPARE(textEdit->text(), editPrivate->text); // select word @@ -1942,7 +1942,7 @@ void tst_qdeclarativetextedit::canPaste() { QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; QDeclarativeComponent textEditComponent(&engine); textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QDeclarative1TextEdit *textEdit = qobject_cast(textEditComponent.create()); QVERIFY(textEdit != 0); // check initial value - QTBUG-17765 @@ -1960,7 +1960,7 @@ void tst_qdeclarativetextedit::canPasteEmpty() { QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; QDeclarativeComponent textEditComponent(&engine); textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextEdit *textEdit = qobject_cast(textEditComponent.create()); + QDeclarative1TextEdit *textEdit = qobject_cast(textEditComponent.create()); QVERIFY(textEdit != 0); // check initial value - QTBUG-17765 @@ -1978,7 +1978,7 @@ void tst_qdeclarativetextedit::readOnly() QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextEdit *edit = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); + QDeclarative1TextEdit *edit = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(edit != 0); QTRY_VERIFY(edit->hasActiveFocus() == true); @@ -2072,9 +2072,9 @@ void tst_qdeclarativetextedit::textInput() { QGraphicsScene scene; QGraphicsView view(&scene); - QDeclarativeTextEdit edit; + QDeclarative1TextEdit edit; QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); - QDeclarativeTextEditPrivate *editPrivate = static_cast(pri); + QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); edit.setPos(0, 0); scene.addItem(&edit); view.show(); @@ -2101,7 +2101,7 @@ void tst_qdeclarativetextedit::openInputPanelOnClick() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextEdit edit; + QDeclarative1TextEdit edit; QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); edit.setText("Hello world"); edit.setPos(0, 0); @@ -2113,7 +2113,7 @@ void tst_qdeclarativetextedit::openInputPanelOnClick() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); - QDeclarativeTextEditPrivate *editPrivate = static_cast(pri); + QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); // input panel on click editPrivate->showInputPanelOnFocus = false; @@ -2149,7 +2149,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextEdit edit; + QDeclarative1TextEdit edit; QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); edit.setText("Hello world"); edit.setPos(0, 0); @@ -2161,7 +2161,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); - QDeclarativeTextEditPrivate *editPrivate = static_cast(pri); + QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); editPrivate->showInputPanelOnFocus = true; // test default values @@ -2190,7 +2190,7 @@ void tst_qdeclarativetextedit::openInputPanelOnFocus() // input method should stay enabled if focus // is lost to an item that also accepts inputs - QDeclarativeTextEdit anotherEdit; + QDeclarative1TextEdit anotherEdit; scene.addItem(&anotherEdit); anotherEdit.setFocus(true); QApplication::processEvents(); @@ -2290,10 +2290,10 @@ void tst_qdeclarativetextedit::pastingRichText_QTBUG_14003() QString componentStr = "import QtQuick 1.0\nTextEdit { textFormat: TextEdit.PlainText }"; QDeclarativeComponent component(&engine); component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeTextEdit *obj = qobject_cast(component.create()); + QDeclarative1TextEdit *obj = qobject_cast(component.create()); QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->textFormat() == QDeclarativeTextEdit::PlainText); + QTRY_VERIFY(obj->textFormat() == QDeclarative1TextEdit::PlainText); QMimeData *mData = new QMimeData; mData->setHtml("Hello"); @@ -2301,7 +2301,7 @@ void tst_qdeclarativetextedit::pastingRichText_QTBUG_14003() obj->paste(); QTRY_VERIFY(obj->text() == ""); - QTRY_VERIFY(obj->textFormat() == QDeclarativeTextEdit::PlainText); + QTRY_VERIFY(obj->textFormat() == QDeclarative1TextEdit::PlainText); #endif } @@ -2322,7 +2322,7 @@ void tst_qdeclarativetextedit::implicitSize() QString componentStr = "import QtQuick 1.1\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeTextEdit *textObject = qobject_cast(textComponent.create()); + QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); QVERIFY(textObject->width() < textObject->implicitWidth()); QVERIFY(textObject->height() == textObject->implicitHeight()); @@ -2391,7 +2391,7 @@ void tst_qdeclarativetextedit::preeditMicroFocus() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextEdit edit; + QDeclarative1TextEdit edit; edit.setFocus(true); scene.addItem(&edit); view.show(); @@ -2451,7 +2451,7 @@ void tst_qdeclarativetextedit::inputContextMouseHandler() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextEdit edit; + QDeclarative1TextEdit edit; edit.setPos(0, 0); edit.setWidth(200); edit.setText(text.mid(0, 12)); @@ -2571,7 +2571,7 @@ void tst_qdeclarativetextedit::inputMethodComposing() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextEdit edit; + QDeclarative1TextEdit edit; edit.setWidth(200); edit.setText(text.mid(0, 12)); edit.setCursorPosition(12); @@ -2609,7 +2609,7 @@ void tst_qdeclarativetextedit::cursorRectangleSize() QApplication::setActiveWindow(canvas); QTest::qWaitForWindowShown(canvas); - QDeclarativeTextEdit *textEdit = qobject_cast(canvas->rootObject()); + QDeclarative1TextEdit *textEdit = qobject_cast(canvas->rootObject()); QVERIFY(textEdit != 0); textEdit->setFocus(Qt::OtherFocusReason); QRectF cursorRect = textEdit->positionToRectangle(textEdit->cursorPosition()); diff --git a/tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/cursorTest.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/echoMode.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/geometrySignals.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/halign_center.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/halign_center.png rename to tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png diff --git a/tests/auto/declarative/qdeclarativetextinput/data/halign_left.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/halign_left.png rename to tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png diff --git a/tests/auto/declarative/qdeclarativetextinput/data/halign_right.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/halign_right.png rename to tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png diff --git a/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/inputmethods.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/inputmethods.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/masks.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/masks.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/maxLength.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_default.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselection_default.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_readonly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_readonly.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselection_false_words.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_readonly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_readonly.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselection_true_words.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselectionmode_characters.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselectionmode_characters.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselectionmode_default.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselectionmode_default.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/mouseselectionmode_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/mouseselectionmode_words.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/navigation.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/navigation.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/positionAt.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/positionAt.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/readOnly.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/data/validators.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml similarity index 100% rename from tests/auto/declarative/qdeclarativetextinput/data/validators.qml rename to tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro similarity index 63% rename from tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro rename to tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro index df765db9ec..d39da270a3 100644 --- a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro +++ b/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetextinput.cpp @@ -12,4 +12,4 @@ symbian: { DEFINES += SRCDIR=\\\"$$PWD\\\" } -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp similarity index 85% rename from tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp rename to tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 63b768ca33..7cc79c7878 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -43,9 +43,9 @@ #include "../../../shared/util.h" #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -57,7 +57,7 @@ #define SRCDIR "." #endif -Q_DECLARE_METATYPE(QDeclarativeTextInput::SelectionMode) +Q_DECLARE_METATYPE(QDeclarative1TextInput::SelectionMode) QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) { @@ -179,7 +179,7 @@ void tst_qdeclarativetextinput::text() { QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData("import QtQuick 1.0\nTextInput { text: \"\" }", QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), QString("")); @@ -192,7 +192,7 @@ void tst_qdeclarativetextinput::text() QString componentStr = "import QtQuick 1.0\nTextInput { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->text(), standard.at(i)); @@ -208,7 +208,7 @@ void tst_qdeclarativetextinput::width() { QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData("import QtQuick 1.0\nTextInput { text: \"\" }", QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->width(), 0.0); @@ -225,7 +225,7 @@ void tst_qdeclarativetextinput::width() QString componentStr = "import QtQuick 1.0\nTextInput { text: \"" + standard.at(i) + "\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); int delta = abs(int(int(textinputObject->width()) - metricWidth)); @@ -242,7 +242,7 @@ void tst_qdeclarativetextinput::font() QString componentStr = "import QtQuick 1.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().pointSize(), 40); @@ -256,7 +256,7 @@ void tst_qdeclarativetextinput::font() QString componentStr = "import QtQuick 1.0\nTextInput { font.bold: true; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().bold(), true); @@ -269,7 +269,7 @@ void tst_qdeclarativetextinput::font() QString componentStr = "import QtQuick 1.0\nTextInput { font.italic: true; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().italic(), true); @@ -282,7 +282,7 @@ void tst_qdeclarativetextinput::font() QString componentStr = "import QtQuick 1.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().family(), QString("Helvetica")); @@ -296,7 +296,7 @@ void tst_qdeclarativetextinput::font() QString componentStr = "import QtQuick 1.0\nTextInput { font.family: \"\"; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->font().family(), QString("")); @@ -313,7 +313,7 @@ void tst_qdeclarativetextinput::color() QString componentStr = "import QtQuick 1.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); @@ -326,7 +326,7 @@ void tst_qdeclarativetextinput::color() QString componentStr = "import QtQuick 1.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); @@ -339,7 +339,7 @@ void tst_qdeclarativetextinput::color() QString componentStr = "import QtQuick 1.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); @@ -354,7 +354,7 @@ void tst_qdeclarativetextinput::color() QString componentStr = "import QtQuick 1.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), testColor); @@ -369,7 +369,7 @@ void tst_qdeclarativetextinput::selection() QString componentStr = "import QtQuick 1.0\nTextInput { text: \""+ testStr +"\"; }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -489,7 +489,7 @@ void tst_qdeclarativetextinput::isRightToLeft() QFETCH(bool, midString); QFETCH(bool, endString); - QDeclarativeTextInput textInput; + QDeclarative1TextInput textInput; textInput.setText(text); // first test that the right string is delivered to the QString::isRightToLeft() @@ -520,7 +520,7 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() QTest::addColumn("testStr"); QTest::addColumn("cursorPosition"); QTest::addColumn("movePosition"); - QTest::addColumn("mode"); + QTest::addColumn("mode"); QTest::addColumn("selectionStart"); QTest::addColumn("selectionEnd"); QTest::addColumn("reversible"); @@ -529,157 +529,157 @@ void tst_qdeclarativetextinput::moveCursorSelection_data() // <> contains the actual selection. QTest::newRow("(t)he|characters") - << standard[0] << 0 << 1 << QDeclarativeTextInput::SelectCharacters << 0 << 1 << true; + << standard[0] << 0 << 1 << QDeclarative1TextInput::SelectCharacters << 0 << 1 << true; QTest::newRow("do(g)|characters") - << standard[0] << 43 << 44 << QDeclarativeTextInput::SelectCharacters << 43 << 44 << true; + << standard[0] << 43 << 44 << QDeclarative1TextInput::SelectCharacters << 43 << 44 << true; QTest::newRow("jum(p)ed|characters") - << standard[0] << 23 << 24 << QDeclarativeTextInput::SelectCharacters << 23 << 24 << true; + << standard[0] << 23 << 24 << QDeclarative1TextInput::SelectCharacters << 23 << 24 << true; QTest::newRow("jumped( )over|characters") - << standard[0] << 26 << 27 << QDeclarativeTextInput::SelectCharacters << 26 << 27 << true; + << standard[0] << 26 << 27 << QDeclarative1TextInput::SelectCharacters << 26 << 27 << true; QTest::newRow("(the )|characters") - << standard[0] << 0 << 4 << QDeclarativeTextInput::SelectCharacters << 0 << 4 << true; + << standard[0] << 0 << 4 << QDeclarative1TextInput::SelectCharacters << 0 << 4 << true; QTest::newRow("( dog)|characters") - << standard[0] << 40 << 44 << QDeclarativeTextInput::SelectCharacters << 40 << 44 << true; + << standard[0] << 40 << 44 << QDeclarative1TextInput::SelectCharacters << 40 << 44 << true; QTest::newRow("( jumped )|characters") - << standard[0] << 19 << 27 << QDeclarativeTextInput::SelectCharacters << 19 << 27 << true; + << standard[0] << 19 << 27 << QDeclarative1TextInput::SelectCharacters << 19 << 27 << true; QTest::newRow("th(e qu)ick|characters") - << standard[0] << 2 << 6 << QDeclarativeTextInput::SelectCharacters << 2 << 6 << true; + << standard[0] << 2 << 6 << QDeclarative1TextInput::SelectCharacters << 2 << 6 << true; QTest::newRow("la(zy d)og|characters") - << standard[0] << 38 << 42 << QDeclarativeTextInput::SelectCharacters << 38 << 42 << true; + << standard[0] << 38 << 42 << QDeclarative1TextInput::SelectCharacters << 38 << 42 << true; QTest::newRow("jum(ped ov)er|characters") - << standard[0] << 23 << 29 << QDeclarativeTextInput::SelectCharacters << 23 << 29 << true; + << standard[0] << 23 << 29 << QDeclarative1TextInput::SelectCharacters << 23 << 29 << true; QTest::newRow("()the|characters") - << standard[0] << 0 << 0 << QDeclarativeTextInput::SelectCharacters << 0 << 0 << true; + << standard[0] << 0 << 0 << QDeclarative1TextInput::SelectCharacters << 0 << 0 << true; QTest::newRow("dog()|characters") - << standard[0] << 44 << 44 << QDeclarativeTextInput::SelectCharacters << 44 << 44 << true; + << standard[0] << 44 << 44 << QDeclarative1TextInput::SelectCharacters << 44 << 44 << true; QTest::newRow("jum()ped|characters") - << standard[0] << 23 << 23 << QDeclarativeTextInput::SelectCharacters << 23 << 23 << true; + << standard[0] << 23 << 23 << QDeclarative1TextInput::SelectCharacters << 23 << 23 << true; QTest::newRow("<(t)he>|words") - << standard[0] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 3 << true; + << standard[0] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 3 << true; QTest::newRow("|words") - << standard[0] << 43 << 44 << QDeclarativeTextInput::SelectWords << 41 << 44 << true; + << standard[0] << 43 << 44 << QDeclarative1TextInput::SelectWords << 41 << 44 << true; QTest::newRow("|words") - << standard[0] << 23 << 24 << QDeclarativeTextInput::SelectWords << 20 << 26 << true; + << standard[0] << 23 << 24 << QDeclarative1TextInput::SelectWords << 20 << 26 << true; QTest::newRow("over|words,ltr") - << standard[0] << 26 << 27 << QDeclarativeTextInput::SelectWords << 20 << 27 << false; + << standard[0] << 26 << 27 << QDeclarative1TextInput::SelectWords << 20 << 27 << false; QTest::newRow("jumped<( )over>|words,rtl") - << standard[0] << 27 << 26 << QDeclarativeTextInput::SelectWords << 26 << 31 << false; + << standard[0] << 27 << 26 << QDeclarative1TextInput::SelectWords << 26 << 31 << false; QTest::newRow("<(the )>quick|words,ltr") - << standard[0] << 0 << 4 << QDeclarativeTextInput::SelectWords << 0 << 4 << false; + << standard[0] << 0 << 4 << QDeclarative1TextInput::SelectWords << 0 << 4 << false; QTest::newRow("<(the )quick>|words,rtl") - << standard[0] << 4 << 0 << QDeclarativeTextInput::SelectWords << 0 << 9 << false; + << standard[0] << 4 << 0 << QDeclarative1TextInput::SelectWords << 0 << 9 << false; QTest::newRow("|words,ltr") - << standard[0] << 40 << 44 << QDeclarativeTextInput::SelectWords << 36 << 44 << false; + << standard[0] << 40 << 44 << QDeclarative1TextInput::SelectWords << 36 << 44 << false; QTest::newRow("lazy<( dog)>|words,rtl") - << standard[0] << 44 << 40 << QDeclarativeTextInput::SelectWords << 40 << 44 << false; + << standard[0] << 44 << 40 << QDeclarative1TextInput::SelectWords << 40 << 44 << false; QTest::newRow("over|words,ltr") - << standard[0] << 19 << 27 << QDeclarativeTextInput::SelectWords << 16 << 27 << false; + << standard[0] << 19 << 27 << QDeclarative1TextInput::SelectWords << 16 << 27 << false; QTest::newRow("fox<( jumped )over>|words,rtl") - << standard[0] << 27 << 19 << QDeclarativeTextInput::SelectWords << 19 << 31 << false; + << standard[0] << 27 << 19 << QDeclarative1TextInput::SelectWords << 19 << 31 << false; QTest::newRow("|words") - << standard[0] << 2 << 6 << QDeclarativeTextInput::SelectWords << 0 << 9 << true; + << standard[0] << 2 << 6 << QDeclarative1TextInput::SelectWords << 0 << 9 << true; QTest::newRow("") - << standard[0] << 38 << 42 << QDeclarativeTextInput::SelectWords << 36 << 44 << true; + << standard[0] << 38 << 42 << QDeclarative1TextInput::SelectWords << 36 << 44 << true; QTest::newRow("|words") - << standard[0] << 23 << 29 << QDeclarativeTextInput::SelectWords << 20 << 31 << true; + << standard[0] << 23 << 29 << QDeclarative1TextInput::SelectWords << 20 << 31 << true; QTest::newRow("<()>the|words") - << standard[0] << 0 << 0 << QDeclarativeTextInput::SelectWords << 0 << 0 << true; + << standard[0] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << true; QTest::newRow("dog<()>|words") - << standard[0] << 44 << 44 << QDeclarativeTextInput::SelectWords << 44 << 44 << true; + << standard[0] << 44 << 44 << QDeclarative1TextInput::SelectWords << 44 << 44 << true; QTest::newRow("jum<()>ped|words") - << standard[0] << 23 << 23 << QDeclarativeTextInput::SelectWords << 23 << 23 << true; + << standard[0] << 23 << 23 << QDeclarative1TextInput::SelectWords << 23 << 23 << true; QTest::newRow("Hello<(,)> |words") - << standard[2] << 5 << 6 << QDeclarativeTextInput::SelectWords << 5 << 6 << true; + << standard[2] << 5 << 6 << QDeclarative1TextInput::SelectWords << 5 << 6 << true; QTest::newRow("Hello<(, )>world|words,ltr") - << standard[2] << 5 << 7 << QDeclarativeTextInput::SelectWords << 5 << 7 << false; + << standard[2] << 5 << 7 << QDeclarative1TextInput::SelectWords << 5 << 7 << false; QTest::newRow("Hello<(, )world>|words,rtl") - << standard[2] << 7 << 5 << QDeclarativeTextInput::SelectWords << 5 << 12 << false; + << standard[2] << 7 << 5 << QDeclarative1TextInput::SelectWords << 5 << 12 << false; QTest::newRow("world|words,ltr") - << standard[2] << 3 << 7 << QDeclarativeTextInput::SelectWords << 0 << 7 << false; + << standard[2] << 3 << 7 << QDeclarative1TextInput::SelectWords << 0 << 7 << false; QTest::newRow("|words,rtl") - << standard[2] << 7 << 3 << QDeclarativeTextInput::SelectWords << 0 << 12 << false; + << standard[2] << 7 << 3 << QDeclarative1TextInput::SelectWords << 0 << 12 << false; QTest::newRow(",|words") - << standard[2] << 3 << 5 << QDeclarativeTextInput::SelectWords << 0 << 5 << true; + << standard[2] << 3 << 5 << QDeclarative1TextInput::SelectWords << 0 << 5 << true; QTest::newRow("Hello<()>,|words") - << standard[2] << 5 << 5 << QDeclarativeTextInput::SelectWords << 5 << 5 << true; + << standard[2] << 5 << 5 << QDeclarative1TextInput::SelectWords << 5 << 5 << true; QTest::newRow("Hello,<()>|words") - << standard[2] << 6 << 6 << QDeclarativeTextInput::SelectWords << 6 << 6 << true; + << standard[2] << 6 << 6 << QDeclarative1TextInput::SelectWords << 6 << 6 << true; QTest::newRow("Hello<,( )>world|words,ltr") - << standard[2] << 6 << 7 << QDeclarativeTextInput::SelectWords << 5 << 7 << false; + << standard[2] << 6 << 7 << QDeclarative1TextInput::SelectWords << 5 << 7 << false; QTest::newRow("Hello,<( )world>|words,rtl") - << standard[2] << 7 << 6 << QDeclarativeTextInput::SelectWords << 6 << 12 << false; + << standard[2] << 7 << 6 << QDeclarative1TextInput::SelectWords << 6 << 12 << false; QTest::newRow("Hello<,( world)>|words,ltr") - << standard[2] << 6 << 12 << QDeclarativeTextInput::SelectWords << 5 << 12 << false; + << standard[2] << 6 << 12 << QDeclarative1TextInput::SelectWords << 5 << 12 << false; QTest::newRow("Hello,<( world)>|words,rtl") - << standard[2] << 12 << 6 << QDeclarativeTextInput::SelectWords << 6 << 12 << false; + << standard[2] << 12 << 6 << QDeclarative1TextInput::SelectWords << 6 << 12 << false; QTest::newRow("Hello<,( world!)>|words,ltr") - << standard[2] << 6 << 13 << QDeclarativeTextInput::SelectWords << 5 << 13 << false; + << standard[2] << 6 << 13 << QDeclarative1TextInput::SelectWords << 5 << 13 << false; QTest::newRow("Hello,<( world!)>|words,rtl") - << standard[2] << 13 << 6 << QDeclarativeTextInput::SelectWords << 6 << 13 << false; + << standard[2] << 13 << 6 << QDeclarative1TextInput::SelectWords << 6 << 13 << false; QTest::newRow("Hello<(, world!)>|words") - << standard[2] << 5 << 13 << QDeclarativeTextInput::SelectWords << 5 << 13 << true; + << standard[2] << 5 << 13 << QDeclarative1TextInput::SelectWords << 5 << 13 << true; QTest::newRow("world<(!)>|words") - << standard[2] << 12 << 13 << QDeclarativeTextInput::SelectWords << 12 << 13 << true; + << standard[2] << 12 << 13 << QDeclarative1TextInput::SelectWords << 12 << 13 << true; QTest::newRow("world!<()>)|words") - << standard[2] << 13 << 13 << QDeclarativeTextInput::SelectWords << 13 << 13 << true; + << standard[2] << 13 << 13 << QDeclarative1TextInput::SelectWords << 13 << 13 << true; QTest::newRow("world<()>!)|words") - << standard[2] << 12 << 12 << QDeclarativeTextInput::SelectWords << 12 << 12 << true; + << standard[2] << 12 << 12 << QDeclarative1TextInput::SelectWords << 12 << 12 << true; QTest::newRow("<(,)>olleH |words") - << standard[3] << 7 << 8 << QDeclarativeTextInput::SelectWords << 7 << 8 << true; + << standard[3] << 7 << 8 << QDeclarative1TextInput::SelectWords << 7 << 8 << true; QTest::newRow("olleH|words,ltr") - << standard[3] << 6 << 8 << QDeclarativeTextInput::SelectWords << 1 << 8 << false; + << standard[3] << 6 << 8 << QDeclarative1TextInput::SelectWords << 1 << 8 << false; QTest::newRow("dlrow<( ,)>olleH|words,rtl") - << standard[3] << 8 << 6 << QDeclarativeTextInput::SelectWords << 6 << 8 << false; + << standard[3] << 8 << 6 << QDeclarative1TextInput::SelectWords << 6 << 8 << false; QTest::newRow("|words,ltr") - << standard[3] << 6 << 10 << QDeclarativeTextInput::SelectWords << 1 << 13 << false; + << standard[3] << 6 << 10 << QDeclarative1TextInput::SelectWords << 1 << 13 << false; QTest::newRow("dlrow<( ,ol)leH>|words,rtl") - << standard[3] << 10 << 6 << QDeclarativeTextInput::SelectWords << 6 << 13 << false; + << standard[3] << 10 << 6 << QDeclarative1TextInput::SelectWords << 6 << 13 << false; QTest::newRow(",<(ol)leH>,|words") - << standard[3] << 8 << 10 << QDeclarativeTextInput::SelectWords << 8 << 13 << true; + << standard[3] << 8 << 10 << QDeclarative1TextInput::SelectWords << 8 << 13 << true; QTest::newRow(",<()>olleH|words") - << standard[3] << 8 << 8 << QDeclarativeTextInput::SelectWords << 8 << 8 << true; + << standard[3] << 8 << 8 << QDeclarative1TextInput::SelectWords << 8 << 8 << true; QTest::newRow("<()>,olleH|words") - << standard[3] << 7 << 7 << QDeclarativeTextInput::SelectWords << 7 << 7 << true; + << standard[3] << 7 << 7 << QDeclarative1TextInput::SelectWords << 7 << 7 << true; QTest::newRow(",olleH|words,ltr") - << standard[3] << 6 << 7 << QDeclarativeTextInput::SelectWords << 1 << 7 << false; + << standard[3] << 6 << 7 << QDeclarative1TextInput::SelectWords << 1 << 7 << false; QTest::newRow("dlrow<( ),>olleH|words,rtl") - << standard[3] << 7 << 6 << QDeclarativeTextInput::SelectWords << 6 << 8 << false; + << standard[3] << 7 << 6 << QDeclarative1TextInput::SelectWords << 6 << 8 << false; QTest::newRow("<(dlrow )>,olleH|words,ltr") - << standard[3] << 1 << 7 << QDeclarativeTextInput::SelectWords << 1 << 7 << false; + << standard[3] << 1 << 7 << QDeclarative1TextInput::SelectWords << 1 << 7 << false; QTest::newRow("<(dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 1 << QDeclarativeTextInput::SelectWords << 1 << 8 << false; + << standard[3] << 7 << 1 << QDeclarative1TextInput::SelectWords << 1 << 8 << false; QTest::newRow("<(!dlrow )>,olleH|words,ltr") - << standard[3] << 0 << 7 << QDeclarativeTextInput::SelectWords << 0 << 7 << false; + << standard[3] << 0 << 7 << QDeclarative1TextInput::SelectWords << 0 << 7 << false; QTest::newRow("<(!dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 0 << QDeclarativeTextInput::SelectWords << 0 << 8 << false; + << standard[3] << 7 << 0 << QDeclarative1TextInput::SelectWords << 0 << 8 << false; QTest::newRow("(!dlrow ,)olleH|words") - << standard[3] << 0 << 8 << QDeclarativeTextInput::SelectWords << 0 << 8 << true; + << standard[3] << 0 << 8 << QDeclarative1TextInput::SelectWords << 0 << 8 << true; QTest::newRow("<(!)>dlrow|words") - << standard[3] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 1 << true; + << standard[3] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 1 << true; QTest::newRow("<()>!dlrow|words") - << standard[3] << 0 << 0 << QDeclarativeTextInput::SelectWords << 0 << 0 << true; + << standard[3] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << true; QTest::newRow("!<()>dlrow|words") - << standard[3] << 1 << 1 << QDeclarativeTextInput::SelectWords << 1 << 1 << true; + << standard[3] << 1 << 1 << QDeclarative1TextInput::SelectWords << 1 << 1 << true; QTest::newRow(" text |words") - << standard[4] << 1 << 4 << QDeclarativeTextInput::SelectWords << 1 << 7 << true; + << standard[4] << 1 << 4 << QDeclarative1TextInput::SelectWords << 1 << 7 << true; QTest::newRow(" spacey |words") - << standard[4] << 11 << 13 << QDeclarativeTextInput::SelectWords << 10 << 14 << true; + << standard[4] << 11 << 13 << QDeclarative1TextInput::SelectWords << 10 << 14 << true; QTest::newRow("<( )>spacey text |words|ltr") - << standard[4] << 0 << 1 << QDeclarativeTextInput::SelectWords << 0 << 1 << false; + << standard[4] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 1 << false; QTest::newRow("<( )spacey> text |words|rtl") - << standard[4] << 1 << 0 << QDeclarativeTextInput::SelectWords << 0 << 7 << false; + << standard[4] << 1 << 0 << QDeclarative1TextInput::SelectWords << 0 << 7 << false; QTest::newRow("spacey |words|ltr") - << standard[4] << 14 << 15 << QDeclarativeTextInput::SelectWords << 10 << 15 << false; + << standard[4] << 14 << 15 << QDeclarative1TextInput::SelectWords << 10 << 15 << false; QTest::newRow("spacey text<( )>|words|rtl") - << standard[4] << 15 << 14 << QDeclarativeTextInput::SelectWords << 14 << 15 << false; + << standard[4] << 15 << 14 << QDeclarative1TextInput::SelectWords << 14 << 15 << false; QTest::newRow("<()> spacey text |words") - << standard[4] << 0 << 0 << QDeclarativeTextInput::SelectWords << 0 << 0 << false; + << standard[4] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << false; QTest::newRow(" spacey text <()>|words") - << standard[4] << 15 << 15 << QDeclarativeTextInput::SelectWords << 15 << 15 << false; + << standard[4] << 15 << 15 << QDeclarative1TextInput::SelectWords << 15 << 15 << false; } void tst_qdeclarativetextinput::moveCursorSelection() @@ -687,7 +687,7 @@ void tst_qdeclarativetextinput::moveCursorSelection() QFETCH(QString, testStr); QFETCH(int, cursorPosition); QFETCH(int, movePosition); - QFETCH(QDeclarativeTextInput::SelectionMode, mode); + QFETCH(QDeclarative1TextInput::SelectionMode, mode); QFETCH(int, selectionStart); QFETCH(int, selectionEnd); QFETCH(bool, reversible); @@ -695,7 +695,7 @@ void tst_qdeclarativetextinput::moveCursorSelection() QString componentStr = "import QtQuick 1.1\nTextInput { text: \""+ testStr +"\"; }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); textinputObject->setCursorPosition(cursorPosition); @@ -903,17 +903,17 @@ void tst_qdeclarativetextinput::moveCursorSelectionSequence() QString componentStr = "import QtQuick 1.1\nTextInput { text: \""+ testStr +"\"; }"; QDeclarativeComponent textinputComponent(&engine); textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textinputObject = qobject_cast(textinputComponent.create()); + QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); QVERIFY(textinputObject != 0); textinputObject->setCursorPosition(cursorPosition); - textinputObject->moveCursorSelection(movePosition1, QDeclarativeTextInput::SelectWords); + textinputObject->moveCursorSelection(movePosition1, QDeclarative1TextInput::SelectWords); QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); QCOMPARE(textinputObject->selectionStart(), selection1Start); QCOMPARE(textinputObject->selectionEnd(), selection1End); - textinputObject->moveCursorSelection(movePosition2, QDeclarativeTextInput::SelectWords); + textinputObject->moveCursorSelection(movePosition2, QDeclarative1TextInput::SelectWords); QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); QCOMPARE(textinputObject->selectionStart(), selection2Start); QCOMPARE(textinputObject->selectionEnd(), selection2End); @@ -949,7 +949,7 @@ void tst_qdeclarativetextinput::mouseSelection() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textInputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); QVERIFY(textInputObject != 0); // press-and-drag-and-release from x1 to x2 @@ -997,7 +997,7 @@ void tst_qdeclarativetextinput::deferEnableSelectByMouse() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textInputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); QVERIFY(textInputObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1037,7 +1037,7 @@ void tst_qdeclarativetextinput::deferDisableSelectByMouse() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textInputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); QVERIFY(textInputObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1068,7 +1068,7 @@ void tst_qdeclarativetextinput::dragMouseSelection() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textInputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); QVERIFY(textInputObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1127,7 +1127,7 @@ void tst_qdeclarativetextinput::mouseSelectionMode() QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textInputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); QVERIFY(textInputObject != 0); // press-and-drag-and-release from x1 to x2 @@ -1193,41 +1193,41 @@ void tst_qdeclarativetextinput::horizontalAlignment() void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft() { QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml"); - QDeclarativeTextInput *textInput = canvas->rootObject()->findChild("text"); + QDeclarative1TextInput *textInput = canvas->rootObject()->findChild("text"); QVERIFY(textInput != 0); canvas->show(); - QDeclarativeTextInputPrivate *textInputPrivate = QDeclarativeTextInputPrivate::get(textInput); + QDeclarative1TextInputPrivate *textInputPrivate = QDeclarative1TextInputPrivate::get(textInput); QVERIFY(textInputPrivate != 0); QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); // implicit alignment should follow the reading direction of RTL text - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); // explicitly left aligned - textInput->setHAlign(QDeclarativeTextInput::AlignLeft); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft); + textInput->setHAlign(QDeclarative1TextInput::AlignLeft); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft); QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); // explicitly right aligned - textInput->setHAlign(QDeclarativeTextInput::AlignRight); + textInput->setHAlign(QDeclarative1TextInput::AlignRight); QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); // explicitly center aligned - textInput->setHAlign(QDeclarativeTextInput::AlignHCenter); + textInput->setHAlign(QDeclarative1TextInput::AlignHCenter); QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignHCenter); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignHCenter); QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); QVERIFY(-textInputPrivate->hscroll + textInputPrivate->width() > canvas->width()/2); // reseted alignment should go back to following the text reading direction textInput->resetHAlign(); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); @@ -1235,20 +1235,20 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft() QDeclarativeItemPrivate::get(textInput)->setLayoutMirror(true); // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); // explicitly right aligned behaves as left aligned - textInput->setHAlign(QDeclarativeTextInput::AlignRight); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), QDeclarativeTextInput::AlignLeft); + textInput->setHAlign(QDeclarative1TextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); + QCOMPARE(textInput->effectiveHAlign(), QDeclarative1TextInput::AlignLeft); QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); // mirrored explicitly left aligned behaves as right aligned - textInput->setHAlign(QDeclarativeTextInput::AlignLeft); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft); - QCOMPARE(textInput->effectiveHAlign(), QDeclarativeTextInput::AlignRight); + textInput->setHAlign(QDeclarative1TextInput::AlignLeft); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft); + QCOMPARE(textInput->effectiveHAlign(), QDeclarative1TextInput::AlignRight); QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); // disable mirroring @@ -1258,7 +1258,7 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft() // English text should be implicitly left aligned textInput->setText("Hello world!"); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignLeft); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft); QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); #ifndef Q_OS_MAC // QTBUG-18040 @@ -1266,13 +1266,13 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft() // keyboard input direction from QApplication::keyboardInputDirection textInput->setText(""); QCOMPARE(textInput->hAlign(), QApplication::keyboardInputDirection() == Qt::LeftToRight ? - QDeclarativeTextInput::AlignLeft : QDeclarativeTextInput::AlignRight); + QDeclarative1TextInput::AlignLeft : QDeclarative1TextInput::AlignRight); if (QApplication::keyboardInputDirection() == Qt::LeftToRight) QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); else QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - textInput->setHAlign(QDeclarativeTextInput::AlignRight); - QCOMPARE(textInput->hAlign(), QDeclarativeTextInput::AlignRight); + textInput->setHAlign(QDeclarative1TextInput::AlignRight); + QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); #endif @@ -1283,9 +1283,9 @@ void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft() QString componentStr = "import QtQuick 1.0\nTextInput {}"; QDeclarativeComponent textComponent(&engine); textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarativeTextInput *textObject = qobject_cast(textComponent.create()); + QDeclarative1TextInput *textObject = qobject_cast(textComponent.create()); QCOMPARE(textObject->hAlign(), QApplication::keyboardInputDirection() == Qt::LeftToRight ? - QDeclarativeTextInput::AlignLeft : QDeclarativeTextInput::AlignRight); + QDeclarative1TextInput::AlignLeft : QDeclarative1TextInput::AlignRight); delete textObject; #endif } @@ -1299,7 +1299,7 @@ void tst_qdeclarativetextinput::positionAt() QApplication::setActiveWindow(canvas); QTest::qWaitForWindowShown(canvas); - QDeclarativeTextInput *textinputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textinputObject = qobject_cast(canvas->rootObject()); QVERIFY(textinputObject != 0); // Check autoscrolled... @@ -1316,8 +1316,8 @@ void tst_qdeclarativetextinput::positionAt() #endif int x = textinputObject->positionToRectangle(pos + 1).x() - 1; - QCOMPARE(textinputObject->positionAt(x, QDeclarativeTextInput::CursorBetweenCharacters), pos + 1); - QCOMPARE(textinputObject->positionAt(x, QDeclarativeTextInput::CursorOnCharacter), pos); + QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorBetweenCharacters), pos + 1); + QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorOnCharacter), pos); // Check without autoscroll... textinputObject->setAutoScroll(false); @@ -1332,8 +1332,8 @@ void tst_qdeclarativetextinput::positionAt() #endif x = textinputObject->positionToRectangle(pos + 1).x() - 1; - QCOMPARE(textinputObject->positionAt(x, QDeclarativeTextInput::CursorBetweenCharacters), pos + 1); - QCOMPARE(textinputObject->positionAt(x, QDeclarativeTextInput::CursorOnCharacter), pos); + QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorBetweenCharacters), pos + 1); + QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorOnCharacter), pos); const qreal x0 = textinputObject->positionToRectangle(pos).x(); const qreal x1 = textinputObject->positionToRectangle(pos + 1).x(); @@ -1366,7 +1366,7 @@ void tst_qdeclarativetextinput::maxLength() QApplication::setActiveWindow(canvas); QTest::qWaitForWindowShown(canvas); - QDeclarativeTextInput *textinputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textinputObject = qobject_cast(canvas->rootObject()); QVERIFY(textinputObject != 0); QVERIFY(textinputObject->text().isEmpty()); QVERIFY(textinputObject->maxLength() == 10); @@ -1396,7 +1396,7 @@ void tst_qdeclarativetextinput::masks() canvas->show(); canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *textinputObject = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textinputObject = qobject_cast(canvas->rootObject()); QVERIFY(textinputObject != 0); QTRY_VERIFY(textinputObject->hasActiveFocus() == true); QVERIFY(textinputObject->text().length() == 0); @@ -1424,7 +1424,7 @@ void tst_qdeclarativetextinput::validators() QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *intInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("intInput"))); + QDeclarative1TextInput *intInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("intInput"))); QVERIFY(intInput); intInput->setFocus(true); QTRY_VERIFY(intInput->hasActiveFocus()); @@ -1445,7 +1445,7 @@ void tst_qdeclarativetextinput::validators() QCOMPARE(intInput->text(), QLatin1String("11")); QCOMPARE(intInput->hasAcceptableInput(), true); - QDeclarativeTextInput *dblInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("dblInput"))); + QDeclarative1TextInput *dblInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("dblInput"))); QTRY_VERIFY(dblInput); dblInput->setFocus(true); QVERIFY(dblInput->hasActiveFocus() == true); @@ -1474,7 +1474,7 @@ void tst_qdeclarativetextinput::validators() QCOMPARE(dblInput->text(), QLatin1String("12.11")); QCOMPARE(dblInput->hasAcceptableInput(), true); - QDeclarativeTextInput *strInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("strInput"))); + QDeclarative1TextInput *strInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("strInput"))); QTRY_VERIFY(strInput); strInput->setFocus(true); QVERIFY(strInput->hasActiveFocus() == true); @@ -1516,7 +1516,7 @@ void tst_qdeclarativetextinput::inputMethods() // test input method hints QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *input = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *input = qobject_cast(canvas->rootObject()); QVERIFY(input != 0); QVERIFY(input->imHints() & Qt::ImhNoPredictiveText); QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText); @@ -1568,7 +1568,7 @@ void tst_qdeclarativetextinput::navigation() QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); + QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); input->setCursorPosition(0); @@ -1609,7 +1609,7 @@ void tst_qdeclarativetextinput::navigation_RTL() QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); + QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; @@ -1657,7 +1657,7 @@ void tst_qdeclarativetextinput::copyAndPaste() { QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; QDeclarativeComponent textInputComponent(&engine); textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textInput = qobject_cast(textInputComponent.create()); + QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); QVERIFY(textInput != 0); // copy and paste @@ -1702,12 +1702,12 @@ void tst_qdeclarativetextinput::copyAndPaste() { // when echo mode is set to hide text/password mode int index = 0; while (index < 4) { - QDeclarativeTextInput::EchoMode echoMode = QDeclarativeTextInput::EchoMode(index); + QDeclarative1TextInput::EchoMode echoMode = QDeclarative1TextInput::EchoMode(index); textInput->setEchoMode(echoMode); textInput->setText("My password"); textInput->select(0, textInput->text().length());; textInput->copy(); - if (echoMode == QDeclarativeTextInput::Normal) { + if (echoMode == QDeclarative1TextInput::Normal) { QVERIFY(!clipboard->text().isEmpty()); QCOMPARE(clipboard->text(), QString("My password")); clipboard->clear(); @@ -1729,7 +1729,7 @@ void tst_qdeclarativetextinput::canPasteEmpty() { QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; QDeclarativeComponent textInputComponent(&engine); textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textInput = qobject_cast(textInputComponent.create()); + QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); QVERIFY(textInput != 0); QLineControl lc; @@ -1747,7 +1747,7 @@ void tst_qdeclarativetextinput::canPaste() { QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; QDeclarativeComponent textInputComponent(&engine); textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textInput = qobject_cast(textInputComponent.create()); + QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); QVERIFY(textInput != 0); QLineControl lc; @@ -1762,7 +1762,7 @@ void tst_qdeclarativetextinput::passwordCharacter() QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }"; QDeclarativeComponent textInputComponent(&engine); textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarativeTextInput *textInput = qobject_cast(textInputComponent.create()); + QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); QVERIFY(textInput != 0); textInput->setPasswordCharacter("X"); @@ -1779,7 +1779,7 @@ void tst_qdeclarativetextinput::cursorDelegate() QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); view->show(); view->setFocus(); - QDeclarativeTextInput *textInputObject = view->rootObject()->findChild("textInputObject"); + QDeclarative1TextInput *textInputObject = view->rootObject()->findChild("textInputObject"); QVERIFY(textInputObject != 0); QVERIFY(textInputObject->findChild("cursorInstance")); //Test Delegate gets created @@ -1820,7 +1820,7 @@ void tst_qdeclarativetextinput::cursorVisible() QTest::qWaitForWindowShown(&view); QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - QDeclarativeTextInput input; + QDeclarative1TextInput input; QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); QCOMPARE(input.isCursorVisible(), false); @@ -1884,7 +1884,7 @@ void tst_qdeclarativetextinput::cursorRectangle() { QString text = "Hello World!"; - QDeclarativeTextInput input; + QDeclarative1TextInput input; input.setText(text); QFontMetricsF fm(input.font()); input.setWidth(fm.width(text.mid(0, 5))); @@ -1934,7 +1934,7 @@ void tst_qdeclarativetextinput::readOnly() QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); + QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasActiveFocus() == true); @@ -1961,21 +1961,21 @@ void tst_qdeclarativetextinput::echoMode() QVERIFY(canvas->rootObject() != 0); - QDeclarativeTextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); + QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasActiveFocus() == true); QString initial = input->text(); Qt::InputMethodHints ref; QCOMPARE(initial, QLatin1String("ABCDefgh")); - QCOMPARE(input->echoMode(), QDeclarativeTextInput::Normal); + QCOMPARE(input->echoMode(), QDeclarative1TextInput::Normal); QCOMPARE(input->displayText(), input->text()); //Normal ref &= ~Qt::ImhHiddenText; ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); QCOMPARE(input->imHints(), Qt::ImhNone); - input->setEchoMode(QDeclarativeTextInput::NoEcho); + input->setEchoMode(QDeclarative1TextInput::NoEcho); QCOMPARE(input->text(), initial); QCOMPARE(input->displayText(), QLatin1String("")); QCOMPARE(input->passwordCharacter(), QLatin1String("*")); @@ -1984,7 +1984,7 @@ void tst_qdeclarativetextinput::echoMode() ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); QCOMPARE(input->imHints(), Qt::ImhNone); - input->setEchoMode(QDeclarativeTextInput::Password); + input->setEchoMode(QDeclarative1TextInput::Password); //Password ref |= Qt::ImhHiddenText; ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); @@ -1996,7 +1996,7 @@ void tst_qdeclarativetextinput::echoMode() QCOMPARE(input->passwordCharacter(), QLatin1String("Q")); QCOMPARE(input->text(), initial); QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); - input->setEchoMode(QDeclarativeTextInput::PasswordEchoOnEdit); + input->setEchoMode(QDeclarative1TextInput::PasswordEchoOnEdit); //PasswordEchoOnEdit ref &= ~Qt::ImhHiddenText; ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); @@ -2026,31 +2026,31 @@ void tst_qdeclarativetextinput::echoMode() input->setIMHints(Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); ref |= Qt::ImhDialableCharactersOnly; //Normal - input->setEchoMode(QDeclarativeTextInput::Normal); + input->setEchoMode(QDeclarative1TextInput::Normal); ref |= Qt::ImhHiddenText; ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); //NoEcho - input->setEchoMode(QDeclarativeTextInput::NoEcho); + input->setEchoMode(QDeclarative1TextInput::NoEcho); ref |= Qt::ImhHiddenText; ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); //Password - input->setEchoMode(QDeclarativeTextInput::Password); + input->setEchoMode(QDeclarative1TextInput::Password); ref |= Qt::ImhHiddenText; ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); //PasswordEchoOnEdit - input->setEchoMode(QDeclarativeTextInput::PasswordEchoOnEdit); + input->setEchoMode(QDeclarative1TextInput::PasswordEchoOnEdit); ref &= ~Qt::ImhHiddenText; ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); //Normal - input->setEchoMode(QDeclarativeTextInput::Normal); + input->setEchoMode(QDeclarative1TextInput::Normal); ref |= Qt::ImhHiddenText; ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); QCOMPARE(input->inputMethodHints(), ref); @@ -2139,7 +2139,7 @@ void tst_qdeclarativetextinput::openInputPanelOnClick() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextInput input; + QDeclarative1TextInput input; QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); input.setText("Hello world"); input.setPos(0, 0); @@ -2151,7 +2151,7 @@ void tst_qdeclarativetextinput::openInputPanelOnClick() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input); - QDeclarativeTextInputPrivate *inputPrivate = static_cast(pri); + QDeclarative1TextInputPrivate *inputPrivate = static_cast(pri); // input panel on click inputPrivate->showInputPanelOnFocus = false; @@ -2186,7 +2186,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextInput input; + QDeclarative1TextInput input; QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); input.setText("Hello world"); input.setPos(0, 0); @@ -2198,7 +2198,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input); - QDeclarativeTextInputPrivate *inputPrivate = static_cast(pri); + QDeclarative1TextInputPrivate *inputPrivate = static_cast(pri); inputPrivate->showInputPanelOnFocus = true; // test default values @@ -2227,7 +2227,7 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() // input method should stay enabled if focus // is lost to an item that also accepts inputs - QDeclarativeTextInput anotherInput; + QDeclarative1TextInput anotherInput; scene.addItem(&anotherInput); anotherInput.setFocus(true); QApplication::processEvents(); @@ -2311,17 +2311,17 @@ void tst_qdeclarativetextinput::openInputPanelOnFocus() QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); } -class MyTextInput : public QDeclarativeTextInput +class MyTextInput : public QDeclarative1TextInput { public: - MyTextInput(QDeclarativeItem *parent = 0) : QDeclarativeTextInput(parent) + MyTextInput(QDeclarativeItem *parent = 0) : QDeclarative1TextInput(parent) { nbPaint = 0; } void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { nbPaint++; - QDeclarativeTextInput::paint(painter, option, widget); + QDeclarative1TextInput::paint(painter, option, widget); } int nbPaint; }; @@ -2337,7 +2337,7 @@ void tst_qdeclarativetextinput::setHAlignClearCache() QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); QTRY_COMPARE(input.nbPaint, 1); - input.setHAlign(QDeclarativeTextInput::AlignRight); + input.setHAlign(QDeclarative1TextInput::AlignRight); QApplication::processEvents(); //Changing the alignment should trigger a repaint QCOMPARE(input.nbPaint, 2); @@ -2347,8 +2347,8 @@ void tst_qdeclarativetextinput::focusOutClearSelection() { QGraphicsScene scene; QGraphicsView view(&scene); - QDeclarativeTextInput input; - QDeclarativeTextInput input2; + QDeclarative1TextInput input; + QDeclarative1TextInput input2; input.setText(QLatin1String("Hello world")); input.setFocus(true); scene.addItem(&input2); @@ -2427,7 +2427,7 @@ void tst_qdeclarativetextinput::preeditAutoScroll() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextInput input; + QDeclarative1TextInput input; QFontMetricsF fm(input.font()); input.setWidth(fm.width(committedText)); input.setText(committedText); @@ -2526,7 +2526,7 @@ void tst_qdeclarativetextinput::preeditMicroFocus() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextInput input; + QDeclarative1TextInput input; input.setPos(0, 0); input.setAutoScroll(false); input.setFocus(true); @@ -2582,7 +2582,7 @@ void tst_qdeclarativetextinput::inputContextMouseHandler() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextInput input; + QDeclarative1TextInput input; input.setWidth(200); input.setText(text.mid(0, 12)); input.setCursorPosition(12); @@ -2700,7 +2700,7 @@ void tst_qdeclarativetextinput::inputMethodComposing() QGraphicsView view(&scene); MyInputContext ic; view.setInputContext(&ic); - QDeclarativeTextInput input; + QDeclarative1TextInput input; input.setWidth(200); input.setText(text.mid(0, 12)); input.setCursorPosition(12); @@ -2738,7 +2738,7 @@ void tst_qdeclarativetextinput::cursorRectangleSize() QApplication::setActiveWindow(canvas); QTest::qWaitForWindowShown(canvas); - QDeclarativeTextInput *textInput = qobject_cast(canvas->rootObject()); + QDeclarative1TextInput *textInput = qobject_cast(canvas->rootObject()); QVERIFY(textInput != 0); textInput->setFocus(Qt::OtherFocusReason); QRectF cursorRect = textInput->positionToRectangle(textInput->cursorPosition()); diff --git a/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro new file mode 100644 index 0000000000..dfc3421c2b --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro @@ -0,0 +1,12 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativetimer.cpp + +!symbian: { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp new file mode 100644 index 0000000000..8b1b79a034 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp @@ -0,0 +1,344 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +class tst_qdeclarativetimer : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativetimer(); + +private slots: + void notRepeating(); + void notRepeatingStart(); + void repeat(); + void noTriggerIfNotRunning(); + void triggeredOnStart(); + void triggeredOnStartRepeat(); + void changeDuration(); + void restart(); + void parentProperty(); +}; + +class TimerHelper : public QObject +{ + Q_OBJECT +public: + TimerHelper() : QObject(), count(0) + { + } + + int count; + +public slots: + void timeout() { + ++count; + } +}; + +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86) +// Increase wait as emulator startup can cause unexpected delays +#define TIMEOUT_TIMEOUT 2000 +#else +#define TIMEOUT_TIMEOUT 200 +#endif + +tst_qdeclarativetimer::tst_qdeclarativetimer() +{ +} + +void tst_qdeclarativetimer::notRepeating() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile("")); + QDeclarative1Timer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + QVERIFY(timer->isRunning()); + QVERIFY(!timer->isRepeating()); + QCOMPARE(timer->interval(), 100); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QVERIFY(timer->isRunning() == false); +} + +void tst_qdeclarativetimer::notRepeatingStart() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100 }"), QUrl::fromLocalFile("")); + QDeclarative1Timer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + QVERIFY(!timer->isRunning()); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 0); + + timer->start(); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 1); + QVERIFY(timer->isRunning() == false); + + delete timer; +} + +void tst_qdeclarativetimer::repeat() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile("")); + QDeclarative1Timer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > 0); + int oldCount = helper.count; + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > oldCount); + QVERIFY(timer->isRunning()); + + oldCount = helper.count; + timer->stop(); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count == oldCount); + QVERIFY(timer->isRunning() == false); + + QSignalSpy spy(timer, SIGNAL(repeatChanged())); + + timer->setRepeating(false); + QVERIFY(!timer->isRepeating()); + QCOMPARE(spy.count(),1); + + timer->setRepeating(false); + QCOMPARE(spy.count(),1); + + timer->setRepeating(true); + QCOMPARE(spy.count(),2); + + delete timer; +} + +void tst_qdeclarativetimer::triggeredOnStart() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile("")); + QDeclarative1Timer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + QVERIFY(timer->triggeredOnStart()); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QTest::qWait(1); + QCOMPARE(helper.count, 1); + + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 2); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(helper.count, 2); + QVERIFY(timer->isRunning() == false); + + QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged())); + + timer->setTriggeredOnStart(false); + QVERIFY(!timer->triggeredOnStart()); + QCOMPARE(spy.count(),1); + + timer->setTriggeredOnStart(false); + QCOMPARE(spy.count(),1); + + timer->setTriggeredOnStart(true); + QCOMPARE(spy.count(),2); + + delete timer; +} + +void tst_qdeclarativetimer::triggeredOnStartRepeat() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile("")); + QDeclarative1Timer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QTest::qWait(1); + QCOMPARE(helper.count, 1); + + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > 1); + int oldCount = helper.count; + QTest::qWait(TIMEOUT_TIMEOUT); + QVERIFY(helper.count > oldCount); + QVERIFY(timer->isRunning()); + + delete timer; +} + +void tst_qdeclarativetimer::noTriggerIfNotRunning() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray( + "import QtQuick 1.0\n" + "Item { property bool ok: true\n" + "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }" + "Timer { interval: 10; running: true; onTriggered: t1.running=false }" + "}" + ), QUrl::fromLocalFile("")); + QObject *item = component.create(); + QVERIFY(item != 0); + QTest::qWait(TIMEOUT_TIMEOUT); + QCOMPARE(item->property("ok").toBool(), true); + + delete item; +} + +void tst_qdeclarativetimer::changeDuration() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile("")); + QDeclarative1Timer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(500); + QCOMPARE(helper.count, 2); + + timer->setInterval(500); + + QTest::qWait(600); + QCOMPARE(helper.count, 3); + QVERIFY(timer->isRunning()); + + QSignalSpy spy(timer, SIGNAL(intervalChanged())); + + timer->setInterval(200); + QCOMPARE(timer->interval(), 200); + QCOMPARE(spy.count(),1); + + timer->setInterval(200); + QCOMPARE(spy.count(),1); + + timer->setInterval(300); + QCOMPARE(spy.count(),2); + + delete timer; +} + +void tst_qdeclarativetimer::restart() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile("")); + QDeclarative1Timer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(600); + QCOMPARE(helper.count, 1); + + QTest::qWait(300); + + timer->restart(); + + QTest::qWait(700); + + QCOMPARE(helper.count, 2); + QVERIFY(timer->isRunning()); + + delete timer; +} + +void tst_qdeclarativetimer::parentProperty() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile("")); + QDeclarativeItem *item = qobject_cast(component.create()); + QVERIFY(item != 0); + QDeclarative1Timer *timer = item->findChild("timer"); + QVERIFY(timer != 0); + + QVERIFY(timer->isRunning()); + + delete timer; +} + +QTEST_MAIN(tst_qdeclarativetimer) + +#include "tst_qdeclarativetimer.moc" diff --git a/tests/auto/declarative/qdeclarativeview/data/error1.qml b/tests/auto/qtquick1/qdeclarativeview/data/error1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeview/data/error1.qml rename to tests/auto/qtquick1/qdeclarativeview/data/error1.qml diff --git a/tests/auto/declarative/qdeclarativeview/data/resizemodedeclarativeitem.qml b/tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeview/data/resizemodedeclarativeitem.qml rename to tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml diff --git a/tests/auto/declarative/qdeclarativeview/data/resizemodegraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeview/data/resizemodegraphicswidget.qml rename to tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml diff --git a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro b/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro similarity index 62% rename from tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro rename to tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro index 5b401973f9..603eab08d7 100644 --- a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro +++ b/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeview.cpp @@ -11,4 +11,4 @@ symbian: { } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp similarity index 99% rename from tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp rename to tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp index 0483e0a0e8..d98215126b 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp @@ -42,8 +42,8 @@ #include #include #include -#include -#include +#include +#include #include #include "../../../shared/util.h" diff --git a/tests/auto/declarative/qdeclarativeviewer/data/orientation.qml b/tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml similarity index 100% rename from tests/auto/declarative/qdeclarativeviewer/data/orientation.qml rename to tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml diff --git a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro similarity index 71% rename from tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro rename to tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro index c24467575f..010fa3696a 100644 --- a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro +++ b/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle include(../../../../tools/qmlviewer/qml.pri) @@ -17,4 +17,4 @@ symbian: { } CONFIG += parallel_test -QT += core-private gui-private declarative-private +QT += core-private gui-private declarative-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp similarity index 99% rename from tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp rename to tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 4e2b313414..6ef2a114d7 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -41,8 +41,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml similarity index 100% rename from tests/auto/declarative/qdeclarativevisualdatamodel/data/datalist.qml rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/modelproperties.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml similarity index 100% rename from tests/auto/declarative/qdeclarativevisualdatamodel/data/modelproperties.qml rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/modelproperties2.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativevisualdatamodel/data/modelproperties2.qml rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml similarity index 100% rename from tests/auto/declarative/qdeclarativevisualdatamodel/data/objectlist.qml rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml similarity index 100% rename from tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole1.qml rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml similarity index 100% rename from tests/auto/declarative/qdeclarativevisualdatamodel/data/singlerole2.qml rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/data/visualdatamodel.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml similarity index 100% rename from tests/auto/declarative/qdeclarativevisualdatamodel/data/visualdatamodel.qml rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro b/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro similarity index 79% rename from tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro index e15a7b0577..93019a53c5 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro +++ b/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui qtquick1 macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativevisualdatamodel.cpp @@ -14,4 +14,4 @@ symbian: { CONFIG += parallel_test -QT += core-private gui-private declarative-private script-private +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp similarity index 86% rename from tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp rename to tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index ee787e2923..d08251e67b 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -45,10 +45,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -181,7 +181,7 @@ void tst_qdeclarativevisualdatamodel::rootIndex() engine.rootContext()->setContextProperty("myModel", &model); - QDeclarativeVisualDataModel *obj = qobject_cast(c.create()); + QDeclarative1VisualDataModel *obj = qobject_cast(c.create()); QVERIFY(obj != 0); QMetaObject::invokeMethod(obj, "setRoot"); @@ -209,31 +209,31 @@ void tst_qdeclarativevisualdatamodel::updateLayout() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QDeclarativeText *name = findItem(contentItem, "display", 0); + QDeclarative1Text *name = findItem(contentItem, "display", 0); QVERIFY(name); QCOMPARE(name->text(), QString("Row 1 Item")); - name = findItem(contentItem, "display", 1); + name = findItem(contentItem, "display", 1); QVERIFY(name); QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); + name = findItem(contentItem, "display", 2); QVERIFY(name); QCOMPARE(name->text(), QString("Row 3 Item")); model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder); - name = findItem(contentItem, "display", 0); + name = findItem(contentItem, "display", 0); QVERIFY(name); QCOMPARE(name->text(), QString("Row 3 Item")); - name = findItem(contentItem, "display", 1); + name = findItem(contentItem, "display", 1); QVERIFY(name); QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); + name = findItem(contentItem, "display", 2); QVERIFY(name); QCOMPARE(name->text(), QString("Row 1 Item")); } @@ -249,45 +249,45 @@ void tst_qdeclarativevisualdatamodel::childChanged() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QDeclarativeVisualDataModel *vdm = listview->findChild("visualModel"); + QDeclarative1VisualDataModel *vdm = listview->findChild("visualModel"); vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0)))); - QDeclarativeText *name = findItem(contentItem, "display", 0); + QDeclarative1Text *name = findItem(contentItem, "display", 0); QVERIFY(name); QCOMPARE(name->text(), QString("Row 2 Child Item")); model.item(1,0)->child(0,0)->setText("Row 2 updated child"); - name = findItem(contentItem, "display", 0); + name = findItem(contentItem, "display", 0); QVERIFY(name); QCOMPARE(name->text(), QString("Row 2 updated child")); model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2"))); QTest::qWait(300); - name = findItem(contentItem, "display", 1); + name = findItem(contentItem, "display", 1); QVERIFY(name != 0); QCOMPARE(name->text(), QString("Row 2 Child Item 2")); model.item(1,0)->takeRow(1); - name = findItem(contentItem, "display", 1); + name = findItem(contentItem, "display", 1); QVERIFY(name == 0); vdm->setRootIndex(QVariant::fromValue(QModelIndex())); QTest::qWait(300); - name = findItem(contentItem, "display", 0); + name = findItem(contentItem, "display", 0); QVERIFY(name); QCOMPARE(name->text(), QString("Row 1 Item")); - name = findItem(contentItem, "display", 1); + name = findItem(contentItem, "display", 1); QVERIFY(name); QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); + name = findItem(contentItem, "display", 2); QVERIFY(name); QCOMPARE(name->text(), QString("Row 3 Item")); } @@ -307,16 +307,16 @@ void tst_qdeclarativevisualdatamodel::objectListModel() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/objectlist.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QDeclarativeText *name = findItem(contentItem, "name", 0); + QDeclarative1Text *name = findItem(contentItem, "name", 0); QCOMPARE(name->text(), QString("Item 1")); - QDeclarativeText *section = findItem(contentItem, "section", 0); + QDeclarative1Text *section = findItem(contentItem, "section", 0); QCOMPARE(section->text(), QString("Item 1")); dataList[0]->setProperty("name", QLatin1String("Changed")); @@ -335,13 +335,13 @@ void tst_qdeclarativevisualdatamodel::singleRole() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole1.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QDeclarativeText *name = findItem(contentItem, "name", 1); + QDeclarative1Text *name = findItem(contentItem, "name", 1); QCOMPARE(name->text(), QString("two")); model.set(1, "Changed"); @@ -357,13 +357,13 @@ void tst_qdeclarativevisualdatamodel::singleRole() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole2.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); QVERIFY(contentItem != 0); - QDeclarativeText *name = findItem(contentItem, "name", 1); + QDeclarative1Text *name = findItem(contentItem, "name", 1); QCOMPARE(name->text(), QString("two")); model.set(1, "Changed"); @@ -383,7 +383,7 @@ void tst_qdeclarativevisualdatamodel::modelProperties() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/modelproperties.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -415,7 +415,7 @@ void tst_qdeclarativevisualdatamodel::modelProperties() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/modelproperties.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -457,7 +457,7 @@ void tst_qdeclarativevisualdatamodel::modelProperties() view.setSource(source); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); QDeclarativeItem *contentItem = listview->contentItem(); @@ -489,10 +489,10 @@ void tst_qdeclarativevisualdatamodel::noDelegate() view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); - QDeclarativeListView *listview = qobject_cast(view.rootObject()); + QDeclarative1ListView *listview = qobject_cast(view.rootObject()); QVERIFY(listview != 0); - QDeclarativeVisualDataModel *vdm = listview->findChild("visualModel"); + QDeclarative1VisualDataModel *vdm = listview->findChild("visualModel"); QVERIFY(vdm != 0); QCOMPARE(vdm->count(), 3); diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml new file mode 100644 index 0000000000..4e03503f90 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml @@ -0,0 +1,61 @@ +import QtQuick 1.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } + + id: root + + property bool preTest: false + property bool postTest: false + + function runPreTest() { + if (root.get(0) != undefined) + return; + + preTest = true; + } + + function runPostTest() { + if (root.get(-1) != undefined) + return; + + var row = root.get(0); + if (row.name != "Polly" || + row.type != "Parrot" || + row.age != 12 || + row.size != "Small") + return; + + row = root.get(1); + if (row.name != "Penny" || + row.type != "Turtle" || + row.age != 4 || + row.size != "Small") + return; + + row = root.get(7); + if (row.name != "Rover" || + row.type != "Dog" || + row.age != 0 || + row.size != "Large") + return; + + row = root.get(8); + if (row.name != "Tiny" || + row.type != "Elephant" || + row.age != 15 || + row.size != "Large") + return; + + if (root.get(9) != undefined) + return; + + postTest = true; + } +} + diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml new file mode 100644 index 0000000000..fdacb6c445 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml new file mode 100644 index 0000000000..40cd6d0432 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml @@ -0,0 +1,54 @@ + + + Polly + Parrot + 12 + Small + + + Penny + Turtle + 4 + Small + + + Warren + Rabbit + 2 + Small + + + Spot + Dog + 9 + Medium + + + Whiskers + Cat + 2 + Medium + + + Joey + Kangaroo + 1 + + + Kimba + Bunny + 65 + Large + + + Rover + Dog + Large + + + Tiny + Elephant + 15 + Large + + diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml new file mode 100644 index 0000000000..dab2ec6dc0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml @@ -0,0 +1,14 @@ + + + Polly + Parrot + 12 + Small + + + Penny + Turtle + 4 + Small + + diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml new file mode 100644 index 0000000000..ed674ce36f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { objectName: "role"; name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml new file mode 100644 index 0000000000..6345101d9a --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +XmlListModel { + source: "recipes.xml" + query: "/recipes/recipe" + XmlRole { name: "title"; query: "@title/string()" } + XmlRole { name: "picture"; query: "picture/string()" } + XmlRole { name: "ingredients"; query: "ingredients/string()" } + XmlRole { name: "preparation"; query: "method/string()" } +} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml new file mode 100644 index 0000000000..d71de60710 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml @@ -0,0 +1,90 @@ + + + content/pics/pancakes.jpg + +
    +
  • 1 cup (150g) self-raising flour +
  • 1 tbs caster sugar +
  • 3/4 cup (185ml) milk +
  • 1 egg +
+ + ]]>
+ +
    +
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
  4. Turn over and cook other side until golden. +
+ + ]]>
+
+ + content/pics/fruit-salad.jpg + + + + + content/pics/vegetable-soup.jpg + +
    +
  • 1 onion +
  • 1 turnip +
  • 1 potato +
  • 1 carrot +
  • 1 head of celery +
  • 1 1/2 litres of water +
+ + ]]>
+ +
    +
  1. Chop vegetables. +
  2. Boil in water until vegetables soften. +
  3. Season with salt and pepper to taste. +
+ + ]]>
+
+ + content/pics/hamburger.jpg + +
    +
  • 500g minced beef +
  • Seasoning +
  • lettuce, tomato, onion, cheese +
  • 1 hamburger bun for each burger +
+ + ]]>
+ +
    +
  1. Mix the beef, together with seasoning, in a food processor. +
  2. Shape the beef into burgers. +
  3. Grill the burgers for about 5 mins on each side (until cooked through) +
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
+ + ]]>
+
+ + content/pics/lemonade.jpg + +
    +
  • 1 cup Lemon Juice +
  • 1 cup Sugar +
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
+ + ]]>
+ +
    +
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
  3. Chill or serve over ice cubes. +
+ + ]]>
+
+
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml new file mode 100644 index 0000000000..492dad920f --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +XmlListModel { + id: model + XmlRole {} + Component.onCompleted: model.roles = 0 +} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml new file mode 100644 index 0000000000..a0d846f188 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml @@ -0,0 +1,10 @@ +import QtQuick 1.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "/name/string()" } //starts with '/' + XmlRole { name: "type"; query: "type" } //no type + XmlRole { name: "age"; query: "age/" } //ends with '/' + XmlRole { name: "size"; query: "size/number()" } //wrong type +} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml new file mode 100644 index 0000000000..d90cd61096 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml @@ -0,0 +1,13 @@ +import QtQuick 1.0 + +XmlListModel { + query: "/data/item" + XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true } + XmlRole { name: "age"; query: "age/number()"; isKey: true } + XmlRole { name: "sport"; query: "sport/string()" } + + function disableNameKey() { + nameRole.isKey = false; + } +} + diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml new file mode 100644 index 0000000000..4dbcc029e0 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +XmlListModel { + query: "/data" + XmlRole { name: "stringValue"; query: "a-string/string()" } + XmlRole { name: "numberValue"; query: "a-number/number()" } +} + diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml new file mode 100644 index 0000000000..dab8ffa78e --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +XmlListModel { + source: "model.xml" + query: "/Pets/Pet" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "name"; query: "type/string()" } +} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro new file mode 100644 index 0000000000..6a4a50c7a3 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro @@ -0,0 +1,21 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative script gui network qtquick1 +contains(QT_CONFIG,xmlpatterns) { + QT += xmlpatterns + DEFINES += QTEST_XMLPATTERNS +} +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativexmllistmodel.cpp + +symbian: { + importFiles.files = data + importFiles.path = . + DEPLOYMENT += importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private script-private qtquick1-private diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp new file mode 100644 index 0000000000..35a78e0a46 --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -0,0 +1,965 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef QTEST_XMLPATTERNS +#include +#include +#include +#include "../../../shared/util.h" + +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +#define SRCDIR "." +#endif + +typedef QPair QDeclarativeXmlListRange; +typedef QList QDeclarativeXmlModelData; + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(QDeclarativeXmlModelData) +Q_DECLARE_METATYPE(QDeclarative1XmlListModel::Status) + +class tst_qdeclarativexmllistmodel : public QObject + +{ + Q_OBJECT +public: + tst_qdeclarativexmllistmodel() {} + +private slots: + void initTestCase() { + qRegisterMetaType("QDeclarative1XmlListModel::Status"); + } + + void buildModel(); + void testTypes(); + void testTypes_data(); + void cdata(); + void attributes(); + void roles(); + void roleErrors(); + void uniqueRoleNames(); + void headers(); + void xml(); + void xml_data(); + void source(); + void source_data(); + void data(); + void get(); + void reload(); + void useKeys(); + void useKeys_data(); + void noKeysValueChanges(); + void keysChanged(); + void threading(); + void threading_data(); + void propertyChanges(); + + void roleCrash(); + +private: + QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const + { + if (modelData) + modelData->clear(); + QString xml; + + if (!data.isEmpty()) { + QStringList items = data.split(";"); + foreach(const QString &item, items) { + if (item.isEmpty()) + continue; + QVariantList variants; + xml += QLatin1String(""); + QStringList fields = item.split(","); + foreach(const QString &field, fields) { + QStringList values = field.split("="); + if (values.count() != 2) { + qWarning() << "makeItemXmlAndData: invalid field:" << field; + continue; + } + xml += QString("<%1>%2").arg(values[0], values[1]); + if (!modelData) + continue; + bool isNum = false; + int number = values[1].toInt(&isNum); + if (isNum) + variants << number; + else + variants << values[1]; + } + xml += QLatin1String(""); + if (modelData) + modelData->append(variants); + } + } + + QString decl = ""; + return decl + QLatin1String("") + xml + QLatin1String(""); + } + + QDeclarativeEngine engine; +}; + +class CustomNetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory +{ + Q_OBJECT +public: + QVariantMap lastSentHeaders; + +protected: + QNetworkAccessManager *create(QObject *parent); +}; + +class CustomNetworkAccessManager : public QNetworkAccessManager +{ + Q_OBJECT +public: + CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent) + : QNetworkAccessManager(parent), m_factory(factory) {} + +protected: + QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0) + { + if (m_factory) { + QVariantMap map; + foreach (const QString &header, req.rawHeaderList()) + map[header] = req.rawHeader(header.toUtf8()); + m_factory->lastSentHeaders = map; + } + return QNetworkAccessManager::createRequest(op, req, outgoingData); + } + + QPointer m_factory; +}; + +QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent) +{ + return new CustomNetworkAccessManager(this, parent); +} + + +void tst_qdeclarativexmllistmodel::buildModel() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QList roles; + roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3; + QHash data = model->data(3, roles); + QVERIFY(data.count() == 4); + QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot")); + QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog")); + QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9); + QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium")); + + delete model; +} + +void tst_qdeclarativexmllistmodel::testTypes() +{ + QFETCH(QString, xml); + QFETCH(QString, roleName); + QFETCH(QVariant, expectedValue); + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/testtypes.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + model->setXml(xml.toUtf8()); + model->reload(); + QTRY_COMPARE(model->count(), 1); + + int role = -1; + foreach (int i, model->roles()) { + if (model->toString(i) == roleName) { + role = i; + break; + } + } + QVERIFY(role >= 0); + + if (expectedValue.toString() == "nan") + QVERIFY(qIsNaN(model->data(0, role).toDouble())); + else + QCOMPARE(model->data(0, role), expectedValue); + + delete model; +} + +void tst_qdeclarativexmllistmodel::testTypes_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("roleName"); + QTest::addColumn("expectedValue"); + + QTest::newRow("missing string field") << "" + << "stringValue" << QVariant(""); + QTest::newRow("empty string") << "" + << "stringValue" << QVariant(""); + QTest::newRow("1-char string") << "5" + << "stringValue" << QVariant("5"); + QTest::newRow("string ok") << "abc def g" + << "stringValue" << QVariant("abc def g"); + + QTest::newRow("missing number field") << "" + << "numberValue" << QVariant(""); + double nan = qQNaN(); + QTest::newRow("empty number field") << "" + << "numberValue" << QVariant(nan); + QTest::newRow("number field with string") << "a string" + << "numberValue" << QVariant(nan); + QTest::newRow("-1") << "-1" + << "numberValue" << QVariant("-1"); + QTest::newRow("-1.5") << "-1.5" + << "numberValue" << QVariant("-1.5"); + QTest::newRow("0") << "0" + << "numberValue" << QVariant("0"); + QTest::newRow("+1") << "1" + << "numberValue" << QVariant("1"); + QTest::newRow("+1.5") << "1.5" + << "numberValue" << QVariant("1.5"); +} + +void tst_qdeclarativexmllistmodel::cdata() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 5); + + QList roles; + roles << Qt::UserRole + 2; + QHash data = model->data(2, roles); + QVERIFY(data.count() == 1); + QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String(""))); + + delete model; +} + +void tst_qdeclarativexmllistmodel::attributes() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 5); + QList roles; + roles << Qt::UserRole; + QHash data = model->data(2, roles); + QVERIFY(data.count() == 1); + QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup")); + + delete model; +} + +void tst_qdeclarativexmllistmodel::roles() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QList roles = model->roles(); + QCOMPARE(roles.count(), 4); + QCOMPARE(model->toString(roles.at(0)), QLatin1String("name")); + QCOMPARE(model->toString(roles.at(1)), QLatin1String("type")); + QCOMPARE(model->toString(roles.at(2)), QLatin1String("age")); + QCOMPARE(model->toString(roles.at(3)), QLatin1String("size")); + + delete model; +} + +void tst_qdeclarativexmllistmodel::roleErrors() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml")); + QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); + QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":9:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); + + //### make sure we receive all expected warning messages. + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QList roles; + roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3; + QHash data = model->data(3, roles); + QVERIFY(data.count() == 4); + + //### should any of these return valid values? + QCOMPARE(data.value(Qt::UserRole), QVariant()); + QCOMPARE(data.value(Qt::UserRole+1), QVariant()); + QCOMPARE(data.value(Qt::UserRole+2), QVariant()); + + QEXPECT_FAIL("", "QTBUG-10797", Continue); + QCOMPARE(data.value(Qt::UserRole+3), QVariant()); + + delete model; +} + +void tst_qdeclarativexmllistmodel::uniqueRoleNames() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml")); + QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QList roles = model->roles(); + QCOMPARE(roles.count(), 1); + + delete model; +} + + +void tst_qdeclarativexmllistmodel::xml() +{ + QFETCH(QString, xml); + QFETCH(int, count); + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status))); + + QVERIFY(model->errorString().isEmpty()); + QCOMPARE(model->progress(), qreal(0.0)); + QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); + QCOMPARE(model->progress(), qreal(1.0)); + QCOMPARE(model->count(), 9); + + // if xml is empty (i.e. clearing) it won't have any effect if a source is set + if (xml.isEmpty()) + model->setSource(QUrl()); + model->setXml(xml); + QCOMPARE(model->progress(), qreal(1.0)); // immediately goes to 1.0 if using setXml() + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); + QCOMPARE(model->count(), count); + + delete model; +} + +void tst_qdeclarativexmllistmodel::xml_data() +{ + QTest::addColumn("xml"); + QTest::addColumn("count"); + + QTest::newRow("xml with no items") << "" << 0; + QTest::newRow("empty xml") << "" << 0; + QTest::newRow("one item") << "HobbesTiger7Large" << 1; +} + +void tst_qdeclarativexmllistmodel::headers() +{ + // ensure the QNetworkAccessManagers created for this test are immediately deleted + QDeclarativeEngine qmlEng; + + CustomNetworkAccessManagerFactory factory; + qmlEng.setNetworkAccessManagerFactory(&factory); + + QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->status(), QDeclarative1XmlListModel::Ready); + + QVariantMap expectedHeaders; + expectedHeaders["Accept"] = "application/xml,*/*"; + + QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count()); + foreach (const QString &header, expectedHeaders.keys()) { + QVERIFY(factory.lastSentHeaders.contains(header)); + QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString()); + } + + delete model; +} + +void tst_qdeclarativexmllistmodel::source() +{ + QFETCH(QUrl, source); + QFETCH(int, count); + QFETCH(QDeclarative1XmlListModel::Status, status); + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status))); + + QVERIFY(model->errorString().isEmpty()); + QCOMPARE(model->progress(), qreal(0.0)); + QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready); + QVERIFY(model->errorString().isEmpty()); + QCOMPARE(model->progress(), qreal(1.0)); + QCOMPARE(model->count(), 9); + + model->setSource(source); + QCOMPARE(model->progress(), qreal(0.0)); + QTRY_COMPARE(spy.count(), 1); spy.clear(); + QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); + QVERIFY(model->errorString().isEmpty()); + + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + connect(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status)), &loop, SLOT(quit())); + connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + timer.start(20000); + loop.exec(); + + if (spy.count() == 0 && status != QDeclarative1XmlListModel::Ready) { + qWarning("QDeclarative1XmlListModel invalid source test timed out"); + } else { + QCOMPARE(spy.count(), 1); spy.clear(); + } + + QCOMPARE(model->status(), status); + QCOMPARE(model->count(), count); + + if (status == QDeclarative1XmlListModel::Ready) + QCOMPARE(model->progress(), qreal(1.0)); + + QCOMPARE(model->errorString().isEmpty(), status == QDeclarative1XmlListModel::Ready); + + delete model; +} + +void tst_qdeclarativexmllistmodel::source_data() +{ + QTest::addColumn("source"); + QTest::addColumn("count"); + QTest::addColumn("status"); + + QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/model2.xml") << 2 << QDeclarative1XmlListModel::Ready; + QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarative1XmlListModel::Error; + + // empty file + QTemporaryFile *temp = new QTemporaryFile(this); + if (temp->open()) + QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 << QDeclarative1XmlListModel::Ready; + temp->close(); +} + +void tst_qdeclarativexmllistmodel::data() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + QHash blank; + for (int i=0; iroles().count(); i++) + blank.insert(model->roles()[i], QVariant()); + for (int i=0; i<9; i++) { + QCOMPARE(model->data(i, model->roles()), blank); + for (int j=0; jroles().count(); j++) { + QCOMPARE(model->data(i, j), QVariant()); + } + } + QTRY_COMPARE(model->count(), 9); + + delete model; +} + +void tst_qdeclarativexmllistmodel::get() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/get.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + QVERIFY(QMetaObject::invokeMethod(model, "runPreTest")); + QCOMPARE(model->property("preTest").toBool(), true); + + QTRY_COMPARE(model->count(), 9); + + QVERIFY(QMetaObject::invokeMethod(model, "runPostTest")); + QCOMPARE(model->property("postTest").toBool(), true); + + delete model; +} + +void tst_qdeclarativexmllistmodel::reload() +{ + // If no keys are used, the model should be rebuilt from scratch when + // reload() is called. + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + //reload multiple times to test the xml query aborting + model->reload(); + model->reload(); + QCoreApplication::processEvents(); + model->reload(); + model->reload(); + QTRY_COMPARE(spyCount.count(), 1); + QTRY_COMPARE(spyInsert.count(), 1); + QTRY_COMPARE(spyRemove.count(), 1); + + QCOMPARE(spyInsert[0][0].toInt(), 0); + QCOMPARE(spyInsert[0][1].toInt(), 9); + + QCOMPARE(spyRemove[0][0].toInt(), 0); + QCOMPARE(spyRemove[0][1].toInt(), 9); + + delete model; +} + +void tst_qdeclarativexmllistmodel::useKeys() +{ + // If using incremental updates through keys, the model should only + // insert & remove some of the items, instead of throwing everything + // away and causing the view to repaint the whole view. + + QFETCH(QString, oldXml); + QFETCH(int, oldCount); + QFETCH(QString, newXml); + QFETCH(QDeclarativeXmlModelData, newData); + QFETCH(QList, insertRanges); + QFETCH(QList, removeRanges); + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + model->setXml(oldXml); + QTRY_COMPARE(model->count(), oldCount); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + model->setXml(newXml); + + if (oldCount != newData.count()) { + QTRY_COMPARE(model->count(), newData.count()); + QCOMPARE(spyCount.count(), 1); + } else { + QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0); + QCOMPARE(spyCount.count(), 0); + } + + QList roles = model->roles(); + for (int i=0; icount(); i++) { + for (int j=0; jdata(i, roles[j]), newData[i][j]); + } + + QCOMPARE(spyInsert.count(), insertRanges.count()); + for (int i=0; i("oldXml"); + QTest::addColumn("oldCount"); + QTest::addColumn("newXml"); + QTest::addColumn("newData"); + QTest::addColumn >("insertRanges"); + QTest::addColumn >("removeRanges"); + + QDeclarativeXmlModelData modelData; + + QTest::newRow("append 1") + << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData) + << modelData + << (QList() << qMakePair(1, 1)) + << QList(); + + QTest::newRow("append multiple") + << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) + << modelData + << (QList() << qMakePair(1, 2)) + << QList(); + + QTest::newRow("insert in different spots") + << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) + << modelData + << (QList() << qMakePair(0, 1) << qMakePair(2,2)) + << QList(); + + QTest::newRow("insert in middle") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) + << modelData + << (QList() << qMakePair(1, 2)) + << QList(); + + QTest::newRow("remove first") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 + << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData) + << modelData + << QList() + << (QList() << qMakePair(0, 1)); + + QTest::newRow("remove last") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 + << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData) + << modelData + << QList() + << (QList() << qMakePair(1, 1)); + + QTest::newRow("remove from multiple spots") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData) + << modelData + << QList() + << (QList() << qMakePair(1, 1) << qMakePair(3,2)); + + QTest::newRow("remove all") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 + << makeItemXmlAndData("", &modelData) + << modelData + << QList() + << (QList() << qMakePair(0, 3)); + + QTest::newRow("replace item") + << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 + << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData) + << modelData + << (QList() << qMakePair(0, 1)) + << (QList() << qMakePair(0, 1)); + + QTest::newRow("add and remove simultaneously, in different spots") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4 + << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData) + << modelData + << (QList() << qMakePair(1, 1)) + << (QList() << qMakePair(0, 1) << qMakePair(2,2)); + + QTest::newRow("insert at start, remove at end i.e. rss feed") + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3 + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) + << modelData + << (QList() << qMakePair(0, 2)) + << (QList() << qMakePair(1, 2)); + + QTest::newRow("remove at start, insert at end") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData) + << modelData + << (QList() << qMakePair(1, 2)) + << (QList() << qMakePair(0, 2)); + + QTest::newRow("all data has changed") + << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2 + << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) + << modelData + << (QList() << qMakePair(0, 2)) + << (QList() << qMakePair(0, 2)); +} + +void tst_qdeclarativexmllistmodel::noKeysValueChanges() +{ + // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml. + // If a 'sport' value is changed, the model should not be reloaded, + // since 'sport' is not marked as a key. + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + QString xml; + + xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); + model->setXml(xml); + QTRY_COMPARE(model->count(), 2); + + model->setXml(""); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics"); + model->setXml(xml); + + // wait for the new xml data to be set, and verify no signals were emitted + QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football")); + QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules")); + + QVERIFY(spyInsert.count() == 0); + QVERIFY(spyRemove.count() == 0); + QVERIFY(spyCount.count() == 0); + + QCOMPARE(model->count(), 2); + + delete model; +} + +void tst_qdeclarativexmllistmodel::keysChanged() +{ + // If the key roles change, the next time the data is reloaded, it should + // delete all its data and build a clean model (i.e. same behaviour as + // if no keys are set). + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + + QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); + model->setXml(xml); + QTRY_COMPARE(model->count(), 2); + + model->setXml(""); + + QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); + QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); + QSignalSpy spyCount(model, SIGNAL(countChanged())); + + QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey")); + model->setXml(xml); + + QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0); + + QCOMPARE(spyInsert.count(), 1); + QCOMPARE(spyInsert[0][0].toInt(), 0); + QCOMPARE(spyInsert[0][1].toInt(), 2); + + QCOMPARE(spyRemove.count(), 1); + QCOMPARE(spyRemove[0][0].toInt(), 0); + QCOMPARE(spyRemove[0][1].toInt(), 2); + + QCOMPARE(spyCount.count(), 0); + + delete model; +} + +void tst_qdeclarativexmllistmodel::threading() +{ + QFETCH(int, xmlDataCount); + + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + + QDeclarative1XmlListModel *m1 = qobject_cast(component.create()); + QVERIFY(m1 != 0); + QDeclarative1XmlListModel *m2 = qobject_cast(component.create()); + QVERIFY(m2 != 0); + QDeclarative1XmlListModel *m3 = qobject_cast(component.create()); + QVERIFY(m3 != 0); + + for (int dataCount=0; dataCountsetXml(makeItemXmlAndData(data1)); + m2->setXml(makeItemXmlAndData(data2)); + m3->setXml(makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + m2->setXml(makeItemXmlAndData(data2)); + m1->setXml(makeItemXmlAndData(data1)); + m2->setXml(makeItemXmlAndData(data2)); + QCoreApplication::processEvents(); + m3->setXml(makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + m2->setXml(makeItemXmlAndData(data2)); + m1->setXml(makeItemXmlAndData(data1)); + m2->setXml(makeItemXmlAndData(data2)); + m3->setXml(makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + m2->setXml(makeItemXmlAndData(data2)); + m3->setXml(makeItemXmlAndData(data3)); + m3->setXml(makeItemXmlAndData(data3)); + QCoreApplication::processEvents(); + + QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount); + + for (int i=0; idata(i, m1->roles()[0]).toString(), QString("A" + QString::number(i))); + QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i))); + QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football")); + + QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i))); + QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i))); + QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics")); + + QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i))); + QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i))); + QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling")); + } + } + + delete m1; + delete m2; + delete m3; +} + +void tst_qdeclarativexmllistmodel::threading_data() +{ + QTest::addColumn("xmlDataCount"); + + QTest::newRow("1") << 1; + QTest::newRow("2") << 2; + QTest::newRow("10") << 10; +} + +void tst_qdeclarativexmllistmodel::propertyChanges() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + QTRY_COMPARE(model->count(), 9); + + QDeclarative1XmlListModelRole *role = model->findChild("role"); + QVERIFY(role); + + QSignalSpy nameSpy(role, SIGNAL(nameChanged())); + QSignalSpy querySpy(role, SIGNAL(queryChanged())); + QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged())); + + role->setName("size"); + role->setQuery("size/string()"); + role->setIsKey(true); + + QCOMPARE(role->name(), QString("size")); + QCOMPARE(role->query(), QString("size/string()")); + QVERIFY(role->isKey()); + + QCOMPARE(nameSpy.count(),1); + QCOMPARE(querySpy.count(),1); + QCOMPARE(isKeySpy.count(),1); + + role->setName("size"); + role->setQuery("size/string()"); + role->setIsKey(true); + + QCOMPARE(nameSpy.count(),1); + QCOMPARE(querySpy.count(),1); + QCOMPARE(isKeySpy.count(),1); + + QSignalSpy sourceSpy(model, SIGNAL(sourceChanged())); + QSignalSpy xmlSpy(model, SIGNAL(xmlChanged())); + QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged())); + QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged())); + + model->setSource(QUrl("")); + model->setXml("PollyParrot12Small"); + model->setQuery("/Pets"); + model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";"); + + QCOMPARE(model->source(), QUrl("")); + QCOMPARE(model->xml(), QString("PollyParrot12Small")); + QCOMPARE(model->query(), QString("/Pets")); + QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";")); + + QTRY_VERIFY(model->count() == 1); + + QCOMPARE(sourceSpy.count(),1); + QCOMPARE(xmlSpy.count(),1); + QCOMPARE(modelQuerySpy.count(),1); + QCOMPARE(namespaceDeclarationsSpy.count(),1); + + model->setSource(QUrl("")); + model->setXml("PollyParrot12Small"); + model->setQuery("/Pets"); + model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";"); + + QCOMPARE(sourceSpy.count(),1); + QCOMPARE(xmlSpy.count(),1); + QCOMPARE(modelQuerySpy.count(),1); + QCOMPARE(namespaceDeclarationsSpy.count(),1); + + QTRY_VERIFY(model->count() == 1); + delete model; +} + +void tst_qdeclarativexmllistmodel::roleCrash() +{ + // don't crash + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleCrash.qml")); + QDeclarative1XmlListModel *model = qobject_cast(component.create()); + QVERIFY(model != 0); + delete model; +} + +QTEST_MAIN(tst_qdeclarativexmllistmodel) + +#include "tst_qdeclarativexmllistmodel.moc" + +#else +QTEST_NOOP_MAIN +#endif diff --git a/tests/auto/qtquick1/qtquick1.pro b/tests/auto/qtquick1/qtquick1.pro new file mode 100644 index 0000000000..0c3e2498ff --- /dev/null +++ b/tests/auto/qtquick1/qtquick1.pro @@ -0,0 +1,50 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + qdeclarativeview \ + qdeclarativeviewer \ + moduleqt47 + +contains(QT_CONFIG, private_tests) { + SUBDIRS += \ + qdeclarativeanchors \ + qdeclarativeanimatedimage \ + qdeclarativeanimations \ + qdeclarativeapplication \ + qdeclarativebehaviors \ + qdeclarativebinding \ + qdeclarativeborderimage \ + qdeclarativeconnection \ + qdeclarativeflickable \ + qdeclarativeflipable \ + qdeclarativefocusscope \ + qdeclarativefontloader \ + qdeclarativegridview \ + qdeclarativeimage \ + qdeclarativeimageprovider \ + qdeclarativeitem \ + qdeclarativelayoutitem \ +# qdeclarativelistmodel \ + qdeclarativelistview \ + qdeclarativeloader \ + qdeclarativemousearea \ + qdeclarativeparticles \ + qdeclarativepathview \ + qdeclarativepincharea \ + qdeclarativepositioners \ + qdeclarativerepeater \ + qdeclarativesmoothedanimation \ + qdeclarativespringanimation \ + qdeclarativestates \ + qdeclarativesystempalette \ + qdeclarativetext \ + qdeclarativetextedit \ + qdeclarativetextinput \ + qdeclarativetimer \ + qdeclarativevisualdatamodel \ + qdeclarativexmllistmodel \ + +} + +# Tests which should run in Pulse +PULSE_TESTS = $$SUBDIRS diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index b78a68a691..ea82bc1b2e 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include @@ -537,19 +536,18 @@ int main(int argc, char *argv[]) } } - QDeclarativeView view; - QDeclarativeEngine *engine = view.engine(); + QDeclarativeEngine engine; if (!pluginImportPath.isEmpty()) { QDir cur = QDir::current(); cur.cd(pluginImportPath); pluginImportPath = cur.absolutePath(); QDir::setCurrent(pluginImportPath); - engine->addImportPath(pluginImportPath); + engine.addImportPath(pluginImportPath); } // find all QMetaObjects reachable from the builtin module QByteArray importCode("import QtQuick 2.0\n"); - QSet defaultReachable = collectReachableMetaObjects(importCode, engine); + QSet defaultReachable = collectReachableMetaObjects(importCode, &engine); // this will hold the meta objects we want to dump information of QSet metas; @@ -570,7 +568,7 @@ int main(int argc, char *argv[]) { QByteArray code = importCode; code += "QtObject {}"; - QDeclarativeComponent c(engine); + QDeclarativeComponent c(&engine); c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/typelist.qml")); c.create(); @@ -581,7 +579,7 @@ int main(int argc, char *argv[]) } } - QSet candidates = collectReachableMetaObjects(importCode, engine); + QSet candidates = collectReachableMetaObjects(importCode, &engine); candidates.subtract(defaultReachable); // Also eliminate meta objects with the same classname. diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index a4b3c9f312..1d3641b61e 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,7 +55,6 @@ #include #include -#include #include #include diff --git a/tools/qmlscene/qmlscene.pro b/tools/qmlscene/qmlscene.pro index a2da6ad982..8e252e589f 100644 --- a/tools/qmlscene/qmlscene.pro +++ b/tools/qmlscene/qmlscene.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = qmlscene DESTDIR= ../../bin -QT += declarative declarative-private +QT += declarative declarative-private qtquick1 target.path = $$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/qmlviewer/qdeclarativetester.cpp b/tools/qmlviewer/qdeclarativetester.cpp index 9700e40cb7..842c3a369d 100644 --- a/tools/qmlviewer/qdeclarativetester.cpp +++ b/tools/qmlviewer/qdeclarativetester.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ #include #include #ifndef Q_OS_SYMBIAN -#include +#include #endif QT_BEGIN_NAMESPACE diff --git a/tools/qmlviewer/qmlruntime.cpp b/tools/qmlviewer/qmlruntime.cpp index 1ace146490..55f0f4f2bc 100644 --- a/tools/qmlviewer/qmlruntime.cpp +++ b/tools/qmlviewer/qmlruntime.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include +#include #ifdef hz #undef hz diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 87b5899fcc..e9edd605e6 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -1,6 +1,7 @@ TEMPLATE = app CONFIG += qt uic DESTDIR = ../../bin +QT += declarative qtquick1 qtquick1-private include(qml.pri)