diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-10 01:17:51 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-10 01:17:51 (GMT) |
commit | 9c13caa3c99af01a9b4c3ff6e178e7dadb61741f (patch) | |
tree | b69df0a23c4628359fc3740e09958980eda7478e /src/declarative | |
parent | bb1bdcab28e4c52dcea37dfaaa435045b1985eeb (diff) | |
parent | 883da42f7c75775502c818aa456c8576d8457ff8 (diff) | |
download | Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.zip Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.gz Qt-9c13caa3c99af01a9b4c3ff6e178e7dadb61741f.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui-gv
Conflicts:
examples/itemviews/frozencolumn/main.cpp
src/declarative/canvas/qsimplecanvas.cpp
src/declarative/canvas/qsimplecanvas_p.h
src/declarative/canvas/qsimplecanvasitem.h
src/declarative/extra/qfxparticles.cpp
src/declarative/fx/fx.pri
src/declarative/fx/qfxblurfilter.h
src/declarative/fx/qfxcontentwrapper.cpp
src/declarative/fx/qfxflickable.cpp
src/declarative/fx/qfxfocuspanel.h
src/declarative/fx/qfxfocusrealm.h
src/declarative/fx/qfxhighlightfilter.cpp
src/declarative/fx/qfxhighlightfilter.h
src/declarative/fx/qfximage.cpp
src/declarative/fx/qfxitem.cpp
src/declarative/fx/qfxitem.h
src/declarative/fx/qfxrect.cpp
src/declarative/fx/qfxreflectionfilter.h
src/declarative/fx/qfxshadowfilter.cpp
src/declarative/fx/qfxshadowfilter.h
src/declarative/fx/qfxtext.cpp
src/declarative/fx/qfxtext.h
src/declarative/fx/qfxtextedit.cpp
src/declarative/opengl/glbasicshaders.h
src/declarative/test/qfxtestengine.cpp
src/declarative/test/qfxtestengine.h
src/declarative/test/qfxtestobjects.cpp
src/declarative/test/qfxtestobjects.h
src/declarative/test/qfxtestview.h
src/declarative/util/qfxglobal.h
src/declarative/util/qfxview.cpp
src/gui/graphicsview/qgraphicsitem_p.h
tools/qmlviewer/qmlviewer.cpp
Diffstat (limited to 'src/declarative')
217 files changed, 6325 insertions, 4183 deletions
diff --git a/src/declarative/debugger/qmldebugclient.cpp b/src/declarative/debugger/qmldebugclient.cpp index 3dacf01..e442333 100644 --- a/src/declarative/debugger/qmldebugclient.cpp +++ b/src/declarative/debugger/qmldebugclient.cpp @@ -185,6 +185,6 @@ void QmlDebugClientPlugin::messageReceived(const QByteArray &) { } -#include "qmldebugclient.moc" - QT_END_NAMESPACE + +#include "qmldebugclient.moc" diff --git a/src/declarative/debugger/qmldebugger.cpp b/src/declarative/debugger/qmldebugger.cpp index 9ab3247..78c4090 100644 --- a/src/declarative/debugger/qmldebugger.cpp +++ b/src/declarative/debugger/qmldebugger.cpp @@ -50,6 +50,7 @@ #include <private/qmlboundsignal_p.h> #include <private/qmlcontext_p.h> #include <private/qmlengine_p.h> +#include <private/qmlexpression_p.h> #include <private/qmlobjecttree_p.h> #include <QtCore/qdebug.h> #include <QtCore/qfile.h> @@ -62,6 +63,8 @@ #include <private/qmlpropertyview_p.h> #include <private/qmlwatches_p.h> +QT_BEGIN_NAMESPACE + QmlDebugger::QmlDebugger(QWidget *parent) : QWidget(parent), m_tree(0), m_warnings(0), m_watchTable(0), m_watches(0), m_properties(0), m_text(0), m_highlightedItem(0) @@ -260,7 +263,7 @@ bool QmlDebugger::makeItem(QObject *obj, QmlDebuggerItem *item) delete item; return false; - } else if(QmlBoundSignal *bs = qobject_cast<QmlBoundSignal *>(obj)) { + } else if(qobject_cast<QmlBoundSignal *>(obj)) { delete item; return false; } else { @@ -353,3 +356,4 @@ void QmlDebugger::setDebugObject(QObject *obj) item->setExpanded(true); } +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebugger.h b/src/declarative/debugger/qmldebugger.h index 10b2f9a..03efeb6 100644 --- a/src/declarative/debugger/qmldebugger.h +++ b/src/declarative/debugger/qmldebugger.h @@ -101,4 +101,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QMLDEBUGGER_H - diff --git a/src/declarative/debugger/qmldebuggerstatus.h b/src/declarative/debugger/qmldebuggerstatus.h index 62336de..a8480f4 100644 --- a/src/declarative/debugger/qmldebuggerstatus.h +++ b/src/declarative/debugger/qmldebuggerstatus.h @@ -64,4 +64,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QLMDEBUGGERSTATUS_P_H - diff --git a/src/declarative/debugger/qmldebugserver.cpp b/src/declarative/debugger/qmldebugserver.cpp index 23e59e0..e055ad5 100644 --- a/src/declarative/debugger/qmldebugserver.cpp +++ b/src/declarative/debugger/qmldebugserver.cpp @@ -294,6 +294,6 @@ void QmlDebugServerPlugin::messageReceived(const QByteArray &) { } -#include "qmldebugserver.moc" - QT_END_NAMESPACE + +#include "qmldebugserver.moc" diff --git a/src/declarative/debugger/qmlobjecttree.cpp b/src/declarative/debugger/qmlobjecttree.cpp index 27dc000..8a2358a 100644 --- a/src/declarative/debugger/qmlobjecttree.cpp +++ b/src/declarative/debugger/qmlobjecttree.cpp @@ -48,6 +48,8 @@ #include <QtGui/qinputdialog.h> #include <QtGui/qboxlayout.h> +QT_BEGIN_NAMESPACE + QmlObjectTree::QmlObjectTree(QWidget *parent) : QTreeWidget(parent) { @@ -73,3 +75,4 @@ void QmlObjectTree::mousePressEvent(QMouseEvent *me) } } +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmlobjecttree_p.h b/src/declarative/debugger/qmlobjecttree_p.h index 4e6d484..54d6d8e 100644 --- a/src/declarative/debugger/qmlobjecttree_p.h +++ b/src/declarative/debugger/qmlobjecttree_p.h @@ -42,10 +42,23 @@ #ifndef QMLOBJECTTREE_P_H #define QMLOBJECTTREE_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 <QtGui/qtreewidget.h> #include <QtCore/qurl.h> #include <QtCore/qpointer.h> +QT_BEGIN_NAMESPACE + class QmlBindableValue; class QmlDebuggerItem : public QTreeWidgetItem { @@ -82,5 +95,7 @@ protected: virtual void mousePressEvent(QMouseEvent *); }; +QT_END_NAMESPACE + #endif // QMLOBJECTTREE_P_H diff --git a/src/declarative/debugger/qmlpropertyview.cpp b/src/declarative/debugger/qmlpropertyview.cpp index abe1902..76a192d 100644 --- a/src/declarative/debugger/qmlpropertyview.cpp +++ b/src/declarative/debugger/qmlpropertyview.cpp @@ -47,6 +47,8 @@ #include <QtDeclarative/qmlbindablevalue.h> #include <private/qmlboundsignal_p.h> +QT_BEGIN_NAMESPACE + QmlPropertyView::QmlPropertyView(QmlWatches *watches, QWidget *parent) : QWidget(parent), m_tree(0), m_watches(watches) { @@ -221,4 +223,6 @@ void QmlPropertyView::refresh() setObject(m_object); } +QT_END_NAMESPACE + #include "qmlpropertyview.moc" diff --git a/src/declarative/debugger/qmlpropertyview_p.h b/src/declarative/debugger/qmlpropertyview_p.h index 469a08d..4694482 100644 --- a/src/declarative/debugger/qmlpropertyview_p.h +++ b/src/declarative/debugger/qmlpropertyview_p.h @@ -42,6 +42,17 @@ #ifndef QMLPROPERTYVIEW_P_H #define QMLPROPERTYVIEW_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 <QtGui/qwidget.h> #include <QtCore/qpointer.h> #include <private/qmlwatches_p.h> diff --git a/src/declarative/debugger/qmlwatches.cpp b/src/declarative/debugger/qmlwatches.cpp index bac4cbd..8fc9e89 100644 --- a/src/declarative/debugger/qmlwatches.cpp +++ b/src/declarative/debugger/qmlwatches.cpp @@ -46,6 +46,8 @@ #include <QtDeclarative/qmlmetatype.h> #include <QtDeclarative/qmlexpression.h> +QT_BEGIN_NAMESPACE + QString QmlWatches::objectToString(QObject *obj) { if(!obj) @@ -301,4 +303,6 @@ QVariant QmlWatches::data(const QModelIndex &idx, int role) const } } +QT_END_NAMESPACE + #include "qmlwatches.moc" diff --git a/src/declarative/debugger/qmlwatches_p.h b/src/declarative/debugger/qmlwatches_p.h index 6c383a1..dfec979 100644 --- a/src/declarative/debugger/qmlwatches_p.h +++ b/src/declarative/debugger/qmlwatches_p.h @@ -42,6 +42,17 @@ #ifndef QMLWATCHES_P_H #define QMLWATCHES_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 <QtCore/qbytearray.h> #include <QtCore/qobject.h> #include <QtCore/qpointer.h> diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp index 6911b89..d109836 100644 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ b/src/declarative/debugger/qpacketprotocol.cpp @@ -1,20 +1,54 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_EXTENDED_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qpacketprotocol.h" #include <QBuffer> +QT_BEGIN_NAMESPACE + #define MAX_PACKET_SIZE 0x7FFFFFFF /*! \class QPacketProtocol + \internal \brief The QPacketProtocol class encapsulates communicating discrete packets across fragmented IO channels, such as TCP sockets. @@ -321,7 +355,7 @@ QIODevice * QPacketProtocol::device() /*! \class QPacket - \inpublicgroup QtBaseModule + \internal \brief The QPacket class encapsulates an unfragmentable packet of data to be transmitted by QPacketProtocol. @@ -443,7 +477,7 @@ void QPacket::clear() /*! \class QPacketAutoSend - \inpublicgroup QtBaseModule + \internal \internal */ @@ -458,5 +492,7 @@ QPacketAutoSend::~QPacketAutoSend() p->send(*this); } +QT_END_NAMESPACE + #include "qpacketprotocol.moc" diff --git a/src/declarative/debugger/qpacketprotocol.h b/src/declarative/debugger/qpacketprotocol.h index 6dd8bda..f3fb44b 100644 --- a/src/declarative/debugger/qpacketprotocol.h +++ b/src/declarative/debugger/qpacketprotocol.h @@ -1,10 +1,41 @@ /**************************************************************************** ** -** This file is part of the $PACKAGE_NAME$. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (C) $THISYEAR$ $COMPANY_NAME$. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_EXTENDED_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -14,6 +45,12 @@ #include <QtCore/qobject.h> #include <QtCore/qdatastream.h> +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + class QIODevice; class QBuffer; class QPacket; @@ -78,4 +115,8 @@ private: QPacketProtocol * p; }; +QT_END_NAMESPACE + +QT_END_HEADER + #endif diff --git a/src/declarative/declarative.pro b/src/declarative/declarative.pro index e2954e5..f52d893 100644 --- a/src/declarative/declarative.pro +++ b/src/declarative/declarative.pro @@ -3,7 +3,6 @@ QPRO_PWD = $$PWD QT = core gui xml script network contains(QT_CONFIG, svg): QT += svg DEFINES += QT_BUILD_DECLARATIVE_LIB -DEFINES += QT_NO_USING_NAMESPACE win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 @@ -19,7 +18,6 @@ include(3rdparty/3rdparty.pri) include(util/util.pri) include(fx/fx.pri) include(qml/qml.pri) -include(timeline/timeline.pri) include(extra/extra.pri) include(widgets/widgets.pri) include(debugger/debugger.pri) diff --git a/src/declarative/extra/extra.pri b/src/declarative/extra/extra.pri index 2590fbc..fc21d0f 100644 --- a/src/declarative/extra/extra.pri +++ b/src/declarative/extra/extra.pri @@ -1,14 +1,29 @@ SOURCES += \ extra/qnumberformat.cpp \ extra/qmlnumberformatter.cpp \ + extra/qmldatetimeformatter.cpp \ extra/qfxintegermodel.cpp \ - extra/qmltimer.cpp + extra/qmlfolderlistmodel.cpp \ + extra/qmltimer.cpp \ + extra/qfxanimatedimageitem.cpp \ + extra/qfxflowview.cpp \ + extra/qfxparticles.cpp \ + extra/qmlbehaviour.cpp \ + extra/qbindablemap.cpp HEADERS += \ extra/qnumberformat.h \ extra/qmlnumberformatter.h \ + extra/qmldatetimeformatter.h \ extra/qfxintegermodel.h \ - extra/qmltimer.h + extra/qmlfolderlistmodel.h \ + extra/qmltimer.h \ + extra/qfxanimatedimageitem.h \ + extra/qfxanimatedimageitem_p.h \ + extra/qfxflowview.h \ + extra/qfxparticles.h \ + extra/qmlbehaviour.h \ + extra/qbindablemap.h contains(QT_CONFIG, xmlpatterns) { QT+=xmlpatterns diff --git a/src/declarative/util/qbindablemap.cpp b/src/declarative/extra/qbindablemap.cpp index c8c8ced..c8c8ced 100644 --- a/src/declarative/util/qbindablemap.cpp +++ b/src/declarative/extra/qbindablemap.cpp diff --git a/src/declarative/util/qbindablemap.h b/src/declarative/extra/qbindablemap.h index c76928d..aa1908e 100644 --- a/src/declarative/util/qbindablemap.h +++ b/src/declarative/extra/qbindablemap.h @@ -48,7 +48,6 @@ #include <QtCore/QStringList> #include <QtCore/QVariant> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -80,8 +79,8 @@ private: friend class QBindableMapMetaObject; }; - QT_END_NAMESPACE QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp index d22959a..d22959a 100644 --- a/src/declarative/fx/qfxanimatedimageitem.cpp +++ b/src/declarative/extra/qfxanimatedimageitem.cpp diff --git a/src/declarative/fx/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h index 8ef2b1c..720d187 100644 --- a/src/declarative/fx/qfxanimatedimageitem.h +++ b/src/declarative/extra/qfxanimatedimageitem.h @@ -44,12 +44,12 @@ #include <QtDeclarative/qfximage.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QMovie; class QFxAnimatedImageItemPrivate; @@ -91,10 +91,10 @@ private: Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxAnimatedImageItem) }; -QML_DECLARE_TYPE(QFxAnimatedImageItem) - - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxAnimatedImageItem) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h index cb5da63..e7d8fb8 100644 --- a/src/declarative/fx/qfxanimatedimageitem_p.h +++ b/src/declarative/extra/qfxanimatedimageitem_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include "qfximage_p.h" +#include <private/qfximage_p.h> QT_BEGIN_NAMESPACE diff --git a/src/declarative/fx/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp index e02e186..412cbc8 100644 --- a/src/declarative/fx/qfxflowview.cpp +++ b/src/declarative/extra/qfxflowview.cpp @@ -42,6 +42,8 @@ #include "qfxvisualitemmodel.h" #include "qfxflowview.h" +#include <QGraphicsSceneMouseEvent> + QT_BEGIN_NAMESPACE class QFxFlowViewAttached : public QObject @@ -128,10 +130,11 @@ void QFxFlowView::refresh() { if (m_model && m_columns >= 1) { for (int ii = 0; ii < m_model->count(); ++ii) { - QFxItem *item = m_model->item(ii); - item->setParent(this); - item->setZ(0); - m_items << item; + if (QFxItem *item = m_model->item(ii)) { + item->setParent(this); + item->setZ(0); + m_items << item; + } } reflow(); @@ -196,8 +199,6 @@ void QFxFlowView::reflowDrag(const QPointF &dp) qreal maxY = 0; qreal x = 0; - int flowedItems = 0; - clearTimeLine(); QList<QFxItem *> items; @@ -287,8 +288,6 @@ void QFxFlowView::moveItem(QFxItem *item, const QPointF &p) m_timeline.move(*yv, p.y(), 100); } -#include <QGraphicsSceneMouseEvent> - void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event) { for (int ii = 0; ii < m_items.count(); ++ii) { @@ -315,6 +314,7 @@ QRectF QFxFlowView::rectForItem(int idx) const void QFxFlowView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { + Q_UNUSED(event); if (m_dragItem) { m_dragItem->setZ(0); @@ -375,6 +375,6 @@ void QFxFlowView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QML_DEFINE_TYPE(QFxFlowView,FlowView); -#include "qfxflowview.moc" - QT_END_NAMESPACE + +#include "qfxflowview.moc" diff --git a/src/declarative/fx/qfxflowview.h b/src/declarative/extra/qfxflowview.h index 0e7c2d3..126f567 100644 --- a/src/declarative/fx/qfxflowview.h +++ b/src/declarative/extra/qfxflowview.h @@ -42,7 +42,7 @@ #ifndef QFXFLOWVIEW_H #define QFXFLOWVIEW_H -#include <QtDeclarative/QmlTimeLine> +#include <private/qmltimeline_p.h> #include <QtDeclarative/qfxitem.h> QT_BEGIN_HEADER @@ -50,6 +50,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxVisualItemModel; class QFxFlowViewValue; class QFxFlowViewAttached; @@ -97,10 +98,11 @@ private: QList<QFxFlowViewValue *> m_values; int m_dragIdx; }; -QML_DECLARE_TYPE(QFxFlowView); QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFlowView); + QT_END_HEADER #endif // QFXFLOWVIEW_H diff --git a/src/declarative/extra/qfxintegermodel.cpp b/src/declarative/extra/qfxintegermodel.cpp index 53814cd..437073e 100644 --- a/src/declarative/extra/qfxintegermodel.cpp +++ b/src/declarative/extra/qfxintegermodel.cpp @@ -41,8 +41,8 @@ #include "qfxintegermodel.h" - QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QFxIntegerModel, IntegerModel) class QFxIntegerModelPrivate diff --git a/src/declarative/extra/qfxintegermodel.h b/src/declarative/extra/qfxintegermodel.h index 43504d8..7fced2c 100644 --- a/src/declarative/extra/qfxintegermodel.h +++ b/src/declarative/extra/qfxintegermodel.h @@ -46,12 +46,12 @@ #include <QtDeclarative/qml.h> #include <QtDeclarative/qlistmodelinterface.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxIntegerModelPrivate; class Q_DECLARATIVE_EXPORT QFxIntegerModel : public QListModelInterface { @@ -77,10 +77,10 @@ private: QFxIntegerModelPrivate *d; }; -QML_DECLARE_TYPE(QFxIntegerModel) - - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxIntegerModel) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 0a6a628..322ec53 100644 --- a/src/declarative/fx/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qfxitem_p.h" +#include "private/qfxitem_p.h" #include <stdlib.h> #include <math.h> @@ -51,7 +51,7 @@ #define INT_MAX 2147483647 #endif #include <qfxpixmap.h> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <private/qmlanimation_p.h> #include "qfxparticles.h" diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/extra/qfxparticles.h index be4dc91..9f085cd 100644 --- a/src/declarative/fx/qfxparticles.h +++ b/src/declarative/extra/qfxparticles.h @@ -62,7 +62,6 @@ public: virtual void created(QFxParticle &); virtual void destroy(QFxParticle &); }; -QML_DECLARE_TYPE(QFxParticleMotion) class Q_DECLARATIVE_EXPORT QFxParticleMotionLinear : public QFxParticleMotion { @@ -73,7 +72,6 @@ public: virtual void advance(QFxParticle &, int interval); }; -QML_DECLARE_TYPE(QFxParticleMotionLinear) class Q_DECLARATIVE_EXPORT QFxParticleMotionGravity : public QFxParticleMotion { @@ -102,7 +100,6 @@ private: int _yAttr; qreal _accel; }; -QML_DECLARE_TYPE(QFxParticleMotionGravity) class Q_DECLARATIVE_EXPORT QFxParticleMotionWander : public QFxParticleMotion { @@ -142,7 +139,6 @@ private: qreal _yvariance; qreal _pace; }; -QML_DECLARE_TYPE(QFxParticleMotionWander) class QFxParticlesPrivate; class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem @@ -222,10 +218,15 @@ private: Q_DISABLE_COPY(QFxParticles) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxParticles) }; -QML_DECLARE_TYPE(QFxParticles) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxParticleMotion) +QML_DECLARE_TYPE(QFxParticleMotionLinear) +QML_DECLARE_TYPE(QFxParticleMotionGravity) +QML_DECLARE_TYPE(QFxParticleMotionWander) +QML_DECLARE_TYPE(QFxParticles) + QT_END_HEADER #endif diff --git a/src/declarative/util/qmlbehaviour.cpp b/src/declarative/extra/qmlbehaviour.cpp index 3617541..4165d56 100644 --- a/src/declarative/util/qmlbehaviour.cpp +++ b/src/declarative/extra/qmlbehaviour.cpp @@ -115,7 +115,7 @@ public: color: "#00ff00" y: 200 //initial value y: Behavior { - NumericAnimation { + NumberAnimation { easing: "easeOutBounce(amplitude:100)" duration: 200 } @@ -254,6 +254,6 @@ void QmlBehaviour::classComplete() d->context->deactivate(); } -#include "qmlbehaviour.moc" - QT_END_NAMESPACE + +#include "qmlbehaviour.moc" diff --git a/src/declarative/util/qmlbehaviour.h b/src/declarative/extra/qmlbehaviour.h index 7cc83b2..1b5f524 100644 --- a/src/declarative/util/qmlbehaviour.h +++ b/src/declarative/extra/qmlbehaviour.h @@ -51,6 +51,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlAbstractAnimation; class QmlBehaviourPrivate; class Q_DECLARATIVE_EXPORT QmlBehaviour : public QmlPropertyValueSource, @@ -86,10 +87,11 @@ protected: private Q_SLOTS: void propertyValueChanged(); }; -QML_DECLARE_TYPE(QmlBehaviour) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlBehaviour) + QT_END_HEADER #endif // QMLBEHAVIOUR_H diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/extra/qmldatetimeformatter.cpp index ad0e473..158431a 100644 --- a/src/declarative/util/qmldatetimeformatter.cpp +++ b/src/declarative/extra/qmldatetimeformatter.cpp @@ -44,6 +44,7 @@ #include <QtCore/qlocale.h> QT_BEGIN_NAMESPACE + //TODO: may need optimisation as the QDateTime member may not be needed? // be able to set a locale? @@ -365,4 +366,5 @@ void QmlDateTimeFormatter::classComplete() } QML_DEFINE_TYPE(QmlDateTimeFormatter, DateTimeFormatter) + QT_END_NAMESPACE diff --git a/src/declarative/util/qmldatetimeformatter.h b/src/declarative/extra/qmldatetimeformatter.h index 84b27e3..71b366c 100644 --- a/src/declarative/util/qmldatetimeformatter.h +++ b/src/declarative/extra/qmldatetimeformatter.h @@ -50,6 +50,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlDateTimeFormatterPrivate; class Q_DECLARATIVE_EXPORT QmlDateTimeFormatter : public QObject, public QmlParserStatus { @@ -106,10 +107,10 @@ private: Q_DECLARE_PRIVATE(QmlDateTimeFormatter) }; -QML_DECLARE_TYPE(QmlDateTimeFormatter) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlDateTimeFormatter) + QT_END_HEADER #endif diff --git a/src/declarative/extra/qmlfolderlistmodel.cpp b/src/declarative/extra/qmlfolderlistmodel.cpp new file mode 100644 index 0000000..acee5e1 --- /dev/null +++ b/src/declarative/extra/qmlfolderlistmodel.cpp @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "private/qobject_p.h" +#include <QDirModel> +#include <qdebug.h> +#include "qmlfolderlistmodel.h" + +QT_BEGIN_NAMESPACE + +class QmlFolderListModelPrivate : public QObjectPrivate +{ +public: + QmlFolderListModelPrivate() : count(0) { + folder = QDir::currentPath(); + nameFilters << QLatin1String("*"); + } + + QDirModel model; + QString folder; + QStringList nameFilters; + QModelIndex folderIndex; + int count; +}; + +QmlFolderListModel::QmlFolderListModel(QObject *parent) + : QListModelInterface(*(new QmlFolderListModelPrivate), parent) +{ + Q_D(QmlFolderListModel); + d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives); + connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int)) + , this, SLOT(inserted(const QModelIndex&,int,int))); + connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int)) + , this, SLOT(removed(const QModelIndex&,int,int))); + connect(&d->model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)) + , this, SLOT(dataChanged(const QModelIndex&,const QModelIndex&))); + connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh())); +} + +QmlFolderListModel::~QmlFolderListModel() +{ +} + +QHash<int,QVariant> QmlFolderListModel::data(int index, const QList<int> &roles) const +{ + Q_UNUSED(roles); + Q_D(const QmlFolderListModel); + QHash<int,QVariant> folderData; + QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex); + if (modelIndex.isValid()) { + folderData[QDirModel::FileNameRole] = d->model.data(modelIndex, QDirModel::FileNameRole); + folderData[QDirModel::FilePathRole] = d->model.data(modelIndex, QDirModel::FilePathRole); + } + + return folderData; +} + +int QmlFolderListModel::count() const +{ + Q_D(const QmlFolderListModel); + return d->count; +} + +QList<int> QmlFolderListModel::roles() const +{ + QList<int> r; + r << QDirModel::FileNameRole; + r << QDirModel::FilePathRole; + return r; +} + +QString QmlFolderListModel::toString(int role) const +{ + switch (role) { + case QDirModel::FileNameRole: + return QLatin1String("fileName"); + case QDirModel::FilePathRole: + return QLatin1String("filePath"); + } + + return QString(); +} + +QString QmlFolderListModel::folder() const +{ + Q_D(const QmlFolderListModel); + return d->folder; +} + +void QmlFolderListModel::setFolder(const QString &folder) +{ + Q_D(QmlFolderListModel); + if (folder == d->folder) + return; + QModelIndex index = d->model.index(folder); + if (index.isValid() && d->model.isDir(index)) { + d->folder = folder; + QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); + emit folderChanged(); + } +} + +QStringList QmlFolderListModel::nameFilters() const +{ + Q_D(const QmlFolderListModel); + return d->nameFilters; +} + +void QmlFolderListModel::setNameFilters(const QStringList &filters) +{ + Q_D(QmlFolderListModel); + d->nameFilters = filters; + d->model.setNameFilters(d->nameFilters); +} + +void QmlFolderListModel::classComplete() +{ + Q_D(QmlFolderListModel); + if (!d->folderIndex.isValid()) + QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); +} + +bool QmlFolderListModel::isFolder(int index) const +{ + Q_D(const QmlFolderListModel); + return d->model.isDir(d->model.index(index, 0, d->folderIndex)); +} + +void QmlFolderListModel::refresh() +{ + Q_D(QmlFolderListModel); + d->folderIndex = QModelIndex(); + if (d->count) { + int tmpCount = d->count; + d->count = 0; + emit itemsRemoved(0, tmpCount); + } + d->folderIndex = d->model.index(d->folder); + d->count = d->model.rowCount(d->folderIndex); + if (d->count) { + emit itemsInserted(0, d->count); + } +} + +void QmlFolderListModel::inserted(const QModelIndex &index, int start, int end) +{ + Q_D(QmlFolderListModel); + if (index == d->folderIndex) { + d->count = d->model.rowCount(d->folderIndex); + emit itemsInserted(start, end - start + 1); + } +} + +void QmlFolderListModel::removed(const QModelIndex &index, int start, int end) +{ + Q_D(QmlFolderListModel); + if (index == d->folderIndex) { + d->count = d->model.rowCount(d->folderIndex); + emit itemsRemoved(start, end - start + 1); + } +} + +void QmlFolderListModel::dataChanged(const QModelIndex &start, const QModelIndex &end) +{ + Q_D(QmlFolderListModel); + if (start.parent() == d->folderIndex) + emit itemsChanged(start.row(), end.row() - start.row() + 1, roles()); +} + +QML_DEFINE_TYPE(QmlFolderListModel,FolderListModel) + +QT_END_NAMESPACE + diff --git a/src/declarative/extra/qmlfolderlistmodel.h b/src/declarative/extra/qmlfolderlistmodel.h new file mode 100644 index 0000000..8c99b22 --- /dev/null +++ b/src/declarative/extra/qmlfolderlistmodel.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLFOLDERLISTMODEL_H +#define QMLFOLDERLISTMODEL_H + +#include <QtDeclarative/qml.h> +#include <QtDeclarative/QListModelInterface> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlContext; +class QModelIndex; + +class QmlFolderListModelPrivate; +class Q_DECLARATIVE_EXPORT QmlFolderListModel : public QListModelInterface, public QmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QmlParserStatus) + + Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged) + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters) + +public: + QmlFolderListModel(QObject *parent = 0); + ~QmlFolderListModel(); + + virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const; + virtual int count() const; + virtual QList<int> roles() const; + virtual QString toString(int role) const; + + QString folder() const; + void setFolder(const QString &folder); + + QStringList nameFilters() const; + void setNameFilters(const QStringList &filters); + + virtual void classComplete(); + + Q_INVOKABLE bool isFolder(int index) const; + +Q_SIGNALS: + void folderChanged(); + +private Q_SLOTS: + void refresh(); + void inserted(const QModelIndex &index, int start, int end); + void removed(const QModelIndex &index, int start, int end); + void dataChanged(const QModelIndex &start, const QModelIndex &end); + +private: + Q_DECLARE_PRIVATE(QmlFolderListModel) + Q_DISABLE_COPY(QmlFolderListModel) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlFolderListModel) + +QT_END_HEADER + +#endif // QMLFOLDERLISTMODEL_H diff --git a/src/declarative/extra/qmlnumberformatter.cpp b/src/declarative/extra/qmlnumberformatter.cpp index 1549525..b24f2d8 100644 --- a/src/declarative/extra/qmlnumberformatter.cpp +++ b/src/declarative/extra/qmlnumberformatter.cpp @@ -42,8 +42,8 @@ #include "qmlnumberformatter.h" #include "private/qobject_p.h" - QT_BEGIN_NAMESPACE + //TODO: set locale // docs // this is a wrapper around qnumberformat (test integration) @@ -210,6 +210,6 @@ void QmlNumberFormatter::classComplete() d->classComplete = true; d->updateText(); } - QML_DEFINE_TYPE(QmlNumberFormatter, NumberFormatter); + QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlnumberformatter.h b/src/declarative/extra/qmlnumberformatter.h index e4efc03..6924fa5 100644 --- a/src/declarative/extra/qmlnumberformatter.h +++ b/src/declarative/extra/qmlnumberformatter.h @@ -45,12 +45,12 @@ #include <QtDeclarative/qml.h> #include <QtDeclarative/qnumberformat.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlNumberFormatterPrivate; class Q_DECLARATIVE_EXPORT QmlNumberFormatter : public QObject, public QmlParserStatus { @@ -83,10 +83,10 @@ private: Q_DECLARE_PRIVATE(QmlNumberFormatter) }; -QML_DECLARE_TYPE(QmlNumberFormatter) - - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlNumberFormatter) + QT_END_HEADER + #endif diff --git a/src/declarative/extra/qmlsqlconnection.h b/src/declarative/extra/qmlsqlconnection.h index ede8bcb..88a727a 100644 --- a/src/declarative/extra/qmlsqlconnection.h +++ b/src/declarative/extra/qmlsqlconnection.h @@ -50,6 +50,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QSqlDatabase; class QmlSqlConnectionPrivate; class Q_DECLARATIVE_EXPORT QmlSqlConnection : public QObject, public QmlParserStatus @@ -107,10 +108,11 @@ private: Q_DECLARE_PRIVATE(QmlSqlConnection) }; -QML_DECLARE_TYPE(QmlSqlConnection) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlSqlConnection) + QT_END_HEADER + #endif // QMLXMLLISTMODEL_H diff --git a/src/declarative/extra/qmlsqlquery.cpp b/src/declarative/extra/qmlsqlquery.cpp index 2b11774..d9d9760 100644 --- a/src/declarative/extra/qmlsqlquery.cpp +++ b/src/declarative/extra/qmlsqlquery.cpp @@ -55,6 +55,7 @@ #include <QTimerEvent> QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QmlSqlBind, SqlBind) QML_DEFINE_TYPE(QmlSqlQuery, SqlQuery) @@ -790,4 +791,5 @@ void QmlSqlQueryPrivate::grabRoles() const roles.append(i); } } + QT_END_NAMESPACE diff --git a/src/declarative/extra/qmlsqlquery.h b/src/declarative/extra/qmlsqlquery.h index 06ade08..8be758f 100644 --- a/src/declarative/extra/qmlsqlquery.h +++ b/src/declarative/extra/qmlsqlquery.h @@ -82,8 +82,6 @@ private: Q_DECLARE_PRIVATE(QmlSqlBind) }; -QML_DECLARE_TYPE(QmlSqlBind) - class QSqlQuery; class QmlSqlQueryPrivate; class Q_DECLARATIVE_EXPORT QmlSqlQuery : public QListModelInterface, public QmlParserStatus @@ -135,10 +133,12 @@ private: Q_DECLARE_PRIVATE(QmlSqlQuery) }; -QML_DECLARE_TYPE(QmlSqlQuery) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlSqlBind) +QML_DECLARE_TYPE(QmlSqlQuery) + QT_END_HEADER + #endif diff --git a/src/declarative/extra/qmltimer.cpp b/src/declarative/extra/qmltimer.cpp index 1e1a6de..4af83d3 100644 --- a/src/declarative/extra/qmltimer.cpp +++ b/src/declarative/extra/qmltimer.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "QtCore/qcoreapplication.h" #include "QtCore/qpauseanimation.h" #include "private/qobject_p.h" #include "qmltimer.h" @@ -52,27 +53,59 @@ class QmlTimerPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlTimer) public: - QmlTimerPrivate() : interval(1000) {} + QmlTimerPrivate() + : interval(1000), running(false), repeating(false), triggeredOnStart(false) + , componentComplete(false) {} int interval; + bool running; + bool repeating; + bool triggeredOnStart; QPauseAnimation pause; + bool componentComplete; }; +/*! + \qmlclass Timer QFxTimer + \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. + + \qml + Timer { + interval: 500; running: true; repeat: true + onTriggered: Time.text = Date().toString() + } + Text { + id: Time + } + \endqml + +*/ + QmlTimer::QmlTimer(QObject *parent) : QObject(*(new QmlTimerPrivate), parent) { Q_D(QmlTimer); connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked())); - d->pause.setLoopCount(-1); + connect(&d->pause, SIGNAL(finished()), this, SLOT(ticked())); + connect(&d->pause, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)) + , this, SLOT(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + d->pause.setLoopCount(1); d->pause.setDuration(d->interval); } +/*! + \qmlproperty int Timer::interval + + Sets the \a interval in milliseconds between triggering. +*/ void QmlTimer::setInterval(int interval) { Q_D(QmlTimer); if (interval != d->interval) { d->interval = interval; - d->pause.setDuration(d->interval); - d->pause.start(); + update(); } } @@ -82,16 +115,119 @@ int QmlTimer::interval() const return d->interval; } -void QmlTimer::componentComplete() +/*! + \qmlproperty bool Timer::running + + If set to true, starts the timer; otherwise stops the timer. + For a non-repeating timer, \a running will be set to false after the + timer has been triggered. + + \sa repeat +*/ +bool QmlTimer::isRunning() const +{ + Q_D(const QmlTimer); + return d->running; +} + +void QmlTimer::setRunning(bool running) +{ + Q_D(QmlTimer); + if (d->running != running) { + d->running = running; + emit runningChanged(); + update(); + } +} + +/*! + \qmlproperty bool Timer::repeat + + If \a repeat is true the timer will be 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). + + \sa running +*/ +bool QmlTimer::isRepeating() const +{ + Q_D(const QmlTimer); + return d->repeating; +} + +void QmlTimer::setRepeating(bool repeating) +{ + Q_D(QmlTimer); + if (repeating != d->repeating) { + d->repeating = repeating; + update(); + } +} + +/*! + \qmlproperty bool Timer::triggeredOnStart + + If \a triggeredOnStart is true, the timer will be triggered immediately + when started, and subsequently at the specified interval. + + \sa running +*/ +bool QmlTimer::triggeredOnStart() const +{ + Q_D(const QmlTimer); + return d->triggeredOnStart; +} + +void QmlTimer::setTriggeredOnStart(bool triggeredOnStart) +{ + Q_D(QmlTimer); + if (d->triggeredOnStart != triggeredOnStart) { + d->triggeredOnStart = triggeredOnStart; + update(); + } +} + +void QmlTimer::update() { Q_D(QmlTimer); - if (d->pause.state() != QAbstractAnimation::Running) + if (!d->componentComplete) + return; + d->pause.stop(); + if (d->running) { + d->pause.setLoopCount(d->repeating ? -1 : 1); + d->pause.setDuration(d->interval); d->pause.start(); + if (d->triggeredOnStart) { + QCoreApplication::removePostedEvents(this, QEvent::MetaCall); + QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection); + } + } +} + +void QmlTimer::componentComplete() +{ + Q_D(QmlTimer); + d->componentComplete = true; + update(); } +/*! + \qmlsignal Timer::onTriggered + + This handler is called when the Timer is triggered. +*/ void QmlTimer::ticked() { - emit timeout(); + emit triggered(); +} + +void QmlTimer::stateChanged(QAbstractAnimation::State, QAbstractAnimation::State state) +{ + Q_D(QmlTimer); + if (d->running && state != QAbstractAnimation::Running) { + d->running = false; + emit runningChanged(); + } } QT_END_NAMESPACE diff --git a/src/declarative/extra/qmltimer.h b/src/declarative/extra/qmltimer.h index 75603c6..0df4cb9 100644 --- a/src/declarative/extra/qmltimer.h +++ b/src/declarative/extra/qmltimer.h @@ -44,9 +44,11 @@ #include <QtDeclarative/qfxglobal.h> #include <QtCore/qobject.h> +#include <QtCore/qabstractanimation.h> #include <QtDeclarative/qml.h> QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -56,7 +58,11 @@ class Q_DECLARATIVE_EXPORT QmlTimer : public QObject, public QmlParserStatus { Q_OBJECT Q_DECLARE_PRIVATE(QmlTimer) + Q_INTERFACES(QmlParserStatus) Q_PROPERTY(int interval READ interval WRITE setInterval) + Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) + Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating) + Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart) public: QmlTimer(QObject *parent=0); @@ -64,17 +70,34 @@ public: 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 componentComplete(); Q_SIGNALS: - void timeout(); + void triggered(); + void runningChanged(); + +private: + void update(); private Q_SLOTS: void ticked(); + void stateChanged(QAbstractAnimation::State,QAbstractAnimation::State); }; -QML_DECLARE_TYPE(QmlTimer) QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlTimer) + QT_END_HEADER + #endif diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 51905fa..95c3de6 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -58,10 +58,9 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(XmlListModelRole, Role) +QML_DEFINE_TYPE(XmlListModelRole, XmlRole) QML_DEFINE_TYPE(QmlXmlListModel, XmlListModel) - class QmlXmlListModelPrivate; struct QmlXmlRoleList : public QmlConcreteList<XmlListModelRole *> { @@ -105,7 +104,7 @@ public: m_modelData.clear(); m_size = 0; m_data = data; - m_query = query; + m_query = QLatin1String("doc($src)") + query; m_namespaces = namespaces; m_roleObjects = roleObjects; if (!isRunning()) { @@ -224,6 +223,13 @@ void QmlXmlQuery::doSubQueryJob() //### we might be able to condense even further (query for everything in one go) for (int i = 0; i < m_roleObjects->size(); ++i) { XmlListModelRole *role = m_roleObjects->at(i); + if (!role->isValid()) { + QList<QVariant> resultList; + for (int j = 0; j < m_size; ++j) + resultList << QVariant(); + m_modelData << resultList; + continue; + } subquery.setQuery(m_prefix + QLatin1String("(let $v := ") + role->query() + QLatin1String(" return if ($v) then ") + role->query() + QLatin1String(" else \"\")")); QXmlResultItems output3; subquery.evaluateTo(&output3); @@ -233,6 +239,9 @@ void QmlXmlQuery::doSubQueryJob() resultList << item.toAtomicValue(); //### we used to trim strings item = output3.next(); } + //### should warn here if things have gone wrong. + while (resultList.count() < m_size) + resultList << QVariant(); m_modelData << resultList; b.seek(0); } @@ -280,11 +289,11 @@ class QmlXmlListModelPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlXmlListModel) public: QmlXmlListModelPrivate() - : isClassComplete(false), size(-1), highestRole(Qt::UserRole) + : isComponentComplete(true), size(-1), highestRole(Qt::UserRole) , reply(0), status(QmlXmlListModel::Idle), progress(0.0) , queryId(-1), roleObjects(this) {} - bool isClassComplete; + bool isComponentComplete; QUrl src; QString query; QString namespaces; @@ -308,6 +317,38 @@ void QmlXmlRoleList::append(XmlListModelRole *role) { model->roleNames << role->name(); ++model->highestRole; } + +/*! + \qmlclass XmlRole + \brief The XmlRole element allows you to specify a role for an XmlListModel. +*/ + +/*! + \qmlproperty string XmlRole::name + The name for the role. This name is used to access the model data for this role from Qml. + + \qml + XmlRole { name: "title"; query: "title/string()" } + + ... + + Component { + id: Delegate + Text { text: title } + } + \endqml +*/ + +/*! + \qmlproperty string XmlRole::query + The relative XPath query for this role. The query should not start with a '/' (i.e. it must be + relative). + + \qml + XmlRole { name: "title"; query: "title/string()" } + \endqml +*/ + //XXX clear, removeAt, and insert need to invalidate any cached data (in data table) as well // (and the model should emit the appropriate signals) void QmlXmlRoleList::clear() @@ -316,12 +357,15 @@ void QmlXmlRoleList::clear() model->roleNames.clear(); QmlConcreteList<XmlListModelRole *>::clear(); } + void QmlXmlRoleList::removeAt(int i) { model->roles.removeAt(i); model->roleNames.removeAt(i); QmlConcreteList<XmlListModelRole *>::removeAt(i); } + +//### we should enforce unique role names void QmlXmlRoleList::insert(int i, XmlListModelRole *role) { QmlConcreteList<XmlListModelRole *>::insert(i, role); @@ -332,7 +376,7 @@ void QmlXmlRoleList::insert(int i, XmlListModelRole *role) /*! \qmlclass XmlListModel - \brief The XmlListModel class allows you to specify a model using XQuery. + \brief The XmlListModel element allows you to specify a model using XPath expressions. XmlListModel allows you to construct a model from XML data that can then be used as a data source for the view classes (ListView, PathView, GridView) and any other classes that interact with model @@ -343,13 +387,14 @@ void QmlXmlRoleList::insert(int i, XmlListModelRole *role) XmlListModel { id: FeedModel source: "http://rss.news.yahoo.com/rss/oceania" - query: "doc($src)/rss/channel/item" - Role { name: "title"; query: "title/string()" } - Role { name: "link"; query: "link/string()" } - Role { name: "description"; query: "description/string()" } + query: "/rss/channel/item" + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } } \endqml - \note The model is currently static, so the above is really just a snapshot of an RSS feed. + \note The model is currently static, so the above is really just a snapshot of an RSS feed. To force a + reload of the entire model, you can call the reload function. */ QmlXmlListModel::QmlXmlListModel(QObject *parent) @@ -364,6 +409,11 @@ QmlXmlListModel::~QmlXmlListModel() { } +/*! + \qmlproperty list<XmlRole> QmlListModel::roles + + The roles to make available for this model. +*/ QmlList<XmlListModelRole *> *QmlXmlListModel::roleObjects() { Q_D(QmlXmlListModel); @@ -403,6 +453,10 @@ QString QmlXmlListModel::toString(int role) const return d->roleNames.at(index); } +/*! + \qmlproperty url XmlListModel::source + The location of the XML data source. +*/ QUrl QmlXmlListModel::source() const { Q_D(const QmlXmlListModel); @@ -418,6 +472,11 @@ void QmlXmlListModel::setSource(const QUrl &src) } } +/*! + \qmlproperty url XmlListModel::query + An absolute XPath query representing the base query for the model items. The query should start with + a '/' or '//'. +*/ QString QmlXmlListModel::query() const { Q_D(const QmlXmlListModel); @@ -427,12 +486,21 @@ QString QmlXmlListModel::query() const void QmlXmlListModel::setQuery(const QString &query) { Q_D(QmlXmlListModel); + if (!query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << "An XmlListModel query must start with '/' or \"//\""; + return; + } + if (d->query != query) { d->query = query; reload(); } } +/*! + \qmlproperty string XmlListModel::namespaceDeclarations + A set of declarations for the namespaces used in the query. +*/ QString QmlXmlListModel::namespaceDeclarations() const { Q_D(const QmlXmlListModel); @@ -447,30 +515,64 @@ void QmlXmlListModel::setNamespaceDeclarations(const QString &declarations) reload(); } } + +/*! + \qmlproperty enum XmlListModel::status + + This property holds the status of data source loading. It can be one of: + \list + \o Idle - no data source has been set, or the data source has been loaded + \o Loading - the data source is currently being loaded + \o Error - an error occurred while loading the data source + \endlist + + \sa progress + +*/ QmlXmlListModel::Status QmlXmlListModel::status() const { Q_D(const QmlXmlListModel); return d->status; } +/*! + \qmlproperty real XmlListModel::progress + + This property holds the progress of data source loading, from 0.0 (nothing loaded) + to 1.0 (finished). + + \sa status +*/ qreal QmlXmlListModel::progress() const { Q_D(const QmlXmlListModel); return d->progress; } -void QmlXmlListModel::classComplete() +void QmlXmlListModel::classBegin() +{ + Q_D(QmlXmlListModel); + d->isComponentComplete = false; +} + +void QmlXmlListModel::componentComplete() { Q_D(QmlXmlListModel); - d->isClassComplete = true; + d->isComponentComplete = true; reload(); } +/*! + \qmlmethod XmlListModel::reload() + + Reloads the model. All the existing model data will be removed, and the model + will be rebuilt from scratch. +*/ void QmlXmlListModel::reload() { Q_D(QmlXmlListModel); - if (!d->isClassComplete) + if (!d->isComponentComplete) return; d->qmlXmlQuery.abort(); @@ -484,7 +586,7 @@ void QmlXmlListModel::reload() emit itemsRemoved(0, count); if (d->src.isEmpty()) { - qWarning() << "Can't load empty src string"; + qmlInfo(this) << "Can't load empty src string"; return; } @@ -546,6 +648,6 @@ void QmlXmlListModel::queryCompleted(int id, int size) } } -#include "qmlxmllistmodel.moc" - QT_END_NAMESPACE + +#include "qmlxmllistmodel.moc" diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index c6aae4a..d9871ab 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -44,6 +44,7 @@ #include <QtDeclarative/qml.h> #include <QtDeclarative/QListModelInterface> +#include <QtDeclarative/qmlinfo.h> QT_BEGIN_HEADER @@ -66,13 +67,23 @@ public: void setName(const QString &name) { m_name = name; } QString query() const { return m_query; } - void setQuery(const QString &query) { m_query = query; } + void setQuery(const QString &query) + { + if (query.startsWith(QLatin1Char('/'))) { + qmlInfo(this) << "An XmlRole query must not start with '/'"; + return; + } + m_query = query; + } + + bool isValid() { + return !m_name.isEmpty() && !m_query.isEmpty(); + } private: QString m_name; QString m_query; }; -QML_DECLARE_TYPE(XmlListModelRole) class QmlXmlListModelPrivate; class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public QmlParserStatus @@ -88,6 +99,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations) Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects) Q_CLASSINFO("DefaultProperty", "roles") + public: QmlXmlListModel(QObject *parent = 0); ~QmlXmlListModel(); @@ -112,7 +124,8 @@ public: Status status() const; qreal progress() const; - virtual void classComplete(); + virtual void classBegin(); + virtual void componentComplete(); signals: void statusChanged(Status); @@ -131,10 +144,11 @@ private: Q_DISABLE_COPY(QmlXmlListModel) }; -QML_DECLARE_TYPE(QmlXmlListModel) - QT_END_NAMESPACE +QML_DECLARE_TYPE(XmlListModelRole) +QML_DECLARE_TYPE(QmlXmlListModel) + QT_END_HEADER #endif // QMLXMLLISTMODEL_H diff --git a/src/declarative/extra/qnumberformat.cpp b/src/declarative/extra/qnumberformat.cpp index 424c125..cde2fb0 100644 --- a/src/declarative/extra/qnumberformat.cpp +++ b/src/declarative/extra/qnumberformat.cpp @@ -41,9 +41,9 @@ #include "qnumberformat.h" - QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(QNumberFormat,NumberFormat) + +QML_DEFINE_NOCREATE_TYPE(QNumberFormat) QNumberFormat::QNumberFormat(QObject *parent) : QObject(parent), _number(0), _type(Decimal), _groupingSize(0) @@ -221,4 +221,5 @@ QString QNumberFormat::formatDecimal(const QString &formatDec, const QString &de } return outputDecimal; } + QT_END_NAMESPACE diff --git a/src/declarative/extra/qnumberformat.h b/src/declarative/extra/qnumberformat.h index fba9872..830cf79 100644 --- a/src/declarative/extra/qnumberformat.h +++ b/src/declarative/extra/qnumberformat.h @@ -163,10 +163,11 @@ private: QString _text; }; -QML_DECLARE_TYPE(QNumberFormat) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QNumberFormat) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri index 7d8f565..71517fd 100644 --- a/src/declarative/fx/fx.pri +++ b/src/declarative/fx/fx.pri @@ -1,17 +1,13 @@ HEADERS += \ fx/qfxanchors.h \ fx/qfxanchors_p.h \ - fx/qfxanimatedimageitem.h \ fx/qfxcomponentinstance.h \ fx/qfxcomponentinstance_p.h \ - fx/qfxcontentwrapper.h \ - fx/qfxcontentwrapper_p.h \ fx/qfxevents_p.h \ fx/qfxflickable.h \ fx/qfxflickable_p.h \ fx/qfxflipable.h \ fx/qfxgridview.h \ - fx/qfxflowview.h \ fx/qfximage.h \ fx/qfxpainteditem.h \ fx/qfxpainteditem_p.h \ @@ -24,7 +20,6 @@ HEADERS += \ fx/qfxlayouts_p.h \ fx/qfxmouseregion.h \ fx/qfxmouseregion_p.h \ - fx/qfxparticles.h \ fx/qfxpath.h \ fx/qfxpath_p.h \ fx/qfxpathview.h \ @@ -46,14 +41,11 @@ HEADERS += \ SOURCES += \ fx/qfxanchors.cpp \ - fx/qfxanimatedimageitem.cpp \ fx/qfxcomponentinstance.cpp \ - fx/qfxcontentwrapper.cpp \ fx/qfxevents.cpp \ fx/qfxflickable.cpp \ fx/qfxflipable.cpp \ fx/qfxgridview.cpp \ - fx/qfxflowview.cpp \ fx/qfximage.cpp \ fx/qfxpainteditem.cpp \ fx/qfxitem.cpp \ @@ -61,7 +53,6 @@ SOURCES += \ fx/qfxkeyproxy.cpp \ fx/qfxlayouts.cpp \ fx/qfxmouseregion.cpp \ - fx/qfxparticles.cpp \ fx/qfxpath.cpp \ fx/qfxpathview.cpp \ fx/qfxrect.cpp \ diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index 509e2c8..22b9b08 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -51,7 +51,6 @@ QT_BEGIN_NAMESPACE QML_DEFINE_TYPE(QFxAnchors,Anchors) //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? -//TODO: baseline support //TODO: support non-parent, non-sibling (need to find lowest common ancestor) //### const item? @@ -402,8 +401,8 @@ void QFxAnchorsPrivate::updateVerticalAnchors() if (fill || centeredIn || !isItemComplete()) return; - if (!updatingVerticalAnchor) { - updatingVerticalAnchor = true; + if (updatingVerticalAnchor < 2) { + ++updatingVerticalAnchor; if (usedAnchors & QFxAnchors::HasTopAnchor) { //Handle stretching bool invalid = true; @@ -455,7 +454,7 @@ void QFxAnchorsPrivate::updateVerticalAnchors() setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset()); } } - updatingVerticalAnchor = false; + --updatingVerticalAnchor; } else { // ### Make this certain :) qmlInfo(item) << "Possible anchor loop detected on vertical anchor."; @@ -467,8 +466,8 @@ void QFxAnchorsPrivate::updateHorizontalAnchors() if (fill || centeredIn || !isItemComplete()) return; - if (!updatingHorizontalAnchor) { - updatingHorizontalAnchor = true; + if (updatingHorizontalAnchor < 2) { + ++updatingHorizontalAnchor; if (usedAnchors & QFxAnchors::HasLeftAnchor) { //Handle stretching @@ -514,7 +513,7 @@ void QFxAnchorsPrivate::updateHorizontalAnchors() } } - updatingHorizontalAnchor = false; + --updatingHorizontalAnchor; } else { // ### Make this certain :) qmlInfo(item) << "Possible anchor loop detected on horizontal anchor."; @@ -760,93 +759,99 @@ void QFxAnchors::resetHorizontalCenter() d->updateHorizontalAnchors(); } -int QFxAnchors::leftMargin() const +qreal QFxAnchors::leftMargin() const { Q_D(const QFxAnchors); return d->leftMargin; } -void QFxAnchors::setLeftMargin(int offset) +void QFxAnchors::setLeftMargin(qreal offset) { Q_D(QFxAnchors); if (d->leftMargin == offset) return; d->leftMargin = offset; + d->updateHorizontalAnchors(); emit leftMarginChanged(); } -int QFxAnchors::rightMargin() const +qreal QFxAnchors::rightMargin() const { Q_D(const QFxAnchors); return d->rightMargin; } -void QFxAnchors::setRightMargin(int offset) +void QFxAnchors::setRightMargin(qreal offset) { Q_D(QFxAnchors); if (d->rightMargin == offset) return; d->rightMargin = offset; + d->updateHorizontalAnchors(); emit rightMarginChanged(); } -int QFxAnchors::horizontalCenterOffset() const +qreal QFxAnchors::horizontalCenterOffset() const { Q_D(const QFxAnchors); return d->hCenterOffset; } -void QFxAnchors::setHorizontalCenterOffset(int offset) +void QFxAnchors::setHorizontalCenterOffset(qreal offset) { Q_D(QFxAnchors); if (d->hCenterOffset == offset) return; d->hCenterOffset = offset; + d->updateHorizontalAnchors(); emit horizontalCenterOffsetChanged(); } -int QFxAnchors::topMargin() const +qreal QFxAnchors::topMargin() const { Q_D(const QFxAnchors); return d->topMargin; } -void QFxAnchors::setTopMargin(int offset) +void QFxAnchors::setTopMargin(qreal offset) { Q_D(QFxAnchors); if (d->topMargin == offset) return; d->topMargin = offset; + d->updateVerticalAnchors(); emit topMarginChanged(); } -int QFxAnchors::bottomMargin() const +qreal QFxAnchors::bottomMargin() const { Q_D(const QFxAnchors); return d->bottomMargin; } -void QFxAnchors::setBottomMargin(int offset) +void QFxAnchors::setBottomMargin(qreal offset) { Q_D(QFxAnchors); if (d->bottomMargin == offset) return; d->bottomMargin = offset; + d->updateVerticalAnchors(); emit bottomMarginChanged(); } -int QFxAnchors::verticalCenterOffset() const +qreal QFxAnchors::verticalCenterOffset() const { Q_D(const QFxAnchors); return d->vCenterOffset; } -void QFxAnchors::setVerticalCenterOffset(int offset) +void QFxAnchors::setVerticalCenterOffset(qreal offset) { Q_D(QFxAnchors); if (d->vCenterOffset == offset) return; d->vCenterOffset = offset; + d->updateVerticalAnchors(); emit verticalCenterOffsetChanged(); } diff --git a/src/declarative/fx/qfxanchors.h b/src/declarative/fx/qfxanchors.h index 206a05c..dcd5d79 100644 --- a/src/declarative/fx/qfxanchors.h +++ b/src/declarative/fx/qfxanchors.h @@ -46,15 +46,13 @@ #include <QtDeclarative/qfxglobal.h> #include <QtDeclarative/qml.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QFxItem; -class QFxAnchorsPrivate; +class QFxItem; class QFxAnchorLine { public: @@ -79,8 +77,6 @@ public: AnchorLine anchorLine; }; -Q_DECLARE_METATYPE(QFxAnchorLine) - class QFxAnchorsPrivate; class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject { @@ -93,12 +89,12 @@ class Q_DECLARATIVE_EXPORT QFxAnchors : public QObject Q_PROPERTY(QFxAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom) Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) Q_PROPERTY(QFxAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline) - Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) - Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) - Q_PROPERTY(int horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) - Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) - Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) - Q_PROPERTY(int verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) + 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(QFxItem *fill READ fill WRITE setFill) Q_PROPERTY(QFxItem *centeredIn READ centeredIn WRITE setCenteredIn) @@ -121,7 +117,7 @@ public: QFxAnchorLine left() const; void setLeft(const QFxAnchorLine &edge); - Q_INVOKABLE void resetLeft(); //### temporarily invokable for testing + void resetLeft(); QFxAnchorLine right() const; void setRight(const QFxAnchorLine &edge); @@ -147,23 +143,23 @@ public: void setBaseline(const QFxAnchorLine &edge); void resetBaseline(); - int leftMargin() const; - void setLeftMargin(int); + qreal leftMargin() const; + void setLeftMargin(qreal); - int rightMargin() const; - void setRightMargin(int); + qreal rightMargin() const; + void setRightMargin(qreal); - int horizontalCenterOffset() const; - void setHorizontalCenterOffset(int); + qreal horizontalCenterOffset() const; + void setHorizontalCenterOffset(qreal); - int topMargin() const; - void setTopMargin(int); + qreal topMargin() const; + void setTopMargin(qreal); - int bottomMargin() const; - void setBottomMargin(int); + qreal bottomMargin() const; + void setBottomMargin(qreal); - int verticalCenterOffset() const; - void setVerticalCenterOffset(int); + qreal verticalCenterOffset() const; + void setVerticalCenterOffset(qreal); QFxItem *fill() const; void setFill(QFxItem *); @@ -189,10 +185,11 @@ private: Q_DECLARE_PRIVATE(QFxAnchors) }; -QML_DECLARE_TYPE(QFxAnchors) - - QT_END_NAMESPACE +Q_DECLARE_METATYPE(QFxAnchorLine) +QML_DECLARE_TYPE(QFxAnchors) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxanchors_p.h b/src/declarative/fx/qfxanchors_p.h index 32d8b75..a7c904b 100644 --- a/src/declarative/fx/qfxanchors_p.h +++ b/src/declarative/fx/qfxanchors_p.h @@ -56,15 +56,15 @@ #include "qfxanchors.h" #include "private/qobject_p.h" - QT_BEGIN_NAMESPACE + class QFxAnchorsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QFxAnchors) public: QFxAnchorsPrivate() - : updatingMe(false), updatingHorizontalAnchor(false), - updatingVerticalAnchor(false), item(0), usedAnchors(0), fill(0), + : updatingMe(false), updatingHorizontalAnchor(0), + updatingVerticalAnchor(0), item(0), usedAnchors(0), fill(0), centeredIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), vCenterOffset(0), hCenterOffset(0) { @@ -80,9 +80,9 @@ public: void remDepend(QFxItem *); bool isItemComplete() const; - bool updatingMe:1; - bool updatingHorizontalAnchor:1; - bool updatingVerticalAnchor:1; + bool updatingMe; + int updatingHorizontalAnchor; + int updatingVerticalAnchor; void setItemHeight(qreal); void setItemWidth(qreal); @@ -119,12 +119,12 @@ public: QFxAnchorLine hCenter; QFxAnchorLine baseline; - int leftMargin; - int rightMargin; - int topMargin; - int bottomMargin; - int vCenterOffset; - int hCenterOffset; + qreal leftMargin; + qreal rightMargin; + qreal topMargin; + qreal bottomMargin; + qreal vCenterOffset; + qreal hCenterOffset; }; diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp index d3f7061..6cf8e74 100644 --- a/src/declarative/fx/qfxcomponentinstance.cpp +++ b/src/declarative/fx/qfxcomponentinstance.cpp @@ -41,8 +41,7 @@ #include "qfxcomponentinstance.h" #include "qfxcomponentinstance_p.h" -#include <qfxperf.h> -#include <qfxcontentwrapper.h> +#include <private/qfxperf_p.h> #include <QtDeclarative/qmlinfo.h> diff --git a/src/declarative/fx/qfxcomponentinstance.h b/src/declarative/fx/qfxcomponentinstance.h index 97b8b7b..940fb6d 100644 --- a/src/declarative/fx/qfxcomponentinstance.h +++ b/src/declarative/fx/qfxcomponentinstance.h @@ -44,12 +44,12 @@ #include <QtDeclarative/qfxitem.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxComponentInstancePrivate; class Q_DECLARATIVE_EXPORT QFxComponentInstance : public QFxItem { @@ -80,10 +80,11 @@ protected: private: Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxComponentInstance) }; -QML_DECLARE_TYPE(QFxComponentInstance) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxComponentInstance) + QT_END_HEADER #endif // QFXCOMPONENTINSTANCE_H diff --git a/src/declarative/fx/qfxcontentwrapper.cpp b/src/declarative/fx/qfxcontentwrapper.cpp deleted file mode 100644 index 1fa0fde..0000000 --- a/src/declarative/fx/qfxcontentwrapper.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfxcontentwrapper.h" -#include "qfxcontentwrapper_p.h" - - -QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(QFxContentWrapper,ContentWrapper) - -/*! - \qmlclass ContentWrapper QFxContentWrapper - \ingroup group_utility - \brief ContentWrapper provides a component which contains content. - \inherits Item - - In some cases the content of a component is not defined by the component itself. - For example, the items placed in a group box need to be specified external to - group box component definition itself. - In cases like these \l Content can be used to specify at what location in the component - the content should be placed. It is used in conjuntion with the \e content property of - ContentWrapper: any items listed as content will be placed in the location - specified by Content. The component containing the Content must be of type - ContentWrapper. - - GroupBox component definition: - \quotefile doc/src/snippets/declarative/GroupBox.qml - - \bold Note that in the above component definition ContentWrapper's \e children - property is specified explicitly since \e content is the default property. - - Component use: - \table - \row \o \image content.png - \o \quotefile doc/src/snippets/declarative/content.qml - \endtable - - \sa Content -*/ - -QFxContentWrapper::QFxContentWrapper(QFxItem *parent) -: QFxItem(*(new QFxContentWrapperPrivate), parent) -{ -} - -QFxContentWrapper::QFxContentWrapper(QFxContentWrapperPrivate &dd, QFxItem *parent) - : QFxItem(dd, parent) -{ -} - -/*! - \qmlproperty list<Item> ContentWrapper::content - - Contains the list of elements to replace the \l Content - placeholder. - - \sa Content -*/ -QList<QFxItem *> *QFxContentWrapper::content() -{ - Q_D(QFxContentWrapper); - return &(d->_content); -} - -void QFxContentWrapper::componentComplete() -{ - QFxItem::componentComplete(); - if (content()->size() < 1) - return; - - QList<QGraphicsItem *> nodes; - nodes.append(this); - QFxItem *target = findContent(nodes); - if (!target) - return; - target = target->itemParent(); - - QList<QFxItem*> myContent(*content()); - for (int ii = 0; ii < myContent.count(); ++ii) - myContent.at(ii)->setParent(target); -} - -QFxItem *QFxContentWrapper::findContent(QList<QGraphicsItem *> &nodes) -{ - QGraphicsItem *item = nodes.takeFirst(); - if (qobject_cast<QFxContent*>(item)) - return static_cast<QFxItem *>(item); - nodes << item->children(); - if (nodes.isEmpty()) - return 0; - return findContent(nodes); -} - -QML_DEFINE_TYPE(QFxContent,Content) - -/*! - \qmlclass Content QFxContent - \ingroup group_utility - \brief Content is used as a placeholder for the content of a component. - \inherits Item - - The Content element is used to place content within a component. - See \l ContentWrapper for usage. -*/ - -QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxevents_p.h b/src/declarative/fx/qfxevents_p.h index 2eb29af..fbf0c5f 100644 --- a/src/declarative/fx/qfxevents_p.h +++ b/src/declarative/fx/qfxevents_p.h @@ -42,6 +42,17 @@ #ifndef QFXEVENTS_P_H #define QFXEVENTS_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 <QtDeclarative/qfxglobal.h> #include <QtDeclarative/qml.h> #include <QtCore/qobject.h> @@ -78,8 +89,6 @@ private: QKeyEvent event; }; -QML_DECLARE_TYPE(QFxKeyEvent) - class QFxMouseEvent : public QObject { Q_OBJECT @@ -120,8 +129,9 @@ private: bool _accepted; }; -QML_DECLARE_TYPE(QFxMouseEvent) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxKeyEvent) +QML_DECLARE_TYPE(QFxMouseEvent) + #endif // QFXEVENTS_P_H diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index f85f3dc..59191c9 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -112,8 +112,8 @@ void QFxFlickablePrivate::init() QObject::connect(&_tl, SIGNAL(completed()), q, SLOT(movementEnding())); q->setAcceptedMouseButtons(Qt::LeftButton); q->setOptions(QFxItem::ChildMouseFilter | QFxItem::MouseEvents); - QObject::connect(_flick, SIGNAL(leftChanged()), q, SIGNAL(positionChanged())); - QObject::connect(_flick, SIGNAL(topChanged()), q, SIGNAL(positionChanged())); + QObject::connect(_flick, SIGNAL(xChanged()), q, SIGNAL(positionChanged())); + QObject::connect(_flick, SIGNAL(yChanged()), q, SIGNAL(positionChanged())); QObject::connect(&elasticX, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(&elasticY, SIGNAL(updated()), q, SLOT(ticked())); QObject::connect(q, SIGNAL(heightChanged()), q, SLOT(heightChange())); @@ -597,7 +597,13 @@ void QFxFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) int dx = int(event->pos().x() - pressPos.x()); if (qAbs(dx) > FlickThreshold || pressTime.elapsed() > 200) { qreal newX = dx + pressX; - if (q->overShoot() || (newX <= q->minXExtent() && newX >= q->maxXExtent())) { + const qreal minX = q->minXExtent(); + const qreal maxX = q->maxXExtent(); + if (newX > minX) + newX = minX + (newX - minX) / 2; + if (newX < maxX && maxX - minX < 0) + newX = maxX + (newX - maxX) / 2; + if (q->overShoot() || (newX <= minX && newX >= maxX)) { if (dragMode == QFxFlickable::Hard) _moveX.setValue(newX); else diff --git a/src/declarative/fx/qfxflickable.h b/src/declarative/fx/qfxflickable.h index a08e814..a6c2a6c 100644 --- a/src/declarative/fx/qfxflickable.h +++ b/src/declarative/fx/qfxflickable.h @@ -44,12 +44,12 @@ #include <QtDeclarative/qfxitem.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxFlickablePrivate; class Q_DECLARATIVE_EXPORT QFxFlickable : public QFxItem { @@ -186,10 +186,11 @@ private: Q_DISABLE_COPY(QFxFlickable) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlickable) }; -QML_DECLARE_TYPE(QFxFlickable) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFlickable) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxflickable_p.h b/src/declarative/fx/qfxflickable_p.h index a3b1500..28ec6d8 100644 --- a/src/declarative/fx/qfxflickable_p.h +++ b/src/declarative/fx/qfxflickable_p.h @@ -57,7 +57,7 @@ #include "qfxflickable.h" #include "qfxitem_p.h" #include "qml.h" -#include "qmltimelinevalueproxy.h" +#include "private/qmltimeline_p.h" #include "private/qmlanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index d6222f3..6089d0a 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -44,6 +44,8 @@ #include "qfxtransform.h" #include <QtDeclarative/qmlinfo.h> +QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QFxFlipable,Flipable) class QFxFlipablePrivate : public QFxItemPrivate @@ -94,7 +96,7 @@ Flipable { ] transitions: [ Transition { - NumericAnimation { + NumberAnimation { easing: "easeInOutQuad" properties: "rotation" } diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h index 5a6271b..5aa038d 100644 --- a/src/declarative/fx/qfxflipable.h +++ b/src/declarative/fx/qfxflipable.h @@ -94,10 +94,11 @@ private: Q_DISABLE_COPY(QFxFlipable) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlipable) }; -QML_DECLARE_TYPE(QFxFlipable) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxFlipable) + QT_END_HEADER #endif // QFXFLIPABLE_H diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 0ca9393..11b630a 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -234,6 +234,8 @@ public: int count = columns - 1 - (modelIndex - visibleItems.last()->index - 1) % columns; return visibleItems.last()->colPos() - count * colSize(); } + } else { + return (modelIndex % columns) * colSize(); } return 0; } @@ -252,6 +254,8 @@ public: int rows = col / (columns * colSize()); return visibleItems.last()->rowPos() + rows * rowSize(); } + } else { + return (modelIndex / columns) * rowSize(); } return 0; } @@ -364,8 +368,8 @@ void QFxGridViewPrivate::releaseItem(FxGridItem *item) if (!item) return; if (trackedItem == item) { - QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); trackedItem = 0; } if (model->release(item->item) == 0) { @@ -544,15 +548,15 @@ void QFxGridViewPrivate::updateTrackedItem() item = highlight; if (trackedItem && item != trackedItem) { - QObject::disconnect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); trackedItem = 0; } if (!trackedItem && item) { trackedItem = item; - QObject::connect(trackedItem->item, SIGNAL(topChanged()), q, SLOT(trackedPositionChanged())); - QObject::connect(trackedItem->item, SIGNAL(leftChanged()), q, SLOT(trackedPositionChanged())); + QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); + QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); q->trackedPositionChanged(); } if (trackedItem) diff --git a/src/declarative/fx/qfxgridview.h b/src/declarative/fx/qfxgridview.h index d561965..8f443e1 100644 --- a/src/declarative/fx/qfxgridview.h +++ b/src/declarative/fx/qfxgridview.h @@ -139,10 +139,10 @@ private: void refill(); }; -QML_DECLARE_TYPE(QFxGridView) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxGridView) + QT_END_HEADER #endif diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index fa56ee1..148c269 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -41,7 +41,7 @@ #include "qfximage.h" #include "qfximage_p.h" -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <QNetworkRequest> #include <QNetworkReply> #include <QFile> diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 72530ee..925a520 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -113,10 +113,11 @@ private: Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxImage) void setGridScaledImage(const QFxGridScaledImage& sci); }; -QML_DECLARE_TYPE(QFxImage) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxImage) + QT_END_HEADER #endif // QFXIMAGE_H diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index cd8cabd..da4f1b3 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -47,7 +47,7 @@ #include <QNetworkRequest> #include <QGraphicsSceneMouseEvent> #include <QtScript/qscriptengine.h> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include "qmlengine.h" #include "qmlstate.h" @@ -64,10 +64,10 @@ #include "qfxevents_p.h" #include <qmlcomponent.h> - QT_BEGIN_NAMESPACE -#ifndef INT_MAX -#define INT_MAX 2147483647 + +#ifndef FLT_MAX +#define FLT_MAX 1E+37 #endif QML_DEFINE_NOCREATE_TYPE(QFxContents) @@ -121,86 +121,94 @@ QML_DEFINE_TYPE(QFxItem,Item) */ -QFxContents::QFxContents() : _height(0), _width(0) +QFxContents::QFxContents() : m_height(0), m_width(0) { } /*! + \qmlproperty qreal Item::contents.width + \qmlproperty qreal Item::contents.height + + The contents properties allow an item access to the size of its + children. This property is useful if you have an item that needs to be + sized to fit its children. +*/ + +/*! \property QFxContents::height \brief The height of the contents. */ -int QFxContents::height() const +qreal QFxContents::height() const { - return _height; + return m_height; } /*! \property QFxContents::width \brief The width of the contents. */ -int QFxContents::width() const +qreal QFxContents::width() const { - return _width; + return m_width; } //TODO: optimization: only check sender(), if there is one void QFxContents::calcHeight() { - int oldheight = _height; - - int top = INT_MAX; - int bottom = 0; + qreal oldheight = m_height; - QList<QGraphicsItem *> children = _item->childItems(); + qreal top = FLT_MAX; + qreal bottom = 0; + QList<QGraphicsItem *> children = m_item->childItems(); for (int i = 0; i < children.count(); ++i) { QFxItem *child = qobject_cast<QFxItem *>(children.at(i)); - int y = int(child->y()); + qreal y = child->y(); if (y + child->height() > bottom) bottom = y + child->height(); if (y < top) top = y; } - _height = bottom - top; + m_height = qMax(bottom - top, qreal(0.0)); - if (_height != oldheight) + if (m_height != oldheight) emit heightChanged(); } //TODO: optimization: only check sender(), if there is one void QFxContents::calcWidth() { - int oldwidth = _width; + qreal oldwidth = m_width; - int left = INT_MAX; - int right = 0; - QList<QGraphicsItem *> children = _item->childItems(); + qreal left = FLT_MAX; + qreal right = 0; + QList<QGraphicsItem *> children = m_item->childItems(); for (int i = 0; i < children.count(); ++i) { QFxItem *child = qobject_cast<QFxItem *>(children.at(i)); - int x = int(child->x()); + qreal x = child->x(); if (x + child->width() > right) right = x + child->width(); if (x < left) left = x; } - _width = right - left; + m_width = qMax(right - left, qreal(0.0)); - if (_width != oldwidth) + if (m_width != oldwidth) emit widthChanged(); } void QFxContents::setItem(QFxItem *item) { - _item = item; + m_item = item; - QList<QGraphicsItem *> children = _item->childItems(); + QList<QGraphicsItem *> children = m_item->childItems(); for (int i = 0; i < children.count(); ++i) { QFxItem *child = qobject_cast<QFxItem *>(children.at(i)); connect(child, SIGNAL(heightChanged()), this, SLOT(calcHeight())); - connect(child, SIGNAL(topChanged()), this, SLOT(calcHeight())); + connect(child, SIGNAL(yChanged()), this, SLOT(calcHeight())); connect(child, SIGNAL(widthChanged()), this, SLOT(calcWidth())); - connect(child, SIGNAL(leftChanged()), this, SLOT(calcWidth())); + connect(child, SIGNAL(xChanged()), this, SLOT(calcWidth())); } calcHeight(); @@ -268,15 +276,15 @@ void QFxContents::setItem(QFxItem *item) */ /*! - \fn void QFxItem::leftChanged() + \fn void QFxItem::xChanged() - This signal is emitted when the left coordinate of the item changes. + This signal is emitted when the x coordinate of the item changes. */ /*! - \fn void QFxItem::topChanged() + \fn void QFxItem::yChanged() - This signal is emitted when the top coordinate of the item changes. + This signal is emitted when the y coordinate of the item changes. */ /*! @@ -912,7 +920,16 @@ void QFxItem::qmlLoaded() QmlContext *ctxt = new QmlContext(qmlContext(this)); ctxt->addDefaultObject(this); + if (!d->_qmlcomp->errors().isEmpty()) { + qWarning() << d->_qmlcomp->errors(); + delete d->_qmlcomp; + d->_qmlcomp = 0; + emit qmlChanged(); + return; + } QObject *obj = d->_qmlcomp->create(ctxt); + if (!d->_qmlcomp->errors().isEmpty()) + qWarning() << d->_qmlcomp->errors(); QFxItem *qmlChild = qobject_cast<QFxItem *>(obj); if (qmlChild) { qmlChild->setItemParent(this); @@ -931,8 +948,8 @@ void QFxItem::qmlLoaded() /*! \qmlproperty real Item::x \qmlproperty real Item::y - \qmlproperty int Item::width - \qmlproperty int Item::height + \qmlproperty real Item::width + \qmlproperty real Item::height Defines the item's position and size relative to its parent. @@ -1073,11 +1090,11 @@ void QFxItem::geometryChanged(const QRectF &newGeometry, } if (newGeometry.x() != oldGeometry.x()) - emit leftChanged(); + emit xChanged(); if (newGeometry.width() != oldGeometry.width()) emit widthChanged(); if (newGeometry.y() != oldGeometry.y()) - emit topChanged(); + emit yChanged(); if (newGeometry.height() != oldGeometry.height()) emit heightChanged(); @@ -1306,13 +1323,14 @@ QFxAnchorLine QFxItem::baseline() const \qmlproperty AnchorLine Item::anchors.baseline \qmlproperty Item Item::anchors.fill - - \qmlproperty int Item::anchors.topMargin - \qmlproperty int Item::anchors.bottomMargin - \qmlproperty int Item::anchors.leftMargin - \qmlproperty int Item::anchors.rightMargin - \qmlproperty int Item::anchors.horizontalCenterOffset - \qmlproperty int Item::anchors.verticalCenterOffset + \qmlproperty Item Item::anchors.centeredIn + + \qmlproperty real Item::anchors.topMargin + \qmlproperty real Item::anchors.bottomMargin + \qmlproperty real Item::anchors.leftMargin + \qmlproperty real Item::anchors.rightMargin + \qmlproperty real Item::anchors.horizontalCenterOffset + \qmlproperty real Item::anchors.verticalCenterOffset Anchors provide a way to position an item by specifying its relationship with other items. @@ -1371,11 +1389,11 @@ QFxAnchorLine QFxItem::baseline() const For non-text items, a default baseline offset of 0 is used. */ -int QFxItem::baselineOffset() const +qreal QFxItem::baselineOffset() const { Q_D(const QFxItem); if (!d->_baselineOffset.isValid()) { - return 0; + return 0.0; } else return d->_baselineOffset; } @@ -1383,7 +1401,7 @@ int QFxItem::baselineOffset() const /*! \internal */ -void QFxItem::setBaselineOffset(int offset) +void QFxItem::setBaselineOffset(qreal offset) { Q_D(QFxItem); if (offset == d->_baselineOffset) diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 050cc3e..bb48d16 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -63,14 +63,14 @@ QT_MODULE(Declarative) class Q_DECLARATIVE_EXPORT QFxContents : public QObject { Q_OBJECT - Q_PROPERTY(int height READ height NOTIFY heightChanged) - Q_PROPERTY(int width READ width NOTIFY widthChanged) + Q_PROPERTY(qreal height READ height NOTIFY heightChanged) + Q_PROPERTY(qreal width READ width NOTIFY widthChanged) public: QFxContents(); - int height() const; + qreal height() const; - int width() const; + qreal width() const; void setItem(QFxItem *item); @@ -83,11 +83,10 @@ Q_SIGNALS: void widthChanged(); private: - QFxItem *_item; - int _height; - int _width; + QFxItem *m_item; + qreal m_height; + qreal m_width; }; -QML_DECLARE_TYPE(QFxContents) Q_DECLARE_OPERATORS_FOR_FLAGS(QFxAnchors::UsedAnchors) class QmlState; @@ -105,27 +104,27 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QString id READ id WRITE setId) Q_PROPERTY(QmlList<QFxItem *>* children READ children DESIGNABLE false) Q_PROPERTY(QmlList<QObject *>* resources READ resources DESIGNABLE false) - Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false) + Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT) Q_PROPERTY(QmlList<QObject *> *data READ data DESIGNABLE false) - Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false) + Q_PROPERTY(QFxContents * contents READ contents DESIGNABLE false CONSTANT) Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false) Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false) Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY leftChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY topChanged) + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(qreal z READ z WRITE setZ) - Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) - Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(int baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(QFxAnchorLine left READ left) - Q_PROPERTY(QFxAnchorLine right READ right) - Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter) - Q_PROPERTY(QFxAnchorLine top READ top) - Q_PROPERTY(QFxAnchorLine bottom READ bottom) - Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter) - Q_PROPERTY(QFxAnchorLine baseline READ baseline) + Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged) + Q_PROPERTY(QFxAnchorLine left READ left CONSTANT) + Q_PROPERTY(QFxAnchorLine right READ right CONSTANT) + Q_PROPERTY(QFxAnchorLine horizontalCenter READ horizontalCenter CONSTANT) + Q_PROPERTY(QFxAnchorLine top READ top CONSTANT) + Q_PROPERTY(QFxAnchorLine bottom READ bottom CONSTANT) + Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT) + Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT) + Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) @@ -196,8 +195,8 @@ public: QUrl qml() const; void setQml(const QUrl &); - int baselineOffset() const; - void setBaselineOffset(int); + qreal baselineOffset() const; + void setBaselineOffset(qreal); qreal rotation() const; void setRotation(qreal); @@ -282,10 +281,10 @@ public Q_SLOTS: void newChild(const QString &url); Q_SIGNALS: - void leftChanged(); + void xChanged(); + void yChanged(); void widthChanged(); void heightChanged(); - void topChanged(); void baselineOffsetChanged(); void stateChanged(const QString &); void focusChanged(); @@ -343,7 +342,7 @@ private: Q_DISABLE_COPY(QFxItem) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxItem) }; -QML_DECLARE_TYPE(QFxItem) + Q_DECLARE_OPERATORS_FOR_FLAGS(QFxItem::Options) template<typename T> @@ -354,8 +353,11 @@ T qobject_cast(QGraphicsItem *item) return qobject_cast<T>(o); } - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxContents) +QML_DECLARE_TYPE(QFxItem) + QT_END_HEADER + #endif // QFXITEM_H diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 113c860..93bcf6c 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -143,7 +143,7 @@ public: QList<QUrl> _qmlnewloading; QList<QmlComponent*> _qmlnewcomp; - QmlNullableValue<int> _baselineOffset; + QmlNullableValue<qreal> _baselineOffset; float _rotation; bool _classComplete:1; diff --git a/src/declarative/fx/qfxkeyactions.h b/src/declarative/fx/qfxkeyactions.h index cea992a..91c2806 100644 --- a/src/declarative/fx/qfxkeyactions.h +++ b/src/declarative/fx/qfxkeyactions.h @@ -47,12 +47,12 @@ #include <QtDeclarative/qml.h> #include <QtDeclarative/qfxitem.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxKeyActionsPrivate; class Q_DECLARATIVE_EXPORT QFxKeyActions : public QFxItem { @@ -310,10 +310,10 @@ private: QFxKeyActionsPrivate *d; }; -QML_DECLARE_TYPE(QFxKeyActions) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxKeyActions) + QT_END_HEADER #endif // QFXKEYACTIONS_H diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h index 38cff7a..d075295 100644 --- a/src/declarative/fx/qfxkeyproxy.h +++ b/src/declarative/fx/qfxkeyproxy.h @@ -49,6 +49,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxKeyProxyPrivate; class Q_DECLARATIVE_EXPORT QFxKeyProxy : public QFxItem { @@ -69,10 +70,10 @@ private: QFxKeyProxyPrivate *d; }; -QML_DECLARE_TYPE(QFxKeyProxy) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxKeyProxy) + QT_END_HEADER #endif // QFXKEYPROXY_H diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp index 67cf00a..f71b35a 100644 --- a/src/declarative/fx/qfxlayouts.cpp +++ b/src/declarative/fx/qfxlayouts.cpp @@ -45,7 +45,7 @@ #include "qmlstate.h" #include "qmlstategroup.h" #include "qmlstateoperations.h" -#include "qfxperf.h" +#include "private/qfxperf_p.h" #include "qfxlayouts.h" #include "qfxlayouts_p.h" @@ -132,7 +132,7 @@ BaseLayout { id: layout y: 0 move: Transition { - NumericAnimation { + NumberAnimation { properties: "y" ease: "easeOutBounce" } @@ -161,7 +161,7 @@ BaseLayout { id: layout y: 0 add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -196,7 +196,7 @@ BaseLayout { id: layout y: 0 remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -310,9 +310,6 @@ void QFxBaseLayout::preLayout() d->_ep = true; QCoreApplication::postEvent(this, new QEvent(QEvent::User)); } - if (d->stateGroup) { - delete d->stateGroup; d->stateGroup = 0; - } QSet<QFxItem *> allItems; QList<QGraphicsItem *> children = childItems(); for (int ii = 0; ii < children.count(); ++ii) { @@ -389,32 +386,29 @@ void QFxBaseLayout::preLayout() } //###This should be considered to move more centrally, as it seems useful -void QFxBaseLayout::applyTransition(const QList<QPair<QString, QVariant> >& changes, - QFxItem* target, QmlTransition* trans) +void QFxBaseLayout::applyTransition(const QList<QPair<QString, QVariant> >& changes, QFxItem* target, QmlTransition* trans) { Q_D(QFxBaseLayout); if (!trans||!target)//TODO: if !trans, just apply changes return; setLayoutItem(target); - if (d->stateGroup) - delete d->stateGroup; - d->stateGroup = new QmlStateGroup(this); - QmlState *state = new QmlState; - *(d->stateGroup->statesProperty()) << state; + QmlStateOperation::ActionList actions; + for (int ii=0; ii<changes.size(); ++ii){ - QmlSetProperty *sp = new QmlSetProperty(state); - sp->setObject(target); - QVariant val = changes[ii].second; - if (d->_margin && - (changes[ii].first == QLatin1String("x") || changes[ii].first == QLatin1String("y"))){ + + QVariant val = changes[ii].second; + if (d->_margin && + (changes[ii].first == QLatin1String("x") || + changes[ii].first == QLatin1String("y"))) { val = QVariant(val.toInt() + d->_margin); - } - sp->setValue(val); - sp->setProperty(changes[ii].first); - *state << sp; + } + + actions << Action(target, changes[ii].first, val); + } - state->apply(d->stateGroup, trans, 0); + + d->transitionManager.transition(actions, trans); d->_animated << target; } @@ -513,7 +507,7 @@ VerticalLayout { VerticalLayout { id: layout remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -540,7 +534,7 @@ VerticalLayout { VerticalLayout { id: layout add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -567,7 +561,7 @@ VerticalLayout { VerticalLayout { id: layout move: Transition { - NumericAnimation { + NumberAnimation { properties: "y" ease: "easeOutBounce" } @@ -686,7 +680,7 @@ HorizontalLayout { HorizontalLayout { id: layout remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -708,7 +702,7 @@ HorizontalLayout { HorizontalLayout { id: layout add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -730,7 +724,7 @@ HorizontalLayout { HorizontalLayout { id: layout move: Transition { - NumericAnimation { + NumberAnimation { properties: "x" ease: "easeOutBounce" } @@ -879,7 +873,7 @@ GridLayout { GridLayout { id: layout remove: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 1 @@ -904,7 +898,7 @@ GridLayout { GridLayout { id: layout add: Transition { - NumericAnimation { + NumberAnimation { target: layout.item properties: "opacity" from: 0 @@ -927,7 +921,7 @@ GridLayout { GridLayout { id: layout move: Transition { - NumericAnimation { + NumberAnimation { properties: "x,y" ease: "easeOutBounce" } diff --git a/src/declarative/fx/qfxlayouts.h b/src/declarative/fx/qfxlayouts.h index abf4bb2..5767bc5 100644 --- a/src/declarative/fx/qfxlayouts.h +++ b/src/declarative/fx/qfxlayouts.h @@ -128,7 +128,6 @@ protected Q_SLOTS: private: Q_DISABLE_COPY(QFxVerticalLayout) }; -QML_DECLARE_TYPE(QFxVerticalLayout) class Q_DECLARATIVE_EXPORT QFxHorizontalLayout: public QFxBaseLayout { @@ -140,7 +139,6 @@ protected Q_SLOTS: private: Q_DISABLE_COPY(QFxHorizontalLayout) }; -QML_DECLARE_TYPE(QFxHorizontalLayout) class Q_DECLARATIVE_EXPORT QFxGridLayout : public QFxBaseLayout { @@ -163,9 +161,13 @@ private: int _columns; Q_DISABLE_COPY(QFxGridLayout) }; -QML_DECLARE_TYPE(QFxGridLayout) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxVerticalLayout) +QML_DECLARE_TYPE(QFxHorizontalLayout) +QML_DECLARE_TYPE(QFxGridLayout) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxlayouts_p.h b/src/declarative/fx/qfxlayouts_p.h index 77b0ea1..5ffe70e 100644 --- a/src/declarative/fx/qfxlayouts_p.h +++ b/src/declarative/fx/qfxlayouts_p.h @@ -58,7 +58,7 @@ #include <QtCore/QString> #include <QtDeclarative/qfxlayouts.h> #include <QtDeclarative/qmlstate.h> - +#include <private/qmltransitionmanager_p.h> QT_BEGIN_NAMESPACE class QFxBaseLayoutPrivate : public QFxItemPrivate @@ -69,7 +69,7 @@ public: QFxBaseLayoutPrivate() : _ep(false), _componentComplete(false), _spacing(0), _margin(0), aut(QFxBaseLayout::None), moveTransition(0), addTransition(0), - removeTransition(0), _layoutItem(0), stateGroup(0), _movingItem(0) + removeTransition(0), _layoutItem(0), _movingItem(0) { } @@ -92,7 +92,8 @@ public: QSet<QFxItem *> _newItems; QSet<QFxItem *> _animated; QFxItem *_layoutItem; - QmlStateGroup *stateGroup; + QmlTransitionManager transitionManager; +// QmlStateGroup *stateGroup; QFxItem *_movingItem; }; diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index a8c0747..889cfdd 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -444,7 +444,7 @@ void QFxListViewPrivate::releaseItem(FxListItem *item) else QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized())); if (trackedItem == item) { - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged()); + const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); QObject::disconnect(trackedItem->item, notifier1, q, SLOT(trackedPositionChanged())); QObject::disconnect(trackedItem->item, notifier2, q, SLOT(trackedPositionChanged())); @@ -588,7 +588,7 @@ void QFxListViewPrivate::updateTrackedItem() if (highlight) item = highlight; - const char *notifier1 = orient == Qt::Vertical ? SIGNAL(topChanged()) : SIGNAL(leftChanged()); + const char *notifier1 = orient == Qt::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged()); const char *notifier2 = orient == Qt::Vertical ? SIGNAL(heightChanged()) : SIGNAL(widthChanged()); if (trackedItem && item != trackedItem) { diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h index 7fa2050..2a70af0 100644 --- a/src/declarative/fx/qfxlistview.h +++ b/src/declarative/fx/qfxlistview.h @@ -44,12 +44,12 @@ #include <QtDeclarative/qfxflickable.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxVisualItemModel; class QFxListViewPrivate; class Q_DECLARATIVE_EXPORT QFxListView : public QFxFlickable @@ -145,10 +145,10 @@ private Q_SLOTS: void destroyingItem(QFxItem *item); }; -QML_DECLARE_TYPE(QFxListView) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxListView) + QT_END_HEADER #endif diff --git a/src/declarative/fx/qfxmouseregion.h b/src/declarative/fx/qfxmouseregion.h index d8586e9..224dd54 100644 --- a/src/declarative/fx/qfxmouseregion.h +++ b/src/declarative/fx/qfxmouseregion.h @@ -86,7 +86,6 @@ private: int _ymax; Q_DISABLE_COPY(QFxDrag) }; -QML_DECLARE_TYPE(QFxDrag) class QFxMouseEvent; class QFxMouseRegionPrivate; @@ -154,10 +153,12 @@ private: Q_DISABLE_COPY(QFxMouseRegion) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxMouseRegion) }; -QML_DECLARE_TYPE(QFxMouseRegion) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxDrag) +QML_DECLARE_TYPE(QFxMouseRegion) + QT_END_HEADER #endif // QFXMOUSEREGION_H diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index d88f4f0..8323628 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -151,7 +151,6 @@ void QFxPaintedItem::setSmooth(bool smooth) Q_D(QFxPaintedItem); if (d->smooth == smooth) return; d->smooth = smooth; - clearCache(); update(); } @@ -272,7 +271,8 @@ void QFxPaintedItem::paintContents(QPainter &p) for (int i = 0; i < rects.count(); ++i) { const QRect &r = rects.at(i); QPixmap img(r.size()); - img.fill(Qt::transparent); + if (d->fillColor.isValid()) + img.fill(d->fillColor); { QPainter qp(&img); qp.translate(-r.x(),-r.y()); @@ -339,4 +339,30 @@ void QFxPaintedItem::setCacheSize(int pixels) d->max_imagecache_size = pixels; } +/*! + \property QFxPaintedItem::fillColor + + The color to be used to fill the item prior to calling drawContents(). + By default, this is Qt::transparent. + + Performance improvements can be achieved if subclasses call this with either an + invalid color (QColor()), or an appropriate solid color. +*/ +void QFxPaintedItem::setFillColor(const QColor& c) +{ + Q_D(QFxPaintedItem); + if (d->fillColor == c) + return; + d->fillColor = c; + emit fillColorChanged(); + update(); +} + +QColor QFxPaintedItem::fillColor() const +{ + Q_D(const QFxPaintedItem); + return d->fillColor; +} + + QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpainteditem.h b/src/declarative/fx/qfxpainteditem.h index 566e8a4..e74ead0 100644 --- a/src/declarative/fx/qfxpainteditem.h +++ b/src/declarative/fx/qfxpainteditem.h @@ -59,6 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxPaintedItem : public QFxItem Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize) Q_PROPERTY(bool smooth READ isSmooth WRITE setSmooth) + Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged) Q_PROPERTY(int cacheSize READ cacheSize WRITE setCacheSize) public: @@ -76,11 +77,17 @@ public: int cacheSize() const; void setCacheSize(int pixels); + QColor fillColor() const; + void setFillColor(const QColor&); + protected: QFxPaintedItem(QFxPaintedItemPrivate &dd, QFxItem *parent); virtual void drawContents(QPainter *p, const QRect &) = 0; +Q_SIGNALS: + void fillColorChanged(); + protected Q_SLOTS: void dirtyCache(const QRect &); void clearCache(); @@ -90,10 +97,11 @@ private: Q_DISABLE_COPY(QFxPaintedItem) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPaintedItem) }; -QML_DECLARE_TYPE(QFxPaintedItem) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPaintedItem) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxpainteditem_p.h b/src/declarative/fx/qfxpainteditem_p.h index 5c79cd5..06e80ff 100644 --- a/src/declarative/fx/qfxpainteditem_p.h +++ b/src/declarative/fx/qfxpainteditem_p.h @@ -63,7 +63,7 @@ class QFxPaintedItemPrivate : public QFxItemPrivate public: QFxPaintedItemPrivate() - : max_imagecache_size(100000), smooth(false) + : max_imagecache_size(100000), smooth(false), fillColor(Qt::transparent) { } @@ -80,6 +80,7 @@ public: int max_imagecache_size; bool smooth; QSize contentsSize; + QColor fillColor; }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxpath.cpp b/src/declarative/fx/qfxpath.cpp index ee2a272..a1b6032 100644 --- a/src/declarative/fx/qfxpath.cpp +++ b/src/declarative/fx/qfxpath.cpp @@ -41,7 +41,7 @@ #include "qfxpath.h" #include "qfxpath_p.h" -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <private/qbezier_p.h> #include <QSet> diff --git a/src/declarative/fx/qfxpath.h b/src/declarative/fx/qfxpath.h index 39b9d01..04d24c6 100644 --- a/src/declarative/fx/qfxpath.h +++ b/src/declarative/fx/qfxpath.h @@ -61,7 +61,6 @@ public: Q_SIGNALS: void changed(); }; -QML_DECLARE_TYPE(QFxPathElement) class Q_DECLARATIVE_EXPORT QFxPathAttribute : public QFxPathElement { @@ -83,7 +82,6 @@ private: QString _name; qreal _value; }; -QML_DECLARE_TYPE(QFxPathAttribute) class Q_DECLARATIVE_EXPORT QFxCurve : public QFxPathElement { @@ -106,7 +104,6 @@ private: qreal _x; qreal _y; }; -QML_DECLARE_TYPE(QFxCurve) class Q_DECLARATIVE_EXPORT QFxPathLine : public QFxCurve { @@ -116,7 +113,6 @@ public: void addToPath(QPainterPath &path); }; -QML_DECLARE_TYPE(QFxPathLine) class Q_DECLARATIVE_EXPORT QFxPathQuad : public QFxCurve { @@ -139,7 +135,6 @@ private: qreal _controlX; qreal _controlY; }; -QML_DECLARE_TYPE(QFxPathQuad) class Q_DECLARATIVE_EXPORT QFxPathCubic : public QFxCurve { @@ -172,7 +167,6 @@ private: int _control2X; int _control2Y; }; -QML_DECLARE_TYPE(QFxPathCubic) class Q_DECLARATIVE_EXPORT QFxPathPercent : public QFxPathElement { @@ -187,7 +181,6 @@ public: private: qreal _value; }; -QML_DECLARE_TYPE(QFxPathPercent) class QFxPathPrivate; class Q_DECLARATIVE_EXPORT QFxPath : public QObject, public QmlParserStatus @@ -249,9 +242,18 @@ private: Q_DISABLE_COPY(QFxPath) Q_DECLARE_PRIVATE(QFxPath) }; -QML_DECLARE_TYPE(QFxPath) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPathElement) +QML_DECLARE_TYPE(QFxPathAttribute) +QML_DECLARE_TYPE(QFxCurve) +QML_DECLARE_TYPE(QFxPathLine) +QML_DECLARE_TYPE(QFxPathQuad) +QML_DECLARE_TYPE(QFxPathCubic) +QML_DECLARE_TYPE(QFxPathPercent) +QML_DECLARE_TYPE(QFxPath) + QT_END_HEADER + #endif // QFXPATH_H diff --git a/src/declarative/fx/qfxpathview.h b/src/declarative/fx/qfxpathview.h index a40f1f2..9d91006 100644 --- a/src/declarative/fx/qfxpathview.h +++ b/src/declarative/fx/qfxpathview.h @@ -127,10 +127,11 @@ private: Q_DISABLE_COPY(QFxPathView) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxPathView) }; -QML_DECLARE_TYPE(QFxPathView) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPathView) + QT_END_HEADER #endif // QFXPATHVIEW_H diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h index fea207f..f996d1d 100644 --- a/src/declarative/fx/qfxpathview_p.h +++ b/src/declarative/fx/qfxpathview_p.h @@ -58,7 +58,6 @@ #include "qfxitem_p.h" #include "qfxvisualitemmodel.h" #include "qml.h" -#include "qmltimelinevalueproxy.h" #include "private/qmlanimation_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp index f2c6217..ac8a701 100644 --- a/src/declarative/fx/qfxpixmap.cpp +++ b/src/declarative/fx/qfxpixmap.cpp @@ -43,7 +43,7 @@ #include <QHash> #include <QNetworkReply> #include <QPixmapCache> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <QtDeclarative/qmlengine.h> #include <QFile> #include <QtCore/qdebug.h> diff --git a/src/declarative/fx/qfxrect.cpp b/src/declarative/fx/qfxrect.cpp index a068fd4..2ad8536 100644 --- a/src/declarative/fx/qfxrect.cpp +++ b/src/declarative/fx/qfxrect.cpp @@ -55,9 +55,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient) \brief The QFxPen class provides a pen used for drawing rect borders on a QFxView. By default, the pen is invalid and nothing is drawn. You must either set a color (then the default - width is 0) or a width (then the default color is black). + width is 1) or a width (then the default color is black). - A width of 0 indicates a cosmetic pen, a single-pixel line on the border of the item being painted. + A width of 1 indicates is a single-pixel line on the border of the item being painted. Example: \qml @@ -68,9 +68,9 @@ QML_DEFINE_TYPE(QFxGradient,Gradient) /*! \property QFxPen::width \brief the width of the pen. - A width of 0 is a single-pixel line on the border of the item being painted. + A width of 1 is a single-pixel line on the border of the item being painted. - If the width is less than 0 the pen is considered invalid and won't be used. + If the width is less than 1 the pen is considered invalid and won't be used. */ /*! @@ -103,18 +103,18 @@ void QFxPen::setColor(const QColor &c) \brief the width of the pen. \qml - // rect with green border using hexidecimal notation Rect { pen.width: 4 } \endqml - A width of 0 creates a thin line. For no line, use a negative width or a transparent color. + A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. - Odd pen widths generally lead to half-pixel painting. + To keep the border smooth (rather than blurry), odd pen widths cause the rect to be painted at + a half-pixel offset; */ void QFxPen::setWidth(int w) { _width = w; - _valid = (_width < 0) ? false : true; + _valid = (_width < 1) ? false : true; emit updated(); } @@ -472,7 +472,10 @@ void QFxRect::generateRoundedRect() p.setPen(Qt::NoPen); } p.setBrush(d->color); - p.drawRoundedRect((pw+1)/2, (pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2, d->radius, d->radius); + if (pw%2) + p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius); + else + p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius); } } @@ -487,12 +490,16 @@ void QFxRect::generateBorderedRect() p.setRenderHint(QPainter::Antialiasing); if (d->pen && d->pen->isValid()) { QPen pn(QColor(d->pen->color()), d->pen->width()); + pn.setJoinStyle(Qt::MiterJoin); p.setPen(pn); } else { p.setPen(Qt::NoPen); } p.setBrush(d->color); - p.drawRect(qreal(pw+1)/2, qreal(pw+1)/2, d->rectImage.width()-(pw+1)/2*2, d->rectImage.height()-(pw+1)/2*2); + if (pw%2) + p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1))); + else + p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw)); } } @@ -512,7 +519,7 @@ void QFxRect::drawRect(QPainter &p) if (d->gradient && d->gradient->gradient() /*|| p.usingQt() */) { // XXX This path is still slower than the image path // Image path won't work for gradients though - QPainter::RenderHints oldHints = p.renderHints(); + bool oldAA = p.testRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing); if (d->pen && d->pen->isValid()) { QPen pn(QColor(d->pen->color()), d->pen->width()); @@ -525,7 +532,7 @@ void QFxRect::drawRect(QPainter &p) p.drawRoundedRect(0, 0, width(), height(), d->radius, d->radius); else p.drawRect(0, 0, width(), height()); - p.setRenderHints(oldHints); + p.setRenderHint(QPainter::Antialiasing, oldAA); } else { int offset = 0; const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0; diff --git a/src/declarative/fx/qfxrect.h b/src/declarative/fx/qfxrect.h index 46f918b..7790af1 100644 --- a/src/declarative/fx/qfxrect.h +++ b/src/declarative/fx/qfxrect.h @@ -59,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QFxPen : public QObject Q_PROPERTY(QColor color READ color WRITE setColor) public: QFxPen(QObject *parent=0) - : QObject(parent), _width(0), _color("#000000"), _valid(false) + : QObject(parent), _width(1), _color("#000000"), _valid(false) {} int width() const { return _width; } @@ -78,7 +78,6 @@ private: QColor _color; bool _valid; }; -QML_DECLARE_TYPE(QFxPen) class Q_DECLARATIVE_EXPORT QFxGradientStop : public QObject { @@ -103,7 +102,6 @@ private: qreal m_position; QColor m_color; }; -QML_DECLARE_TYPE(QFxGradientStop) class Q_DECLARATIVE_EXPORT QFxGradient : public QObject { @@ -131,7 +129,6 @@ private: mutable QGradient *m_gradient; friend class QFxGradientStop; }; -QML_DECLARE_TYPE(QFxGradient) class QFxRectPrivate; class Q_DECLARATIVE_EXPORT QFxRect : public QFxItem @@ -178,10 +175,14 @@ private: Q_DISABLE_COPY(QFxRect) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRect) }; -QML_DECLARE_TYPE(QFxRect) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxPen) +QML_DECLARE_TYPE(QFxGradientStop) +QML_DECLARE_TYPE(QFxGradient) +QML_DECLARE_TYPE(QFxRect) + QT_END_HEADER #endif // QFXRECT_H diff --git a/src/declarative/fx/qfxrepeater.h b/src/declarative/fx/qfxrepeater.h index 2c903d1..6f950d3 100644 --- a/src/declarative/fx/qfxrepeater.h +++ b/src/declarative/fx/qfxrepeater.h @@ -44,12 +44,12 @@ #include <QtDeclarative/qfxitem.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QFxRepeaterPrivate; class Q_DECLARATIVE_EXPORT QFxRepeater : public QFxItem { @@ -80,10 +80,11 @@ private: Q_DISABLE_COPY(QFxRepeater) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxRepeater) }; -QML_DECLARE_TYPE(QFxRepeater) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxRepeater) + QT_END_HEADER -#endif // _QFXREPEATER_H_ +#endif // QFXREPEATER_H diff --git a/src/declarative/fx/qfxscalegrid.h b/src/declarative/fx/qfxscalegrid.h index 4a9a72f..986bcda 100644 --- a/src/declarative/fx/qfxscalegrid.h +++ b/src/declarative/fx/qfxscalegrid.h @@ -109,10 +109,11 @@ private: int _b; QString _pix; }; -QML_DECLARE_TYPE(QFxScaleGrid) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxScaleGrid) + QT_END_HEADER + #endif // QFXSCALEGRID_H diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 1f6890d..8618b87 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -43,8 +43,7 @@ #include "qfxtext_p.h" #include <private/qtextcontrol_p.h> - -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <QTextLayout> #include <QTextLine> #include <QTextDocument> @@ -158,7 +157,7 @@ void QFxText::setText(const QString &n) if (d->text == n) return; - d->richText = Qt::mightBeRichText(n); // ### what's the cost? + d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n)); if (d->richText) { if (!d->doc) { @@ -166,7 +165,7 @@ void QFxText::setText(const QString &n) d->control->setTextInteractionFlags(Qt::TextBrowserInteraction); d->doc = d->control->document(); d->doc->setDocumentMargin(0); - } + } d->doc->setHtml(n); } @@ -373,6 +372,77 @@ void QFxText::setWrap(bool w) } /*! + \qmlproperty enumeration Text::textFormat + + The way the text property should be displayed. + + Supported text formats are \c AutoText, \c PlainText and \c RichText. + + The default is AutoText. If the text format is AutoText the text element + will automatically determine whether the text should be treated as + rich text. This determination is made using Qt::mightBeRichText(). + + \table + \row + \o + \qml +VerticalLayout { + TextEdit { + font.size: 24 + text: "<b>Hello</b> <i>World!</i>" + } + TextEdit { + font.size: 24 + textFormat: "RichText" + text: "<b>Hello</b> <i>World!</i>" + } + TextEdit { + font.size: 24 + textFormat: "PlainText" + text: "<b>Hello</b> <i>World!</i>" + } +} + \endqml + \o \image declarative-textformat.png + \endtable +*/ + +QFxText::TextFormat QFxText::textFormat() const +{ + Q_D(const QFxText); + return d->format; +} + +void QFxText::setTextFormat(TextFormat format) +{ + Q_D(QFxText); + if (format == d->format) + return; + bool wasRich = d->richText; + d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text)); + + if (wasRich && !d->richText) { + //### delete control? (and vice-versa below) + d->imgDirty = true; + d->updateSize(); + update(); + } else if (!wasRich && d->richText) { + if (!d->doc) + { + d->control = new QTextControl(this); + d->control->setTextInteractionFlags(Qt::TextBrowserInteraction); + d->doc = d->control->document(); + d->doc->setDocumentMargin(0); + } + d->doc->setHtml(d->text); + d->imgDirty = true; + d->updateSize(); + update(); + } + d->format = format; +} + +/*! \qmlproperty Qt::TextElideMode Text::elide Set this property to elide parts of the text fit to the Text item's width. @@ -686,6 +756,21 @@ void QFxTextPrivate::checkImgCache() imgDirty = false; } +bool QFxText::smoothTransform() const +{ + Q_D(const QFxText); + return d->smooth; +} + +void QFxText::setSmoothTransform(bool s) +{ + Q_D(QFxText); + if (d->smooth == s) + return; + d->smooth = s; + update(); +} + void QFxText::paintContents(QPainter &p) { Q_D(QFxText); @@ -693,6 +778,11 @@ void QFxText::paintContents(QPainter &p) if (d->imgCache.isNull()) return; + bool oldAA = p.testRenderHint(QPainter::Antialiasing); + bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform); + if (d->smooth) + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); + int w = width(); int h = height(); @@ -733,6 +823,11 @@ void QFxText::paintContents(QPainter &p) p.drawPixmap(x, y, d->imgCache); if (needClip) p.restore(); + + if (d->smooth) { + p.setRenderHint(QPainter::Antialiasing, oldAA); + p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); + } } void QFxText::componentComplete() diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index 2358fe3..b7ec333 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -58,17 +58,20 @@ class Q_DECLARATIVE_EXPORT QFxText : public QFxItem Q_ENUMS(HAlignment) Q_ENUMS(VAlignment) Q_ENUMS(TextStyle) + Q_ENUMS(TextFormat) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QmlFont *font READ font) + Q_PROPERTY(QmlFont *font READ font CONSTANT) Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(TextStyle style READ style WRITE setStyle) Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor) Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) Q_PROPERTY(bool wrap READ wrap WRITE setWrap) + Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) Q_PROPERTY(Qt::TextElideMode elide READ elideMode WRITE setElideMode) Q_PROPERTY(QString activeLink READ activeLink) + Q_PROPERTY(bool smooth READ smoothTransform WRITE setSmoothTransform) public: QFxText(QFxItem *parent=0); @@ -84,6 +87,9 @@ public: Outline, Raised, Sunken }; + enum TextFormat { AutoText, + PlainText, + RichText }; QString text() const; void setText(const QString &); @@ -108,11 +114,17 @@ public: bool wrap() const; void setWrap(bool w); + TextFormat textFormat() const; + void setTextFormat(TextFormat format); + Qt::TextElideMode elideMode() const; void setElideMode(Qt::TextElideMode); QString activeLink() const; + bool smoothTransform() const; + void setSmoothTransform(bool); + virtual QString propertyInfo() const; void paintContents(QPainter &p); @@ -138,10 +150,11 @@ private: Q_DISABLE_COPY(QFxText) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxText) }; -QML_DECLARE_TYPE(QFxText) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxText) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxtext_p.h b/src/declarative/fx/qfxtext_p.h index e0b1909..6692d9e 100644 --- a/src/declarative/fx/qfxtext_p.h +++ b/src/declarative/fx/qfxtext_p.h @@ -71,7 +71,8 @@ public: QFxTextPrivate() : _font(0), color((QRgb)0), style(QFxText::Normal), imgDirty(true), hAlign(QFxText::AlignLeft), vAlign(QFxText::AlignTop), elideMode(Qt::ElideNone), - dirty(false), wrap(false), richText(false), singleline(false), control(0), doc(0) + dirty(false), wrap(false), smooth(false), richText(false), singleline(false), control(0), doc(0), + format(QFxText::AutoText) { } @@ -118,12 +119,14 @@ public: Qt::TextElideMode elideMode; bool dirty; bool wrap; + bool smooth; bool richText; bool singleline; QTextControl *control; QTextDocument *doc; QTextLayout layout; QSize cachedLayoutSize; + QFxText::TextFormat format; }; QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 7a42bdf..cdd94b5 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -41,10 +41,8 @@ #include <qfxtextedit.h> #include "qfxtextedit_p.h" - #include <private/qtextcontrol_p.h> - -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include "qfxevents_p.h" #include <QTextLayout> #include <QTextLine> @@ -175,7 +173,7 @@ void QFxTextEdit::setText(const QString &text) Supported text formats are \c AutoText, \c PlainText and \c RichText. The default is AutoText. If the text format is AutoText the text edit - edit will automatically determine whether the text should be treated as + will automatically determine whether the text should be treated as rich text. This determination is made using Qt::mightBeRichText(). \table @@ -320,6 +318,36 @@ void QFxTextEdit::setHighlightColor(const QColor &color) } /*! + \qmlproperty color TextEdit::highlightedTextColor + + The highlighted text color, used in selections. +*/ + +/*! + \property QFxTextEdit::highlightedTextColor + \brief the text edit's default highlighted text color +*/ +QColor QFxTextEdit::highlightedTextColor() const +{ + Q_D(const QFxTextEdit); + return d->highlightColor; +} + +void QFxTextEdit::setHighlightedTextColor(const QColor &color) +{ + Q_D(QFxTextEdit); + if (d->highlightedTextColor == color) + return; + + clearCache(); + d->highlightedTextColor = color; + QPalette pal = d->control->palette(); + pal.setColor(QPalette::HighlightedText, color); + d->control->setPalette(pal); + update(); +} + +/*! \qmlproperty enumeration TextEdit::hAlign \qmlproperty enumeration TextEdit::vAlign @@ -406,7 +434,7 @@ void QFxTextEdit::setWrap(bool w) } /*! - \property QFxTextEdit::cursorVisible + \qmlproperty TextEdit::cursorVisible \brief If true the text edit shows a cursor. This property is set and unset when the text edit gets focus, but it can also @@ -431,6 +459,164 @@ void QFxTextEdit::setCursorVisible(bool on) } /*! + \qmlproperty TextEdit::cursorPosition + \brief The position of the cursor in the TextEdit. +*/ +int QFxTextEdit::cursorPosition() const +{ + Q_D(const QFxTextEdit); + return d->control->textCursor().position(); +} + +void QFxTextEdit::setCursorPosition(int pos) +{ + Q_D(QFxTextEdit); + QTextCursor cursor = d->control->textCursor(); + if (cursor.position() == pos) + return; + cursor.setPosition(pos); + d->control->setTextCursor(cursor); +} + +/*! + \qmlproperty TextEdit::cursorDelegate + \brief The delegate for the cursor in the TextEdit. + + If you set a cursorDelegate for a TextEdit, this delegate will be used for + drawing the cursor instead of the standard cursor. An instance of the + delegate will be created and managed by the text edit when a cursor is + needed, and the x and y properties of delegate instance will be set so as + to be one pixel before the top left of the current character. + + Note that the root item of the delegate component must be a QFxItem or + QFxItem derived item. +*/ +QmlComponent* QFxTextEdit::cursorDelegate() const +{ + Q_D(const QFxTextEdit); + return d->cursorComponent; +} + +void QFxTextEdit::setCursorDelegate(QmlComponent* c) +{ + Q_D(QFxTextEdit); + if(d->cursorComponent){ + delete d->cursorComponent; + if(d->cursor){ + disconnect(d->control, SIGNAL(cursorPositionChanged()), + this, SLOT(moveCursorDelegate())); + d->control->setCursorWidth(-1); + dirtyCache(cursorRect()); + delete d->cursor; + d->cursor = 0; + } + } + d->cursorComponent = c; + if(c && c->isReady()){ + loadCursorDelegate(); + }else{ + if(c) + connect(c, SIGNAL(statusChanged()), + this, SLOT(loadCursorDelegate())); + } +} + +void QFxTextEdit::loadCursorDelegate() +{ + Q_D(QFxTextEdit); + if(d->cursorComponent->isLoading()) + return; + d->cursor = qobject_cast<QFxItem*>(d->cursorComponent->create(qmlContext(this))); + if(d->cursor){ + connect(d->control, SIGNAL(cursorPositionChanged()), + this, SLOT(moveCursorDelegate())); + d->control->setCursorWidth(0); + dirtyCache(cursorRect()); + d->cursor->setItemParent(this); + d->cursor->setHeight(QFontMetrics(d->font.font()).height()); + moveCursorDelegate(); + }else{ + qWarning() << "Error loading cursor delegate for TextEdit:" + objectName(); + } +} + +/*! + \qmlproperty int TextEdit::selectionStart + + The cursor position before the first character in the current selection. + Setting this and selectionEnd allows you to specify a selection in the + text edit. + + Note that if selectionStart == selectionEnd then there is no current + selection. If you attempt to set selectionStart to a value outside of + the current text, selectionStart will not be changed. + + \sa selectionEnd, cursorPosition, selectedText +*/ +int QFxTextEdit::selectionStart() const +{ + Q_D(const QFxTextEdit); + return d->control->textCursor().selectionStart(); +} + +void QFxTextEdit::setSelectionStart(int s) +{ + Q_D(QFxTextEdit); + if(d->lastSelectionStart == s || s < 0 || s > text().length()) + return; + d->lastSelectionStart = s; + d->updateSelection();// Will emit the relevant signals +} + +/*! + \qmlproperty int TextEdit::selectionEnd + + The cursor position after the last character in the current selection. + Setting this and selectionStart allows you to specify a selection in the + text edit. + + Note that if selectionStart == selectionEnd then there is no current + selection. If you attempt to set selectionEnd to a value outside of + the current text, selectionEnd will not be changed. + + \sa selectionStart, cursorPosition, selectedText +*/ +int QFxTextEdit::selectionEnd() const +{ + Q_D(const QFxTextEdit); + return d->control->textCursor().selectionEnd(); +} + +void QFxTextEdit::setSelectionEnd(int s) +{ + Q_D(QFxTextEdit); + if(d->lastSelectionEnd == s || s < 0 || s > text().length()) + return; + d->lastSelectionEnd = s; + d->updateSelection();// Will emit the relevant signals +} + +/*! + \qmlproperty string TextEdit::selectedText + + This read-only property provides the text currently selected in the + text edit. + + It is equivalent to the following snippet, but is faster and easier + to use. + \code + //myTextEdit is the id of the TextEdit + myTextEdit.text.toString().substring(myTextEdit.selectionStart, + myTextEdit.selectionEnd); + \endcode +*/ +QString QFxTextEdit::selectedText() const +{ + Q_D(const QFxTextEdit); + return d->control->textCursor().selectedText(); +} + +/*! \qmlproperty bool TextEdit::focusOnPress Whether the TextEdit should gain focus on a mouse press. By default this is @@ -820,6 +1006,10 @@ void QFxTextEdit::fontChanged() Q_D(QFxTextEdit); clearCache(); d->document->setDefaultFont(d->font.font()); + if(d->cursor){ + d->cursor->setHeight(QFontMetrics(d->font.font()).height()); + moveCursorDelegate(); + } updateSize(); emit update(); } @@ -846,6 +1036,9 @@ void QFxTextEditPrivate::init() QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF))); QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged())); + QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); + QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers())); + QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers())); QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged())); document = control->document(); @@ -863,6 +1056,51 @@ void QFxTextEdit::q_textChanged() emit textChanged(text()); } +void QFxTextEdit::moveCursorDelegate() +{ + Q_D(QFxTextEdit); + if(!d->cursor) + return; + QRectF cursorRect = d->control->cursorRect(); + d->cursor->setX(cursorRect.x()); + d->cursor->setY(cursorRect.y()); +} + +void QFxTextEditPrivate::updateSelection() +{ + Q_Q(QFxTextEdit); + QTextCursor cursor = control->textCursor(); + bool startChange = (lastSelectionStart != cursor.selectionStart()); + bool endChange = (lastSelectionEnd != cursor.selectionEnd()); + //### Is it worth calculating a more minimal set of movements? + cursor.beginEditBlock(); + cursor.setPosition(lastSelectionStart, QTextCursor::MoveAnchor); + cursor.setPosition(lastSelectionEnd, QTextCursor::KeepAnchor); + cursor.endEditBlock(); + control->setTextCursor(cursor); + if(startChange) + q->selectionStartChanged(); + if(endChange) + q->selectionEndChanged(); + startChange = (lastSelectionStart != control->textCursor().selectionStart()); + endChange = (lastSelectionEnd != control->textCursor().selectionEnd()); + if(startChange || endChange) + qWarning() << "QFxTextEditPrivate::updateSelection() has failed you."; +} + +void QFxTextEdit::updateSelectionMarkers() +{ + Q_D(QFxTextEdit); + if(d->lastSelectionStart != d->control->textCursor().selectionStart()){ + d->lastSelectionStart = d->control->textCursor().selectionStart(); + emit selectionStartChanged(); + } + if(d->lastSelectionEnd != d->control->textCursor().selectionEnd()){ + d->lastSelectionEnd = d->control->textCursor().selectionEnd(); + emit selectionEndChanged(); + } +} + //### 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 QFxTextEdit::updateSize() diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index 93540a4..77fac29 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -70,6 +70,7 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QColor color READ color WRITE setColor) Q_PROPERTY(QColor highlightColor READ highlightColor WRITE setHighlightColor) + Q_PROPERTY(QColor highlightedTextColor READ highlightedTextColor WRITE setHighlightedTextColor) Q_PROPERTY(QmlFont * font READ font) Q_PROPERTY(HAlignment hAlign READ hAlign WRITE setHAlign) Q_PROPERTY(VAlignment vAlign READ vAlign WRITE setVAlign) @@ -77,6 +78,11 @@ class Q_DECLARATIVE_EXPORT QFxTextEdit : public QFxPaintedItem Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat) Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly) Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible) + Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) + Q_PROPERTY(QmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate) + Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged) + Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) + Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged) Q_PROPERTY(bool focusOnPress READ focusOnPress WRITE setFocusOnPress) Q_PROPERTY(bool preserveSelection READ preserveSelection WRITE setPreserveSelection) Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin) @@ -117,6 +123,9 @@ public: QColor highlightColor() const; void setHighlightColor(const QColor &c); + QColor highlightedTextColor() const; + void setHighlightedTextColor(const QColor &c); + HAlignment hAlign() const; void setHAlign(HAlignment align); @@ -129,6 +138,20 @@ public: bool isCursorVisible() const; void setCursorVisible(bool on); + int cursorPosition() const; + void setCursorPosition(int pos); + + QmlComponent* cursorDelegate() const; + void setCursorDelegate(QmlComponent*); + + int selectionStart() const; + void setSelectionStart(int); + + int selectionEnd() const; + void setSelectionEnd(int); + + QString selectedText() const; + bool focusOnPress() const; void setFocusOnPress(bool on); @@ -163,6 +186,9 @@ public: Q_SIGNALS: void textChanged(const QString &); void cursorPositionChanged(); + void selectionStartChanged(); + void selectionEndChanged(); + void selectionChanged(); public Q_SLOTS: void selectAll(); @@ -171,6 +197,9 @@ private Q_SLOTS: void fontChanged(); void updateImgCache(const QRectF &rect); void q_textChanged(); + void updateSelectionMarkers(); + void moveCursorDelegate(); + void loadCursorDelegate(); private: void updateSize(); @@ -201,10 +230,11 @@ private: Q_DISABLE_COPY(QFxTextEdit) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxTextEdit) }; -QML_DECLARE_TYPE(QFxTextEdit) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxTextEdit) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxtextedit_p.h b/src/declarative/fx/qfxtextedit_p.h index 403bd18..267e48b 100644 --- a/src/declarative/fx/qfxtextedit_p.h +++ b/src/declarative/fx/qfxtextedit_p.h @@ -69,8 +69,9 @@ class QFxTextEditPrivate : public QFxPaintedItemPrivate public: QFxTextEditPrivate() : font(0), color("black"), imgDirty(true), hAlign(QFxTextEdit::AlignLeft), vAlign(QFxTextEdit::AlignTop), - dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false), preserveSelection(true), - textMargin(0.0), format(QFxTextEdit::AutoText), document(0) + dirty(false), wrap(false), richText(false), cursorVisible(false), focusOnPress(false), + preserveSelection(true), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), + cursor(0), cursorComponent(0), format(QFxTextEdit::AutoText), document(0) { } @@ -78,11 +79,13 @@ public: void updateDefaultTextOption(); void relayoutDocument(); + void updateSelection(); QString text; QmlFont font; QColor color; QColor highlightColor; + QColor highlightedTextColor; QString style; QColor styleColor; bool imgDirty; @@ -97,6 +100,10 @@ public: bool focusOnPress; bool preserveSelection; qreal textMargin; + int lastSelectionStart; + int lastSelectionEnd; + QmlComponent* cursorComponent; + QFxItem* cursor; QFxTextEdit::TextFormat format; QTextDocument *document; QTextControl *control; diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index 8973295..f08d830 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -46,11 +46,11 @@ #include <math.h> #ifndef M_PI - -QT_BEGIN_NAMESPACE #define M_PI 3.14159265358979323846 #endif +QT_BEGIN_NAMESPACE + QML_DEFINE_NOCREATE_TYPE(QFxTransform); /*! @@ -84,6 +84,125 @@ void QFxTransform::update() } /*! + \qmlclass Scale + \brief A Scale object provides a way to scale an Item. + + The scale object gives more control over scaling than using Item's scale property. Specifically, + it allows a different scale for the x and y axes, and allows the scale to be relative to an + arbitrary point. + + The following example scales the X axis of the Rect, relative to its interior point 25, 25: + \qml + Rect { + width: 100; height: 100 + color: "blue" + transform: Scale { originX: 25; originY: 25; xScale: 3} + } + \endqml +*/ + +QFxScale::QFxScale(QObject *parent) +: QFxTransform(parent), _originX(0), _originY(0), _xScale(1), _yScale(1), _dirty(true) +{ +} + +QFxScale::~QFxScale() +{ +} + +/*! + \qmlproperty real Scale::originX + \qmlproperty real Scale::originY + + The origin point for the scale. The scale will be relative to this point. +*/ +qreal QFxScale::originX() const +{ + return _originX; +} + +void QFxScale::setOriginX(qreal ox) +{ + _originX = ox; + update(); +} + +qreal QFxScale::originY() const +{ + return _originY; +} + +void QFxScale::setOriginY(qreal oy) +{ + _originY = oy; + update(); +} + +/*! + \qmlproperty real Scale::xScale + + The scaling factor for the X axis. +*/ +qreal QFxScale::xScale() const +{ + return _xScale; +} + +void QFxScale::setXScale(qreal scale) +{ + if (_xScale == scale) + return; + _xScale = scale; + update(); + emit scaleChanged(); +} + +/*! + \qmlproperty real Scale::yScale + + The scaling factor for the Y axis. +*/ +qreal QFxScale::yScale() const +{ + return _yScale; +} + +void QFxScale::setYScale(qreal scale) +{ + if (_yScale == scale) + return; + _yScale = scale; + update(); + emit scaleChanged(); +} + +bool QFxScale::isIdentity() const +{ + return (_xScale == 1. && _yScale == 1.); +} + +QTransform QFxScale::transform() const +{ + if (_dirty) { + _transform = QTransform(); + _dirty = false; + _transform.translate(_originX, _originY); + _transform.scale(_xScale, _yScale); + _transform.translate(-_originX, -_originY); + } + return _transform; +} + +void QFxScale::update() +{ + _dirty = true; + QFxTransform::update(); +} + +QML_DEFINE_TYPE(QFxScale, Scale) + + +/*! \qmlclass Axis \brief A Axis object defines an axis that can be used for rotation or translation. diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h index a549b30..fb49294 100644 --- a/src/declarative/fx/qfxtransform.h +++ b/src/declarative/fx/qfxtransform.h @@ -64,7 +64,48 @@ public: virtual bool isIdentity() const; virtual QTransform transform() const; }; -QML_DECLARE_TYPE(QFxTransform) + +class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform +{ + Q_OBJECT + + Q_PROPERTY(qreal originX READ originX WRITE setOriginX) + Q_PROPERTY(qreal originY READ originY WRITE setOriginY) + Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged()) + Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged()) +public: + QFxScale(QObject *parent=0); + ~QFxScale(); + + qreal originX() const; + void setOriginX(qreal); + + qreal originY() const; + void setOriginY(qreal); + + qreal xScale() const; + void setXScale(qreal); + + qreal yScale() const; + void setYScale(qreal); + + virtual bool isIdentity() const; + virtual QTransform transform() const; + +Q_SIGNALS: + void scaleChanged(); + +private Q_SLOTS: + void update(); +private: + qreal _originX; + qreal _originY; + qreal _xScale; + qreal _yScale; + + mutable bool _dirty; + mutable QTransform _transform; +}; class Q_DECLARATIVE_EXPORT QFxAxis : public QObject { @@ -104,7 +145,6 @@ private: qreal _endY; qreal _endZ; }; -QML_DECLARE_TYPE(QFxAxis) class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform { @@ -142,7 +182,6 @@ private: mutable bool _dirty; mutable QTransform _transform; }; -QML_DECLARE_TYPE(QFxRotation) class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform { @@ -171,7 +210,6 @@ private: mutable bool _dirty; mutable QTransform _transform; }; -QML_DECLARE_TYPE(QFxRotation3D) class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform { @@ -200,7 +238,6 @@ private: mutable bool _dirty; mutable QTransform _transform; }; -QML_DECLARE_TYPE(QFxTranslation3D) class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform { @@ -237,7 +274,6 @@ private: qreal _angle; qreal _aspect; }; -QML_DECLARE_TYPE(QFxPerspective) class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform { @@ -303,10 +339,18 @@ private: QSizeF s; QPointF p1, p2, p3, p4; }; -QML_DECLARE_TYPE(QFxSquish) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxTransform) +QML_DECLARE_TYPE(QFxScale) +QML_DECLARE_TYPE(QFxAxis) +QML_DECLARE_TYPE(QFxRotation) +QML_DECLARE_TYPE(QFxRotation3D) +QML_DECLARE_TYPE(QFxTranslation3D) +QML_DECLARE_TYPE(QFxPerspective) +QML_DECLARE_TYPE(QFxSquish) + QT_END_HEADER #endif // QFXTRANSFORM_H diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index 7d260ab..eb10df3 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -53,9 +53,9 @@ #include "qfxvisualitemmodel.h" #include <QtCore/qdebug.h> +QML_DECLARE_TYPE(QListModelInterface) QT_BEGIN_NAMESPACE -QML_DECLARE_TYPE(QListModelInterface) class QFxVisualItemModelParts; class QFxVisualItemModelData; diff --git a/src/declarative/fx/qfxvisualitemmodel.h b/src/declarative/fx/qfxvisualitemmodel.h index 968cc2e..551c08d 100644 --- a/src/declarative/fx/qfxvisualitemmodel.h +++ b/src/declarative/fx/qfxvisualitemmodel.h @@ -70,7 +70,7 @@ class Q_DECLARATIVE_EXPORT QFxVisualItemModel : public QObject Q_PROPERTY(QVariant model READ model WRITE setModel) Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) Q_PROPERTY(QString part READ part WRITE setPart) - Q_PROPERTY(QObject *parts READ parts) + Q_PROPERTY(QObject *parts READ parts CONSTANT) Q_CLASSINFO("DefaultProperty", "delegate") public: QFxVisualItemModel(); @@ -123,10 +123,11 @@ private Q_SLOTS: private: Q_DISABLE_COPY(QFxVisualItemModel) }; -QML_DECLARE_TYPE(QFxVisualItemModel) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxVisualItemModel) + QT_END_HEADER #endif // QFXVISUALITEMMODEL_H diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index ec7c548..da10004 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -418,12 +418,6 @@ void QFxWebView::setInteractive(bool i) emit interactiveChanged(); } -void QFxWebView::updateCacheForVisibility() -{ - if (!isVisible()) - clearCache(); -} - void QFxWebView::expandToWebPage() { Q_D(QFxWebView); @@ -875,7 +869,6 @@ void QFxWebView::setPage(QWebPage *page) d->idealheight>0 ? d->idealheight : -1)); d->page->mainFrame()->setScrollBarPolicy(Qt::Horizontal,Qt::ScrollBarAlwaysOff); d->page->mainFrame()->setScrollBarPolicy(Qt::Vertical,Qt::ScrollBarAlwaysOff); - connect(this,SIGNAL(visibleChanged()),this,SLOT(updateCacheForVisibility())); connect(d->page,SIGNAL(repaintRequested(QRect)),this,SLOT(paintPage(QRect))); connect(d->page->mainFrame(),SIGNAL(urlChanged(QUrl)),this,SIGNAL(urlChanged())); connect(d->page->mainFrame(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString))); @@ -1047,6 +1040,6 @@ QObject *QFxWebPage::createPlugin(const QString &, const QUrl &url, const QStrin return new QWidget_Dummy_Plugin(comp,view(),paramNames,paramValues); } -#include "qfxwebview.moc" - QT_END_NAMESPACE + +#include "qfxwebview.moc" diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index d4b70d3..ab20281 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -49,14 +49,14 @@ #include <QtNetwork/qnetworkaccessmanager.h> #include <QtWebKit/QWebPage> - QT_BEGIN_HEADER +class QWebHistory; +class QWebSettings; + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QWebHistory; -class QWebSettings; class QFxWebViewPrivate; class QNetworkRequest; class QFxWebView; @@ -181,7 +181,6 @@ Q_SIGNALS: void doubleClick(); private Q_SLOTS: - void updateCacheForVisibility(); void expandToWebPage(); void paintPage(const QRect&); void doLoadProgress(int p); @@ -209,10 +208,11 @@ private: Q_DISABLE_COPY(QFxWebView) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxWebView) }; -QML_DECLARE_TYPE(QFxWebView) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxWebView) + QT_END_HEADER + #endif diff --git a/src/declarative/fx/qfxwidgetcontainer.h b/src/declarative/fx/qfxwidgetcontainer.h index cc36010..862a280 100644 --- a/src/declarative/fx/qfxwidgetcontainer.h +++ b/src/declarative/fx/qfxwidgetcontainer.h @@ -72,10 +72,11 @@ protected: private: QGraphicsWidget *_graphicsWidget; }; -QML_DECLARE_TYPE(QFxWidgetContainer) QT_END_NAMESPACE +QML_DECLARE_TYPE(QFxWidgetContainer) + QT_END_HEADER #endif // QFXGRAPHICSWIDGET_H diff --git a/src/declarative/qml/parser/qmljs.g b/src/declarative/qml/parser/qmljs.g index 907ca52..3ed6ee2 100644 --- a/src/declarative/qml/parser/qmljs.g +++ b/src/declarative/qml/parser/qmljs.g @@ -3,7 +3,7 @@ -- Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -- Contact: Qt Software Information (qt-info@nokia.com) -- --- This file is part of the QtScript module of the Qt Toolkit. +-- This file is part of the QtDeclarative module of the Qt Toolkit. -- -- $QT_BEGIN_LICENSE:LGPL$ -- No Commercial Usage @@ -84,6 +84,7 @@ --- context keywords. %token T_PUBLIC "public" %token T_IMPORT "import" +%token T_AS "as" %nonassoc SHIFT_THERE %nonassoc T_IDENTIFIER T_COLON T_SIGNAL T_PROPERTY @@ -254,6 +255,7 @@ public: AST::UiProgram *UiProgram; AST::UiImportList *UiImportList; AST::UiImport *UiImport; + AST::UiParameterList *UiParameterList; AST::UiPublicMember *UiPublicMember; AST::UiObjectDefinition *UiObjectDefinition; AST::UiObjectInitializer *UiObjectInitializer; @@ -536,6 +538,48 @@ case $rule_number: { } break; ./ +UiImport: T_IMPORT T_STRING_LITERAL T_AS JsIdentifier T_AUTOMATIC_SEMICOLON; +UiImport: T_IMPORT T_STRING_LITERAL T_AS JsIdentifier T_SEMICOLON; +/. +case $rule_number: { + AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).sval); + node->importId = sym(4).sval; + node->importToken = loc(1); + node->fileNameToken = loc(2); + node->asToken = loc(3); + node->importIdToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; +./ + +UiImport: T_IMPORT UiQualifiedId T_AUTOMATIC_SEMICOLON; +UiImport: T_IMPORT UiQualifiedId T_SEMICOLON; +/. +case $rule_number: { + AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId); + node->importToken = loc(1); + node->fileNameToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; +./ + +UiImport: T_IMPORT UiQualifiedId T_AS JsIdentifier T_AUTOMATIC_SEMICOLON; +UiImport: T_IMPORT UiQualifiedId T_AS JsIdentifier T_SEMICOLON; +/. +case $rule_number: { + AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId); + node->importId = sym(4).sval; + node->importToken = loc(1); + node->fileNameToken = loc(2); + node->asToken = loc(3); + node->importIdToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; +./ + Empty: ; /. case $rule_number: { @@ -706,6 +750,52 @@ case $rule_number: { UiPropertyType: T_IDENTIFIER ; +UiParameterListOpt: ; +/. +case $rule_number: { + sym(1).Node = 0; +} break; +./ + +UiParameterListOpt: UiParameterList ; +/. +case $rule_number: { + sym(1).Node = sym(1).UiParameterList->finish (); +} break; +./ + +UiParameterList: UiPropertyType JsIdentifier ; +/. +case $rule_number: { + AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval); + node->identifierToken = loc(2); + sym(1).Node = node; +} break; +./ + +UiParameterList: UiParameterList T_COMMA UiPropertyType JsIdentifier ; +/. +case $rule_number: { + AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).UiParameterList, sym(3).sval, sym(4).sval); + node->commaToken = loc(2); + node->identifierToken = loc(4); + sym(1).Node = node; +} break; +./ + +UiObjectMember: T_SIGNAL T_IDENTIFIER T_LPAREN UiParameterListOpt T_RPAREN ; +/. +case $rule_number: { + AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->parameters = sym(4).UiParameterList; + sym(1).Node = node; +} break; +./ + UiObjectMember: T_SIGNAL T_IDENTIFIER ; /. case $rule_number: { diff --git a/src/declarative/qml/parser/qmljsast_p.h b/src/declarative/qml/parser/qmljsast_p.h index 8dc32ed..bde78c0 100644 --- a/src/declarative/qml/parser/qmljsast_p.h +++ b/src/declarative/qml/parser/qmljsast_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -209,6 +209,7 @@ public: Kind_UiObjectMemberList, Kind_UiArrayMemberList, Kind_UiProgram, + Kind_UiParameterList, Kind_UiPublicMember, Kind_UiQualifiedId, Kind_UiScriptBinding, @@ -2220,15 +2221,23 @@ public: QMLJS_DECLARE_AST_NODE(UiImport) UiImport(NameId *fileName) - : fileName(fileName) + : fileName(fileName), importUri(0), importId(0) + { kind = K; } + + UiImport(UiQualifiedId *uri) + : fileName(0), importUri(uri), importId(0) { kind = K; } virtual void accept0(Visitor *visitor); // attributes NameId *fileName; + UiQualifiedId *importUri; + NameId *importId; SourceLocation importToken; SourceLocation fileNameToken; + SourceLocation asToken; + SourceLocation importIdToken; SourceLocation semicolonToken; }; @@ -2351,6 +2360,42 @@ public: SourceLocation rbraceToken; }; +class UiParameterList: public Node +{ +public: + QMLJS_DECLARE_AST_NODE(UiParameterList) + + UiParameterList(NameId *t, NameId *n): + type (t), name (n), next (this) + { kind = K; } + + UiParameterList(UiParameterList *previous, NameId *t, NameId *n): + type (t), name (n) + { + kind = K; + next = previous->next; + previous->next = this; + } + + virtual ~UiParameterList() {} + + virtual void accept0(Visitor *) {} + + inline UiParameterList *finish () + { + UiParameterList *front = next; + next = 0; + return front; + } + +// attributes + NameId *type; + NameId *name; + UiParameterList *next; + SourceLocation commaToken; + SourceLocation identifierToken; +}; + class UiPublicMember: public UiObjectMember { public: @@ -2358,13 +2403,13 @@ public: UiPublicMember(NameId *memberType, NameId *name) - : type(Property), memberType(memberType), name(name), expression(0), isDefaultMember(false) + : type(Property), memberType(memberType), name(name), expression(0), isDefaultMember(false), parameters(0) { kind = K; } UiPublicMember(NameId *memberType, NameId *name, ExpressionNode *expression) - : type(Property), memberType(memberType), name(name), expression(expression), isDefaultMember(false) + : type(Property), memberType(memberType), name(name), expression(expression), isDefaultMember(false), parameters(0) { kind = K; } virtual SourceLocation firstSourceLocation() const @@ -2388,6 +2433,7 @@ public: NameId *name; ExpressionNode *expression; bool isDefaultMember; + UiParameterList *parameters; SourceLocation defaultToken; SourceLocation propertyToken; SourceLocation typeToken; diff --git a/src/declarative/qml/parser/qmljsengine_p.cpp b/src/declarative/qml/parser/qmljsengine_p.cpp index 42885d8..02d9b9c 100644 --- a/src/declarative/qml/parser/qmljsengine_p.cpp +++ b/src/declarative/qml/parser/qmljsengine_p.cpp @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +20,24 @@ ** 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.0, 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. +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** -**************************************************************************/ +****************************************************************************/ #include "qmljsengine_p.h" #include "qmljsnodepool_p.h" diff --git a/src/declarative/qml/parser/qmljsengine_p.h b/src/declarative/qml/parser/qmljsengine_p.h index b9ff042..5aea983 100644 --- a/src/declarative/qml/parser/qmljsengine_p.h +++ b/src/declarative/qml/parser/qmljsengine_p.h @@ -1,20 +1,18 @@ -/************************************************************************** +/**************************************************************************** ** -** This file is part of Qt Creator +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) ** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,14 +20,39 @@ ** 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.0, 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. +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** -**************************************************************************/ +****************************************************************************/ #ifndef QMLJSENGINE_P_H #define QMLJSENGINE_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 <QString> #include <QSet> diff --git a/src/declarative/qml/parser/qmljsgrammar.cpp b/src/declarative/qml/parser/qmljsgrammar.cpp index 835ee44..5ff2ed8 100644 --- a/src/declarative/qml/parser/qmljsgrammar.cpp +++ b/src/declarative/qml/parser/qmljsgrammar.cpp @@ -2,7 +2,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -35,7 +35,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -51,611 +51,637 @@ const char *const QmlJSGrammar::spell [] = { "||", "+", "+=", "++", "?", "}", "]", "%", "%=", "return", ")", ";", 0, "*", "*=", "string literal", "property", "signal", "switch", "this", "throw", "~", "try", "typeof", "var", "void", "while", "with", "^", "^=", - "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "public", "import", 0, - 0}; + "null", "true", "false", "const", "debugger", "reserved word", "multiline string literal", "public", "import", "as", + 0, 0}; const int QmlJSGrammar::lhs [] = { - 91, 92, 92, 95, 95, 96, 96, 94, 93, 98, - 98, 100, 100, 101, 101, 97, 99, 99, 103, 104, - 104, 99, 99, 99, 99, 99, 99, 99, 111, 111, - 111, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 102, 102, 114, 114, 114, 115, 115, 115, - 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, - 115, 115, 115, 115, 102, 102, 117, 117, 117, 117, - 116, 116, 119, 119, 121, 121, 121, 121, 121, 121, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 122, 123, 123, 124, 124, 124, 124, 124, 127, 127, - 128, 128, 128, 128, 126, 126, 129, 129, 130, 130, - 131, 131, 131, 132, 132, 132, 132, 132, 132, 132, - 132, 132, 132, 133, 133, 133, 133, 134, 134, 134, - 135, 135, 135, 135, 136, 136, 136, 136, 136, 136, - 136, 137, 137, 137, 137, 137, 137, 138, 138, 138, - 138, 138, 139, 139, 139, 139, 139, 140, 140, 141, - 141, 142, 142, 143, 143, 144, 144, 145, 145, 146, - 146, 147, 147, 148, 148, 149, 149, 150, 150, 151, - 151, 120, 120, 152, 152, 153, 153, 153, 153, 153, - 153, 153, 153, 153, 153, 153, 153, 105, 105, 154, - 154, 155, 155, 156, 156, 157, 157, 157, 157, 157, - 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, - 106, 168, 168, 167, 167, 113, 113, 169, 169, 170, - 170, 172, 172, 171, 173, 176, 174, 174, 177, 175, - 175, 107, 108, 108, 110, 110, 158, 158, 158, 158, - 158, 158, 158, 159, 159, 159, 159, 160, 160, 160, - 160, 161, 161, 162, 164, 178, 178, 181, 181, 179, - 179, 182, 180, 163, 163, 163, 165, 165, 166, 166, - 166, 183, 184, 109, 109, 112, 125, 188, 188, 185, - 185, 186, 186, 189, 190, 190, 191, 191, 187, 187, - 118, 118, 192}; + 92, 93, 93, 96, 96, 97, 97, 97, 97, 97, + 97, 97, 97, 95, 94, 101, 101, 103, 103, 104, + 104, 100, 102, 102, 105, 106, 106, 102, 102, 102, + 102, 102, 102, 102, 113, 113, 113, 114, 114, 115, + 115, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 99, 99, 98, 98, 98, 118, 118, + 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, + 118, 118, 118, 118, 118, 99, 99, 120, 120, 120, + 120, 119, 119, 122, 122, 124, 124, 124, 124, 124, + 124, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, + 125, 125, 126, 126, 127, 127, 127, 127, 127, 130, + 130, 131, 131, 131, 131, 129, 129, 132, 132, 133, + 133, 134, 134, 134, 135, 135, 135, 135, 135, 135, + 135, 135, 135, 135, 136, 136, 136, 136, 137, 137, + 137, 138, 138, 138, 138, 139, 139, 139, 139, 139, + 139, 139, 140, 140, 140, 140, 140, 140, 141, 141, + 141, 141, 141, 142, 142, 142, 142, 142, 143, 143, + 144, 144, 145, 145, 146, 146, 147, 147, 148, 148, + 149, 149, 150, 150, 151, 151, 152, 152, 153, 153, + 154, 154, 123, 123, 155, 155, 156, 156, 156, 156, + 156, 156, 156, 156, 156, 156, 156, 156, 107, 107, + 157, 157, 158, 158, 159, 159, 160, 160, 160, 160, + 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, + 160, 108, 171, 171, 170, 170, 117, 117, 172, 172, + 173, 173, 175, 175, 174, 176, 179, 177, 177, 180, + 178, 178, 109, 110, 110, 112, 112, 161, 161, 161, + 161, 161, 161, 161, 162, 162, 162, 162, 163, 163, + 163, 163, 164, 164, 165, 167, 181, 181, 184, 184, + 182, 182, 185, 183, 166, 166, 166, 168, 168, 169, + 169, 169, 186, 187, 111, 111, 116, 128, 191, 191, + 188, 188, 189, 189, 192, 193, 193, 194, 194, 190, + 190, 121, 121, 195}; const int QmlJSGrammar:: rhs[] = { - 2, 1, 1, 1, 2, 3, 3, 0, 1, 1, - 2, 1, 3, 2, 3, 2, 1, 5, 1, 2, - 2, 4, 3, 3, 3, 3, 3, 3, 1, 1, - 1, 2, 4, 4, 5, 5, 6, 6, 7, 7, + 2, 1, 1, 1, 2, 3, 3, 5, 5, 3, + 3, 5, 5, 0, 1, 1, 2, 1, 3, 2, + 3, 2, 1, 5, 1, 2, 2, 4, 3, 3, + 3, 3, 3, 3, 1, 1, 1, 0, 1, 2, + 4, 5, 2, 4, 4, 5, 5, 6, 6, 7, + 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, + 4, 5, 3, 4, 3, 1, 3, 1, 2, 3, + 4, 1, 2, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 3, 3, 4, - 5, 3, 4, 3, 1, 3, 1, 2, 3, 4, - 1, 2, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 4, 3, 5, 1, + 2, 4, 4, 4, 3, 0, 1, 1, 3, 1, + 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 1, 3, 3, 3, 1, 3, + 3, 1, 3, 3, 3, 1, 3, 3, 3, 3, + 3, 3, 1, 3, 3, 3, 3, 3, 1, 3, + 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, + 1, 3, 1, 3, 1, 3, 1, 3, 1, 5, + 1, 5, 1, 3, 1, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 0, 1, 1, 3, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 4, 3, 5, 1, 2, - 4, 4, 4, 3, 0, 1, 1, 3, 1, 1, - 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 1, 3, 3, 3, 1, 3, 3, - 1, 3, 3, 3, 1, 3, 3, 3, 3, 3, - 3, 1, 3, 3, 3, 3, 3, 1, 3, 3, - 3, 3, 1, 3, 3, 3, 3, 1, 3, 1, - 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, - 3, 1, 3, 1, 3, 1, 3, 1, 5, 1, - 5, 1, 3, 1, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, - 1, 1, 3, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 3, 1, 2, 0, 1, 3, 3, 1, 1, 1, - 3, 1, 3, 2, 2, 2, 0, 1, 2, 0, - 1, 1, 2, 2, 7, 5, 7, 7, 5, 9, - 10, 7, 8, 2, 2, 3, 3, 2, 2, 3, - 3, 3, 3, 5, 5, 3, 5, 1, 2, 0, - 1, 4, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 5, 2, 2, 2, 8, 8, 1, 3, 0, - 1, 0, 1, 1, 1, 2, 1, 1, 0, 1, - 0, 1, 2}; + 1, 3, 1, 2, 0, 1, 3, 3, 1, 1, + 1, 3, 1, 3, 2, 2, 2, 0, 1, 2, + 0, 1, 1, 2, 2, 7, 5, 7, 7, 5, + 9, 10, 7, 8, 2, 2, 3, 3, 2, 2, + 3, 3, 3, 3, 5, 5, 3, 5, 1, 2, + 0, 1, 4, 3, 3, 3, 3, 3, 3, 3, + 3, 4, 5, 2, 2, 2, 8, 8, 1, 3, + 0, 1, 0, 1, 1, 1, 2, 1, 1, 0, + 1, 0, 1, 2}; const int QmlJSGrammar::action_default [] = { - 8, 2, 0, 4, 3, 0, 0, 0, 6, 7, - 5, 65, 45, 46, 43, 44, 47, 9, 0, 1, - 0, 0, 16, 66, 41, 248, 0, 0, 46, 14, - 47, 249, 17, 10, 0, 0, 0, 42, 0, 31, - 30, 29, 0, 0, 35, 0, 36, 151, 218, 182, - 190, 186, 130, 202, 178, 0, 115, 49, 131, 194, - 198, 119, 148, 129, 134, 114, 168, 155, 0, 55, - 56, 52, 319, 321, 0, 0, 0, 0, 0, 0, - 50, 53, 0, 0, 54, 48, 0, 51, 0, 0, - 144, 0, 0, 131, 150, 133, 132, 0, 0, 0, - 146, 147, 145, 149, 0, 179, 0, 0, 0, 0, - 169, 0, 0, 0, 0, 0, 0, 159, 0, 0, - 0, 153, 154, 152, 157, 161, 160, 158, 156, 171, - 170, 172, 0, 187, 0, 183, 0, 0, 125, 112, - 124, 113, 81, 82, 83, 108, 84, 109, 85, 86, - 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, - 97, 110, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 111, 0, 0, 123, 219, 126, 0, 127, - 0, 128, 122, 39, 40, 0, 215, 208, 206, 213, - 214, 212, 211, 217, 210, 209, 207, 216, 203, 0, - 191, 0, 0, 195, 0, 0, 199, 0, 0, 125, - 117, 0, 116, 0, 121, 135, 0, 320, 310, 311, - 0, 308, 0, 309, 0, 312, 226, 233, 232, 240, - 228, 0, 229, 313, 0, 318, 230, 231, 236, 234, - 315, 314, 317, 237, 0, 0, 0, 0, 0, 319, - 45, 0, 321, 46, 220, 262, 47, 0, 0, 0, - 0, 0, 238, 239, 227, 235, 263, 264, 307, 316, - 0, 278, 279, 280, 281, 0, 274, 275, 276, 277, - 304, 305, 0, 0, 0, 0, 0, 267, 268, 224, - 222, 184, 192, 188, 204, 180, 225, 0, 131, 196, - 200, 173, 162, 0, 0, 181, 0, 0, 0, 0, - 174, 0, 0, 0, 0, 0, 166, 164, 167, 165, - 163, 176, 175, 177, 0, 189, 0, 185, 0, 223, - 131, 0, 205, 220, 221, 0, 220, 0, 0, 270, - 0, 0, 0, 272, 0, 193, 0, 0, 197, 0, - 0, 201, 260, 0, 252, 261, 255, 0, 259, 0, - 220, 253, 0, 220, 0, 0, 271, 0, 0, 0, - 273, 320, 310, 0, 0, 312, 0, 306, 0, 296, - 0, 0, 0, 266, 0, 265, 0, 322, 0, 80, - 242, 245, 0, 81, 248, 84, 109, 86, 87, 52, - 91, 92, 45, 93, 96, 50, 53, 46, 220, 47, - 54, 99, 48, 101, 51, 103, 104, 249, 106, 107, - 111, 0, 73, 0, 0, 75, 79, 77, 63, 76, - 78, 0, 74, 62, 243, 241, 119, 120, 125, 0, - 118, 0, 295, 0, 282, 283, 0, 294, 0, 0, - 0, 285, 290, 288, 291, 0, 0, 289, 290, 0, - 286, 0, 287, 244, 293, 0, 244, 292, 0, 297, - 298, 0, 244, 299, 300, 0, 0, 301, 0, 0, - 0, 302, 303, 137, 136, 0, 0, 0, 269, 0, - 0, 0, 284, 67, 0, 0, 71, 57, 0, 59, - 69, 0, 60, 70, 72, 61, 68, 58, 0, 64, - 141, 139, 143, 140, 138, 142, 0, 0, 0, 33, - 0, 34, 0, 37, 38, 32, 15, 11, 0, 23, - 26, 24, 0, 25, 28, 244, 0, 19, 0, 27, - 22, 81, 248, 84, 109, 86, 87, 52, 91, 92, - 45, 93, 96, 50, 53, 46, 220, 47, 54, 99, - 48, 101, 51, 103, 104, 249, 106, 107, 111, 49, - 0, 12, 0, 18, 13, 20, 21, 257, 250, 0, - 258, 254, 0, 256, 246, 0, 247, 251, 323}; + 14, 2, 0, 4, 3, 0, 0, 76, 56, 57, + 54, 55, 58, 0, 0, 0, 6, 7, 0, 8, + 9, 0, 10, 0, 11, 0, 12, 13, 77, 5, + 15, 0, 1, 0, 22, 52, 259, 0, 0, 57, + 20, 58, 260, 23, 16, 0, 0, 0, 53, 0, + 37, 36, 35, 0, 0, 46, 0, 47, 162, 229, + 193, 201, 197, 141, 213, 189, 0, 126, 60, 142, + 205, 209, 130, 159, 140, 145, 125, 179, 166, 0, + 66, 67, 63, 330, 332, 0, 0, 0, 0, 0, + 0, 61, 64, 0, 0, 65, 59, 0, 62, 0, + 0, 155, 0, 0, 142, 161, 144, 143, 0, 0, + 0, 157, 158, 156, 160, 0, 190, 0, 0, 0, + 0, 180, 0, 0, 0, 0, 0, 0, 170, 0, + 0, 0, 164, 165, 163, 168, 172, 171, 169, 167, + 182, 181, 183, 0, 198, 0, 194, 0, 0, 136, + 123, 135, 124, 92, 93, 94, 119, 95, 120, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 121, 109, 110, 111, 112, 113, 114, 115, + 116, 117, 118, 122, 0, 0, 134, 230, 137, 0, + 138, 0, 139, 133, 50, 51, 0, 226, 219, 217, + 224, 225, 223, 222, 228, 221, 220, 218, 227, 214, + 0, 202, 0, 0, 206, 0, 0, 210, 0, 0, + 136, 128, 0, 127, 0, 132, 146, 0, 331, 321, + 322, 0, 319, 0, 320, 0, 323, 237, 244, 243, + 251, 239, 0, 240, 324, 0, 329, 241, 242, 247, + 245, 326, 325, 328, 248, 0, 0, 0, 0, 0, + 330, 56, 0, 332, 57, 231, 273, 58, 0, 0, + 0, 0, 0, 249, 250, 238, 246, 274, 275, 318, + 327, 0, 289, 290, 291, 292, 0, 285, 286, 287, + 288, 315, 316, 0, 0, 0, 0, 0, 278, 279, + 235, 233, 195, 203, 199, 215, 191, 236, 0, 142, + 207, 211, 184, 173, 0, 0, 192, 0, 0, 0, + 0, 185, 0, 0, 0, 0, 0, 177, 175, 178, + 176, 174, 187, 186, 188, 0, 200, 0, 196, 0, + 234, 142, 0, 216, 231, 232, 0, 231, 0, 0, + 281, 0, 0, 0, 283, 0, 204, 0, 0, 208, + 0, 0, 212, 271, 0, 263, 272, 266, 0, 270, + 0, 231, 264, 0, 231, 0, 0, 282, 0, 0, + 0, 284, 331, 321, 0, 0, 323, 0, 317, 0, + 307, 0, 0, 0, 277, 0, 276, 0, 333, 0, + 91, 253, 256, 0, 92, 259, 95, 120, 97, 98, + 63, 102, 103, 56, 104, 107, 61, 64, 57, 231, + 58, 65, 110, 59, 112, 62, 114, 115, 260, 117, + 118, 122, 0, 84, 0, 0, 86, 90, 88, 74, + 87, 89, 0, 85, 73, 254, 252, 130, 131, 136, + 0, 129, 0, 306, 0, 293, 294, 0, 305, 0, + 0, 0, 296, 301, 299, 302, 0, 0, 300, 301, + 0, 297, 0, 298, 255, 304, 0, 255, 303, 0, + 308, 309, 0, 255, 310, 311, 0, 0, 312, 0, + 0, 0, 313, 314, 148, 147, 0, 0, 0, 280, + 0, 0, 0, 295, 78, 0, 0, 82, 68, 0, + 70, 80, 0, 71, 81, 83, 72, 79, 69, 0, + 75, 152, 150, 154, 151, 149, 153, 0, 0, 0, + 44, 0, 45, 0, 48, 49, 43, 38, 39, 0, + 0, 0, 0, 41, 42, 40, 21, 17, 0, 29, + 32, 30, 0, 31, 34, 255, 0, 25, 0, 33, + 28, 92, 259, 95, 120, 97, 98, 63, 102, 103, + 56, 104, 107, 61, 64, 57, 231, 58, 65, 110, + 59, 112, 62, 114, 115, 260, 117, 118, 122, 60, + 0, 18, 0, 24, 19, 26, 27, 268, 261, 0, + 269, 265, 0, 267, 257, 0, 258, 262, 334}; const int QmlJSGrammar::goto_default [] = { - 6, 5, 19, 1, 4, 3, 32, 34, 33, 570, - 22, 18, 538, 539, 231, 226, 230, 232, 229, 236, - 517, 235, 264, 57, 65, 495, 494, 388, 387, 48, - 386, 389, 140, 61, 56, 178, 63, 52, 177, 58, - 64, 90, 62, 47, 67, 66, 301, 54, 295, 49, - 291, 51, 293, 50, 292, 59, 299, 60, 300, 53, - 294, 290, 331, 443, 296, 297, 390, 237, 228, 227, - 239, 265, 238, 243, 262, 263, 392, 391, 36, 579, - 578, 353, 354, 581, 356, 580, 355, 451, 455, 458, - 454, 453, 473, 474, 220, 234, 216, 219, 233, 241, - 240, 0}; + 6, 5, 32, 1, 4, 3, 68, 31, 43, 45, + 44, 590, 34, 558, 559, 242, 237, 241, 243, 240, + 247, 528, 539, 538, 246, 275, 76, 506, 505, 399, + 398, 59, 397, 400, 151, 72, 67, 189, 74, 63, + 188, 69, 75, 101, 73, 58, 78, 77, 312, 65, + 306, 60, 302, 62, 304, 61, 303, 70, 310, 71, + 311, 64, 305, 301, 342, 454, 307, 308, 401, 248, + 239, 238, 250, 276, 249, 254, 273, 274, 403, 402, + 47, 599, 598, 364, 365, 601, 367, 600, 366, 462, + 466, 469, 465, 464, 484, 485, 231, 245, 227, 230, + 244, 252, 251, 0}; const int QmlJSGrammar::action_index [] = { - 8, -91, 14, -91, -15, 296, 67, 94, -91, -91, - -91, -91, -91, -91, -91, -91, -91, -91, 109, -91, - 184, 408, -91, -91, -91, -91, 45, 125, 170, -91, - 46, -91, -91, -91, 429, 171, 130, -91, 120, -91, - -91, -91, -19, 169, -91, 733, -91, 72, -91, 22, - -26, -59, 173, -91, 278, 174, -91, -91, 574, 51, - 112, 183, 177, -91, -91, -91, 412, 214, 733, -91, - -91, -91, 161, 1566, 980, 733, 733, 733, 653, 733, - -91, -91, 733, 733, -91, -91, 733, -91, 733, 733, - -91, 733, 733, 98, 235, -91, -91, 733, 733, 733, - -91, -91, -91, 230, 733, 276, 733, 733, 733, 733, - 396, 733, 733, 733, 733, 733, 733, 288, 733, 733, - 733, 88, 87, 74, 288, 288, 288, 218, 221, 486, - 372, 362, 733, 4, 733, 76, 1479, 733, 733, -91, - -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, - -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, - -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, - -91, -91, -91, 102, 733, -91, -91, 60, 3, -91, - 733, -91, -91, -91, -91, 733, -91, -91, -91, -91, - -91, -91, -91, -91, -91, -91, -91, -91, -91, 733, - -6, 733, 733, 30, 32, 733, -91, 1479, 733, 733, - -91, 107, -91, -14, -91, -91, 69, -91, 191, 49, - 18, -91, 233, -91, 47, 1827, -91, -91, -91, -91, - -91, 204, -91, -91, 39, -91, -91, -91, -91, -91, - -91, 1827, -91, -91, 322, 281, 103, 1740, 50, 203, - 77, 40, 2001, 53, 733, -91, 52, 29, 733, 25, - 28, 35, -91, -91, -91, -91, -91, -91, -91, -91, - 113, -91, -91, -91, -91, 106, -91, -91, -91, -91, - -91, -91, 15, 68, 733, 135, 119, -91, -91, 897, - -91, 82, 58, 17, -91, 261, 84, 42, 494, 91, - 79, 304, 288, 208, 733, 245, 733, 733, 733, 733, - 418, 733, 733, 733, 733, 733, 288, 288, 288, 288, - 288, 343, 336, 279, 733, -57, 733, 19, 733, -91, - 574, 733, -91, 733, -7, -30, 733, -60, 1740, -91, - 733, 111, 1740, -91, 733, 2, 733, 733, 43, 37, - 733, -91, 34, 118, 23, -91, -91, 733, -91, 238, - 733, -91, -5, 733, -17, 1740, -91, 733, 133, 1740, - -91, -9, 194, -32, -8, 1827, -25, -91, 1740, -91, - 733, 100, 1740, 21, 1740, -91, 31, 26, -20, -91, - -91, 1740, -38, 283, 41, 291, 85, 733, 1740, -1, - -34, 252, 54, -27, 653, 9, 5, -91, 817, -91, - 6, -21, 7, 733, 11, -28, 733, 1, 733, -33, - -10, 733, -91, 1653, 33, -91, -91, -91, -91, -91, - -91, 733, -91, -91, -91, -91, 172, -91, 733, -24, - -91, 1740, -91, 73, -91, -91, 1740, -91, 733, 93, - 0, -91, 24, -91, 36, 122, 733, -91, 44, 48, - -91, -3, -91, 1740, -91, 110, 1740, -91, 192, -91, - -91, 124, 1740, 27, -91, -12, -29, -91, 155, -53, - -22, -91, -91, -91, -91, 733, 123, 1740, -91, 733, - 92, 1740, -91, -91, 105, 1229, -91, -91, 1146, -91, - -91, 1063, -91, -91, -91, -91, -91, -91, 90, -91, - -91, -91, -91, -91, -91, -91, 71, 70, 222, -91, - 733, -91, 164, -91, -91, -91, -91, -91, 1392, -91, - -91, -91, 268, -91, -91, 1914, 1312, -91, 75, -91, - -91, 350, 55, 303, 108, 733, 1740, 59, 38, 242, - 62, 40, 527, 63, 81, -91, 817, -91, 138, 29, - 65, 733, 78, 56, 733, 80, 733, 61, 66, 57, - 101, -91, 347, -91, -91, -91, -91, 64, -91, 140, - -91, -91, 733, -91, -91, 144, -91, -91, -91, + -11, -92, 395, -92, 10, 364, 99, -92, -92, -92, + -92, -92, -92, 135, 285, 214, -92, -92, 93, -92, + -92, 214, -92, 214, -92, 101, -92, -92, -92, -92, + -92, 97, -92, 462, -92, -92, -92, 72, 198, 193, + -92, 75, -92, -92, -92, 485, 299, 171, -92, 174, + -92, -92, -92, 74, 192, -92, 761, -92, 85, -92, + 96, 73, 14, 227, -92, 292, 131, -92, -92, 600, + 94, 123, 168, 176, -92, -92, -92, 511, 157, 761, + -92, -92, -92, 139, 1604, 1263, 761, 761, 761, 680, + 761, -92, -92, 761, 761, -92, -92, 761, -92, 761, + 761, -92, 761, 761, 90, 205, -92, -92, 761, 761, + 761, -92, -92, -92, 195, 761, 305, 761, 761, 761, + 761, 511, 761, 761, 761, 761, 761, 761, 203, 761, + 761, 761, 119, 77, 91, 191, 185, 188, 194, 222, + 415, 405, 432, 761, 9, 761, 81, 1516, 761, 761, + -92, -92, -92, -92, -92, -92, -92, -92, -92, -92, + -92, -92, -92, -92, -92, -92, -92, -92, -92, -92, + -92, -92, -92, -92, -92, -92, -92, -92, -92, -92, + -92, -92, -92, -92, 108, 761, -92, -92, 82, 67, + -92, 761, -92, -92, -92, -92, 761, -92, -92, -92, + -92, -92, -92, -92, -92, -92, -92, -92, -92, -92, + 761, 70, 761, 761, 78, 71, 761, -92, 1516, 761, + 761, -92, 102, -92, 62, -92, -92, 59, -92, 214, + 68, 60, -92, 255, -92, 55, 1780, -92, -92, -92, + -92, -92, 232, -92, -92, 69, -92, -92, -92, -92, + -92, -92, 1780, -92, -92, 344, 359, 95, 1868, 65, + 246, 76, 58, 2044, 64, 761, -92, 63, 48, 761, + 40, 39, 49, -92, -92, -92, -92, -92, -92, -92, + -92, 104, -92, -92, -92, -92, 86, -92, -92, -92, + -92, -92, -92, -4, 50, 761, 129, 118, -92, -92, + 842, -92, 88, 43, -12, -92, 373, 66, 32, 536, + 151, 124, 442, 264, 250, 761, 373, 761, 761, 761, + 761, 329, 761, 761, 761, 761, 761, 244, 270, 280, + 271, 245, 352, 442, 335, 761, -74, 761, 4, 761, + -92, 600, 761, -92, 761, 2, -52, 761, -40, 1868, + -92, 761, 127, 1868, -92, 761, -34, 761, 761, 15, + 12, 761, -92, -1, 111, -16, -92, -92, 761, -92, + 261, 761, -92, -31, 761, -36, 1868, -92, 761, 107, + 1868, -92, -14, 237, -49, -32, 1780, -23, -92, 1868, + -92, 761, 92, 1868, -10, 1868, -92, 51, 54, 26, + -92, -92, 1868, 24, 319, 57, 333, 79, 761, 1868, + 56, 29, 263, 42, 19, 680, 30, 31, -92, 927, + -92, 28, 0, 22, 761, 33, 13, 761, 36, 761, + 5, -3, 761, -92, 1692, 44, -92, -92, -92, -92, + -92, -92, 761, -92, -92, -92, -92, 175, -92, 761, + -58, -92, 1868, -92, 89, -92, -92, 1868, -92, 761, + 100, 35, -92, 23, -92, 16, 116, 761, -92, 8, + 11, -92, -28, -92, 1868, -92, 98, 1868, -92, 226, + -92, -92, 103, 1868, -13, -92, -24, -8, -92, 169, + -37, -7, -92, -92, -92, -92, 761, 125, 1868, -92, + 761, 126, 1868, -92, -92, 138, 1011, -92, -92, 1179, + -92, -92, 1095, -92, -92, -92, -92, -92, -92, 121, + -92, -92, -92, -92, -92, -92, -92, -5, 18, 224, + -92, 761, -92, 212, -92, -92, -33, 172, 61, -60, + 214, 140, 214, -92, -92, -92, -92, -92, 1428, -92, + -92, -92, 307, -92, -92, 1956, 1347, -92, 83, -92, + -92, 316, 47, 336, 114, 761, 1868, 52, 21, 290, + 46, 20, 680, 45, 53, -92, 927, -92, 37, 6, + 38, 761, 41, 17, 761, 27, 761, 3, 25, 34, + 105, -92, 342, -92, -92, -92, -92, -9, -92, 183, + -92, -92, 761, -92, -92, 214, -92, -92, -92, - -102, -102, -102, -102, 19, 103, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -4, 249, -102, -102, -102, -102, -102, -7, -102, -102, - -102, -102, -102, -102, 257, -102, -13, -102, -11, -102, - -102, -102, -102, -102, -102, -3, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -44, -102, - -102, -102, -102, -102, -102, -102, -102, -102, 141, -102, - -102, -102, -8, -102, 0, 16, 116, 122, 129, 119, - -102, -102, 90, 64, -102, -102, 94, -102, 91, 86, - -102, 71, 79, -102, -102, -102, -102, 159, 81, 76, - -102, -102, -102, -102, 98, -102, 67, 63, 47, 163, - -102, 160, 115, 104, 105, 127, 133, -102, 151, 144, - 130, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, 145, -102, 152, -102, 162, 31, 21, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, 23, -102, -102, -102, -102, -102, - 29, -102, -102, -102, -102, 34, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, 89, - -102, 68, 36, -102, -102, 42, -102, 235, 46, 49, - -102, -102, -102, -102, -102, -102, -102, -102, 33, -102, - -102, -102, 26, -102, -102, -18, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, 53, -102, -102, 8, 20, -102, -5, -102, 32, - -102, -102, -102, -102, 39, -102, -102, -102, 37, 73, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, 40, -102, -102, -102, -102, 97, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, 41, 213, -102, 186, 199, 203, 209, - -102, 50, 51, 38, 57, 60, -102, -102, -102, -102, - -102, -102, -102, -102, 212, -102, 174, -102, 166, -102, - -102, 168, -102, 125, -102, -102, 61, -102, 1, -102, - 45, -102, -9, -102, 172, -102, 184, 176, -102, -102, - 170, -102, -102, -102, -102, -102, -102, 215, -102, 124, - 132, -102, -102, 178, -102, -29, -102, 25, -102, 2, - -102, -102, 62, -102, -102, 102, -102, -102, -28, -102, - 22, -102, -31, -102, -33, -102, -102, -102, -102, -102, - -102, -34, -102, 17, -102, 18, -102, 111, -20, -102, - -102, 24, -102, -102, 153, -102, -102, -102, 30, -102, - -102, -102, -102, 28, -102, 73, 140, -102, 205, -102, - -102, 5, -102, 44, -102, -102, -102, -102, -102, -102, - -102, 43, -102, -102, -102, -102, -102, -102, 135, -102, - -102, 7, -102, -102, -102, -102, 4, -102, 55, -102, - -102, -102, -102, -102, -25, -102, 48, -102, 9, -102, - -102, -102, -102, -69, -102, -102, -70, -102, -102, -102, - -102, -102, -102, -92, -102, -102, -12, -102, -10, -102, - -1, -102, -102, -102, -102, 11, -102, -40, -102, 14, - -102, -39, -102, -102, -102, -17, -102, -102, 54, -102, - -102, -24, -102, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -102, -102, -102, -102, -102, -102, -102, -102, - 3, -102, -102, -102, -102, -102, -102, -102, 267, -102, - -102, -102, 12, -102, -102, -102, 301, -102, -102, -102, - -102, -19, -102, -15, -102, 59, -64, -102, -102, -2, - -102, -102, 142, -102, -102, -102, -14, -102, -102, -102, - -102, 6, -102, 73, 52, -102, 75, -102, -102, -102, - -102, -102, 128, -102, -102, -102, -102, -102, -102, -102, - -102, -102, -6, -102, -102, 58, -102, -102, -102}; + -104, -104, 87, -104, 69, 82, -104, -104, -104, -104, + -104, -104, -104, -104, -104, 49, -104, -104, -104, -104, + -104, 45, -104, 50, -104, -104, -104, -104, -104, -104, + -104, -104, -104, 253, -104, -104, -104, -104, 26, -104, + -104, -104, -104, -104, -104, 261, -104, 1, -104, -7, + -104, -104, -104, -104, -104, -104, -11, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -38, + -104, -104, -104, -104, -104, -104, -104, -104, -104, 135, + -104, -104, -104, 11, -104, -16, 8, 139, 147, 148, + 144, -104, -104, 138, 127, -104, -104, 115, -104, 119, + 150, -104, 120, 125, -104, -104, -104, -104, 116, 232, + 172, -104, -104, -104, -104, 171, -104, 151, 154, 158, + 161, -104, 163, 165, 143, 126, 64, 68, -104, 80, + 86, 61, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, 63, -104, 67, -104, 74, 20, 6, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, -104, -104, 28, -104, -104, -104, -104, + -104, 14, -104, -104, -104, -104, 12, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, + 89, -104, 94, 31, -104, -104, 38, -104, 204, 51, + 102, -104, -104, -104, -104, -104, -104, -104, -104, 7, + -104, -104, -104, 16, -104, -104, -59, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, 44, -104, -104, 92, 19, -104, -41, -104, + 24, -104, -104, -104, -104, 5, -104, -104, -104, -4, + -8, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, -104, -104, 52, -104, -104, -104, -104, + 91, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, -104, 66, 185, -104, 177, 173, 176, + 188, -104, 88, 95, 97, 107, 101, -104, -104, -104, + -104, -104, -104, -104, -104, 212, -104, 187, -104, 199, + -104, -104, 201, -104, 108, -104, -104, 100, -104, -14, + -104, 34, -104, -20, -104, 200, -104, 211, 209, -104, + -104, 202, -104, -104, -104, -104, -104, -104, 186, -104, + 90, 98, -104, -104, 85, -104, -22, -104, 37, -104, + -10, -104, -104, 81, -104, -104, 43, -104, -104, -15, + -104, 32, -104, -24, -104, -34, -104, -104, -104, -104, + -104, -104, -32, -104, 92, -104, 33, -104, 76, -27, + -104, -104, 36, -104, -104, 114, -104, -104, -104, 25, + -104, -104, -104, -104, 18, -104, 59, 79, -104, 83, + -104, -104, 42, -104, 39, -104, -104, -104, -104, -104, + -104, -104, 55, -104, -104, -104, -104, -104, -104, 166, + -104, -104, 15, -104, -104, -104, -104, -3, -104, 46, + -104, -104, -104, -104, -104, -23, -104, 53, -104, -26, + -104, -104, -104, -104, -21, -104, -104, -73, -104, -104, + -104, -104, -104, -104, -94, -104, -104, 0, -104, 22, + -104, 13, -104, -104, -104, -104, 3, -104, -47, -104, + 9, -104, -49, -104, -104, -104, -19, -104, -104, 169, + -104, -104, -25, -104, -104, -104, -104, -104, -104, -104, + -104, -104, -104, -104, -104, -104, -104, -104, -104, -104, + -104, -13, -104, -104, -104, -104, -104, 10, -104, -104, + -6, -18, 4, -104, -104, -104, -104, -104, 264, -104, + -104, -104, 48, -104, -104, -104, 330, -104, -104, -104, + -104, 92, -104, 71, -104, 60, 21, -104, -104, 70, + -104, -104, 57, -104, -104, -104, 23, -104, -104, -104, + -104, 35, -104, 47, 41, -104, 56, -104, -104, -104, + -104, -104, 73, -104, -104, -104, -104, -104, -104, -104, + -104, -104, 54, -104, -104, 72, -104, -104, -104}; const int QmlJSGrammar::action_info [] = { - 338, 174, 289, 485, 472, 472, -89, 480, -105, 380, - 43, 472, -79, -78, -100, 448, -97, 435, -102, 134, - 304, 326, 132, 104, 478, 375, 489, 372, 374, 456, - 377, 336, 199, 452, 423, 433, 440, 384, 421, 205, - 431, 456, 132, 365, 350, 344, 214, 476, -108, 456, - 324, 357, 462, 199, 367, 463, 363, 222, 472, 446, - 441, -75, -108, 182, 485, 448, -89, 588, 180, -75, - -97, 489, -100, 2, 289, 525, 380, 104, 224, 7, - 225, 582, 134, 304, 378, -102, 289, -105, -79, 472, - -65, 283, 328, 344, 268, 326, 2, 485, 174, 518, - 174, 174, 489, 333, 284, 218, 324, 372, 174, 572, - 174, 38, 91, 498, 91, 174, 0, 466, 174, 174, - 0, 0, 0, 92, 20, 92, 359, 91, 91, 346, - 475, 174, 459, 347, 445, 444, 576, 575, 92, 92, - 95, 174, 21, 174, 476, -78, 281, 280, 585, 39, - 509, 96, 491, 450, 12, 9, 8, 573, 175, 12, - 382, 499, 201, 212, 281, 280, 202, 279, 278, 281, - 280, 342, 174, 12, 274, 273, 45, 460, 528, 360, - 288, 287, 174, 487, 12, 0, 20, 207, 136, 97, - 12, 13, 16, 369, 41, 286, 13, 16, 207, 39, - 174, 586, 584, 0, 21, 40, 208, 137, 438, 138, - 13, 16, 174, 12, 0, 0, 0, 208, 0, 209, - 12, 13, 16, 12, 0, 524, 523, 13, 16, 520, - 46, 44, 12, 0, 98, 184, 183, 12, 0, 118, - 99, 119, 97, 118, 41, 119, 118, 97, 119, 0, - 13, 16, 120, 470, 469, 40, 120, 13, 16, 120, - 13, 16, 12, 306, 307, 267, 266, 12, 0, 13, - 16, 12, 0, 0, 13, 16, 174, 0, -319, 306, - 307, 12, 0, 521, 519, 0, 0, 98, -319, 0, - 308, 309, 98, 99, 106, 107, 106, 107, 99, 13, - 16, 21, 311, 312, 13, 16, 308, 309, 13, 16, - 12, 313, 12, 118, 314, 119, 315, 0, 13, 16, - 12, 108, 109, 108, 109, 12, 120, 311, 312, 267, - 266, 0, 12, 0, 0, 0, 313, 0, 0, 314, - 0, 315, 277, 276, 272, 271, 0, 13, 16, 13, - 16, 12, 277, 276, 0, 15, 0, 13, 16, 311, - 312, 0, 13, 16, 277, 276, 311, 312, 313, 13, - 16, 314, 0, 315, 0, 313, 12, 0, 314, 12, - 315, 14, 0, 272, 271, 111, 112, 0, 13, 16, - 0, 0, 0, 113, 114, 111, 112, 115, 0, 116, - 0, 0, 0, 113, 114, 0, 15, 115, 0, 116, - 0, 272, 271, 13, 16, 0, 13, 16, 26, 111, - 112, 0, 0, 0, 0, 0, 0, 113, 114, 0, - 27, 115, 14, 116, 0, 111, 112, 12, 0, 26, - 0, 311, 312, 113, 114, 0, 0, 115, 0, 116, - 313, 27, 0, 314, 0, 315, 0, 0, 12, 0, - 0, 0, 0, 29, 0, 0, 0, 15, 0, 0, - 0, 0, 0, 0, 28, 30, 0, 0, 0, 0, - 0, 0, 31, 0, 526, 0, 0, 0, 15, 0, - 0, 25, 0, 14, 0, 28, 30, 186, 0, 0, - 0, 0, 0, 31, 0, 0, 0, 187, 0, 111, - 112, 188, 25, 0, 14, 0, 0, 113, 114, 0, - 189, 115, 190, 116, 0, 340, 0, 0, 0, 0, - 0, 0, 0, 191, 0, 192, 95, 0, 0, 69, - 70, 0, 0, 193, 0, 0, 194, 96, 0, 72, - 0, 0, 195, 0, 0, 0, 12, 0, 196, 0, - 73, 74, 0, 75, 0, 0, 0, 0, 0, 0, - 78, 0, 0, 197, 81, 0, 0, 186, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 187, 0, 0, - 0, 188, 84, 13, 16, 0, 85, 0, 0, 0, - 189, 0, 190, 0, 0, 0, 0, 80, 87, 71, - 0, 0, 0, 191, 0, 192, 95, 0, 0, 0, - 0, 0, 0, 193, 0, 0, 194, 96, 0, 0, - 0, 0, 195, 0, 0, 0, 0, 0, 196, 0, + 544, 386, 451, 537, 337, 315, 395, 487, 602, 347, + 185, 385, 489, 467, 335, 378, 368, 355, 474, 361, + 349, 467, 383, 491, 376, 483, 483, 473, 467, -111, + 374, 383, 388, 500, -116, -89, 459, -108, -90, 496, + -113, 496, 459, -116, -89, -111, 483, 529, -113, -86, + 483, 442, -108, -86, -119, 391, 391, 300, 432, -100, + -90, 500, 434, -100, -119, 300, 337, -76, 463, 541, + 457, 452, 294, 483, 339, 496, 233, 2, 216, 446, + 210, 444, 115, 389, 459, 500, 295, 145, 236, 315, + 191, 335, 145, 344, 391, 229, 210, 115, 2, 608, + 185, 300, 0, 54, 536, 477, 185, 0, 185, 486, + 185, 0, 23, 592, 0, 185, 185, 102, 143, 370, + 235, 143, 225, 487, 279, 102, 470, 193, 103, 185, + 33, 102, 106, 185, 185, 185, 103, 185, 49, 185, + 292, 291, 103, 107, 596, 595, 509, 290, 289, 0, + 456, 455, 393, 355, 20, 19, 292, 291, 223, 102, + 461, 593, 27, 26, 186, 285, 284, 380, 8, 50, + 103, 471, 371, 212, 357, 292, 291, 213, 358, 299, + 298, 520, 129, 218, 130, 498, 502, 353, 108, 297, + 218, 605, 195, 194, 510, 131, 17, 16, 8, 56, + 8, 50, 219, 50, 220, 9, 12, 108, 0, 219, + 129, 449, 130, 129, 52, 130, 129, 108, 130, 129, + 185, 130, 50, 131, 15, 51, 131, 8, 129, 131, + 130, 531, 131, 109, 185, 9, 12, 9, 12, 110, + 185, 131, 147, 8, 606, 604, 52, 129, 52, 130, + 0, 0, 109, 57, 55, 0, 0, 51, 110, 51, + 131, 148, 109, 149, 9, 12, 8, 52, 110, 129, + 129, 130, 130, 535, 534, 8, 0, 0, 51, 8, + 9, 12, 131, 131, 8, 532, 530, 481, 480, 129, + 8, 130, 8, 278, 277, 129, 129, 130, 130, -330, + 23, 0, 131, 9, 12, 129, 548, 130, 131, 131, + 117, 118, 9, 12, 23, 185, 9, 12, 131, 8, + 0, 9, 12, 117, 118, 0, -330, 9, 12, 9, + 12, 0, 33, 0, 0, 0, 0, 119, 120, 0, + 33, 0, 0, 0, 0, 8, 24, 22, 8, 0, + 119, 120, 322, 323, 0, 0, 9, 12, 322, 323, + 0, 324, 8, 0, 325, 8, 326, 324, 278, 277, + 325, 8, 326, 8, 21, 322, 323, 283, 282, 0, + 283, 282, 9, 12, 324, 9, 12, 325, 8, 326, + 0, 317, 318, 8, 288, 287, 0, 288, 287, 9, + 12, 11, 9, 12, 0, 283, 282, 0, 9, 12, + 9, 12, 0, 0, 0, 0, 0, 0, 319, 320, + 288, 287, 0, 11, 8, 9, 12, 10, 122, 123, + 9, 12, 0, 0, 0, 0, 124, 125, 122, 123, + 126, 0, 127, 0, 0, 0, 124, 125, 0, 10, + 126, 0, 127, 0, 11, 122, 123, 0, 0, 0, + 13, 9, 12, 124, 125, 322, 323, 126, 0, 127, + 0, 0, 37, 0, 324, 0, 0, 325, 0, 326, + 10, 0, 0, 0, 38, 0, 0, 0, 0, 0, + 0, 8, 0, 0, 0, 37, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 38, 0, 0, + 0, 0, 0, 0, 8, 0, 0, 40, 0, 0, + 0, 11, 0, 0, 0, 0, 0, 0, 39, 41, + 0, 0, 0, 0, 122, 123, 42, 0, 0, 197, + 546, 0, 124, 125, 11, 36, 126, 10, 127, 198, + 0, 39, 41, 199, 0, 0, 0, 0, 0, 42, + 0, 0, 200, 0, 201, 0, 0, 351, 36, 0, + 10, 0, 0, 0, 0, 202, 0, 203, 106, 0, + 0, 0, 0, 0, 0, 204, 0, 0, 205, 107, + 0, 0, 0, 0, 206, 0, 0, 0, 0, 0, + 207, 0, 0, 197, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 198, 0, 208, 0, 199, 0, 0, + 0, 0, 0, 0, 0, 0, 200, 0, 201, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, + 0, 203, 106, 0, 0, 0, 0, 0, 0, 204, + 0, 0, 205, 107, 0, 0, 0, 0, 206, 0, + 0, 0, 0, 0, 207, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 80, 81, 0, 0, 0, 0, 0, 0, + 0, 0, 83, 0, 0, 0, 0, 0, 0, 8, + 0, 0, 0, 84, 85, 0, 86, 0, 0, 0, + 0, 0, 0, 89, 0, 0, 0, 92, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 95, 9, 12, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 197, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 69, 70, 0, 0, 0, - 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, - 0, 0, 12, 0, 0, 0, 73, 74, 0, 75, - 0, 0, 0, 0, 0, 0, 78, 0, 0, 0, - 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 84, 13, - 16, 0, 85, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 80, 87, 71, 0, 0, 0, 0, - 0, 0, 0, 0, 68, 69, 70, 0, 0, 0, - 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, - 0, 0, 12, 0, 0, 0, 73, 74, 0, 75, - 0, 0, 0, 76, 0, 77, 78, 79, 0, 0, - 81, 0, 0, 0, 82, 0, 83, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 84, 13, - 16, 0, 85, 0, 86, 0, 88, 0, 89, 0, - 0, 0, 0, 80, 87, 71, 0, 0, 0, 0, - 0, 0, 0, 0, -98, 0, 0, 0, 68, 69, - 70, 0, 0, 0, 0, 0, 0, 0, 0, 72, - 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, - 73, 74, 0, 75, 0, 0, 0, 76, 0, 77, - 78, 79, 0, 0, 81, 0, 0, 0, 82, 0, - 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 84, 13, 16, 0, 85, 0, 86, 0, - 88, 0, 89, 0, 0, 0, 0, 80, 87, 71, - 0, 0, 0, 0, 0, 0, 0, 0, 68, 69, - 70, 0, 0, 0, 0, 0, 0, 0, 0, 72, - 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, - 73, 74, 0, 75, 0, 0, 0, 76, 0, 77, - 78, 79, 0, 0, 81, 0, 0, 0, 82, 0, - 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 84, 13, 16, 0, 85, 0, 86, 0, - 88, 303, 89, 0, 0, 0, 0, 80, 87, 71, - 0, 0, 0, 0, 0, 0, 0, 0, 496, 0, - 0, 68, 69, 70, 0, 0, 0, 0, 0, 0, - 0, 0, 72, 0, 0, 0, 0, 0, 0, 12, - 0, 0, 0, 73, 74, 0, 75, 0, 0, 0, - 76, 0, 77, 78, 79, 0, 0, 81, 0, 0, - 0, 82, 0, 83, 0, 0, 497, 0, 0, 0, - 0, 0, 0, 0, 0, 84, 13, 16, 0, 85, - 0, 86, 0, 88, 0, 89, 0, 0, 0, 0, - 80, 87, 71, 0, 0, 0, 0, 0, 0, 0, - 0, 504, 0, 0, 68, 69, 70, 0, 0, 0, - 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, - 0, 0, 12, 0, 0, 0, 73, 74, 0, 75, - 0, 0, 0, 76, 0, 77, 78, 79, 0, 0, - 81, 0, 0, 0, 82, 0, 83, 0, 0, 505, - 0, 0, 0, 0, 0, 0, 0, 0, 84, 13, - 16, 0, 85, 0, 86, 0, 88, 0, 89, 0, - 0, 0, 0, 80, 87, 71, 0, 0, 0, 0, - 0, 0, 0, 0, 496, 0, 0, 68, 69, 70, - 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, - 0, 0, 0, 0, 0, 12, 0, 0, 0, 73, - 74, 0, 75, 0, 0, 0, 76, 0, 77, 78, - 79, 0, 0, 81, 0, 0, 0, 82, 0, 83, - 0, 0, 502, 0, 0, 0, 0, 0, 0, 0, - 0, 84, 13, 16, 0, 85, 0, 86, 0, 88, - 0, 89, 0, 0, 0, 0, 80, 87, 71, 0, - 0, 0, 0, 0, 0, 0, 0, 504, 0, 0, - 68, 69, 70, 0, 0, 0, 0, 0, 0, 0, - 0, 72, 0, 0, 0, 0, 0, 0, 12, 0, - 0, 0, 73, 74, 0, 75, 0, 0, 0, 76, - 0, 77, 78, 79, 0, 0, 81, 0, 0, 0, - 82, 0, 83, 0, 0, 507, 0, 0, 0, 0, - 0, 0, 0, 0, 84, 13, 16, 0, 85, 0, - 86, 0, 88, 0, 89, 0, 0, 0, 0, 80, - 87, 71, 0, 0, 0, 0, 0, 0, 0, 0, - 496, 0, 0, 68, 69, 70, 0, 0, 0, 0, - 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, - 0, 12, 0, 0, 0, 73, 74, 0, 75, 0, - 0, 0, 76, 0, 77, 78, 79, 0, 0, 81, - 0, 0, 0, 82, 0, 83, 0, 0, 497, 0, - 0, 15, 0, 0, 0, 0, 0, 84, 13, 16, - 0, 85, 0, 86, 0, 88, 0, 89, 0, 0, - 0, 0, 80, 87, 71, 0, 0, 14, 0, 0, - 0, 0, 0, 68, 69, 70, 0, 0, 0, 0, - 0, 0, 0, 0, 72, 0, 0, 0, 0, 0, - 0, 12, 251, 0, 0, 535, 536, 0, 75, 0, - 0, 0, 76, 0, 77, 78, 79, 0, 0, 81, - 0, 0, 0, 82, 0, 83, 0, 0, 0, 0, - 0, 0, 0, 255, 0, 0, 0, 84, 13, 16, - 0, 85, 0, 86, 0, 88, 0, 89, 0, 0, - 0, 0, 80, 87, 71, 0, 246, 0, 537, 0, - 0, 0, 0, 142, 143, 144, 0, 0, 146, 148, - 149, 0, 0, 150, 0, 151, 0, 0, 0, 153, - 154, 155, 0, 0, 0, 0, 0, 0, 12, 156, - 157, 158, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 159, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 162, 0, - 0, 0, 0, 0, 0, 13, 16, 163, 164, 165, - 0, 167, 168, 169, 170, 171, 172, 0, 0, 160, - 166, 152, 145, 147, 161, 0, 0, 0, 0, 0, - 142, 143, 144, 0, 0, 146, 148, 149, 0, 0, - 150, 0, 151, 0, 0, 0, 153, 154, 155, 0, - 0, 0, 0, 0, 0, 425, 156, 157, 158, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 159, - 0, 0, 0, 426, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 162, 0, 0, 0, 0, - 0, 430, 427, 429, 163, 164, 165, 0, 167, 168, - 169, 170, 171, 172, 0, 0, 160, 166, 152, 145, - 147, 161, 0, 0, 0, 0, 0, 142, 143, 144, - 0, 0, 146, 148, 149, 0, 0, 150, 0, 151, - 0, 0, 0, 153, 154, 155, 0, 0, 0, 0, - 0, 0, 425, 156, 157, 158, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 159, 0, 0, 0, - 426, 0, 0, 0, 0, 0, 0, 0, 428, 0, - 0, 0, 162, 0, 0, 0, 0, 0, 430, 427, - 429, 163, 164, 165, 0, 167, 168, 169, 170, 171, - 172, 0, 0, 160, 166, 152, 145, 147, 161, 0, - 0, 0, 0, 0, 244, 0, 0, 0, 0, 245, - 0, 68, 69, 70, 247, 0, 0, 0, 0, 0, - 0, 248, 72, 0, 0, 0, 0, 0, 0, 250, - 251, 0, 0, 252, 74, 0, 75, 0, 0, 0, - 76, 0, 77, 78, 79, 0, 0, 81, 0, 0, - 0, 82, 0, 83, 0, 0, 0, 0, 0, 254, - 0, 255, 0, 0, 0, 84, 253, 256, 257, 85, - 258, 86, 259, 88, 31, 89, 260, 261, 0, 0, - 80, 87, 71, 25, 246, 0, 0, 0, 0, 0, - 0, 244, 0, 0, 0, 0, 245, 0, 68, 69, - 70, 247, 0, 0, 0, 0, 0, 0, 248, 249, - 0, 0, 0, 0, 0, 0, 250, 251, 0, 0, - 252, 74, 0, 75, 0, 0, 0, 76, 0, 77, - 78, 79, 0, 0, 81, 0, 0, 0, 82, 0, - 83, 0, 0, 0, 0, 0, 254, 0, 255, 0, - 0, 0, 84, 253, 256, 257, 85, 258, 86, 259, - 88, 31, 89, 260, 261, 0, 0, 80, 87, 71, - 25, 246, 0, 0, 0, 0, 0, 0, 541, 143, - 144, 0, 0, 543, 148, 545, 69, 70, 546, 0, - 151, 0, 0, 0, 153, 548, 549, 0, 0, 0, - 0, 0, 0, 550, 551, 157, 158, 252, 74, 0, - 75, 0, 0, 0, 76, 0, 77, 552, 79, 0, - 0, 554, 0, 0, 0, 82, 0, 83, 0, 0, - 0, 0, 0, 556, 0, 255, 0, 0, 0, 558, - 555, 557, 559, 560, 561, 86, 563, 564, 565, 566, - 567, 568, 0, 0, 553, 562, 547, 542, 544, 161, - 0, 0, 0, 0, 0, 393, 143, 144, 0, 0, - 395, 148, 397, 69, 70, 398, 0, 151, 0, 0, - 0, 153, 400, 401, 0, 0, 0, 0, 0, 0, - 402, 403, 157, 158, 252, 74, 0, 75, 0, 0, - 0, 76, 0, 77, 404, 79, 0, 0, 406, 0, - 0, 0, 82, 0, 83, 0, -244, 0, 0, 0, - 408, 0, 255, 0, 0, 0, 410, 407, 409, 411, - 412, 413, 86, 415, 416, 417, 418, 419, 420, 0, - 0, 405, 414, 399, 394, 396, 161, 0, 0, 0, - 0, 0, + 91, 98, 82, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 79, 80, 81, 0, 0, 0, 0, 0, + 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 84, 85, 0, 86, 0, 0, + 0, 87, 0, 88, 89, 90, 0, 0, 92, 0, + 0, 0, 93, 0, 94, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 95, 9, 12, 0, + 96, 0, 97, 0, 99, 0, 100, 0, 0, 0, + 0, 91, 98, 82, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 79, 80, 81, 0, 0, 0, 0, + 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, + 0, 8, 0, 0, 0, 84, 85, 0, 86, 0, + 0, 0, 87, 0, 88, 89, 90, 0, 0, 92, + 0, 0, 0, 93, 0, 94, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 95, 9, 12, + 0, 96, 0, 97, 0, 99, 314, 100, 0, 0, + 0, 0, 91, 98, 82, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -109, 0, 0, 0, 79, 80, + 81, 0, 0, 0, 0, 0, 0, 0, 0, 83, + 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, + 84, 85, 0, 86, 0, 0, 0, 87, 0, 88, + 89, 90, 0, 0, 92, 0, 0, 0, 93, 0, + 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 95, 9, 12, 0, 96, 0, 97, 0, + 99, 0, 100, 0, 0, 0, 0, 91, 98, 82, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 515, + 0, 0, 79, 80, 81, 0, 0, 0, 0, 0, + 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 84, 85, 0, 86, 0, 0, + 0, 87, 0, 88, 89, 90, 0, 0, 92, 0, + 0, 0, 93, 0, 94, 0, 0, 518, 0, 0, + 0, 0, 0, 0, 0, 0, 95, 9, 12, 0, + 96, 0, 97, 0, 99, 0, 100, 0, 0, 0, + 0, 91, 98, 82, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 515, 0, 0, 79, 80, 81, 0, + 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, + 0, 0, 0, 0, 8, 0, 0, 0, 84, 85, + 0, 86, 0, 0, 0, 87, 0, 88, 89, 90, + 0, 0, 92, 0, 0, 0, 93, 0, 94, 0, + 0, 516, 0, 0, 0, 0, 0, 0, 0, 0, + 95, 9, 12, 0, 96, 0, 97, 0, 99, 0, + 100, 0, 0, 0, 0, 91, 98, 82, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 507, 0, 0, + 79, 80, 81, 0, 0, 0, 0, 0, 0, 0, + 0, 83, 0, 0, 0, 0, 0, 0, 8, 0, + 0, 0, 84, 85, 0, 86, 0, 0, 0, 87, + 0, 88, 89, 90, 0, 0, 92, 0, 0, 0, + 93, 0, 94, 0, 0, 513, 0, 0, 0, 0, + 0, 0, 0, 0, 95, 9, 12, 0, 96, 0, + 97, 0, 99, 0, 100, 0, 0, 0, 0, 91, + 98, 82, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 507, 0, 0, 79, 80, 81, 0, 0, 0, + 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 0, 84, 85, 0, 86, + 0, 0, 0, 87, 0, 88, 89, 90, 0, 0, + 92, 0, 0, 0, 93, 0, 94, 0, 0, 508, + 0, 0, 0, 0, 0, 0, 0, 0, 95, 9, + 12, 0, 96, 0, 97, 0, 99, 0, 100, 0, + 0, 0, 0, 91, 98, 82, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 507, 0, 0, 79, 80, + 81, 0, 0, 0, 0, 0, 0, 0, 0, 83, + 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, + 84, 85, 0, 86, 0, 0, 0, 87, 0, 88, + 89, 90, 0, 0, 92, 0, 0, 0, 93, 0, + 94, 0, 0, 508, 0, 0, 11, 0, 0, 0, + 0, 0, 95, 9, 12, 0, 96, 0, 97, 0, + 99, 0, 100, 0, 0, 0, 0, 91, 98, 82, + 0, 0, 10, 0, 0, 0, 0, 0, 0, 79, + 80, 81, 0, 0, 0, 0, 0, 0, 0, 0, + 83, 0, 0, 0, 0, 0, 0, 8, 262, 0, + 0, 555, 556, 0, 86, 0, 0, 0, 87, 0, + 88, 89, 90, 0, 0, 92, 0, 0, 0, 93, + 0, 94, 0, 0, 0, 0, 0, 0, 0, 266, + 0, 0, 0, 95, 9, 12, 0, 96, 0, 97, + 0, 99, 0, 100, 0, 0, 0, 0, 91, 98, + 82, 0, 257, 0, 557, 0, 0, 0, 0, 0, + 153, 154, 155, 0, 0, 157, 159, 160, 0, 0, + 161, 0, 162, 0, 0, 0, 164, 165, 166, 0, + 0, 0, 0, 0, 0, 8, 167, 168, 169, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 170, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 173, 0, 0, 0, 0, + 0, 0, 9, 12, 174, 175, 176, 0, 178, 179, + 180, 181, 182, 183, 0, 0, 171, 177, 163, 156, + 158, 172, 0, 0, 0, 0, 0, 0, 153, 154, + 155, 0, 0, 157, 159, 160, 0, 0, 161, 0, + 162, 0, 0, 0, 164, 165, 166, 0, 0, 0, + 0, 0, 0, 436, 167, 168, 169, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 170, 0, 0, + 0, 437, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 173, 0, 0, 0, 0, 0, 441, + 438, 440, 174, 175, 176, 0, 178, 179, 180, 181, + 182, 183, 0, 0, 171, 177, 163, 156, 158, 172, + 0, 0, 0, 0, 0, 0, 153, 154, 155, 0, + 0, 157, 159, 160, 0, 0, 161, 0, 162, 0, + 0, 0, 164, 165, 166, 0, 0, 0, 0, 0, + 0, 436, 167, 168, 169, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 170, 0, 0, 0, 437, + 0, 0, 0, 0, 0, 0, 0, 439, 0, 0, + 0, 173, 0, 0, 0, 0, 0, 441, 438, 440, + 174, 175, 176, 0, 178, 179, 180, 181, 182, 183, + 0, 0, 171, 177, 163, 156, 158, 172, 0, 0, + 0, 0, 0, 0, 255, 0, 0, 0, 0, 256, + 0, 79, 80, 81, 258, 0, 0, 0, 0, 0, + 0, 259, 260, 0, 0, 0, 0, 0, 0, 261, + 262, 0, 0, 263, 85, 0, 86, 0, 0, 0, + 87, 0, 88, 89, 90, 0, 0, 92, 0, 0, + 0, 93, 0, 94, 0, 0, 0, 0, 0, 265, + 0, 266, 0, 0, 0, 95, 264, 267, 268, 96, + 269, 97, 270, 99, 42, 100, 271, 272, 0, 0, + 91, 98, 82, 36, 257, 0, 0, 0, 0, 0, + 0, 0, 255, 0, 0, 0, 0, 256, 0, 79, + 80, 81, 258, 0, 0, 0, 0, 0, 0, 259, + 83, 0, 0, 0, 0, 0, 0, 261, 262, 0, + 0, 263, 85, 0, 86, 0, 0, 0, 87, 0, + 88, 89, 90, 0, 0, 92, 0, 0, 0, 93, + 0, 94, 0, 0, 0, 0, 0, 265, 0, 266, + 0, 0, 0, 95, 264, 267, 268, 96, 269, 97, + 270, 99, 42, 100, 271, 272, 0, 0, 91, 98, + 82, 36, 257, 0, 0, 0, 0, 0, 0, 0, + 561, 154, 155, 0, 0, 563, 159, 565, 80, 81, + 566, 0, 162, 0, 0, 0, 164, 568, 569, 0, + 0, 0, 0, 0, 0, 570, 571, 168, 169, 263, + 85, 0, 86, 0, 0, 0, 87, 0, 88, 572, + 90, 0, 0, 574, 0, 0, 0, 93, 0, 94, + 0, 0, 0, 0, 0, 576, 0, 266, 0, 0, + 0, 578, 575, 577, 579, 580, 581, 97, 583, 584, + 585, 586, 587, 588, 0, 0, 573, 582, 567, 562, + 564, 172, 0, 0, 0, 0, 0, 0, 404, 154, + 155, 0, 0, 406, 159, 408, 80, 81, 409, 0, + 162, 0, 0, 0, 164, 411, 412, 0, 0, 0, + 0, 0, 0, 413, 414, 168, 169, 263, 85, 0, + 86, 0, 0, 0, 87, 0, 88, 415, 90, 0, + 0, 417, 0, 0, 0, 93, 0, 94, 0, -255, + 0, 0, 0, 419, 0, 266, 0, 0, 0, 421, + 418, 420, 422, 423, 424, 97, 426, 427, 428, 429, + 430, 431, 0, 0, 416, 425, 410, 405, 407, 172, + 0, 0, 0, 0, 0, 0, - 334, 477, 282, 482, 270, 503, 467, 464, 275, 42, - 577, 55, 506, 479, 481, 217, 516, 522, 185, 23, - 468, 217, 540, 583, 10, 486, 488, 492, 490, 493, - 508, 270, 434, 385, 422, 383, 381, 366, 379, 368, - 270, 275, 468, 275, 334, 173, 282, 217, 242, 223, - 179, 468, 176, 334, 285, 371, 221, 343, 181, 341, - 211, 282, 465, 198, 352, 204, 457, 339, 370, 449, - 447, 206, 432, 442, 424, 334, 0, 93, 179, 501, - 0, 577, 318, 500, 213, 221, 93, 0, 471, 93, - 93, 93, 130, 483, 316, 317, 93, 461, 93, 93, - 215, 319, 93, 93, 320, 514, 93, 93, 129, 17, - 93, 0, 110, 94, 93, 93, 484, 102, 93, 242, - 93, 103, 101, 203, 337, 93, 11, 484, 93, 93, - 93, 513, 483, 93, 574, 515, 298, 93, 587, 334, - 0, 302, 200, 93, 93, 105, 334, 352, 125, 126, - 93, 11, 215, 269, 93, 93, 373, 510, 93, 124, - 512, 93, 436, 511, 179, 437, 93, 0, 242, 93, - 439, 127, 93, 123, 0, 436, 0, 128, 437, 93, - 93, 483, 215, 93, 93, 139, 436, 122, 335, 437, - 93, 93, 334, 141, 121, 362, 133, 376, 93, 93, - 100, 135, 93, 0, 117, 330, 361, 330, 131, 330, - 302, 93, 302, 93, 302, 330, 302, 0, 302, 0, - 302, 0, 0, 93, 327, 93, 345, 329, 302, 332, - 302, 351, 310, 0, 0, 0, 0, 349, 93, 0, - 348, 364, 93, 302, 93, 321, 484, 302, 93, 322, - 0, 93, 93, 302, 330, 323, 302, 302, 139, 302, - 35, 305, 0, 0, 325, 527, 141, 210, 35, 0, - 24, 37, 11, 0, 0, 0, 358, 0, 24, 37, - 11, 532, 529, 531, 533, 530, 534, 0, 0, 0, + 545, 488, 533, 542, 66, 478, 514, 597, 482, 253, + 543, 479, 517, 232, 53, 504, 493, 228, 497, 503, + 345, 499, 234, 519, 501, 286, 196, 293, 490, 492, + 382, 540, 527, 479, 396, 184, 445, 190, 345, 286, + 345, 293, 228, 209, 394, 192, 377, 392, 354, 352, + 479, 25, 379, 390, 350, 18, 28, 475, 381, 187, + 560, 460, 215, 482, 472, 458, 222, 296, 476, 217, + 468, 435, 363, 433, 29, 482, 228, 286, 597, 7, + 150, 594, 104, 453, 494, 603, 443, 232, 7, 293, + 30, 0, 447, 7, 14, 448, 363, 104, 281, 495, + 345, 104, 104, 226, 104, 104, 134, 152, 104, 104, + 138, 253, 253, 345, 139, 345, 144, 104, 146, 226, + 104, 104, 494, 345, 104, 132, 495, 104, 0, 104, + 104, 133, 309, 190, 327, 104, 104, 313, 104, 224, + 387, 328, 104, 329, 211, 0, 280, 331, 104, 447, + 375, 214, 448, 330, 607, 0, 104, 104, 526, 111, + 104, 104, 494, 373, 105, 348, 104, 104, 104, 114, + 525, 0, 137, 346, 372, 0, 104, 384, 226, 104, + 104, 524, 521, 447, 104, 104, 448, 523, 104, 136, + 522, 104, 104, 495, 0, 104, 512, 190, 121, 104, + 511, 140, 104, 450, 104, 141, 104, 0, 142, 128, + 150, 135, 104, 104, 104, 113, 0, 104, 104, 313, + 116, 332, 313, 313, 333, 321, 104, 341, 104, 104, + 0, 313, 313, 313, 313, 316, 334, 152, 221, 338, + 341, 104, 341, 341, 0, 313, 313, 313, 313, 369, + 341, 0, 104, 104, 0, 313, 356, 313, 313, 7, + 46, 0, 340, 0, 343, 362, 336, 7, 46, 359, + 0, 547, 360, 104, 0, 112, 0, 35, 48, 552, + 549, 551, 553, 550, 554, 35, 48, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 571, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 569, 0, 0, 0, 0, 0, - 493, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 589, 0, 591, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 504, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0}; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0}; const int QmlJSGrammar::action_check [] = { - 60, 8, 36, 36, 33, 33, 7, 60, 7, 36, - 29, 33, 7, 7, 7, 36, 7, 55, 7, 78, - 1, 78, 48, 1, 36, 33, 36, 36, 60, 5, - 55, 61, 2, 33, 8, 55, 60, 16, 7, 7, - 7, 5, 48, 60, 7, 2, 60, 20, 7, 5, - 48, 17, 55, 2, 31, 7, 61, 8, 33, 7, - 7, 7, 7, 60, 36, 36, 7, 0, 8, 7, - 7, 36, 7, 88, 36, 29, 36, 1, 60, 65, - 33, 17, 78, 1, 7, 7, 36, 7, 7, 33, - 33, 76, 8, 2, 55, 78, 88, 36, 8, 29, - 8, 8, 36, 61, 36, 36, 48, 36, 8, 8, - 8, 66, 40, 8, 40, 8, -1, 7, 8, 8, - -1, -1, -1, 51, 15, 51, 8, 40, 40, 50, - 6, 8, 10, 54, 61, 62, 61, 62, 51, 51, - 42, 8, 33, 8, 20, 7, 61, 62, 8, 29, - 60, 53, 60, 60, 29, 61, 62, 56, 56, 29, - 60, 56, 50, 56, 61, 62, 54, 61, 62, 61, - 62, 60, 8, 29, 61, 62, 7, 55, 7, 61, - 61, 62, 8, 60, 29, -1, 15, 15, 15, 12, - 29, 66, 67, 60, 74, 60, 66, 67, 15, 29, - 8, 61, 62, -1, 33, 85, 34, 34, 36, 36, - 66, 67, 8, 29, -1, -1, -1, 34, -1, 36, - 29, 66, 67, 29, -1, 61, 62, 66, 67, 7, - 61, 62, 29, -1, 57, 61, 62, 29, -1, 25, - 63, 27, 12, 25, 74, 27, 25, 12, 27, -1, - 66, 67, 38, 61, 62, 85, 38, 66, 67, 38, - 66, 67, 29, 18, 19, 61, 62, 29, -1, 66, - 67, 29, -1, -1, 66, 67, 8, -1, 36, 18, - 19, 29, -1, 61, 62, -1, -1, 57, 36, -1, - 45, 46, 57, 63, 18, 19, 18, 19, 63, 66, - 67, 33, 23, 24, 66, 67, 45, 46, 66, 67, - 29, 32, 29, 25, 35, 27, 37, -1, 66, 67, - 29, 45, 46, 45, 46, 29, 38, 23, 24, 61, - 62, -1, 29, -1, -1, -1, 32, -1, -1, 35, - -1, 37, 61, 62, 61, 62, -1, 66, 67, 66, - 67, 29, 61, 62, -1, 59, -1, 66, 67, 23, - 24, -1, 66, 67, 61, 62, 23, 24, 32, 66, - 67, 35, -1, 37, -1, 32, 29, -1, 35, 29, - 37, 85, -1, 61, 62, 23, 24, -1, 66, 67, - -1, -1, -1, 31, 32, 23, 24, 35, -1, 37, - -1, -1, -1, 31, 32, -1, 59, 35, -1, 37, - -1, 61, 62, 66, 67, -1, 66, 67, 10, 23, - 24, -1, -1, -1, -1, -1, -1, 31, 32, -1, - 22, 35, 85, 37, -1, 23, 24, 29, -1, 10, - -1, 23, 24, 31, 32, -1, -1, 35, -1, 37, - 32, 22, -1, 35, -1, 37, -1, -1, 29, -1, - -1, -1, -1, 55, -1, -1, -1, 59, -1, -1, - -1, -1, -1, -1, 66, 67, -1, -1, -1, -1, - -1, -1, 74, -1, 55, -1, -1, -1, 59, -1, - -1, 83, -1, 85, -1, 66, 67, 3, -1, -1, - -1, -1, -1, 74, -1, -1, -1, 13, -1, 23, - 24, 17, 83, -1, 85, -1, -1, 31, 32, -1, - 26, 35, 28, 37, -1, 31, -1, -1, -1, -1, - -1, -1, -1, 39, -1, 41, 42, -1, -1, 12, - 13, -1, -1, 49, -1, -1, 52, 53, -1, 22, - -1, -1, 58, -1, -1, -1, 29, -1, 64, -1, - 33, 34, -1, 36, -1, -1, -1, -1, -1, -1, - 43, -1, -1, 79, 47, -1, -1, 3, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 13, -1, -1, - -1, 17, 65, 66, 67, -1, 69, -1, -1, -1, - 26, -1, 28, -1, -1, -1, -1, 80, 81, 82, - -1, -1, -1, 39, -1, 41, 42, -1, -1, -1, - -1, -1, -1, 49, -1, -1, 52, 53, -1, -1, - -1, -1, 58, -1, -1, -1, -1, -1, 64, -1, + 60, 33, 60, 36, 78, 1, 16, 20, 17, 61, + 8, 60, 36, 5, 48, 31, 17, 2, 7, 7, + 60, 5, 36, 60, 60, 33, 33, 55, 5, 7, + 61, 36, 55, 36, 7, 7, 36, 7, 7, 36, + 7, 36, 36, 7, 7, 7, 33, 29, 7, 7, + 33, 7, 7, 7, 7, 36, 36, 36, 7, 7, + 7, 36, 8, 7, 7, 36, 78, 33, 33, 8, + 7, 7, 76, 33, 8, 36, 8, 88, 7, 55, + 2, 55, 1, 7, 36, 36, 36, 78, 33, 1, + 8, 48, 78, 61, 36, 36, 2, 1, 88, 0, + 8, 36, -1, 29, 29, 7, 8, -1, 8, 6, + 8, -1, 15, 8, -1, 8, 8, 40, 48, 8, + 60, 48, 60, 20, 55, 40, 10, 60, 51, 8, + 33, 40, 42, 8, 8, 8, 51, 8, 66, 8, + 61, 62, 51, 53, 61, 62, 8, 61, 62, -1, + 61, 62, 60, 2, 61, 62, 61, 62, 56, 40, + 60, 56, 61, 62, 56, 61, 62, 60, 29, 29, + 51, 55, 61, 50, 50, 61, 62, 54, 54, 61, + 62, 60, 25, 15, 27, 60, 60, 60, 12, 60, + 15, 8, 61, 62, 56, 38, 61, 62, 29, 7, + 29, 29, 34, 29, 36, 66, 67, 12, -1, 34, + 25, 36, 27, 25, 74, 27, 25, 12, 27, 25, + 8, 27, 29, 38, 89, 85, 38, 29, 25, 38, + 27, 7, 38, 57, 8, 66, 67, 66, 67, 63, + 8, 38, 15, 29, 61, 62, 74, 25, 74, 27, + -1, -1, 57, 61, 62, -1, -1, 85, 63, 85, + 38, 34, 57, 36, 66, 67, 29, 74, 63, 25, + 25, 27, 27, 61, 62, 29, -1, -1, 85, 29, + 66, 67, 38, 38, 29, 61, 62, 61, 62, 25, + 29, 27, 29, 61, 62, 25, 25, 27, 27, 36, + 15, -1, 38, 66, 67, 25, 7, 27, 38, 38, + 18, 19, 66, 67, 15, 8, 66, 67, 38, 29, + -1, 66, 67, 18, 19, -1, 36, 66, 67, 66, + 67, -1, 33, -1, -1, -1, -1, 45, 46, -1, + 33, -1, -1, -1, -1, 29, 61, 62, 29, -1, + 45, 46, 23, 24, -1, -1, 66, 67, 23, 24, + -1, 32, 29, -1, 35, 29, 37, 32, 61, 62, + 35, 29, 37, 29, 89, 23, 24, 61, 62, -1, + 61, 62, 66, 67, 32, 66, 67, 35, 29, 37, + -1, 18, 19, 29, 61, 62, -1, 61, 62, 66, + 67, 59, 66, 67, -1, 61, 62, -1, 66, 67, + 66, 67, -1, -1, -1, -1, -1, -1, 45, 46, + 61, 62, -1, 59, 29, 66, 67, 85, 23, 24, + 66, 67, -1, -1, -1, -1, 31, 32, 23, 24, + 35, -1, 37, -1, -1, -1, 31, 32, -1, 85, + 35, -1, 37, -1, 59, 23, 24, -1, -1, -1, + 65, 66, 67, 31, 32, 23, 24, 35, -1, 37, + -1, -1, 10, -1, 32, -1, -1, 35, -1, 37, + 85, -1, -1, -1, 22, -1, -1, -1, -1, -1, + -1, 29, -1, -1, -1, 10, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, + -1, -1, -1, -1, 29, -1, -1, 55, -1, -1, + -1, 59, -1, -1, -1, -1, -1, -1, 66, 67, + -1, -1, -1, -1, 23, 24, 74, -1, -1, 3, + 55, -1, 31, 32, 59, 83, 35, 85, 37, 13, + -1, 66, 67, 17, -1, -1, -1, -1, -1, 74, + -1, -1, 26, -1, 28, -1, -1, 31, 83, -1, + 85, -1, -1, -1, -1, 39, -1, 41, 42, -1, + -1, -1, -1, -1, -1, 49, -1, -1, 52, 53, + -1, -1, -1, -1, 58, -1, -1, -1, -1, -1, + 64, -1, -1, 3, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 13, -1, 79, -1, 17, -1, -1, + -1, -1, -1, -1, -1, -1, 26, -1, 28, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, + -1, 41, 42, -1, -1, -1, -1, -1, -1, 49, + -1, -1, 52, 53, -1, -1, -1, -1, 58, -1, + -1, -1, -1, -1, 64, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, - -1, -1, -1, -1, -1, -1, 43, -1, -1, -1, - 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, - 67, -1, 69, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 80, 81, 82, -1, -1, -1, -1, - -1, -1, -1, -1, 11, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, - 67, -1, 69, -1, 71, -1, 73, -1, 75, -1, - -1, -1, -1, 80, 81, 82, -1, -1, -1, -1, + -1, -1, 12, 13, -1, -1, -1, -1, -1, -1, + -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, + -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, + -1, -1, -1, 43, -1, -1, -1, 47, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 65, 66, 67, -1, 69, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, + -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, + 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, + -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, + -1, -1, 51, -1, 53, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 65, 66, 67, -1, + 69, -1, 71, -1, 73, -1, 75, -1, -1, -1, + -1, 80, 81, 82, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 11, 12, 13, -1, -1, -1, -1, + -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, + -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, + -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, + -1, -1, -1, 51, -1, 53, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, + -1, 69, -1, 71, -1, 73, 74, 75, -1, -1, + -1, -1, 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, -1, -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, @@ -664,39 +690,23 @@ const int QmlJSGrammar::action_check [] = { 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, 67, -1, 69, -1, 71, -1, 73, -1, 75, -1, -1, -1, -1, 80, 81, 82, - -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, - -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 65, 66, 67, -1, 69, -1, 71, -1, - 73, 74, 75, -1, -1, -1, -1, 80, 81, 82, - -1, -1, -1, -1, -1, -1, -1, -1, 8, -1, - -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, - -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, - -1, -1, -1, 33, 34, -1, 36, -1, -1, -1, - 40, -1, 42, 43, 44, -1, -1, 47, -1, -1, - -1, 51, -1, 53, -1, -1, 56, -1, -1, -1, - -1, -1, -1, -1, -1, 65, 66, 67, -1, 69, - -1, 71, -1, 73, -1, 75, -1, -1, -1, -1, - 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, - -1, 8, -1, -1, 11, 12, 13, -1, -1, -1, - -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, - -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, - -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, - 47, -1, -1, -1, 51, -1, 53, -1, -1, 56, - -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, - 67, -1, 69, -1, 71, -1, 73, -1, 75, -1, - -1, -1, -1, 80, 81, 82, -1, -1, -1, -1, - -1, -1, -1, -1, 8, -1, -1, 11, 12, 13, - -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, - -1, -1, -1, -1, -1, 29, -1, -1, -1, 33, - 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, - 44, -1, -1, 47, -1, -1, -1, 51, -1, 53, - -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, - -1, 65, 66, 67, -1, 69, -1, 71, -1, 73, - -1, 75, -1, -1, -1, -1, 80, 81, 82, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, + -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, + -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, + 29, -1, -1, -1, 33, 34, -1, 36, -1, -1, + -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, + -1, -1, 51, -1, 53, -1, -1, 56, -1, -1, + -1, -1, -1, -1, -1, -1, 65, 66, 67, -1, + 69, -1, 71, -1, 73, -1, 75, -1, -1, -1, + -1, 80, 81, 82, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, + -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, + -1, -1, -1, -1, 29, -1, -1, -1, 33, 34, + -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, + -1, -1, 47, -1, -1, -1, 51, -1, 53, -1, + -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, + 65, 66, 67, -1, 69, -1, 71, -1, 73, -1, + 75, -1, -1, -1, -1, 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, -1, 29, -1, @@ -706,48 +716,57 @@ const int QmlJSGrammar::action_check [] = { -1, -1, -1, -1, 65, 66, 67, -1, 69, -1, 71, -1, 73, -1, 75, -1, -1, -1, -1, 80, 81, 82, -1, -1, -1, -1, -1, -1, -1, -1, - 8, -1, -1, 11, 12, 13, -1, -1, -1, -1, - -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, - -1, 29, -1, -1, -1, 33, 34, -1, 36, -1, - -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, - -1, -1, -1, 51, -1, 53, -1, -1, 56, -1, - -1, 59, -1, -1, -1, -1, -1, 65, 66, 67, - -1, 69, -1, 71, -1, 73, -1, 75, -1, -1, - -1, -1, 80, 81, 82, -1, -1, 85, -1, -1, - -1, -1, -1, 11, 12, 13, -1, -1, -1, -1, - -1, -1, -1, -1, 22, -1, -1, -1, -1, -1, - -1, 29, 30, -1, -1, 33, 34, -1, 36, -1, - -1, -1, 40, -1, 42, 43, 44, -1, -1, 47, - -1, -1, -1, 51, -1, 53, -1, -1, -1, -1, - -1, -1, -1, 61, -1, -1, -1, 65, 66, 67, - -1, 69, -1, 71, -1, 73, -1, 75, -1, -1, - -1, -1, 80, 81, 82, -1, 84, -1, 86, -1, - -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, - 11, -1, -1, 14, -1, 16, -1, -1, -1, 20, - 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, - 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 43, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, - -1, -1, -1, -1, -1, 66, 67, 68, 69, 70, - -1, 72, 73, 74, 75, 76, 77, -1, -1, 80, - 81, 82, 83, 84, 85, -1, -1, -1, -1, -1, + -1, 8, -1, -1, 11, 12, 13, -1, -1, -1, + -1, -1, -1, -1, -1, 22, -1, -1, -1, -1, + -1, -1, 29, -1, -1, -1, 33, 34, -1, 36, + -1, -1, -1, 40, -1, 42, 43, 44, -1, -1, + 47, -1, -1, -1, 51, -1, 53, -1, -1, 56, + -1, -1, -1, -1, -1, -1, -1, -1, 65, 66, + 67, -1, 69, -1, 71, -1, 73, -1, 75, -1, + -1, -1, -1, 80, 81, 82, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 8, -1, -1, 11, 12, + 13, -1, -1, -1, -1, -1, -1, -1, -1, 22, + -1, -1, -1, -1, -1, -1, 29, -1, -1, -1, + 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, + 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, + 53, -1, -1, 56, -1, -1, 59, -1, -1, -1, + -1, -1, 65, 66, 67, -1, 69, -1, 71, -1, + 73, -1, 75, -1, -1, -1, -1, 80, 81, 82, + -1, -1, 85, -1, -1, -1, -1, -1, -1, 11, + 12, 13, -1, -1, -1, -1, -1, -1, -1, -1, + 22, -1, -1, -1, -1, -1, -1, 29, 30, -1, + -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, + 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, + -1, 53, -1, -1, -1, -1, -1, -1, -1, 61, + -1, -1, -1, 65, 66, 67, -1, 69, -1, 71, + -1, 73, -1, 75, -1, -1, -1, -1, 80, 81, + 82, -1, 84, -1, 86, -1, -1, -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, - -1, -1, -1, 47, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, -1, -1, -1, -1, - -1, 65, 66, 67, 68, 69, 70, -1, 72, 73, + -1, -1, 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, -1, -1, 80, 81, 82, 83, - 84, 85, -1, -1, -1, -1, -1, 4, 5, 6, - -1, -1, 9, 10, 11, -1, -1, 14, -1, 16, - -1, -1, -1, 20, 21, 22, -1, -1, -1, -1, - -1, -1, 29, 30, 31, 32, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 43, -1, -1, -1, - 47, -1, -1, -1, -1, -1, -1, -1, 55, -1, - -1, -1, 59, -1, -1, -1, -1, -1, 65, 66, - 67, 68, 69, 70, -1, 72, 73, 74, 75, 76, - 77, -1, -1, 80, 81, 82, 83, 84, 85, -1, + 84, 85, -1, -1, -1, -1, -1, -1, 4, 5, + 6, -1, -1, 9, 10, 11, -1, -1, 14, -1, + 16, -1, -1, -1, 20, 21, 22, -1, -1, -1, + -1, -1, -1, 29, 30, 31, 32, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 43, -1, -1, + -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 59, -1, -1, -1, -1, -1, 65, + 66, 67, 68, 69, 70, -1, 72, 73, 74, 75, + 76, 77, -1, -1, 80, 81, 82, 83, 84, 85, + -1, -1, -1, -1, -1, -1, 4, 5, 6, -1, + -1, 9, 10, 11, -1, -1, 14, -1, 16, -1, + -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, + -1, 29, 30, 31, 32, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 43, -1, -1, -1, 47, + -1, -1, -1, -1, -1, -1, -1, 55, -1, -1, + -1, 59, -1, -1, -1, -1, -1, 65, 66, 67, + 68, 69, 70, -1, 72, 73, 74, 75, 76, 77, + -1, -1, 80, 81, 82, 83, 84, 85, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, 9, -1, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1, 21, 22, -1, -1, -1, -1, -1, -1, 29, @@ -757,73 +776,76 @@ const int QmlJSGrammar::action_check [] = { -1, 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, -1, 80, 81, 82, 83, 84, -1, -1, -1, -1, -1, - -1, 4, -1, -1, -1, -1, 9, -1, 11, 12, - 13, 14, -1, -1, -1, -1, -1, -1, 21, 22, - -1, -1, -1, -1, -1, -1, 29, 30, -1, -1, - 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, - 43, 44, -1, -1, 47, -1, -1, -1, 51, -1, - 53, -1, -1, -1, -1, -1, 59, -1, 61, -1, - -1, -1, 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, -1, -1, 80, 81, 82, - 83, 84, -1, -1, -1, -1, -1, -1, 4, 5, + -1, -1, 4, -1, -1, -1, -1, 9, -1, 11, + 12, 13, 14, -1, -1, -1, -1, -1, -1, 21, + 22, -1, -1, -1, -1, -1, -1, 29, 30, -1, + -1, 33, 34, -1, 36, -1, -1, -1, 40, -1, + 42, 43, 44, -1, -1, 47, -1, -1, -1, 51, + -1, 53, -1, -1, -1, -1, -1, 59, -1, 61, + -1, -1, -1, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, -1, -1, 80, 81, + 82, 83, 84, -1, -1, -1, -1, -1, -1, -1, + 4, 5, 6, -1, -1, 9, 10, 11, 12, 13, + 14, -1, 16, -1, -1, -1, 20, 21, 22, -1, + -1, -1, -1, -1, -1, 29, 30, 31, 32, 33, + 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, + 44, -1, -1, 47, -1, -1, -1, 51, -1, 53, + -1, -1, -1, -1, -1, 59, -1, 61, -1, -1, + -1, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, -1, -1, 80, 81, 82, 83, + 84, 85, -1, -1, -1, -1, -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, 12, 13, 14, -1, 16, -1, -1, -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, 29, 30, 31, 32, 33, 34, -1, 36, -1, -1, -1, 40, -1, 42, 43, 44, -1, - -1, 47, -1, -1, -1, 51, -1, 53, -1, -1, + -1, 47, -1, -1, -1, 51, -1, 53, -1, 55, -1, -1, -1, 59, -1, 61, -1, -1, -1, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, -1, 80, 81, 82, 83, 84, 85, - -1, -1, -1, -1, -1, 4, 5, 6, -1, -1, - 9, 10, 11, 12, 13, 14, -1, 16, -1, -1, - -1, 20, 21, 22, -1, -1, -1, -1, -1, -1, - 29, 30, 31, 32, 33, 34, -1, 36, -1, -1, - -1, 40, -1, 42, 43, 44, -1, -1, 47, -1, - -1, -1, 51, -1, 53, -1, 55, -1, -1, -1, - 59, -1, 61, -1, -1, -1, 65, 66, 67, 68, - 69, 70, 71, 72, 73, 74, 75, 76, 77, -1, - -1, 80, 81, 82, 83, 84, 85, -1, -1, -1, - -1, -1, + -1, -1, -1, -1, -1, -1, - 14, 93, 66, 15, 23, 29, 76, 76, 23, 20, - 23, 14, 29, 23, 15, 23, 23, 14, 62, 23, - 14, 23, 10, 29, 5, 14, 66, 66, 14, 29, - 14, 23, 66, 66, 29, 66, 14, 66, 66, 14, - 23, 23, 14, 23, 14, 14, 66, 23, 66, 23, - 29, 14, 29, 14, 14, 23, 23, 66, 29, 14, - 14, 66, 14, 29, 23, 29, 91, 66, 66, 14, - 66, 29, 29, 66, 30, 14, -1, 39, 29, 25, - -1, 23, 44, 29, 35, 23, 39, -1, 15, 39, - 39, 39, 45, 41, 44, 44, 39, 88, 39, 39, - 41, 44, 39, 39, 44, 41, 39, 39, 45, 6, - 39, -1, 45, 42, 39, 39, 41, 41, 39, 66, - 39, 42, 41, 55, 63, 39, 23, 41, 39, 39, - 39, 41, 41, 39, 6, 41, 39, 39, 80, 14, - -1, 44, 53, 39, 39, 47, 14, 23, 44, 44, - 39, 23, 41, 100, 39, 39, 94, 41, 39, 44, - 41, 39, 33, 41, 29, 36, 39, -1, 66, 39, - 35, 44, 39, 43, -1, 33, -1, 44, 36, 39, - 39, 41, 41, 39, 39, 23, 33, 43, 63, 36, - 39, 39, 14, 31, 43, 63, 51, 95, 39, 39, - 41, 49, 39, -1, 44, 39, 82, 39, 45, 39, - 44, 39, 44, 39, 44, 39, 44, -1, 44, -1, - 44, -1, -1, 39, 50, 39, 54, 61, 44, 61, - 44, 61, 46, -1, -1, -1, -1, 61, 39, -1, - 56, 63, 39, 44, 39, 46, 41, 44, 39, 46, - -1, 39, 39, 44, 39, 46, 44, 44, 23, 44, - 11, 48, -1, -1, 52, 8, 31, 32, 11, -1, - 21, 22, 23, -1, -1, -1, 61, -1, 21, 22, - 23, 14, 15, 16, 17, 18, 19, -1, -1, -1, + 6, 95, 15, 21, 15, 78, 31, 6, 16, 68, + 6, 15, 31, 6, 21, 31, 16, 6, 15, 68, + 15, 68, 6, 15, 15, 6, 64, 68, 6, 16, + 6, 21, 6, 15, 68, 15, 68, 31, 15, 6, + 15, 68, 6, 31, 68, 31, 68, 15, 68, 15, + 15, 6, 15, 68, 68, 6, 6, 78, 68, 31, + 12, 15, 31, 16, 90, 68, 15, 15, 15, 31, + 93, 32, 6, 31, 5, 16, 6, 6, 6, 6, + 6, 8, 41, 68, 43, 31, 31, 6, 6, 68, + 8, -1, 35, 6, 7, 38, 6, 41, 6, 43, + 15, 41, 41, 43, 41, 41, 45, 33, 41, 41, + 46, 68, 68, 15, 46, 15, 53, 41, 51, 43, + 41, 41, 43, 15, 41, 45, 43, 41, -1, 41, + 41, 45, 41, 31, 46, 41, 41, 46, 41, 37, + 97, 46, 41, 46, 55, -1, 102, 46, 41, 35, + 65, 57, 38, 46, 82, -1, 41, 41, 43, 43, + 41, 41, 43, 65, 44, 65, 41, 41, 41, 44, + 43, -1, 46, 65, 84, -1, 41, 96, 43, 41, + 41, 43, 43, 35, 41, 41, 38, 43, 41, 46, + 43, 41, 41, 43, -1, 41, 27, 31, 47, 41, + 31, 47, 41, 37, 41, 47, 41, -1, 47, 46, + 6, 46, 41, 41, 41, 43, -1, 41, 41, 46, + 49, 48, 46, 46, 48, 48, 41, 41, 41, 41, + -1, 46, 46, 46, 46, 50, 48, 33, 34, 52, + 41, 41, 41, 41, -1, 46, 46, 46, 46, 63, + 41, -1, 41, 41, -1, 46, 56, 46, 46, 6, + 7, -1, 63, -1, 63, 63, 54, 6, 7, 58, + -1, 10, 63, 41, -1, 43, -1, 24, 25, 15, + 16, 17, 18, 19, 20, 24, 25, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 6, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, - 29, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1}; + -1, -1, -1, -1}; diff --git a/src/declarative/qml/parser/qmljsgrammar_p.h b/src/declarative/qml/parser/qmljsgrammar_p.h index c514485..a8d4bdf 100644 --- a/src/declarative/qml/parser/qmljsgrammar_p.h +++ b/src/declarative/qml/parser/qmljsgrammar_p.h @@ -2,7 +2,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtCore module of the Qt Toolkit. ** @@ -35,7 +35,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -59,11 +59,12 @@ class QmlJSGrammar public: enum { EOF_SYMBOL = 0, - REDUCE_HERE = 90, - SHIFT_THERE = 89, + REDUCE_HERE = 91, + SHIFT_THERE = 90, T_AND = 1, T_AND_AND = 2, T_AND_EQ = 3, + T_AS = 89, T_AUTOMATIC_SEMICOLON = 62, T_BREAK = 4, T_CASE = 5, @@ -150,15 +151,15 @@ public: T_XOR = 78, T_XOR_EQ = 79, - ACCEPT_STATE = 588, - RULE_COUNT = 323, - STATE_COUNT = 589, - TERMINAL_COUNT = 91, - NON_TERMINAL_COUNT = 102, + ACCEPT_STATE = 608, + RULE_COUNT = 334, + STATE_COUNT = 609, + TERMINAL_COUNT = 92, + NON_TERMINAL_COUNT = 104, - GOTO_INDEX_OFFSET = 589, - GOTO_INFO_OFFSET = 2092, - GOTO_CHECK_OFFSET = 2092 + GOTO_INDEX_OFFSET = 609, + GOTO_INFO_OFFSET = 2136, + GOTO_CHECK_OFFSET = 2136 }; static const char *const spell []; diff --git a/src/declarative/qml/parser/qmljslexer.cpp b/src/declarative/qml/parser/qmljslexer.cpp index 843f6ae..a22169d 100644 --- a/src/declarative/qml/parser/qmljslexer.cpp +++ b/src/declarative/qml/parser/qmljslexer.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -159,6 +159,8 @@ int Lexer::findReservedWord(const QChar *c, int size) const return QmlJSGrammar::T_IF; else if (c[0] == QLatin1Char('i') && c[1] == QLatin1Char('n')) return QmlJSGrammar::T_IN; + else if (c[0] == QLatin1Char('a') && c[1] == QLatin1Char('s')) + return QmlJSGrammar::T_AS; } break; case 3: { diff --git a/src/declarative/qml/parser/qmljsmemorypool_p.h b/src/declarative/qml/parser/qmljsmemorypool_p.h index d7506be..6bd21f8 100644 --- a/src/declarative/qml/parser/qmljsmemorypool_p.h +++ b/src/declarative/qml/parser/qmljsmemorypool_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsnodepool_p.h b/src/declarative/qml/parser/qmljsnodepool_p.h index 1a5b7f6..e2f0a3c 100644 --- a/src/declarative/qml/parser/qmljsnodepool_p.h +++ b/src/declarative/qml/parser/qmljsnodepool_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsparser.cpp b/src/declarative/qml/parser/qmljsparser.cpp index 6ecff3d..679d0b3 100644 --- a/src/declarative/qml/parser/qmljsparser.cpp +++ b/src/declarative/qml/parser/qmljsparser.cpp @@ -220,56 +220,86 @@ case 6: { sym(1).Node = node; } break; -case 7: { +case 8: { + AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).sval); + node->importId = sym(4).sval; + node->importToken = loc(1); + node->fileNameToken = loc(2); + node->asToken = loc(3); + node->importIdToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; + +case 10: { + AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId); + node->importToken = loc(1); + node->fileNameToken = loc(2); + node->semicolonToken = loc(3); + sym(1).Node = node; +} break; + +case 12: { + AST::UiImport *node = makeAstNode<AST::UiImport>(driver->nodePool(), sym(2).UiQualifiedId); + node->importId = sym(4).sval; + node->importToken = loc(1); + node->fileNameToken = loc(2); + node->asToken = loc(3); + node->importIdToken = loc(4); + node->semicolonToken = loc(5); + sym(1).Node = node; +} break; + +case 13: { sym(1).Node = 0; } break; -case 8: { +case 14: { sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember); } break; -case 9: { +case 15: { sym(1).Node = makeAstNode<AST::UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMember); } break; -case 10: { +case 16: { AST::UiObjectMemberList *node = makeAstNode<AST:: UiObjectMemberList> (driver->nodePool(), sym(1).UiObjectMemberList, sym(2).UiObjectMember); sym(1).Node = node; } break; -case 11: { +case 17: { sym(1).Node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiObjectMember); } break; -case 12: { +case 18: { AST::UiArrayMemberList *node = makeAstNode<AST::UiArrayMemberList> (driver->nodePool(), sym(1).UiArrayMemberList, sym(3).UiObjectMember); node->commaToken = loc(2); sym(1).Node = node; } break; -case 13: { +case 19: { AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), (AST::UiObjectMemberList*)0); node->lbraceToken = loc(1); node->rbraceToken = loc(2); sym(1).Node = node; } break; -case 14: { +case 20: { AST::UiObjectInitializer *node = makeAstNode<AST::UiObjectInitializer> (driver->nodePool(), sym(2).UiObjectMemberList->finish()); node->lbraceToken = loc(1); node->rbraceToken = loc(3); sym(1).Node = node; } break; -case 15: { +case 21: { AST::UiObjectDefinition *node = makeAstNode<AST::UiObjectDefinition> (driver->nodePool(), sym(1).UiQualifiedId->finish(), sym(2).UiObjectInitializer); sym(1).Node = node; } break; -case 17: { +case 23: { AST::UiArrayBinding *node = makeAstNode<AST::UiArrayBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(), sym(4).UiArrayMemberList->finish()); node->colonToken = loc(2); @@ -278,19 +308,19 @@ case 17: { sym(1).Node = node; } break; -case 18: { +case 24: { AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval); node->literalToken = loc(1); sym(1).Node = node; } break; -case 20: { +case 26: { AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 21: { +case 27: { if (AST::UiQualifiedId *qualifiedId = reparseAsQualifiedId(sym(3).Expression)) { AST::UiObjectBinding *node = makeAstNode<AST::UiObjectBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(), qualifiedId, sym(4).UiObjectInitializer); @@ -305,7 +335,7 @@ case 21: { return false; // ### recover } } break; -case 22:case 23:case 24:case 25:case 26:case 27: +case 28:case 29:case 30:case 31:case 32:case 33: { AST::UiScriptBinding *node = makeAstNode<AST::UiScriptBinding> (driver->nodePool(), sym(1).UiQualifiedId->finish(), sym(3).Statement); @@ -313,14 +343,45 @@ case 22:case 23:case 24:case 25:case 26:case 27: sym(1).Node = node; } break; -case 28: +case 34: -case 29: { +case 35: { sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount()); break; } -case 31: { +case 37: { + sym(1).Node = 0; +} break; + +case 38: { + sym(1).Node = sym(1).UiParameterList->finish (); +} break; + +case 39: { + AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).sval, sym(2).sval); + node->identifierToken = loc(2); + sym(1).Node = node; +} break; + +case 40: { + AST::UiParameterList *node = makeAstNode<AST::UiParameterList> (driver->nodePool(), sym(1).UiParameterList, sym(3).sval, sym(4).sval); + node->commaToken = loc(2); + node->identifierToken = loc(4); + sym(1).Node = node; +} break; + +case 41: { + AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval); + node->type = AST::UiPublicMember::Signal; + node->propertyToken = loc(1); + node->typeToken = loc(2); + node->identifierToken = loc(3); + node->parameters = sym(4).UiParameterList; + sym(1).Node = node; +} break; + +case 42: { AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), (NameId *)0, sym(2).sval); node->type = AST::UiPublicMember::Signal; node->propertyToken = loc(1); @@ -329,7 +390,7 @@ case 31: { sym(1).Node = node; } break; -case 33: { +case 44: { AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval); node->propertyToken = loc(1); node->typeToken = loc(2); @@ -338,7 +399,7 @@ case 33: { sym(1).Node = node; } break; -case 35: { +case 46: { AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval); node->isDefaultMember = true; node->defaultToken = loc(1); @@ -349,7 +410,7 @@ case 35: { sym(1).Node = node; } break; -case 37: { +case 48: { AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(2).sval, sym(3).sval, sym(5).Expression); node->propertyToken = loc(1); @@ -360,7 +421,7 @@ case 37: { sym(1).Node = node; } break; -case 39: { +case 50: { AST::UiPublicMember *node = makeAstNode<AST::UiPublicMember> (driver->nodePool(), sym(3).sval, sym(4).sval, sym(6).Expression); node->isDefaultMember = true; @@ -373,76 +434,76 @@ case 39: { sym(1).Node = node; } break; -case 40: { +case 51: { sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node); } break; -case 41: { +case 52: { sym(1).Node = makeAstNode<AST::UiSourceElement>(driver->nodePool(), sym(1).Node); } break; -case 42: -case 43: +case 53: +case 54: { AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount())); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 45: { +case 56: { QString s = QLatin1String(QmlJSGrammar::spell[T_PROPERTY]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } -case 46: { +case 57: { QString s = QLatin1String(QmlJSGrammar::spell[T_SIGNAL]); sym(1).sval = driver->intern(s.constData(), s.length()); break; } -case 47: { +case 58: { AST::ThisExpression *node = makeAstNode<AST::ThisExpression> (driver->nodePool()); node->thisToken = loc(1); sym(1).Node = node; } break; -case 48: { +case 59: { AST::IdentifierExpression *node = makeAstNode<AST::IdentifierExpression> (driver->nodePool(), sym(1).sval); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 49: { +case 60: { AST::NullExpression *node = makeAstNode<AST::NullExpression> (driver->nodePool()); node->nullToken = loc(1); sym(1).Node = node; } break; -case 50: { +case 61: { AST::TrueLiteral *node = makeAstNode<AST::TrueLiteral> (driver->nodePool()); node->trueToken = loc(1); sym(1).Node = node; } break; -case 51: { +case 62: { AST::FalseLiteral *node = makeAstNode<AST::FalseLiteral> (driver->nodePool()); node->falseToken = loc(1); sym(1).Node = node; } break; -case 52: { +case 63: { AST::NumericLiteral *node = makeAstNode<AST::NumericLiteral> (driver->nodePool(), sym(1).dval, lexer->flags); node->literalToken = loc(1); sym(1).Node = node; } break; -case 53: { +case 64: { AST::StringLiteral *node = makeAstNode<AST::StringLiteral> (driver->nodePool(), sym(1).sval); node->literalToken = loc(1); sym(1).Node = node; } break; -case 54: { +case 65: { bool rx = lexer->scanRegExp(Lexer::NoPrefix); if (!rx) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); @@ -453,7 +514,7 @@ case 54: { sym(1).Node = node; } break; -case 55: { +case 66: { bool rx = lexer->scanRegExp(Lexer::EqualPrefix); if (!rx) { diagnostic_messages.append(DiagnosticMessage(DiagnosticMessage::Error, location(lexer), lexer->errorMessage())); @@ -464,28 +525,28 @@ case 55: { sym(1).Node = node; } break; -case 56: { +case 67: { AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), (AST::Elision *) 0); node->lbracketToken = loc(1); node->rbracketToken = loc(2); sym(1).Node = node; } break; -case 57: { +case 68: { AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).Elision->finish()); node->lbracketToken = loc(1); node->rbracketToken = loc(3); sym(1).Node = node; } break; -case 58: { +case 69: { AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish ()); node->lbracketToken = loc(1); node->rbracketToken = loc(3); sym(1).Node = node; } break; -case 59: { +case 70: { AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (), (AST::Elision *) 0); node->lbracketToken = loc(1); @@ -494,7 +555,7 @@ case 59: { sym(1).Node = node; } break; -case 60: { +case 71: { AST::ArrayLiteral *node = makeAstNode<AST::ArrayLiteral> (driver->nodePool(), sym(2).ElementList->finish (), sym(4).Elision->finish()); node->lbracketToken = loc(1); @@ -503,7 +564,7 @@ case 60: { sym(1).Node = node; } break; -case 61: { +case 72: { AST::ObjectLiteral *node = 0; if (sym(2).Node) node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(), @@ -515,7 +576,7 @@ case 61: { sym(1).Node = node; } break; -case 62: { +case 73: { AST::ObjectLiteral *node = makeAstNode<AST::ObjectLiteral> (driver->nodePool(), sym(2).PropertyNameAndValueList->finish ()); node->lbraceToken = loc(1); @@ -523,67 +584,67 @@ case 62: { sym(1).Node = node; } break; -case 63: { +case 74: { AST::NestedExpression *node = makeAstNode<AST::NestedExpression>(driver->nodePool(), sym(2).Expression); node->lparenToken = loc(1); node->rparenToken = loc(3); sym(1).Node = node; } break; -case 64: { +case 75: { AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), sym(1).sval); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 65: { +case 76: { AST::UiQualifiedId *node = makeAstNode<AST::UiQualifiedId> (driver->nodePool(), sym(1).UiQualifiedId, sym(3).sval); node->identifierToken = loc(3); sym(1).Node = node; } break; -case 66: { +case 77: { sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), (AST::Elision *) 0, sym(1).Expression); } break; -case 67: { +case 78: { sym(1).Node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).Elision->finish(), sym(2).Expression); } break; -case 68: { +case 79: { AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList, (AST::Elision *) 0, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 69: { +case 80: { AST::ElementList *node = makeAstNode<AST::ElementList> (driver->nodePool(), sym(1).ElementList, sym(3).Elision->finish(), sym(4).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 70: { +case 81: { AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool()); node->commaToken = loc(1); sym(1).Node = node; } break; -case 71: { +case 82: { AST::Elision *node = makeAstNode<AST::Elision> (driver->nodePool(), sym(1).Elision); node->commaToken = loc(2); sym(1).Node = node; } break; -case 72: { +case 83: { AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyName, sym(3).Expression); node->colonToken = loc(2); sym(1).Node = node; } break; -case 73: { +case 84: { AST::PropertyNameAndValueList *node = makeAstNode<AST::PropertyNameAndValueList> (driver->nodePool(), sym(1).PropertyNameAndValueList, sym(3).PropertyName, sym(5).Expression); node->commaToken = loc(2); @@ -591,58 +652,36 @@ case 73: { sym(1).Node = node; } break; -case 74: { +case 85: { AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 75: -case 76: { +case 86: +case 87: { AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount())); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 77: { +case 88: { AST::StringLiteralPropertyName *node = makeAstNode<AST::StringLiteralPropertyName> (driver->nodePool(), sym(1).sval); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 78: { +case 89: { AST::NumericLiteralPropertyName *node = makeAstNode<AST::NumericLiteralPropertyName> (driver->nodePool(), sym(1).dval); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 79: { +case 90: { AST::IdentifierPropertyName *node = makeAstNode<AST::IdentifierPropertyName> (driver->nodePool(), sym(1).sval); node->propertyNameToken = loc(1); sym(1).Node = node; } break; -case 80: - -case 81: - -case 82: - -case 83: - -case 84: - -case 85: - -case 86: - -case 87: - -case 88: - -case 89: - -case 90: - case 91: case 92: @@ -682,25 +721,47 @@ case 108: case 109: case 110: + +case 111: + +case 112: + +case 113: + +case 114: + +case 115: + +case 116: + +case 117: + +case 118: + +case 119: + +case 120: + +case 121: { sym(1).sval = driver->intern(lexer->characterBuffer(), lexer->characterCount()); } break; -case 115: { +case 126: { AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); node->lbracketToken = loc(2); node->rbracketToken = loc(4); sym(1).Node = node; } break; -case 116: { +case 127: { AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval); node->dotToken = loc(2); node->identifierToken = loc(3); sym(1).Node = node; } break; -case 117: { +case 128: { AST::NewMemberExpression *node = makeAstNode<AST::NewMemberExpression> (driver->nodePool(), sym(2).Expression, sym(4).ArgumentList); node->newToken = loc(1); node->lparenToken = loc(3); @@ -708,384 +769,384 @@ case 117: { sym(1).Node = node; } break; -case 119: { +case 130: { AST::NewExpression *node = makeAstNode<AST::NewExpression> (driver->nodePool(), sym(2).Expression); node->newToken = loc(1); sym(1).Node = node; } break; -case 120: { +case 131: { AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList); node->lparenToken = loc(2); node->rparenToken = loc(4); sym(1).Node = node; } break; -case 121: { +case 132: { AST::CallExpression *node = makeAstNode<AST::CallExpression> (driver->nodePool(), sym(1).Expression, sym(3).ArgumentList); node->lparenToken = loc(2); node->rparenToken = loc(4); sym(1).Node = node; } break; -case 122: { +case 133: { AST::ArrayMemberExpression *node = makeAstNode<AST::ArrayMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); node->lbracketToken = loc(2); node->rbracketToken = loc(4); sym(1).Node = node; } break; -case 123: { +case 134: { AST::FieldMemberExpression *node = makeAstNode<AST::FieldMemberExpression> (driver->nodePool(), sym(1).Expression, sym(3).sval); node->dotToken = loc(2); node->identifierToken = loc(3); sym(1).Node = node; } break; -case 124: { +case 135: { sym(1).Node = 0; } break; -case 125: { +case 136: { sym(1).Node = sym(1).ArgumentList->finish(); } break; -case 126: { +case 137: { sym(1).Node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).Expression); } break; -case 127: { +case 138: { AST::ArgumentList *node = makeAstNode<AST::ArgumentList> (driver->nodePool(), sym(1).ArgumentList, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 131: { +case 142: { AST::PostIncrementExpression *node = makeAstNode<AST::PostIncrementExpression> (driver->nodePool(), sym(1).Expression); node->incrementToken = loc(2); sym(1).Node = node; } break; -case 132: { +case 143: { AST::PostDecrementExpression *node = makeAstNode<AST::PostDecrementExpression> (driver->nodePool(), sym(1).Expression); node->decrementToken = loc(2); sym(1).Node = node; } break; -case 134: { +case 145: { AST::DeleteExpression *node = makeAstNode<AST::DeleteExpression> (driver->nodePool(), sym(2).Expression); node->deleteToken = loc(1); sym(1).Node = node; } break; -case 135: { +case 146: { AST::VoidExpression *node = makeAstNode<AST::VoidExpression> (driver->nodePool(), sym(2).Expression); node->voidToken = loc(1); sym(1).Node = node; } break; -case 136: { +case 147: { AST::TypeOfExpression *node = makeAstNode<AST::TypeOfExpression> (driver->nodePool(), sym(2).Expression); node->typeofToken = loc(1); sym(1).Node = node; } break; -case 137: { +case 148: { AST::PreIncrementExpression *node = makeAstNode<AST::PreIncrementExpression> (driver->nodePool(), sym(2).Expression); node->incrementToken = loc(1); sym(1).Node = node; } break; -case 138: { +case 149: { AST::PreDecrementExpression *node = makeAstNode<AST::PreDecrementExpression> (driver->nodePool(), sym(2).Expression); node->decrementToken = loc(1); sym(1).Node = node; } break; -case 139: { +case 150: { AST::UnaryPlusExpression *node = makeAstNode<AST::UnaryPlusExpression> (driver->nodePool(), sym(2).Expression); node->plusToken = loc(1); sym(1).Node = node; } break; -case 140: { +case 151: { AST::UnaryMinusExpression *node = makeAstNode<AST::UnaryMinusExpression> (driver->nodePool(), sym(2).Expression); node->minusToken = loc(1); sym(1).Node = node; } break; -case 141: { +case 152: { AST::TildeExpression *node = makeAstNode<AST::TildeExpression> (driver->nodePool(), sym(2).Expression); node->tildeToken = loc(1); sym(1).Node = node; } break; -case 142: { +case 153: { AST::NotExpression *node = makeAstNode<AST::NotExpression> (driver->nodePool(), sym(2).Expression); node->notToken = loc(1); sym(1).Node = node; } break; -case 144: { +case 155: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mul, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 145: { +case 156: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Div, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 146: { +case 157: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Mod, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 148: { +case 159: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Add, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 149: { +case 160: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Sub, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 151: { +case 162: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::LShift, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 152: { +case 163: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::RShift, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 153: { +case 164: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::URShift, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 155: { +case 166: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 156: { +case 167: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 157: { +case 168: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 158: { +case 169: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 159: { +case 170: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 160: { +case 171: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::In, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 162: { +case 173: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Lt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 163: { +case 174: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Gt, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 164: { +case 175: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Le, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 165: { +case 176: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Ge, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 166: { +case 177: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::InstanceOf, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 168: { +case 179: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 169: { +case 180: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 170: { +case 181: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 171: { +case 182: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 173: { +case 184: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Equal, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 174: { +case 185: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::NotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 175: { +case 186: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 176: { +case 187: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::StrictNotEqual, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 178: { +case 189: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 180: { +case 191: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitAnd, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 182: { +case 193: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 184: { +case 195: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitXor, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 186: { +case 197: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 188: { +case 199: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::BitOr, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 190: { +case 201: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 192: { +case 203: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::And, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 194: { +case 205: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 196: { +case 207: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, QSOperator::Or, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 198: { +case 209: { AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression); node->questionToken = loc(2); @@ -1093,7 +1154,7 @@ case 198: { sym(1).Node = node; } break; -case 200: { +case 211: { AST::ConditionalExpression *node = makeAstNode<AST::ConditionalExpression> (driver->nodePool(), sym(1).Expression, sym(3).Expression, sym(5).Expression); node->questionToken = loc(2); @@ -1101,112 +1162,112 @@ case 200: { sym(1).Node = node; } break; -case 202: { +case 213: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 204: { +case 215: { AST::BinaryExpression *node = makeAstNode<AST::BinaryExpression> (driver->nodePool(), sym(1).Expression, sym(2).ival, sym(3).Expression); node->operatorToken = loc(2); sym(1).Node = node; } break; -case 205: { +case 216: { sym(1).ival = QSOperator::Assign; } break; -case 206: { +case 217: { sym(1).ival = QSOperator::InplaceMul; } break; -case 207: { +case 218: { sym(1).ival = QSOperator::InplaceDiv; } break; -case 208: { +case 219: { sym(1).ival = QSOperator::InplaceMod; } break; -case 209: { +case 220: { sym(1).ival = QSOperator::InplaceAdd; } break; -case 210: { +case 221: { sym(1).ival = QSOperator::InplaceSub; } break; -case 211: { +case 222: { sym(1).ival = QSOperator::InplaceLeftShift; } break; -case 212: { +case 223: { sym(1).ival = QSOperator::InplaceRightShift; } break; -case 213: { +case 224: { sym(1).ival = QSOperator::InplaceURightShift; } break; -case 214: { +case 225: { sym(1).ival = QSOperator::InplaceAnd; } break; -case 215: { +case 226: { sym(1).ival = QSOperator::InplaceXor; } break; -case 216: { +case 227: { sym(1).ival = QSOperator::InplaceOr; } break; -case 218: { +case 229: { AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 219: { +case 230: { sym(1).Node = 0; } break; -case 222: { +case 233: { AST::Expression *node = makeAstNode<AST::Expression> (driver->nodePool(), sym(1).Expression, sym(3).Expression); node->commaToken = loc(2); sym(1).Node = node; } break; -case 223: { +case 234: { sym(1).Node = 0; } break; -case 240: { +case 251: { AST::Block *node = makeAstNode<AST::Block> (driver->nodePool(), sym(2).StatementList); node->lbraceToken = loc(1); node->rbraceToken = loc(3); sym(1).Node = node; } break; -case 241: { +case 252: { sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).Statement); } break; -case 242: { +case 253: { sym(1).Node = makeAstNode<AST::StatementList> (driver->nodePool(), sym(1).StatementList, sym(2).Statement); } break; -case 243: { +case 254: { sym(1).Node = 0; } break; -case 244: { +case 255: { sym(1).Node = sym(1).StatementList->finish (); } break; -case 246: { +case 257: { AST::VariableStatement *node = makeAstNode<AST::VariableStatement> (driver->nodePool(), sym(2).VariableDeclarationList->finish (/*readOnly=*/sym(1).ival == T_CONST)); node->declarationKindToken = loc(1); @@ -1214,76 +1275,76 @@ case 246: { sym(1).Node = node; } break; -case 247: { +case 258: { sym(1).ival = T_CONST; } break; -case 248: { +case 259: { sym(1).ival = T_VAR; } break; -case 249: { +case 260: { sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration); } break; -case 250: { +case 261: { AST::VariableDeclarationList *node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); node->commaToken = loc(2); sym(1).Node = node; } break; -case 251: { +case 262: { sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclaration); } break; -case 252: { +case 263: { sym(1).Node = makeAstNode<AST::VariableDeclarationList> (driver->nodePool(), sym(1).VariableDeclarationList, sym(3).VariableDeclaration); } break; -case 253: { +case 264: { AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 254: { +case 265: { AST::VariableDeclaration *node = makeAstNode<AST::VariableDeclaration> (driver->nodePool(), sym(1).sval, sym(2).Expression); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 255: { +case 266: { // ### TODO: AST for initializer sym(1) = sym(2); } break; -case 256: { +case 267: { sym(1).Node = 0; } break; -case 258: { +case 269: { // ### TODO: AST for initializer sym(1) = sym(2); } break; -case 259: { +case 270: { sym(1).Node = 0; } break; -case 261: { +case 272: { AST::EmptyStatement *node = makeAstNode<AST::EmptyStatement> (driver->nodePool()); node->semicolonToken = loc(1); sym(1).Node = node; } break; -case 263: { +case 274: { AST::ExpressionStatement *node = makeAstNode<AST::ExpressionStatement> (driver->nodePool(), sym(1).Expression); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 264: { +case 275: { AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement, sym(7).Statement); node->ifToken = loc(1); node->lparenToken = loc(2); @@ -1292,7 +1353,7 @@ case 264: { sym(1).Node = node; } break; -case 265: { +case 276: { AST::IfStatement *node = makeAstNode<AST::IfStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); node->ifToken = loc(1); node->lparenToken = loc(2); @@ -1300,7 +1361,7 @@ case 265: { sym(1).Node = node; } break; -case 267: { +case 278: { AST::DoWhileStatement *node = makeAstNode<AST::DoWhileStatement> (driver->nodePool(), sym(2).Statement, sym(5).Expression); node->doToken = loc(1); node->whileToken = loc(3); @@ -1310,7 +1371,7 @@ case 267: { sym(1).Node = node; } break; -case 268: { +case 279: { AST::WhileStatement *node = makeAstNode<AST::WhileStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); node->whileToken = loc(1); node->lparenToken = loc(2); @@ -1318,7 +1379,7 @@ case 268: { sym(1).Node = node; } break; -case 269: { +case 280: { AST::ForStatement *node = makeAstNode<AST::ForStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Expression, sym(9).Statement); node->forToken = loc(1); @@ -1329,7 +1390,7 @@ case 269: { sym(1).Node = node; } break; -case 270: { +case 281: { AST::LocalForStatement *node = makeAstNode<AST::LocalForStatement> (driver->nodePool(), sym(4).VariableDeclarationList->finish (/*readOnly=*/false), sym(6).Expression, sym(8).Expression, sym(10).Statement); @@ -1342,7 +1403,7 @@ case 270: { sym(1).Node = node; } break; -case 271: { +case 282: { AST:: ForEachStatement *node = makeAstNode<AST::ForEachStatement> (driver->nodePool(), sym(3).Expression, sym(5).Expression, sym(7).Statement); node->forToken = loc(1); @@ -1352,7 +1413,7 @@ case 271: { sym(1).Node = node; } break; -case 272: { +case 283: { AST::LocalForEachStatement *node = makeAstNode<AST::LocalForEachStatement> (driver->nodePool(), sym(4).VariableDeclaration, sym(6).Expression, sym(8).Statement); node->forToken = loc(1); @@ -1363,14 +1424,14 @@ case 272: { sym(1).Node = node; } break; -case 274: { +case 285: { AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool()); node->continueToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 276: { +case 287: { AST::ContinueStatement *node = makeAstNode<AST::ContinueStatement> (driver->nodePool(), sym(2).sval); node->continueToken = loc(1); node->identifierToken = loc(2); @@ -1378,14 +1439,14 @@ case 276: { sym(1).Node = node; } break; -case 278: { +case 289: { AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool()); node->breakToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 280: { +case 291: { AST::BreakStatement *node = makeAstNode<AST::BreakStatement> (driver->nodePool(), sym(2).sval); node->breakToken = loc(1); node->identifierToken = loc(2); @@ -1393,14 +1454,14 @@ case 280: { sym(1).Node = node; } break; -case 282: { +case 293: { AST::ReturnStatement *node = makeAstNode<AST::ReturnStatement> (driver->nodePool(), sym(2).Expression); node->returnToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; } break; -case 283: { +case 294: { AST::WithStatement *node = makeAstNode<AST::WithStatement> (driver->nodePool(), sym(3).Expression, sym(5).Statement); node->withToken = loc(1); node->lparenToken = loc(2); @@ -1408,7 +1469,7 @@ case 283: { sym(1).Node = node; } break; -case 284: { +case 295: { AST::SwitchStatement *node = makeAstNode<AST::SwitchStatement> (driver->nodePool(), sym(3).Expression, sym(5).CaseBlock); node->switchToken = loc(1); node->lparenToken = loc(2); @@ -1416,90 +1477,90 @@ case 284: { sym(1).Node = node; } break; -case 285: { +case 296: { AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses); node->lbraceToken = loc(1); node->rbraceToken = loc(3); sym(1).Node = node; } break; -case 286: { +case 297: { AST::CaseBlock *node = makeAstNode<AST::CaseBlock> (driver->nodePool(), sym(2).CaseClauses, sym(3).DefaultClause, sym(4).CaseClauses); node->lbraceToken = loc(1); node->rbraceToken = loc(5); sym(1).Node = node; } break; -case 287: { +case 298: { sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClause); } break; -case 288: { +case 299: { sym(1).Node = makeAstNode<AST::CaseClauses> (driver->nodePool(), sym(1).CaseClauses, sym(2).CaseClause); } break; -case 289: { +case 300: { sym(1).Node = 0; } break; -case 290: { +case 301: { sym(1).Node = sym(1).CaseClauses->finish (); } break; -case 291: { +case 302: { AST::CaseClause *node = makeAstNode<AST::CaseClause> (driver->nodePool(), sym(2).Expression, sym(4).StatementList); node->caseToken = loc(1); node->colonToken = loc(3); sym(1).Node = node; } break; -case 292: { +case 303: { AST::DefaultClause *node = makeAstNode<AST::DefaultClause> (driver->nodePool(), sym(3).StatementList); node->defaultToken = loc(1); node->colonToken = loc(2); sym(1).Node = node; } break; -case 293: -case 294: { +case 304: +case 305: { AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), driver->intern(lexer->characterBuffer(), lexer->characterCount()), sym(3).Statement); node->identifierToken = loc(1); node->colonToken = loc(2); sym(1).Node = node; } break; -case 295: { +case 306: { AST::LabelledStatement *node = makeAstNode<AST::LabelledStatement> (driver->nodePool(), sym(1).sval, sym(3).Statement); node->identifierToken = loc(1); node->colonToken = loc(2); sym(1).Node = node; } break; -case 297: { +case 308: { AST::ThrowStatement *node = makeAstNode<AST::ThrowStatement> (driver->nodePool(), sym(2).Expression); node->throwToken = loc(1); node->semicolonToken = loc(3); sym(1).Node = node; } break; -case 298: { +case 309: { AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch); node->tryToken = loc(1); sym(1).Node = node; } break; -case 299: { +case 310: { AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Finally); node->tryToken = loc(1); sym(1).Node = node; } break; -case 300: { +case 311: { AST::TryStatement *node = makeAstNode<AST::TryStatement> (driver->nodePool(), sym(2).Statement, sym(3).Catch, sym(4).Finally); node->tryToken = loc(1); sym(1).Node = node; } break; -case 301: { +case 312: { AST::Catch *node = makeAstNode<AST::Catch> (driver->nodePool(), sym(3).sval, sym(5).Block); node->catchToken = loc(1); node->lparenToken = loc(2); @@ -1508,20 +1569,20 @@ case 301: { sym(1).Node = node; } break; -case 302: { +case 313: { AST::Finally *node = makeAstNode<AST::Finally> (driver->nodePool(), sym(2).Block); node->finallyToken = loc(1); sym(1).Node = node; } break; -case 304: { +case 315: { AST::DebuggerStatement *node = makeAstNode<AST::DebuggerStatement> (driver->nodePool()); node->debuggerToken = loc(1); node->semicolonToken = loc(2); sym(1).Node = node; } break; -case 305: { +case 316: { AST::FunctionDeclaration *node = makeAstNode<AST::FunctionDeclaration> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody); node->functionToken = loc(1); node->identifierToken = loc(2); @@ -1532,7 +1593,7 @@ case 305: { sym(1).Node = node; } break; -case 306: { +case 317: { AST::FunctionExpression *node = makeAstNode<AST::FunctionExpression> (driver->nodePool(), sym(2).sval, sym(4).FormalParameterList, sym(7).FunctionBody); node->functionToken = loc(1); if (sym(2).sval) @@ -1544,56 +1605,56 @@ case 306: { sym(1).Node = node; } break; -case 307: { +case 318: { AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).sval); node->identifierToken = loc(1); sym(1).Node = node; } break; -case 308: { +case 319: { AST::FormalParameterList *node = makeAstNode<AST::FormalParameterList> (driver->nodePool(), sym(1).FormalParameterList, sym(3).sval); node->commaToken = loc(2); node->identifierToken = loc(3); sym(1).Node = node; } break; -case 309: { +case 320: { sym(1).Node = 0; } break; -case 310: { +case 321: { sym(1).Node = sym(1).FormalParameterList->finish (); } break; -case 311: { +case 322: { sym(1).Node = 0; } break; -case 313: { +case 324: { sym(1).Node = makeAstNode<AST::FunctionBody> (driver->nodePool(), sym(1).SourceElements->finish ()); } break; -case 314: { +case 325: { sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElement); } break; -case 315: { +case 326: { sym(1).Node = makeAstNode<AST::SourceElements> (driver->nodePool(), sym(1).SourceElements, sym(2).SourceElement); } break; -case 316: { +case 327: { sym(1).Node = makeAstNode<AST::StatementSourceElement> (driver->nodePool(), sym(1).Statement); } break; -case 317: { +case 328: { sym(1).Node = makeAstNode<AST::FunctionSourceElement> (driver->nodePool(), sym(1).FunctionDeclaration); } break; -case 318: { +case 329: { sym(1).sval = 0; } break; -case 320: { +case 331: { sym(1).Node = 0; } break; diff --git a/src/declarative/qml/parser/qmljsparser_p.h b/src/declarative/qml/parser/qmljsparser_p.h index cd2c7f5..e82c9c5 100644 --- a/src/declarative/qml/parser/qmljsparser_p.h +++ b/src/declarative/qml/parser/qmljsparser_p.h @@ -109,6 +109,7 @@ public: AST::UiProgram *UiProgram; AST::UiImportList *UiImportList; AST::UiImport *UiImport; + AST::UiParameterList *UiParameterList; AST::UiPublicMember *UiPublicMember; AST::UiObjectDefinition *UiObjectDefinition; AST::UiObjectInitializer *UiObjectInitializer; @@ -197,9 +198,9 @@ protected: -#define J_SCRIPT_REGEXPLITERAL_RULE1 54 +#define J_SCRIPT_REGEXPLITERAL_RULE1 65 -#define J_SCRIPT_REGEXPLITERAL_RULE2 55 +#define J_SCRIPT_REGEXPLITERAL_RULE2 66 QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/qmljsprettypretty.cpp b/src/declarative/qml/parser/qmljsprettypretty.cpp index 1045792..b6733e5 100644 --- a/src/declarative/qml/parser/qmljsprettypretty.cpp +++ b/src/declarative/qml/parser/qmljsprettypretty.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/parser/qmljsprettypretty_p.h b/src/declarative/qml/parser/qmljsprettypretty_p.h index fe82ca2..3227e7d 100644 --- a/src/declarative/qml/parser/qmljsprettypretty_p.h +++ b/src/declarative/qml/parser/qmljsprettypretty_p.h @@ -3,7 +3,7 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index 51ca612..cd01f6a 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -54,8 +54,6 @@ QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - QT_MODULE(Declarative) #define QML_DECLARE_TYPE(TYPE) \ @@ -73,6 +71,8 @@ QT_MODULE(Declarative) #define QML_DECLARE_INTERFACE_HASMETATYPE(INTERFACE) \ QML_DECLARE_TYPE_HASMETATYPE(INTERFACE) +QT_BEGIN_NAMESPACE + #define QML_DEFINE_INTERFACE(INTERFACE) \ template<> QmlPrivate::InstanceType QmlPrivate::Define<INTERFACE *>::instance(qmlRegisterInterface<INTERFACE>(#INTERFACE)); @@ -93,10 +93,10 @@ class QmlEngine; Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *); Q_DECLARATIVE_EXPORT QmlContext *qmlContext(const QObject *); Q_DECLARATIVE_EXPORT QmlEngine *qmlEngine(const QObject *); -Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *); +Q_DECLARATIVE_EXPORT QObject *qmlAttachedPropertiesObjectById(int, const QObject *, bool create = true); template<typename T> -QObject *qmlAttachedPropertiesObject(const QObject *obj) +QObject *qmlAttachedPropertiesObject(const QObject *obj, bool create = true) { // ### is this threadsafe? static int idx = -1; @@ -107,14 +107,14 @@ QObject *qmlAttachedPropertiesObject(const QObject *obj) if (idx == -1 || !obj) return 0; - return qmlAttachedPropertiesObjectById(idx, obj); + return qmlAttachedPropertiesObjectById(idx, obj, create); } +QT_END_NAMESPACE + QML_DECLARE_TYPE(QObject) Q_DECLARE_METATYPE(QVariant) -QT_END_NAMESPACE - QT_END_HEADER #endif // QML_H diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index efe4d3f..310632e 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -2,6 +2,7 @@ SOURCES += qml/qmlparser.cpp \ qml/qmlinstruction.cpp \ qml/qmlvmemetaobject.cpp \ qml/qmlengine.cpp \ + qml/qmlexpression.cpp \ qml/qmlbindablevalue.cpp \ qml/qmlmetaproperty.cpp \ qml/qmlcomponent.cpp \ @@ -45,6 +46,7 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlvme_p.h \ qml/qmlcompiler_p.h \ qml/qmlengine_p.h \ + qml/qmlexpression_p.h \ qml/qmlprivate.h \ qml/qmldom.h \ qml/qmldom_p.h \ @@ -67,7 +69,7 @@ HEADERS += qml/qmlparser_p.h \ qml/qpodvector_p.h # for qtscript debugger -QT += scripttools +contains(QT_CONFIG, scripttools):QT += scripttools include(script/script.pri) include(parser/parser.pri) diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp index f02a176..478491f 100644 --- a/src/declarative/qml/qmlbasicscript.cpp +++ b/src/declarative/qml/qmlbasicscript.cpp @@ -3,9 +3,39 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -15,7 +45,7 @@ #include <private/qmlengine_p.h> #include <private/qmlcontext_p.h> #include <QStack> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <private/qmlrefcount_p.h> #include <private/qmljsast_p.h> #include <private/qmljsengine_p.h> @@ -107,9 +137,6 @@ QDebug operator<<(QDebug lhs, const QmlBasicScriptNodeCache &rhs) case QmlBasicScriptNodeCache::Attached: lhs << "Attached" << rhs.object << rhs.attached; break; - case QmlBasicScriptNodeCache::Signal: - lhs << "Signal" << rhs.object << rhs.core; - break; case QmlBasicScriptNodeCache::SignalProperty: lhs << "SignalProperty" << rhs.object << rhs.core; break; @@ -246,10 +273,6 @@ QVariant QmlBasicScriptNodeCache::value(const char *) const case Attached: return qVariantFromValue(static_cast<QObject *>(attached)); break; - case Signal: - // XXX - Q_ASSERT(!"Not implemented"); - break; case SignalProperty: break; case Variant: @@ -580,7 +603,10 @@ bool QmlBasicScriptCompiler::parseName(AST::Node *node, instr.type = ScriptInstruction::FetchD0Constant; instr.constant.idx = d0Idx; QMetaProperty prop = context->metaObject()->property(d0Idx); - instr.constant.notify = prop.notifySignalIndex(); + if (prop.isConstant()) + instr.constant.notify = 0; + else + instr.constant.notify = prop.notifySignalIndex(); instr.constant.type = prop.userType(); } else if (d1Idx != -1) { @@ -588,7 +614,10 @@ bool QmlBasicScriptCompiler::parseName(AST::Node *node, instr.type = ScriptInstruction::FetchD1Constant; instr.constant.idx = d1Idx; QMetaProperty prop = component->metaObject()->property(d1Idx); - instr.constant.notify = prop.notifySignalIndex(); + if (prop.isConstant()) + instr.constant.notify = 0; + else + instr.constant.notify = prop.notifySignalIndex(); instr.constant.type = prop.userType(); } else { @@ -612,7 +641,10 @@ bool QmlBasicScriptCompiler::parseName(AST::Node *node, instr.type = ScriptInstruction::FetchConstant; instr.constant.idx = idx; QMetaProperty prop = loadedType->metaObject()->property(idx); - instr.constant.notify = prop.notifySignalIndex(); + if (prop.isConstant()) + instr.constant.notify = 0; + else + instr.constant.notify = prop.notifySignalIndex(); instr.constant.type = prop.userType(); } else { int nref = data.count(); @@ -781,7 +813,7 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c { stack.push(contextPrivate->propertyValues.at(instr.fetch.idx)); enginePrivate->capturedProperties << - QmlEnginePrivate::CapturedProperty(context, contextPrivate->notifyIndex + instr.fetch.idx); + QmlEnginePrivate::CapturedProperty(context, -1, contextPrivate->notifyIndex + instr.fetch.idx); state = Reset; } break; @@ -791,8 +823,9 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c QObject *obj = contextPrivate->defaultObjects.at(0); stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type)); - enginePrivate->capturedProperties << - QmlEnginePrivate::CapturedProperty(obj, instr.constant.notify); + if (instr.constant.notify != 0) + enginePrivate->capturedProperties << + QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify); state = Reset; } break; @@ -802,8 +835,9 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c QObject *obj = contextPrivate->defaultObjects.at(1); stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type)); - enginePrivate->capturedProperties << - QmlEnginePrivate::CapturedProperty(obj, instr.constant.notify); + if (instr.constant.notify != 0) + enginePrivate->capturedProperties << + QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify); state = Reset; } break; @@ -814,8 +848,9 @@ QVariant QmlBasicScript::run(QmlContext *context, void *voidCache, CacheState *c QObject *obj = qvariant_cast<QObject *>(o); stack.push(fetch_value(obj, instr.constant.idx, instr.constant.type)); - enginePrivate->capturedProperties << - QmlEnginePrivate::CapturedProperty(obj, instr.constant.notify); + if (instr.constant.notify != 0) + enginePrivate->capturedProperties << + QmlEnginePrivate::CapturedProperty(obj, instr.constant.idx, instr.constant.notify); state = Reset; } break; diff --git a/src/declarative/qml/qmlbasicscript_p.h b/src/declarative/qml/qmlbasicscript_p.h index 43c0d36..0c69397 100644 --- a/src/declarative/qml/qmlbasicscript_p.h +++ b/src/declarative/qml/qmlbasicscript_p.h @@ -3,15 +3,56 @@ ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** -** This file is part of the $MODULE$ of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QMLBASICSCRIPT_P_H #define QMLBASICSCRIPT_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 <QtCore/QList> #include <QtCore/QByteArray> #include <QtCore/QVariant> @@ -83,7 +124,6 @@ public: enum { Invalid, Core, Attached, - Signal, SignalProperty, Variant } type; @@ -109,5 +149,3 @@ QT_END_NAMESPACE QT_END_HEADER #endif // QMLBASICSCRIPT_P_H - - diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp index d1835cf..8e74250 100644 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ b/src/declarative/qml/qmlbindablevalue.cpp @@ -45,26 +45,28 @@ #include <qmlcontext.h> #include <qmlinfo.h> #include <QVariant> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <QtCore/qdebug.h> +Q_DECLARE_METATYPE(QList<QObject *>); + QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS); QmlBindableValuePrivate::QmlBindableValuePrivate() -: inited(false), updating(false), mePtr(0) +: inited(false), updating(false), enabled(true), mePtr(0) { } QML_DEFINE_NOCREATE_TYPE(QmlBindableValue); -QmlBindableValue::QmlBindableValue(void *data, QmlRefCount *rc, QObject *obj, QObject *parent) -: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(QmlContext::activeContext(), data, rc, obj) +QmlBindableValue::QmlBindableValue(void *data, QmlRefCount *rc, QObject *obj, QmlContext *ctxt, QObject *parent) +: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(ctxt, data, rc, obj) { } -QmlBindableValue::QmlBindableValue(const QString &str, QObject *obj, QObject *parent) -: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(QmlContext::activeContext(), str, obj) +QmlBindableValue::QmlBindableValue(const QString &str, QObject *obj, QmlContext *ctxt, QObject *parent) +: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(ctxt, str, obj) { } @@ -105,7 +107,15 @@ void QmlBindableValue::setExpression(const QString &expr) update(); } -Q_DECLARE_METATYPE(QList<QObject *>); +void QmlBindableValue::forceUpdate() +{ + Q_D(QmlBindableValue); + if (!d->inited) + init(); + else + update(); +} + void QmlBindableValue::update() { Q_D(QmlBindableValue); @@ -113,7 +123,7 @@ void QmlBindableValue::update() #ifdef Q_ENABLE_PERFORMANCE_LOG QFxPerfTimer<QFxPerf::BindableValueUpdate> bu; #endif - if (!d->inited) + if (!d->inited || !d->enabled) return; if (!d->updating) { @@ -159,4 +169,18 @@ void QmlBindableValue::valueChanged() update(); } +void QmlBindableValue::setEnabled(bool e) +{ + Q_D(QmlBindableValue); + d->enabled = e; + setTrackChange(e); +} + +bool QmlBindableValue::enabled() const +{ + Q_D(const QmlBindableValue); + + return d->enabled; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h index f54481a..12da9f6 100644 --- a/src/declarative/qml/qmlbindablevalue.h +++ b/src/declarative/qml/qmlbindablevalue.h @@ -48,12 +48,12 @@ #include <QtDeclarative/qmlpropertyvaluesource.h> #include <QtDeclarative/qmlexpression.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlExpression; class QmlContext; class QmlBindableValuePrivate; @@ -62,8 +62,8 @@ class Q_DECLARATIVE_EXPORT QmlBindableValue : public QmlPropertyValueSource, { Q_OBJECT public: - QmlBindableValue(const QString &, QObject *, QObject *parent=0); - QmlBindableValue(void *, QmlRefCount *, QObject *, QObject *parent); + QmlBindableValue(const QString &, QObject *, QmlContext *, QObject *parent=0); + QmlBindableValue(void *, QmlRefCount *, QObject *, QmlContext *, QObject *parent); ~QmlBindableValue(); virtual void setTarget(const QmlMetaProperty &); @@ -74,8 +74,12 @@ public: virtual void setExpression(const QString &); void init(); + void forceUpdate(); -private Q_SLOTS: + void setEnabled(bool); + bool enabled() const; + +public Q_SLOTS: void update(); protected: @@ -84,10 +88,11 @@ protected: private: Q_DECLARE_PRIVATE(QmlBindableValue) }; -QML_DECLARE_TYPE(QmlBindableValue) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlBindableValue) + QT_END_HEADER + #endif // QMLBINDABLEVALUE_H diff --git a/src/declarative/qml/qmlbindablevalue_p.h b/src/declarative/qml/qmlbindablevalue_p.h index 9476b80..a37b2c0 100644 --- a/src/declarative/qml/qmlbindablevalue_p.h +++ b/src/declarative/qml/qmlbindablevalue_p.h @@ -42,6 +42,17 @@ #ifndef QMLBINDABLEVALUE_P_H #define QMLBINDABLEVALUE_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/qobject_p.h> #include <QtDeclarative/qmlbindablevalue.h> #include <QtDeclarative/qmlmetaproperty.h> @@ -54,8 +65,10 @@ class QmlBindableValuePrivate : public QObjectPrivate public: QmlBindableValuePrivate(); - bool inited; - bool updating; + bool inited:1; + bool updating:1; + bool enabled:1; + QmlMetaProperty property; QmlBindableValue **mePtr; diff --git a/src/declarative/qml/qmlboundsignal.cpp b/src/declarative/qml/qmlboundsignal.cpp index 5815dc6..9779e46 100644 --- a/src/declarative/qml/qmlboundsignal.cpp +++ b/src/declarative/qml/qmlboundsignal.cpp @@ -47,6 +47,7 @@ #include <qmlmetatype.h> #include <qml.h> #include <qmlcontext.h> +#include <QDebug> QT_BEGIN_NAMESPACE @@ -88,7 +89,6 @@ int QmlBoundSignalProxy::qt_metacall(QMetaObject::Call c, int id, void **a) } } -#include <QDebug> QmlBoundSignalParameters::QmlBoundSignalParameters(const QMetaMethod &method, QObject *parent) : QObject(parent), types(0), values(0) diff --git a/src/declarative/qml/qmlboundsignal_p.h b/src/declarative/qml/qmlboundsignal_p.h index 2c05770..39c0c46 100644 --- a/src/declarative/qml/qmlboundsignal_p.h +++ b/src/declarative/qml/qmlboundsignal_p.h @@ -42,10 +42,22 @@ #ifndef QMLBOUNDSIGNAL_P_H #define QMLBOUNDSIGNAL_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 <QtDeclarative/qmlexpression.h> #include <private/qobject_p.h> QT_BEGIN_NAMESPACE + class QmlBoundSignal : public QmlExpressionObject { Q_OBJECT @@ -98,7 +110,6 @@ private: QmlBoundSignalParameters *params; }; +QT_END_NAMESPACE #endif // QMLBOUNDSIGNAL_P_H - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlclassfactory.cpp b/src/declarative/qml/qmlclassfactory.cpp index 7e5b929..ddfbd78 100644 --- a/src/declarative/qml/qmlclassfactory.cpp +++ b/src/declarative/qml/qmlclassfactory.cpp @@ -41,7 +41,10 @@ #include "qmlclassfactory_p.h" +QT_BEGIN_NAMESPACE + QmlClassFactory::~QmlClassFactory() { } +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlclassfactory_p.h b/src/declarative/qml/qmlclassfactory_p.h index e3e71c9..cd80ffc 100644 --- a/src/declarative/qml/qmlclassfactory_p.h +++ b/src/declarative/qml/qmlclassfactory_p.h @@ -42,6 +42,17 @@ #ifndef QMLCLASSFACTORY_P_H #define QMLCLASSFACTORY_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 <QtCore/qglobal.h> QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qmlcompiledcomponent_p.h b/src/declarative/qml/qmlcompiledcomponent_p.h index 2201423..0945892 100644 --- a/src/declarative/qml/qmlcompiledcomponent_p.h +++ b/src/declarative/qml/qmlcompiledcomponent_p.h @@ -42,13 +42,26 @@ #ifndef QMLCOMPILEDCOMPONENT_P_H #define QMLCOMPILEDCOMPONENT_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 <QtDeclarative/qml.h> #include <private/qmlinstruction_p.h> #include <private/qmlcompiler_p.h> #include <private/qmlrefcount_p.h> QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE + namespace QmlParser { class Property; class Object; @@ -72,8 +85,8 @@ private: friend class QmlDomDocument; }; - QT_END_NAMESPACE + QT_END_HEADER #endif // QMLCOMPILEDCOMPONENT_P_H diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 8297ac4..b04c932 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include "private/qmlcompiler_p.h" -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include "qmlparser_p.h" #include "private/qmlscriptparser_p.h" #include <qmlpropertyvaluesource.h> @@ -63,6 +63,7 @@ #include <private/qmlcontext_p.h> #include <private/qmlcomponent_p.h> #include "parser/qmljsast_p.h" +#include <private/qmlvmemetaobject_p.h> #include "qmlscriptparser_p.h" @@ -554,23 +555,27 @@ void QmlCompiler::compileTree(Object *tree) if (!compileObject(tree, 0)) // Compile failed return; - if (tree->metatype) - static_cast<QMetaObject &>(output->root) = *tree->metaObject(); - else - static_cast<QMetaObject &>(output->root) = *output->types.at(tree->type).metaObject(); - QmlInstruction def; init.line = 0; def.type = QmlInstruction::SetDefault; output->bytecode << def; finalizeComponent(0); + + if (tree->metatype) + static_cast<QMetaObject &>(output->root) = *tree->metaObject(); + else + static_cast<QMetaObject &>(output->root) = *output->types.at(tree->type).metaObject(); + } bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) { Q_ASSERT (obj->type != -1); - obj->metatype = output->types.at(obj->type).metaObject(); + const QmlCompiledData::TypeReference &tr = output->types.at(obj->type); + obj->metatype = tr.metaObject(); + if (tr.component) + obj->url = tr.component->url(); if (output->types.at(obj->type).className == "Component") { COMPILE_CHECK(compileComponent(obj, ctxt)); @@ -630,7 +635,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isCustomParser) { // Custom parser types don't support signal properties if (testProperty(prop, obj)) { - if (deferred.contains(prop->name)) + if (deferred.contains(QString::fromLatin1(prop->name.constData()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -641,7 +646,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isSignalPropertyName(prop->name)) { COMPILE_CHECK(compileSignal(prop,obj)); } else { - if (deferred.contains(prop->name)) + if (deferred.contains(QString::fromLatin1(prop->name.constData()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -657,7 +662,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) if (isCustomParser) { if (testProperty(prop, obj)) { QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject()); - if (deferred.contains(p.name())) + if (deferred.contains(QString::fromLatin1(p.name()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -666,7 +671,7 @@ bool QmlCompiler::compileObject(Object *obj, const BindingContext &ctxt) } } else { QMetaProperty p = deferred.isEmpty()?QMetaProperty():QmlMetaType::defaultProperty(obj->metaObject()); - if (deferred.contains(p.name())) + if (deferred.contains(QString::fromLatin1(p.name()))) deferredProps << prop; else COMPILE_CHECK(compileProperty(prop, obj, objCtxt)); @@ -795,13 +800,12 @@ bool QmlCompiler::compileComponentFromRoot(Object *obj, const BindingContext &ct if (obj) COMPILE_CHECK(compileObject(obj, ctxt)); - finalizeComponent(count); + COMPILE_CHECK(finalizeComponent(count)); create.createComponent.count = output->bytecode.count() - count; compileState = oldComponentCompileState; return true; } - bool QmlCompiler::compileFetchedObject(Object *obj, const BindingContext &ctxt) { Q_ASSERT(obj->metatype); @@ -1395,7 +1399,7 @@ bool QmlCompiler::compilePropertyLiteralAssignment(QmlParser::Property *prop, return true; } -bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) +bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj, int preAlias) { // ### FIXME - Check that there is only one default property etc. if (obj->dynamicProperties.isEmpty() && @@ -1403,60 +1407,113 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) obj->dynamicSlots.isEmpty()) return true; + QByteArray dynamicData(sizeof(QmlVMEMetaData), (char)0); + QMetaObjectBuilder builder; if (obj->metatype) builder.setClassName(QByteArray(obj->metatype->className()) + "QML"); builder.setFlags(QMetaObjectBuilder::DynamicMetaObject); + bool hasAlias = false; for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) { const Object::DynamicProperty &p = obj->dynamicProperties.at(ii); - if (p.isDefaultProperty) + if (p.isDefaultProperty && + (p.type != Object::DynamicProperty::Alias || preAlias != -1)) builder.addClassInfo("DefaultProperty", p.name); QByteArray type; + int propertyType; switch(p.type) { + case Object::DynamicProperty::Alias: + hasAlias = true; + continue; + break; case Object::DynamicProperty::Variant: + propertyType = -1; type = "QVariant"; break; case Object::DynamicProperty::Int: + propertyType = QVariant::Int; type = "int"; break; case Object::DynamicProperty::Bool: + propertyType = QVariant::Bool; type = "bool"; break; case Object::DynamicProperty::Real: + propertyType = QVariant::Double; type = "double"; break; case Object::DynamicProperty::String: + propertyType = QVariant::String; type = "QString"; break; case Object::DynamicProperty::Url: + propertyType = QVariant::Url; type = "QUrl"; break; case Object::DynamicProperty::Color: + propertyType = QVariant::Color; type = "QColor"; break; case Object::DynamicProperty::Date: + propertyType = QVariant::Date; type = "QDate"; break; } + ((QmlVMEMetaData *)dynamicData.data())->propertyCount++; + QmlVMEMetaData::PropertyData propertyData = { propertyType }; + dynamicData.append((char *)&propertyData, sizeof(propertyData)); + builder.addSignal(p.name + "Changed()"); builder.addProperty(p.name, type, ii); } + if (preAlias != -1) { + for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) { + const Object::DynamicProperty &p = obj->dynamicProperties.at(ii); + + if (p.type == Object::DynamicProperty::Alias) { + ((QmlVMEMetaData *)dynamicData.data())->aliasCount++; + compileAlias(builder, dynamicData, obj, p); + } + } + } + for (int ii = 0; ii < obj->dynamicSignals.count(); ++ii) { const Object::DynamicSignal &s = obj->dynamicSignals.at(ii); - builder.addSignal(s.name + "()"); + QByteArray sig(s.name + "("); + for (int jj = 0; jj < s.parameterTypes.count(); ++jj) { + if (jj) sig.append(","); + sig.append(s.parameterTypes.at(jj)); + } + sig.append(")"); + QMetaMethodBuilder b = builder.addSignal(sig); + b.setParameterNames(s.parameterNames); + ((QmlVMEMetaData *)dynamicData.data())->signalCount++; } int slotStart = obj->dynamicSlots.isEmpty()?-1:output->primitives.count(); for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) { const Object::DynamicSlot &s = obj->dynamicSlots.at(ii); - builder.addSlot(s.name + "()"); - output->primitives << s.body; + QByteArray sig(s.name + "("); + for (int jj = 0; jj < s.parameterNames.count(); ++jj) { + if (jj) sig.append(","); + sig.append("QVariant"); + } + sig.append(")"); + QMetaMethodBuilder b = builder.addSlot(sig); + b.setParameterNames(s.parameterNames); + + ((QmlVMEMetaData *)dynamicData.data())->methodCount++; + QmlVMEMetaData::MethodData methodData = { s.parameterNames.count() }; + dynamicData.append((char *)&methodData, sizeof(methodData)); + + if (preAlias == -1) + output->primitives << s.body; } if (obj->metatype) @@ -1465,17 +1522,37 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) obj->extObjectData = builder.toMetaObject(); static_cast<QMetaObject &>(obj->extObject) = *obj->extObjectData; - output->synthesizedMetaObjects << obj->extObjectData; - QmlInstruction store; - store.type = QmlInstruction::StoreMetaObject; - store.storeMeta.data = output->synthesizedMetaObjects.count() - 1; - store.storeMeta.slotData = slotStart; - store.line = obj->location.start.line; - output->bytecode << store; + if (preAlias != -1) { + QmlInstruction &store = output->bytecode[preAlias]; + + store.storeMeta.aliasData = output->indexForByteArray(dynamicData); + qFree(output->synthesizedMetaObjects.at(store.storeMeta.data)); + output->synthesizedMetaObjects[store.storeMeta.data] = obj->extObjectData; + + } else { + output->synthesizedMetaObjects << obj->extObjectData; + QmlInstruction store; + store.type = QmlInstruction::StoreMetaObject; + store.storeMeta.data = output->synthesizedMetaObjects.count() - 1; + store.storeMeta.slotData = slotStart; + store.storeMeta.aliasData = output->indexForByteArray(dynamicData); + store.line = obj->location.start.line; + output->bytecode << store; + + if (hasAlias) { + AliasReference alias; + alias.object = obj; + alias.instructionIdx = output->bytecode.count() - 1; + compileState.aliases << alias; + } + } for (int ii = 0; ii < obj->dynamicProperties.count(); ++ii) { const Object::DynamicProperty &p = obj->dynamicProperties.at(ii); + if (p.type == Object::DynamicProperty::Alias) + continue; + if (p.defaultValue) { p.defaultValue->name = p.name; p.defaultValue->isDefault = false; @@ -1486,6 +1563,66 @@ bool QmlCompiler::compileDynamicMeta(QmlParser::Object *obj) return true; } +#include <private/qmljsparser_p.h> +static QStringList astNodeToStringList(QmlJS::AST::Node *node) +{ + if (node->kind == QmlJS::AST::Node::Kind_IdentifierExpression) { + QString name = + static_cast<QmlJS::AST::IdentifierExpression *>(node)->name->asString(); + return QStringList() << name; + } else if (node->kind == QmlJS::AST::Node::Kind_FieldMemberExpression) { + QmlJS::AST::FieldMemberExpression *expr = static_cast<QmlJS::AST::FieldMemberExpression *>(node); + + QStringList rv = astNodeToStringList(expr->base); + if (rv.isEmpty()) + return rv; + rv.append(expr->name->asString()); + return rv; + } + return QStringList(); +} + +bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder, + QByteArray &data, + Object *obj, + const Object::DynamicProperty &prop) +{ + if (!prop.defaultValue) + COMPILE_EXCEPTION("No property alias location"); + + if (prop.defaultValue->values.count() != 1 || + prop.defaultValue->values.at(0)->object || + !prop.defaultValue->values.at(0)->value.isScript()) + COMPILE_EXCEPTION2(prop.defaultValue, "Invalid alias location"); + + QmlJS::AST::Node *node = prop.defaultValue->values.at(0)->value.asAST(); + if (!node) + COMPILE_EXCEPTION("No property alias location"); // ### Can this happen? + + QStringList alias = astNodeToStringList(node); + + if (alias.count() != 2) + COMPILE_EXCEPTION2(prop.defaultValue, "Invalid alias location"); + + if (!compileState.ids.contains(alias.at(0))) + COMPILE_EXCEPTION2(prop.defaultValue, "Invalid alias location"); + + const IdReference &id = compileState.ids[alias.at(0)]; + int propIdx = id.object->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData()); + + if (-1 == propIdx) + COMPILE_EXCEPTION2(prop.defaultValue, "Invalid alias location"); + + QMetaProperty aliasProperty = id.object->metaObject()->property(propIdx); + + data.append((const char *)&id.idx, sizeof(id.idx)); + data.append((const char *)&propIdx, sizeof(propIdx)); + + builder.addSignal(prop.name + "Changed()"); + builder.addProperty(prop.name, aliasProperty.typeName(), builder.methodCount() - 1); + return true; +} + bool QmlCompiler::compileBinding(QmlParser::Value *value, QmlParser::Property *prop, const BindingContext &ctxt) @@ -1554,17 +1691,29 @@ protected: // Update the init instruction with final data, and optimize some simple // bindings -void QmlCompiler::finalizeComponent(int patch) +bool QmlCompiler::finalizeComponent(int patch) { for (int ii = 0; ii < compileState.bindings.count(); ++ii) { const BindingReference &binding = compileState.bindings.at(ii); finalizeBinding(binding); } + for (int ii = 0; ii < compileState.aliases.count(); ++ii) { + const AliasReference &alias = compileState.aliases.at(ii); + COMPILE_CHECK(finalizeAlias(alias)); + } + output->bytecode[patch].init.dataSize = compileState.savedObjects;; output->bytecode[patch].init.bindingsSize = compileState.bindings.count(); output->bytecode[patch].init.parserStatusSize = compileState.parserStatusCount; + + return true; +} + +bool QmlCompiler::finalizeAlias(const AliasReference &alias) +{ + COMPILE_CHECK(compileDynamicMeta(alias.object, alias.instructionIdx)); } void QmlCompiler::finalizeBinding(const BindingReference &binding) @@ -1680,7 +1829,7 @@ QStringList QmlCompiler::deferredProperties(QmlParser::Object *obj) return QStringList(); QMetaClassInfo classInfo = mo->classInfo(idx); - QStringList rv = QString(QLatin1String(classInfo.value())).split(','); + QStringList rv = QString(QLatin1String(classInfo.value())).split(QLatin1Char(',')); return rv; } diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 2559b14..1c45f57 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPILER_P_H #define QMLCOMPILER_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 <QtCore/qbytearray.h> #include <QtCore/qset.h> #include <QtDeclarative/qml.h> @@ -50,9 +61,8 @@ #include <private/qmlcompositetypemanager_p.h> #include <private/qmlparser_p.h> -class QStringList; - QT_BEGIN_NAMESPACE + class QmlEngine; class QmlComponent; class QmlCompiledComponent; @@ -108,6 +118,7 @@ private: int indexForLocation(const QmlParser::LocationSpan &); }; +class QMetaObjectBuilder; class Q_DECLARATIVE_EXPORT QmlCompiler { public: @@ -171,13 +182,19 @@ private: const QMetaProperty &prop, QmlParser::Value *value); - bool compileDynamicMeta(QmlParser::Object *obj); + bool compileDynamicMeta(QmlParser::Object *obj, int preAlias = -1); + bool compileAlias(QMetaObjectBuilder &, + QByteArray &data, + QmlParser::Object *obj, + const QmlParser::Object::DynamicProperty &); bool compileBinding(QmlParser::Value *, QmlParser::Property *prop, const BindingContext &ctxt); - void finalizeComponent(int patch); + bool finalizeComponent(int patch); struct BindingReference; void finalizeBinding(const BindingReference &); + struct AliasReference; + bool finalizeAlias(const AliasReference &); bool canConvert(int, QmlParser::Object *); QStringList deferredProperties(QmlParser::Object *); @@ -189,6 +206,11 @@ private: int idx; }; + struct AliasReference { + QmlParser::Object *object; + int instructionIdx; + }; + struct BindingReference { QmlParser::Variant expression; QmlParser::Property *property; @@ -205,6 +227,7 @@ private: int savedObjects; int pushedProperties; QList<BindingReference> bindings; + QList<AliasReference> aliases; QmlParser::Object *root; }; ComponentCompileState compileState; @@ -215,4 +238,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLCOMPILER_P_H diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index f90af4a..a9f5442 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -46,7 +46,7 @@ #include "qmlvme_p.h" #include "qml.h" #include <QStack> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <QStringList> #include <qmlengine.h> #include <QFileInfo> @@ -58,6 +58,7 @@ #include "qmlscriptparser_p.h" QT_BEGIN_NAMESPACE + class QByteArray; int statusId = qRegisterMetaType<QmlComponent::Status>("QmlComponent::Status"); @@ -269,10 +270,25 @@ QmlComponent::QmlComponent(QmlEngine *engine, const QUrl &url, QObject *parent) } /*! + Create a QmlComponent from the given \a fileName and give it the specified + \a parent and \a engine. + + \sa loadUrl() +*/ +QmlComponent::QmlComponent(QmlEngine *engine, const QString &fileName, + QObject *parent) +: QObject(*(new QmlComponentPrivate), parent) +{ + Q_D(QmlComponent); + d->engine = engine; + loadUrl(QUrl::fromLocalFile(fileName)); +} + +/*! Create a QmlComponent from the given QML \a data and give it the - specified \a parent and \a engine. If \a url is provided, it is used to set - the component name, and to provide a base path for items resolved - by this component. + specified \a parent and \a engine. \a url is used to provide a base path + for items resolved by this component, and may be an empty url if the + component contains no items to resolve. \sa setData() */ @@ -296,6 +312,7 @@ QmlComponent::QmlComponent(QmlEngine *engine, QmlCompiledComponent *cc, int star cc->addref(); d->start = start; d->count = count; + d->url = cc->url; } /*! @@ -337,10 +354,13 @@ void QmlComponent::loadUrl(const QUrl &url) d->clear(); - d->url = url; + if (url.isRelative()) + d->url = d->engine->baseUrl().resolved(url); + else + d->url = url; QmlCompositeTypeData *data = - d->engine->d_func()->typeManager.get(url); + d->engine->d_func()->typeManager.get(d->url); if (data->status == QmlCompositeTypeData::Waiting) { @@ -370,6 +390,29 @@ QList<QmlError> QmlComponent::errors() const } /*! + Return the list of errors that occured during the last compile or create + operation, as a single string. An empty string is returned if isError() + is not set. + + This function is similar to errors(), except more useful when called from + QML. C++ code should usually use errors(). + + \sa errors() +*/ +QString QmlComponent::errorsString() const +{ + Q_D(const QmlComponent); + QString ret; + if(!isError()) + return ret; + foreach(const QmlError &e, d->errors){ + ret += e.url().toString() + ":" + QString::number(e.line()) + " " + + e.description() + "\n"; + } + return ret; +} + +/*! Return the component URL. This is the URL passed to either the constructor, or the loadUrl() or setData() methods. */ @@ -563,4 +606,5 @@ void QmlComponent::completeCreate() d->completePending = false; } } + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index ae2f362..5e6dce9 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -54,6 +54,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlCompiledComponent; class QByteArray; class QmlComponentPrivate; @@ -66,9 +67,10 @@ class Q_DECLARATIVE_EXPORT QmlComponent : public QObject public: QmlComponent(QObject *parent = 0); QmlComponent(QmlEngine *, QObject *parent=0); + QmlComponent(QmlEngine *, const QString &url, QObject *parent = 0); QmlComponent(QmlEngine *, const QUrl &url, QObject *parent = 0); QmlComponent(QmlEngine *, const QByteArray &data, - const QUrl &baseUrl=QUrl(), QObject *parent=0); + const QUrl &baseUrl, QObject *parent=0); virtual ~QmlComponent(); Q_ENUMS(Status) @@ -81,6 +83,7 @@ public: Q_INVOKABLE bool isLoading() const; QList<QmlError> errors() const; + Q_INVOKABLE QString errorsString() const; QUrl url() const; @@ -90,7 +93,7 @@ public: virtual void completeCreate(); void loadUrl(const QUrl &url); - void setData(const QByteArray &, const QUrl &baseUrl = QUrl()); + void setData(const QByteArray &, const QUrl &baseUrl); Q_SIGNALS: void statusChanged(QmlComponent::Status); @@ -104,11 +107,12 @@ private: friend class QmlVME; friend struct QmlCompositeTypeData; }; -Q_DECLARE_METATYPE(QmlComponent::Status) -QML_DECLARE_TYPE(QmlComponent) QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlComponent::Status) +QML_DECLARE_TYPE(QmlComponent) + QT_END_HEADER #endif // QMLCOMPONENT_H diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h index 254d9ba..0be3dc6 100644 --- a/src/declarative/qml/qmlcomponent_p.h +++ b/src/declarative/qml/qmlcomponent_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPONENT_P_H #define QMLCOMPONENT_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 <QtCore/QString> #include <QtCore/QStringList> #include <QtCore/QList> @@ -87,6 +98,6 @@ public: void clear(); }; -#endif // QMLCOMPONENT_P_H - QT_END_NAMESPACE + +#endif // QMLCOMPONENT_P_H diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 9950b48..ef77803 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -50,6 +50,8 @@ #include <QtDeclarative/qmlcomponent.h> #include <private/qmlcomponent_p.h> +QT_BEGIN_NAMESPACE + QmlCompositeTypeData::QmlCompositeTypeData() : status(Invalid), errorType(NoError), component(0), compiledComponent(0) { @@ -365,3 +367,5 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit) doComplete(unit); } } + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index 9312819..96e77d6 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -42,6 +42,17 @@ #ifndef QMLCOMPOSITETYPEMANAGER_P_H #define QMLCOMPOSITETYPEMANAGER_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 <QtCore/qglobal.h> #include <private/qmlscriptparser_p.h> #include <private/qmlrefcount_p.h> diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index e5016f2..b590596 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -41,12 +41,12 @@ #include <qmlcontext.h> #include <private/qmlcontext_p.h> +#include <private/qmlexpression_p.h> #include <private/qmlengine_p.h> #include <qmlengine.h> #include <qscriptengine.h> #include <QtCore/qvarlengtharray.h> - -#include <qdebug.h> +#include <QtCore/qdebug.h> // 6-bits #define MAXIMUM_DEFAULT_OBJECTS 63 diff --git a/src/declarative/qml/qmlcontext.h b/src/declarative/qml/qmlcontext.h index 935c7ca..f5858cb 100644 --- a/src/declarative/qml/qmlcontext.h +++ b/src/declarative/qml/qmlcontext.h @@ -89,6 +89,7 @@ private: friend class QmlEngine; friend class QmlEnginePrivate; friend class QmlExpression; + friend class QmlExpressionPrivate; friend class QmlBasicScript; friend class QmlContextScriptClass; friend class QmlObjectScriptClass; @@ -99,7 +100,6 @@ private: QmlContext(QmlEngine *); }; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlcontext_p.h b/src/declarative/qml/qmlcontext_p.h index 4d88fc2..569b320 100644 --- a/src/declarative/qml/qmlcontext_p.h +++ b/src/declarative/qml/qmlcontext_p.h @@ -42,6 +42,17 @@ #ifndef QMLCONTEXT_P_H #define QMLCONTEXT_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 <QtDeclarative/qmlcontext.h> #include <private/qobject_p.h> #include <private/qmldeclarativedata_p.h> @@ -50,6 +61,7 @@ #include <QtCore/qset.h> QT_BEGIN_NAMESPACE + class QmlContext; class QmlExpression; class QmlEngine; @@ -99,6 +111,7 @@ public: QmlSimpleDeclarativeData contextData; QObjectList contextObjects; }; + QT_END_NAMESPACE #endif // QMLCONTEXT_P_H diff --git a/src/declarative/qml/qmlcustomparser.cpp b/src/declarative/qml/qmlcustomparser.cpp index c90ab47..b543978 100644 --- a/src/declarative/qml/qmlcustomparser.cpp +++ b/src/declarative/qml/qmlcustomparser.cpp @@ -43,6 +43,8 @@ #include "qmlcustomparser_p_p.h" #include "qmlparser_p.h" +#include <QtCore/qdebug.h> + QT_BEGIN_NAMESPACE using namespace QmlParser; @@ -120,7 +122,6 @@ QmlCustomParserNodePrivate::fromObject(QmlParser::Object *root) return rootNode; } -#include <QtCore/qdebug.h> QmlCustomParserProperty QmlCustomParserNodePrivate::fromProperty(QmlParser::Property *p) { diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 75da579..914ddbd 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -42,6 +42,17 @@ #ifndef QMLCUSTOMPARSER_H #define QMLCUSTOMPARSER_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 <QtCore/qbytearray.h> #include <QtCore/qxmlstream.h> #include <QtDeclarative/qfxglobal.h> @@ -74,7 +85,6 @@ private: friend class QmlCustomParserPropertyPrivate; QmlCustomParserPropertyPrivate *d; }; -Q_DECLARE_METATYPE(QmlCustomParserProperty) class QmlCustomParserNodePrivate; class Q_DECLARATIVE_EXPORT QmlCustomParserNode @@ -93,7 +103,6 @@ private: friend class QmlCustomParserNodePrivate; QmlCustomParserNodePrivate *d; }; -Q_DECLARE_METATYPE(QmlCustomParserNode) class Q_DECLARATIVE_EXPORT QmlCustomParser { @@ -108,6 +117,9 @@ public: QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlCustomParserProperty) +Q_DECLARE_METATYPE(QmlCustomParserNode) + QT_END_HEADER #endif diff --git a/src/declarative/qml/qmlcustomparser_p_p.h b/src/declarative/qml/qmlcustomparser_p_p.h index 96e9b32..0011c3b 100644 --- a/src/declarative/qml/qmlcustomparser_p_p.h +++ b/src/declarative/qml/qmlcustomparser_p_p.h @@ -42,6 +42,17 @@ #ifndef QMLCUSTOMPARSER_P_H #define QMLCUSTOMPARSER_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 <QtCore/qglobal.h> #include "qmlcustomparser_p.h" diff --git a/src/declarative/qml/qmldeclarativedata_p.h b/src/declarative/qml/qmldeclarativedata_p.h index 85a80fa..559f0ee 100644 --- a/src/declarative/qml/qmldeclarativedata_p.h +++ b/src/declarative/qml/qmldeclarativedata_p.h @@ -42,6 +42,17 @@ #ifndef QMLDECLARATIVEDATA_P_H #define QMLDECLARATIVEDATA_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/qobject_p.h> QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index d2608c8..648eb36 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -194,8 +194,6 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data, const QUrl d->imports += QUrl(td->data.imports().at(i).uri); } - d->automaticSemicolonOffsets = td->data.automaticSemicolonOffsets(); - if (td->data.tree()) { if (compilerDump()) { qWarning() << "-AST------------------------------------------------------------------------------"; @@ -253,14 +251,6 @@ QmlDomObject QmlDomDocument::rootObject() const return rv; } -QList<int> QmlDomDocument::automaticSemicolonOffsets() const -{ - if (d) - return d->automaticSemicolonOffsets; - else - return QList<int>(); -} - QmlDomPropertyPrivate::QmlDomPropertyPrivate() : property(0) { @@ -278,6 +268,23 @@ QmlDomPropertyPrivate::~QmlDomPropertyPrivate() if (property) property->release(); } +QmlDomDynamicPropertyPrivate::QmlDomDynamicPropertyPrivate(): + valid(false) +{ +} + +QmlDomDynamicPropertyPrivate::QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &other) +: QSharedData(other), valid(other.valid) +{ + property = other.property; + if (valid && property.defaultValue) property.defaultValue->addref(); +} + +QmlDomDynamicPropertyPrivate::~QmlDomDynamicPropertyPrivate() +{ + if (valid && property.defaultValue) property.defaultValue->release(); +} + /*! \class QmlDomProperty \internal @@ -322,8 +329,8 @@ QmlDomProperty &QmlDomProperty::operator=(const QmlDomProperty &other) } /*! - Return the name of this property. - + Return the name of this property. + \qml Text { x: 10 @@ -331,7 +338,7 @@ Text { font.bold: true } \endqml - + As illustrated above, a property name can be a simple string, such as "x" or "y", or a more complex "dot property", such as "font.bold". In both cases the full name is returned ("x", "y" and "font.bold") by this method. @@ -358,7 +365,7 @@ Text { } \endqml - For each of the properties shown above, this method would return ("x"), + For each of the properties shown above, this method would return ("x"), ("y") and ("font", "bold"). \sa QmlDomProperty::propertyName() @@ -370,7 +377,7 @@ QList<QByteArray> QmlDomProperty::propertyNameParts() const } /*! - Return true if this property is used as a default property in the QML + Return true if this property is used as a default property in the QML document. \qml @@ -380,8 +387,8 @@ QList<QByteArray> QmlDomProperty::propertyNameParts() const The above two examples return the same DOM tree, except that the second has the default property flag set on the text property. Observe that whether - or not a property has isDefaultProperty set is determined by how the - property is used, and not only by whether the property is the types default + or not a property has isDefaultProperty set is determined by how the + property is used, and not only by whether the property is the types default property. */ bool QmlDomProperty::isDefaultProperty() const @@ -415,7 +422,7 @@ void QmlDomProperty::setValue(const QmlDomValue &value) } /*! - Returns the position in the input data where the property ID startd, or 0 if + Returns the position in the input data where the property ID startd, or -1 if the property is invalid. */ int QmlDomProperty::position() const @@ -423,19 +430,174 @@ int QmlDomProperty::position() const if (d && d->property) { return d->property->location.range.offset; } else - return 0; + return -1; } /*! Returns the length in the input data from where the property ID started upto - the end of it, or 0 if the property is invalid. + the end of it, or -1 if the property is invalid. */ int QmlDomProperty::length() const { if (d && d->property) return d->property->location.range.length; else - return 0; + return -1; +} + +/*! + Construct an invalid QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty::QmlDomDynamicProperty(): + d(new QmlDomDynamicPropertyPrivate) +{ +} + +/*! + Create a copy of \a other QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty::QmlDomDynamicProperty(const QmlDomDynamicProperty &other): + d(other.d) +{ +} + +/*! + Destroy the QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty::~QmlDomDynamicProperty() +{ +} + +/*! + Assign \a other to this QmlDomDynamicProperty. +*/ +QmlDomDynamicProperty &QmlDomDynamicProperty::operator=(const QmlDomDynamicProperty &other) +{ + d = other.d; + return *this; +} + +bool QmlDomDynamicProperty::isValid() const +{ + return d && d->valid; +} + +/*! + Return the name of this dynamic property. + + \qml +Item { + property int count: 10; +} + \endqml + + As illustrated above, a dynamic property name can have a name and a + default value ("10"). +*/ +QByteArray QmlDomDynamicProperty::propertyName() const +{ + if (isValid()) + return d->property.name; + else + return QByteArray(); +} + +int QmlDomDynamicProperty::propertyType() const +{ + if (isValid()) { + switch (d->property.type) { + case QmlParser::Object::DynamicProperty::Bool: + return QMetaType::type("bool"); + + case QmlParser::Object::DynamicProperty::Color: + return QMetaType::type("QColor"); + + case QmlParser::Object::DynamicProperty::Date: + return QMetaType::type("QDateTime"); + + case QmlParser::Object::DynamicProperty::Int: + return QMetaType::type("int"); + + case QmlParser::Object::DynamicProperty::Real: + return QMetaType::type("double"); + + case QmlParser::Object::DynamicProperty::String: + return QMetaType::type("QString"); + + case QmlParser::Object::DynamicProperty::Url: + return QMetaType::type("QUrl"); + + case QmlParser::Object::DynamicProperty::Variant: + return QMetaType::type("QVariant"); + + default: + break; + } + } + + return -1; +} + +/*! + Return true if this property is used as a default property in the QML + document. + + \qml +<Text text="hello"/> +<Text>hello</Text> + \endqml + + The above two examples return the same DOM tree, except that the second has + the default property flag set on the text property. Observe that whether + or not a property has isDefaultProperty set is determined by how the + property is used, and not only by whether the property is the types default + property. +*/ +bool QmlDomDynamicProperty::isDefaultProperty() const +{ + if (isValid()) + return d->property.isDefaultProperty; + else + return false; +} + +/*! + Returns the default value as a QmlDomProperty. +*/ +QmlDomProperty QmlDomDynamicProperty::defaultValue() const +{ + QmlDomProperty rp; + + if (isValid() && d->property.defaultValue) { + rp.d->property = d->property.defaultValue; + rp.d->property->addref(); + } + + return rp; +} + +/*! + Returns the position in the input data where the property ID startd, or 0 if + the property is invalid. +*/ +int QmlDomDynamicProperty::position() const +{ + if (isValid()) { + return d->property.range.offset; + } else + return -1; +} + +/*! + Returns the length in the input data from where the property ID started upto + the end of it, or 0 if the property is invalid. +*/ +int QmlDomDynamicProperty::length() const +{ + if (isValid()) + return d->property.range.length; + else + return -1; } QmlDomObjectPrivate::QmlDomObjectPrivate() @@ -701,6 +863,41 @@ void QmlDomObject::addProperty(const QByteArray &name, const QmlDomValue &value) qWarning("QmlDomObject::addProperty(const QByteArray &, const QmlDomValue &): Not implemented"); } +QList<QmlDomDynamicProperty> QmlDomObject::dynamicProperties() const +{ + QList<QmlDomDynamicProperty> properties; + + for (int i = 0; i < d->object->dynamicProperties.size(); ++i) { + QmlDomDynamicProperty p; + p.d = new QmlDomDynamicPropertyPrivate; + p.d->property = d->object->dynamicProperties.at(i); + p.d->valid = true; + + if (p.d->property.defaultValue) + p.d->property.defaultValue->addref(); + + properties.append(p); + } + + return properties; +} + +QmlDomDynamicProperty QmlDomObject::dynamicProperty(const QByteArray &name) const +{ + QmlDomDynamicProperty p; + + for (int i = 0; i < d->object->dynamicProperties.size(); ++i) { + if (d->object->dynamicProperties.at(i).name == name) { + p.d = new QmlDomDynamicPropertyPrivate; + p.d->property = d->object->dynamicProperties.at(i); + if (p.d->property.defaultValue) p.d->property.defaultValue->addref(); + p.d->valid = true; + } + } + + return p; +} + /*! Returns true if this object is a custom type. Custom types are special types that allow embeddeding non-QML data, such as SVG or HTML data, @@ -769,26 +966,36 @@ QmlDomComponent QmlDomObject::toComponent() const /*! Returns the position in the input data where the property assignment started -, or 0 if the property is invalid. +, or -1 if the property is invalid. */ int QmlDomObject::position() const { if (d && d->object) return d->object->location.range.offset; else - return 0; + return -1; } /*! Returns the length in the input data from where the property assignment star -ted upto the end of it, or 0 if the property is invalid. +ted upto the end of it, or -1 if the property is invalid. */ int QmlDomObject::length() const { if (d && d->object) return d->object->location.range.length; else - return 0; + return -1; +} + +// Returns the URL of the type, if it is an external type, or an empty URL if +// not +QUrl QmlDomObject::url() const +{ + if (d && d->object) + return d->object->url; + else + return QUrl(); } QmlDomBasicValuePrivate::QmlDomBasicValuePrivate() @@ -959,11 +1166,11 @@ void QmlDomValueBinding::setBinding(const QString &expression) In QML, value sources are special value generating types that may be assigned to properties. Value sources inherit the QmlPropertyValueSource class. In the example below, the "x" property is being assigned the - NumericAnimation value source. + NumberAnimation value source. \qml Rect { - x: NumericAnimation { + x: NumberAnimation { from: 0 to: 100 repeat: true @@ -1008,11 +1215,11 @@ QmlDomValueValueSource &QmlDomValueValueSource::operator=(const QmlDomValueValue /*! Return the value source object. - In the example below, an object representing the NumericAnimation will be + In the example below, an object representing the NumberAnimation will be returned. \qml Rect { - x: NumericAnimation { + x: NumberAnimation { from: 0 to: 100 repeat: true @@ -1313,25 +1520,25 @@ QmlDomList QmlDomValue::toList() const } /*! - Returns the position in the input data where the property value startd, or 0 + Returns the position in the input data where the property value startd, or -1 if the value is invalid. */ int QmlDomValue::position() const { if (type() == Invalid) - return 0; + return -1; else return d->value->location.range.offset; } /*! Returns the length in the input data from where the property value started u -pto the end of it, or 0 if the value is invalid. +pto the end of it, or -1 if the value is invalid. */ int QmlDomValue::length() const { if (type() == Invalid) - return 0; + return -1; else return d->value->location.range.length; } @@ -1357,7 +1564,7 @@ Item { \qml Item { x: 10 - x: NumericAnimation { + x: NumberAnimation { running: false from: 0 to: 100 @@ -1426,7 +1633,7 @@ void QmlDomList::setValues(const QList<QmlDomValue> &values) } /*! - Returns the position in the input data where the list started, or 0 if + Returns the position in the input data where the list started, or -1 if the property is invalid. */ int QmlDomList::position() const @@ -1434,7 +1641,7 @@ int QmlDomList::position() const if (d && d->property) { return d->property->listValueRange.offset; } else - return 0; + return -1; } /*! @@ -1446,7 +1653,7 @@ int QmlDomList::length() const if (d && d->property) return d->property->listValueRange.length; else - return 0; + return -1; } /*! @@ -1561,4 +1768,3 @@ void QmlDomComponent::setComponentRoot(const QmlDomObject &root) } QT_END_NAMESPACE - diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h index fde35a8..ef9fe25 100644 --- a/src/declarative/qml/qmldom.h +++ b/src/declarative/qml/qmldom.h @@ -79,8 +79,6 @@ public: QmlDomObject rootObject() const; - QList<int> automaticSemicolonOffsets() const; - private: QSharedDataPointer<QmlDomDocumentPrivate> d; }; @@ -107,9 +105,36 @@ public: private: friend class QmlDomObject; + friend class QmlDomDynamicProperty; QSharedDataPointer<QmlDomPropertyPrivate> d; }; +class QmlDomDynamicPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty +{ +public: + QmlDomDynamicProperty(); + QmlDomDynamicProperty(const QmlDomDynamicProperty &); + ~QmlDomDynamicProperty(); + QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &); + + bool isValid() const; + + QByteArray propertyName() const; + int propertyType() const; + + bool isDefaultProperty() const; + + QmlDomProperty defaultValue() const; + + int position() const; + int length() const; + +private: + friend class QmlDomObject; + QSharedDataPointer<QmlDomDynamicPropertyPrivate> d; +}; + class QmlDomObjectPrivate; class Q_DECLARATIVE_EXPORT QmlDomObject { @@ -133,6 +158,9 @@ public: void removeProperty(const QByteArray &); void addProperty(const QByteArray &, const QmlDomValue &); + QList<QmlDomDynamicProperty> dynamicProperties() const; + QmlDomDynamicProperty dynamicProperty(const QByteArray &) const; + bool isCustomType() const; QByteArray customTypeData() const; void setCustomTypeData(const QByteArray &); @@ -143,6 +171,7 @@ public: int position() const; int length() const; + QUrl url() const; private: friend class QmlDomDocument; friend class QmlDomComponent; diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index 441269c..5345c44 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -42,16 +42,22 @@ #ifndef QMLDOM_P_H #define QMLDOM_P_H -#include <QtCore/QtGlobal> +// +// 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. +// -QT_BEGIN_HEADER +#include <QtCore/QtGlobal> +#include "qmlparser_p.h" QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) - -#include "qmlparser_p.h" - class QmlDomDocumentPrivate : public QSharedData { public: @@ -91,6 +97,17 @@ public: QmlParser::Property *property; }; +class QmlDomDynamicPropertyPrivate : public QSharedData +{ +public: + QmlDomDynamicPropertyPrivate(); + QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &); + ~QmlDomDynamicPropertyPrivate(); + + bool valid; + QmlParser::Object::DynamicProperty property; +}; + class QmlDomValuePrivate : public QSharedData { public: @@ -114,7 +131,5 @@ public: QT_END_NAMESPACE -QT_END_HEADER - #endif // QMLDOM_P_H diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 36b6424..d88d11f 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -57,7 +57,7 @@ #include <QDebug> #include <QMetaObject> #include "qml.h" -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <QStack> #include "private/qmlbasicscript_p.h" #include "private/qmlcompiledcomponent_p.h" @@ -73,22 +73,15 @@ #include <private/qmlbindablevalue_p.h> #include <private/qmlvme_p.h> +Q_DECLARE_METATYPE(QmlMetaProperty) +Q_DECLARE_METATYPE(QList<QObject *>); + QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER) -Q_DECLARE_METATYPE(QmlMetaProperty) - QML_DEFINE_TYPE(QObject,Object) -static QScriptValue qmlMetaProperty_emit(QScriptContext *ctx, QScriptEngine *engine) -{ - QmlMetaProperty mp = qscriptvalue_cast<QmlMetaProperty>(ctx->thisObject()); - if (mp.type() & QmlMetaProperty::Signal) - mp.emitSignal(); - return engine->nullValue(); -} - struct StaticQtMetaObject : public QObject { static const QMetaObject *get() @@ -142,11 +135,6 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) : rootContext(0), currentBindContext(0), currentExpression(0), q(e), rootComponent(0), networkAccessManager(0), typeManager(e), uniqueId(1) { - QScriptValue proto = scriptEngine.newObject(); - proto.setProperty(QLatin1String("emit"), - scriptEngine.newFunction(qmlMetaProperty_emit)); - scriptEngine.setDefaultPrototype(qMetaTypeId<QmlMetaProperty>(), proto); - QScriptValue qtObject = scriptEngine.newQMetaObject(StaticQtMetaObject::get()); scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject); } @@ -206,8 +194,8 @@ void QmlEnginePrivate::init() //###needed for the other funcs, but should it be exposed? scriptEngine.globalObject().setProperty(QLatin1String("qmlEngine"), scriptEngine.newQObject(q)); - scriptEngine.globalObject().setProperty(QLatin1String("evalQml"), - scriptEngine.newFunction(QmlEngine::createQMLObject, 1)); + scriptEngine.globalObject().setProperty(QLatin1String("createQmlObject"), + scriptEngine.newFunction(QmlEngine::createQmlObject, 1)); scriptEngine.globalObject().setProperty(QLatin1String("createComponent"), scriptEngine.newFunction(QmlEngine::createComponent, 1)); } @@ -220,7 +208,7 @@ QmlContext *QmlEnginePrivate::setCurrentBindContext(QmlContext *c) } QmlEnginePrivate::CapturedProperty::CapturedProperty(const QmlMetaProperty &p) -: object(p.object()), notifyIndex(p.property().notifySignalIndex()) +: object(p.object()), coreIndex(p.coreIndex()), notifyIndex(p.property().notifySignalIndex()) { } @@ -277,22 +265,18 @@ QScriptValue QmlEnginePrivate::propertyObject(const QScriptString &propName, if (!prop.isValid()) return QScriptValue(); - if (prop.type() & QmlMetaProperty::Signal) { - return scriptEngine.newVariant(qVariantFromValue(prop)); + QVariant var = prop.read(); + if (prop.needsChangedNotifier()) + capturedProperties << CapturedProperty(prop); + QObject *varobj = QmlMetaType::toQObject(var); + if (!varobj) + varobj = qvariant_cast<QObject *>(var); + if (varobj) { + return scriptEngine.newObject(objectClass, scriptEngine.newVariant(QVariant::fromValue(varobj))); } else { - QVariant var = prop.read(); - if (prop.needsChangedNotifier()) - capturedProperties << CapturedProperty(prop); - QObject *varobj = QmlMetaType::toQObject(var); - if (!varobj) - varobj = qvariant_cast<QObject *>(var); - if (varobj) { - return scriptEngine.newObject(objectClass, scriptEngine.newVariant(QVariant::fromValue(varobj))); - } else { - if (var.type() == QVariant::Bool) - return QScriptValue(&scriptEngine, var.toBool()); - return scriptEngine.newVariant(var); - } + if (var.type() == QVariant::Bool) + return QScriptValue(&scriptEngine, var.toBool()); + return scriptEngine.newVariant(var); } } @@ -357,13 +341,6 @@ bool QmlEnginePrivate::fetchCache(QmlBasicScriptNodeCache &cache, const QString cache.core = prop.coreIndex(); return true; - } else if (prop.type() & QmlMetaProperty::Signal) { - - cache.object = obj; - cache.type = QmlBasicScriptNodeCache::Signal; - cache.core = prop.coreIndex(); - return true; - } return false; @@ -380,7 +357,7 @@ bool QmlEnginePrivate::loadCache(QmlBasicScriptNodeCache &cache, const QString & cache.type = QmlBasicScriptNodeCache::Variant; cache.context = context; cache.contextIndex = *iter; - capturedProperties << CapturedProperty(context->q_ptr, *iter + context->notifyIndex); + capturedProperties << CapturedProperty(context->q_ptr, -1, *iter + context->notifyIndex); return true; } @@ -661,6 +638,36 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const } /*! + Return the base URL for this engine. The base URL is only used to resolve + components when a relative URL is passed to the QmlComponent constructor. + + If a base URL has not been explicitly set, this method returns the + application's current working directory. + + \sa setBaseUrl() +*/ +QUrl QmlEngine::baseUrl() const +{ + Q_D(const QmlEngine); + if (d->baseUrl.isEmpty()) { + return QUrl::fromLocalFile(QDir::currentPath() + QDir::separator()); + } else { + return d->baseUrl; + } +} + +/*! + Set the base URL for this engine to \a url. + + \sa baseUrl() +*/ +void QmlEngine::setBaseUrl(const QUrl &url) +{ + Q_D(QmlEngine); + d->baseUrl = url; +} + +/*! Returns the QmlContext for the \a object, or 0 if no context has been set. When the QmlEngine instantiates a QObject, the context is set automatically. @@ -730,13 +737,13 @@ QmlEngine *qmlEngine(const QObject *obj) return context?context->engine():0; } -QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object) +QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create) { QmlExtendedDeclarativeData *edata = QmlExtendedDeclarativeData::get(const_cast<QObject *>(object), true); QObject *rv = edata->attachedProperties.value(id); - if (rv) + if (rv || !create) return rv; QmlAttachedPropertiesFunc pf = QmlMetaType::attachedPropertiesFuncById(id); @@ -858,6 +865,7 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine) sprite = component.createObject(); if(sprite == 0){ // Error Handling + print(component.errorsString()); }else{ sprite.parent = page; sprite.x = 200; @@ -865,7 +873,9 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine) } \endcode - \sa QmlComponent::createObject() + If you want to just create an arbitrary string of QML, instead of + loading a qml file, consider the createQmlObject() function. + \sa QmlComponent::createObject(), QmlEngine::createQmlObject() */ QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *engine) { @@ -875,507 +885,92 @@ QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *eng if(ctxt->argumentCount() != 1 || !activeEngine){ c = new QmlComponent(activeEngine); }else{ - QUrl url = QUrl(ctxt->argument(0).toString()); + QUrl url = QUrl(activeEngine->d_func()->currentExpression->context() + ->resolvedUrl(ctxt->argument(0).toString())); + if(!url.isValid()){ + qDebug() << "Error A:" << url << activeEngine->activeContext() << QmlEngine::activeEngine() << activeEngine; + url = QUrl(ctxt->argument(0).toString()); + } c = new QmlComponent(activeEngine, url, activeEngine); } return engine->newQObject(c); } /*! - Creates a new object from the specified string of qml. If a second argument - is provided, this is treated as the filepath that the qml came from. + Creates a new object from the specified string of QML. It requires a + second argument, which is the id of an existing QML object to use as + the new object's parent. If a third argument is provided, this is used + as the filepath that the qml came from. + + Example (where targetItem is the id of an existing QML item): + \code + newObject = createQmlObject('Rect {color: "red"; width: 20; height: 20}', + targetItem, "dynamicSnippet1"); + \endcode This function is intended for use inside QML only. It is intended to behave - similarly to eval, but for creating QML elements. Thus, it is called as - evalQml() in QtScript. + similarly to eval, but for creating QML elements. Returns the created object, or null if there is an error. In the case of an error, details of the error are output using qWarning(). + + Note that this function returns immediately, and therefore may not work if + the QML loads new components. If you are trying to load a new component, + for example from a QML file, consider the createComponent() function + instead. 'New components' refers to external QML files that have not yet + been loaded, and so it is safe to use createQmlObject to load built-in + components. + + \sa QmlEngine::createComponent() */ -QScriptValue QmlEngine::createQMLObject(QScriptContext *ctxt, QScriptEngine *engine) +QScriptValue QmlEngine::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine) { QmlEngine* activeEngine = qobject_cast<QmlEngine*>( engine->globalObject().property(QLatin1String("qmlEngine")).toQObject()); - if(ctxt->argumentCount() < 1 || !activeEngine){ - if(ctxt->argumentCount() < 1){ - qWarning() << "createQMLObject requires a string argument."; + if(ctxt->argumentCount() < 2 || !activeEngine){ + if(ctxt->argumentCount() < 2){ + qWarning() << "createQmlObject requires two arguments, A QML string followed by an existing QML item id."; }else{ - qWarning() << "createQMLObject cannot find engine."; + qWarning() << "createQmlObject cannot find engine."; } return engine->nullValue(); } QString qml = ctxt->argument(0).toString(); QUrl url; - if(ctxt->argumentCount() > 1) - url = QUrl(ctxt->argument(1).toString()); + if(ctxt->argumentCount() > 2) + url = QUrl(ctxt->argument(2).toString()); + QObject *parentArg = ctxt->argument(1).data().toQObject(); + QmlContext *qmlCtxt = qmlContext(parentArg); + url = qmlCtxt->resolvedUrl(url); QmlComponent component(activeEngine, qml.toUtf8(), url); if(component.isError()) { QList<QmlError> errors = component.errors(); foreach (const QmlError &error, errors) { - qWarning() << error; + qWarning() <<"Error in createQmlObject(): "<< error; } return engine->nullValue(); } - QObject *obj = component.create(); + QObject *obj = component.create(qmlCtxt); if(component.isError()) { QList<QmlError> errors = component.errors(); foreach (const QmlError &error, errors) { - qWarning() << error; + qWarning() <<"Error in createQmlObject(): "<< error; } return engine->nullValue(); } if(obj){ + obj->setParent(parentArg); + obj->setProperty("parent", QVariant::fromValue<QObject*>(parentArg)); return qmlScriptObject(obj, activeEngine); } return engine->nullValue(); } -QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b) -: q(b), ctxt(0), sseData(0), proxy(0), me(0), trackChange(false), line(-1), id(0), log(0) -{ -} - -QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, void *expr, QmlRefCount *rc) -: q(b), ctxt(0), sse((const char *)expr, rc), sseData(0), proxy(0), me(0), trackChange(true), line(-1), id(0), log(0) -{ -} - -QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, const QString &expr) -: q(b), ctxt(0), expression(expr), sseData(0), proxy(0), me(0), trackChange(true), line(-1), id(0), log(0) -{ -} - -QmlExpressionPrivate::~QmlExpressionPrivate() -{ - sse.deleteScriptState(sseData); - sseData = 0; - delete proxy; - delete log; -} - -/*! - Create an invalid QmlExpression. - - As the expression will not have an associated QmlContext, this will be a - null expression object and its value will always be an invalid QVariant. - */ -QmlExpression::QmlExpression() -: d(new QmlExpressionPrivate(this)) -{ -} - -/*! \internal */ -QmlExpression::QmlExpression(QmlContext *ctxt, void *expr, - QmlRefCount *rc, QObject *me) -: d(new QmlExpressionPrivate(this, expr, rc)) -{ - d->ctxt = ctxt; - if(ctxt && ctxt->engine()) - d->id = ctxt->engine()->d_func()->getUniqueId(); - if(ctxt) - ctxt->d_func()->childExpressions.insert(this); - d->me = me; -} - -/*! - Create a QmlExpression object. - - The \a expression ECMAScript will be executed in the \a ctxt QmlContext. - If specified, the \a scope object's properties will also be in scope during - the expression's execution. -*/ -QmlExpression::QmlExpression(QmlContext *ctxt, const QString &expression, - QObject *scope) -: d(new QmlExpressionPrivate(this, expression)) -{ - d->ctxt = ctxt; - if(ctxt && ctxt->engine()) - d->id = ctxt->engine()->d_func()->getUniqueId(); - if(ctxt) - ctxt->d_func()->childExpressions.insert(this); - d->me = scope; -} - -/*! - Destroy the QmlExpression instance. -*/ -QmlExpression::~QmlExpression() -{ - if (d->ctxt) - d->ctxt->d_func()->childExpressions.remove(this); - delete d; d = 0; -} - -/*! - Returns the QmlEngine this expression is associated with, or 0 if there - is no association or the QmlEngine has been destroyed. -*/ -QmlEngine *QmlExpression::engine() const -{ - return d->ctxt?d->ctxt->engine():0; -} - -/*! - Returns the QmlContext this expression is associated with, or 0 if there - is no association or the QmlContext has been destroyed. -*/ -QmlContext *QmlExpression::context() const -{ - return d->ctxt; -} - -/*! - Returns the expression string. -*/ -QString QmlExpression::expression() const -{ - if (d->sse.isValid()) - return QLatin1String(d->sse.expression()); - else - return d->expression; -} - -/*! - Clear the expression. -*/ -void QmlExpression::clearExpression() -{ - setExpression(QString()); -} - -/*! - Set the expression to \a expression. -*/ -void QmlExpression::setExpression(const QString &expression) -{ - if (d->sseData) { - d->sse.deleteScriptState(d->sseData); - d->sseData = 0; - } - - delete d->proxy; d->proxy = 0; - - d->expression = expression; - - d->sse.clear(); -} - -/*! - Called by QmlExpression each time the expression value changes from the - last time it was evaluated. The expression must have been evaluated at - least once (by calling QmlExpression::value()) before this callback will - be made. - - The default implementation does nothing. -*/ -void QmlExpression::valueChanged() -{ -} - -Q_DECLARE_METATYPE(QList<QObject *>); - -void BindExpressionProxy::changed() -{ - e->valueChanged(); -} - -/*! - Returns the value of the expression, or an invalid QVariant if the - expression is invalid or has an error. -*/ -QVariant QmlExpression::value() -{ - QVariant rv; - if (!d->ctxt || !engine() || (!d->sse.isValid() && d->expression.isEmpty())) - return rv; - -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer<QFxPerf::BindValue> perf; -#endif - - QmlBasicScript::CacheState cacheState = QmlBasicScript::Reset; - - QmlEnginePrivate *ep = engine()->d_func(); - QmlExpression *lastCurrentExpression = ep->currentExpression; - ep->currentExpression = this; - if (d->sse.isValid()) { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer<QFxPerf::BindValueSSE> perfsse; -#endif - - context()->d_func()->defaultObjects.insert(context()->d_func()->highPriorityCount, d->me); - - if (!d->sseData) - d->sseData = d->sse.newScriptState(); - rv = d->sse.run(context(), d->sseData, &cacheState); - - context()->d_func()->defaultObjects.removeAt(context()->d_func()->highPriorityCount); - } else { -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer<QFxPerf::BindValueQt> perfqt; -#endif - context()->d_func()->defaultObjects.insert(context()->d_func()->highPriorityCount, d->me); - - QScriptEngine *scriptEngine = engine()->scriptEngine(); - QScriptValueList oldScopeChain = scriptEngine->currentContext()->scopeChain(); - for (int i = 0; i < oldScopeChain.size(); ++i) { - scriptEngine->currentContext()->popScope(); - } - for (int i = context()->d_func()->scopeChain.size() - 1; i > -1; --i) { - scriptEngine->currentContext()->pushScope(context()->d_func()->scopeChain.at(i)); - } - QScriptValue svalue = scriptEngine->evaluate(expression(), d->fileName.toString(), d->line); - if (scriptEngine->hasUncaughtException()) { - if (scriptEngine->uncaughtException().isError()){ - QScriptValue exception = scriptEngine->uncaughtException(); - if (!exception.property(QLatin1String("fileName")).toString().isEmpty()){ - qWarning() << exception.property(QLatin1String("fileName")).toString() - << scriptEngine->uncaughtExceptionLineNumber() - << exception.toString(); - - } else { - qWarning() << exception.toString(); - } - } - } - - context()->d_func()->defaultObjects.removeAt(context()->d_func()->highPriorityCount); - if (svalue.isArray()) { - int length = svalue.property(QLatin1String("length")).toInt32(); - if (length && svalue.property(0).isObject()) { - QList<QObject *> list; - for (int ii = 0; ii < length; ++ii) { - QScriptValue arrayItem = svalue.property(ii); - QObject *d = qvariant_cast<QObject *>(arrayItem.data().toVariant()); - if (d) { - list << d; - } else { - list << 0; - } - } - rv = QVariant::fromValue(list); - } - } else if (svalue.isObject()) { - QScriptValue objValue = svalue.data(); - if (objValue.isValid()) - rv = objValue.toVariant(); - } - if (rv.isNull()) { - rv = svalue.toVariant(); - } - - for (int i = 0; i < context()->d_func()->scopeChain.size(); ++i) { - scriptEngine->currentContext()->popScope(); - } - for (int i = oldScopeChain.size() - 1; i > -1; --i) { - scriptEngine->currentContext()->pushScope(oldScopeChain.at(i)); - } - } - ep->currentExpression = lastCurrentExpression; - - if (cacheState != QmlBasicScript::NoChange) { - if (cacheState != QmlBasicScript::Incremental && d->proxy) { - delete d->proxy; - d->proxy = 0; - } - - if (trackChange() && ep->capturedProperties.count()) { - if (!d->proxy) - d->proxy = new BindExpressionProxy(this); - - static int changedIndex = -1; - if (changedIndex == -1) - changedIndex = BindExpressionProxy::staticMetaObject.indexOfSlot("changed()"); - - if(qmlDebugger()) { - QmlExpressionLog log; - log.setTime(engine()->d_func()->getUniqueId()); - log.setExpression(expression()); - log.setResult(rv); - - for (int ii = 0; ii < ep->capturedProperties.count(); ++ii) { - const QmlEnginePrivate::CapturedProperty &prop = - ep->capturedProperties.at(ii); - - if (prop.notifyIndex != -1) { - QMetaObject::connect(prop.object, prop.notifyIndex, - d->proxy, changedIndex); - } else { - // ### FIXME - //QString warn = QLatin1String("Expression depends on property without a NOTIFY signal: [") + QLatin1String(prop.object->metaObject()->className()) + QLatin1String("].") + prop.name; - //log.addWarning(warn); - } - } - d->addLog(log); - - } else { - for (int ii = 0; ii < ep->capturedProperties.count(); ++ii) { - const QmlEnginePrivate::CapturedProperty &prop = - ep->capturedProperties.at(ii); - - if (prop.notifyIndex != -1) - QMetaObject::connect(prop.object, prop.notifyIndex, - d->proxy, changedIndex); - } - } - } else { - QmlExpressionLog log; - log.setTime(engine()->d_func()->getUniqueId()); - log.setExpression(expression()); - log.setResult(rv); - d->addLog(log); - } - - } else { - if(qmlDebugger()) { - QmlExpressionLog log; - log.setTime(engine()->d_func()->getUniqueId()); - log.setExpression(expression()); - log.setResult(rv); - d->addLog(log); - } - } - - ep->capturedProperties.clear(); - - return rv; -} - -/*! - Returns true if the expression results in a constant value. - QmlExpression::value() must have been invoked at least once before the - return from this method is valid. - */ -bool QmlExpression::isConstant() const -{ - return d->proxy == 0; -} - -/*! - Returns true if the changes are tracked in the expression's value. -*/ -bool QmlExpression::trackChange() const -{ - return d->trackChange; -} - -/*! - Set whether changes are tracked in the expression's value to \a trackChange. - - If true, the QmlExpression will monitor properties involved in the - expression's evaluation, and call QmlExpression::valueChanged() if they have - changed. This allows an application to ensure that any value associated - with the result of the expression remains up to date. - - If false, the QmlExpression will not montitor properties involved in the - expression's evaluation, and QmlExpression::valueChanged() will never be - called. This is more efficient if an application wants a "one off" - evaluation of the expression. - - By default, trackChange is true. -*/ -void QmlExpression::setTrackChange(bool trackChange) -{ - d->trackChange = trackChange; -} - -/*! - Set the location of this expression to \a line of \a fileName. This information - is used by the script engine. -*/ -void QmlExpression::setSourceLocation(const QUrl &fileName, int line) -{ - d->fileName = fileName; - d->line = line; -} - -/*! - Returns the expression's scope object, if provided, otherwise 0. - - In addition to data provided by the expression's QmlContext, the scope - object's properties are also in scope during the expression's evaluation. -*/ -QObject *QmlExpression::scopeObject() const -{ - return d->me; -} - -/*! - \internal -*/ -quint32 QmlExpression::id() const -{ - return d->id; -} - -/*! - \class QmlExpression - \brief The QmlExpression class evaluates ECMAScript in a QML context. -*/ - -/*! - \class QmlExpressionObject - \brief The QmlExpressionObject class extends QmlExpression with signals and slots. - - To remain as lightweight as possible, QmlExpression does not inherit QObject - and consequently cannot use signals or slots. For the cases where this is - more convenient in an application, QmlExpressionObject can be used instead. - - QmlExpressionObject behaves identically to QmlExpression, except that the - QmlExpressionObject::value() method is a slot, and the - QmlExpressionObject::valueChanged() callback is a signal. -*/ -/*! - Create a QmlExpression with the specified \a parent. - - As the expression will not have an associated QmlContext, this will be a - null expression object and its value will always be an invalid QVariant. -*/ -QmlExpressionObject::QmlExpressionObject(QObject *parent) -: QObject(parent) -{ -} - -/*! - Create a QmlExpressionObject with the specified \a parent. - - The \a expression ECMAScript will be executed in the \a ctxt QmlContext. - If specified, the \a scope object's properties will also be in scope during - the expression's execution. -*/ -QmlExpressionObject::QmlExpressionObject(QmlContext *ctxt, const QString &expression, QObject *scope, QObject *parent) -: QObject(parent), QmlExpression(ctxt, expression, scope) -{ -} - -/*! \internal */ -QmlExpressionObject::QmlExpressionObject(QmlContext *ctxt, void *d, QmlRefCount *rc, QObject *me) -: QmlExpression(ctxt, d, rc, me) -{ -} - -/*! - Returns the value of the expression, or an invalid QVariant if the - expression is invalid or has an error. -*/ -QVariant QmlExpressionObject::value() -{ - return QmlExpression::value(); -} - -/*! - \fn void QmlExpressionObject::valueChanged() - - Emitted each time the expression value changes from the last time it was - evaluated. The expression must have been evaluated at least once (by - calling QmlExpressionObject::value()) before this signal will be emitted. -*/ - QmlScriptClass::QmlScriptClass(QmlEngine *bindengine) : QScriptClass(bindengine->scriptEngine()), engine(bindengine) { @@ -1459,7 +1054,7 @@ QScriptValue QmlContextScriptClass::property(const QScriptValue &object, } else { rv = scriptEngine->newVariant(value); } - engine->d_func()->capturedProperties << QmlEnginePrivate::CapturedProperty(bindContext, index + bindContext->d_func()->notifyIndex); + engine->d_func()->capturedProperties << QmlEnginePrivate::CapturedProperty(bindContext, -1, index + bindContext->d_func()->notifyIndex); return rv; } default: @@ -1540,7 +1135,7 @@ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine) { engine = bindEngine; prototypeObject = engine->scriptEngine()->newObject(); - prototypeObject.setProperty("destroy", + prototypeObject.setProperty(QLatin1String("destroy"), engine->scriptEngine()->newFunction(QmlObjectDestroy)); } @@ -1628,76 +1223,4 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object, scriptEngine->currentContext()->setActivationObject(oldact); } -void QmlExpressionPrivate::addLog(const QmlExpressionLog &l) -{ - if (!log) - log = new QList<QmlExpressionLog>(); - log->append(l); -} - -QmlExpressionLog::QmlExpressionLog() -{ -} - -QmlExpressionLog::QmlExpressionLog(const QmlExpressionLog &o) -: m_time(o.m_time), - m_expression(o.m_expression), - m_result(o.m_result), - m_warnings(o.m_warnings) -{ -} - -QmlExpressionLog::~QmlExpressionLog() -{ -} - -QmlExpressionLog &QmlExpressionLog::operator=(const QmlExpressionLog &o) -{ - m_time = o.m_time; - m_expression = o.m_expression; - m_result = o.m_result; - m_warnings = o.m_warnings; - return *this; -} - -void QmlExpressionLog::setTime(quint32 time) -{ - m_time = time; -} - -quint32 QmlExpressionLog::time() const -{ - return m_time; -} - -QString QmlExpressionLog::expression() const -{ - return m_expression; -} - -void QmlExpressionLog::setExpression(const QString &e) -{ - m_expression = e; -} - -QStringList QmlExpressionLog::warnings() const -{ - return m_warnings; -} - -void QmlExpressionLog::addWarning(const QString &w) -{ - m_warnings << w; -} - -QVariant QmlExpressionLog::result() const -{ - return m_result; -} - -void QmlExpressionLog::setResult(const QVariant &r) -{ - m_result = r; -} - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index f114379..9e0ac87 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -85,13 +85,16 @@ public: void setNetworkAccessManager(QNetworkAccessManager *); QNetworkAccessManager *networkAccessManager() const; + QUrl baseUrl() const; + void setBaseUrl(const QUrl &); + static QmlContext *contextForObject(const QObject *); static void setContextForObject(QObject *, QmlContext *); static QScriptValue qmlScriptObject(QObject*, QmlEngine*); static QScriptValue createComponent(QScriptContext*, QScriptEngine*); - static QScriptValue createQMLObject(QScriptContext*, QScriptEngine*); + static QScriptValue createQmlObject(QScriptContext*, QScriptEngine*); private: // LK: move to the private class @@ -104,6 +107,7 @@ private: friend class QmlContext; friend class QmlContextPrivate; friend class QmlExpression; + friend class QmlExpressionPrivate; friend class QmlBasicScript; friend class QmlVME; friend class QmlComponent; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index a1028e6..9171fbb 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -42,6 +42,17 @@ #ifndef QMLENGINE_P_H #define QMLENGINE_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 <QtScript/QScriptClass> #include <QtScript/QScriptValue> #include <QtScript/QScriptString> @@ -61,6 +72,7 @@ #include <QtScript/qscriptengine.h> QT_BEGIN_NAMESPACE + class QmlContext; class QmlEngine; class QmlContextPrivate; @@ -91,11 +103,12 @@ public: QScriptValue propertyObject(const QScriptString &propName, QObject *, uint id = 0); struct CapturedProperty { - CapturedProperty(QObject *o, int n) - : object(o), notifyIndex(n) {} + CapturedProperty(QObject *o, int c, int n) + : object(o), coreIndex(c), notifyIndex(n) {} CapturedProperty(const QmlMetaProperty &); QObject *object; + int coreIndex; int notifyIndex; }; QPODVector<CapturedProperty> capturedProperties; @@ -116,6 +129,8 @@ public: QScriptEngine scriptEngine; + QUrl baseUrl; + template<class T> struct SimpleList { SimpleList() @@ -157,23 +172,6 @@ public: } }; - -class BindExpressionProxy : public QObject -{ -Q_OBJECT -public: - BindExpressionProxy(QmlExpression *be) - :e(be) - { - } - -private: - QmlExpression *e; - -private Q_SLOTS: - void changed(); -}; - class QmlScriptClass : public QScriptClass { public: @@ -235,60 +233,6 @@ public: const QScriptValue &value); }; -class QmlExpressionLog -{ -public: - QmlExpressionLog(); - QmlExpressionLog(const QmlExpressionLog &); - ~QmlExpressionLog(); - - QmlExpressionLog &operator=(const QmlExpressionLog &); - - void setTime(quint32); - quint32 time() const; - - QString expression() const; - void setExpression(const QString &); - - QStringList warnings() const; - void addWarning(const QString &); - - QVariant result() const; - void setResult(const QVariant &); - -private: - quint32 m_time; - QString m_expression; - QVariant m_result; - QStringList m_warnings; -}; - -class QmlExpressionPrivate -{ -public: - QmlExpressionPrivate(QmlExpression *); - QmlExpressionPrivate(QmlExpression *, const QString &expr); - QmlExpressionPrivate(QmlExpression *, void *expr, QmlRefCount *rc); - ~QmlExpressionPrivate(); - - QmlExpression *q; - QmlContext *ctxt; - QString expression; - QmlBasicScript sse; - void *sseData; - BindExpressionProxy *proxy; - QObject *me; - bool trackChange; - - QUrl fileName; - int line; - - quint32 id; - - void addLog(const QmlExpressionLog &); - QList<QmlExpressionLog> *log; -}; QT_END_NAMESPACE #endif // QMLENGINE_P_H - diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp new file mode 100644 index 0000000..84352b8 --- /dev/null +++ b/src/declarative/qml/qmlexpression.cpp @@ -0,0 +1,624 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlexpression.h" +#include "qmlexpression_p.h" +#include "qmlengine_p.h" +#include "qmlcontext_p.h" +#include "QtCore/qdebug.h" + +Q_DECLARE_METATYPE(QList<QObject *>); + +QT_BEGIN_NAMESPACE + +DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER) + +QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b) +: q(b), ctxt(0), sseData(0), proxy(0), me(0), trackChange(false), line(-1), id(0), log(0) +{ +} + +QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, void *expr, QmlRefCount *rc) +: q(b), ctxt(0), sse((const char *)expr, rc), sseData(0), proxy(0), me(0), trackChange(true), line(-1), id(0), log(0) +{ +} + +QmlExpressionPrivate::QmlExpressionPrivate(QmlExpression *b, const QString &expr) +: q(b), ctxt(0), expression(expr), sseData(0), proxy(0), me(0), trackChange(true), line(-1), id(0), log(0) +{ +} + +QmlExpressionPrivate::~QmlExpressionPrivate() +{ + sse.deleteScriptState(sseData); + sseData = 0; + delete proxy; + delete log; +} + +/*! + Create an invalid QmlExpression. + + As the expression will not have an associated QmlContext, this will be a + null expression object and its value will always be an invalid QVariant. + */ +QmlExpression::QmlExpression() +: d(new QmlExpressionPrivate(this)) +{ +} + +/*! \internal */ +QmlExpression::QmlExpression(QmlContext *ctxt, void *expr, + QmlRefCount *rc, QObject *me) +: d(new QmlExpressionPrivate(this, expr, rc)) +{ + d->ctxt = ctxt; + if(ctxt && ctxt->engine()) + d->id = ctxt->engine()->d_func()->getUniqueId(); + if(ctxt) + ctxt->d_func()->childExpressions.insert(this); + d->me = me; +} + +/*! + Create a QmlExpression object. + + The \a expression ECMAScript will be executed in the \a ctxt QmlContext. + If specified, the \a scope object's properties will also be in scope during + the expression's execution. +*/ +QmlExpression::QmlExpression(QmlContext *ctxt, const QString &expression, + QObject *scope) +: d(new QmlExpressionPrivate(this, expression)) +{ + d->ctxt = ctxt; + if(ctxt && ctxt->engine()) + d->id = ctxt->engine()->d_func()->getUniqueId(); + if(ctxt) + ctxt->d_func()->childExpressions.insert(this); + d->me = scope; +} + +/*! + Destroy the QmlExpression instance. +*/ +QmlExpression::~QmlExpression() +{ + if (d->ctxt) + d->ctxt->d_func()->childExpressions.remove(this); + delete d; d = 0; +} + +/*! + Returns the QmlEngine this expression is associated with, or 0 if there + is no association or the QmlEngine has been destroyed. +*/ +QmlEngine *QmlExpression::engine() const +{ + return d->ctxt?d->ctxt->engine():0; +} + +/*! + Returns the QmlContext this expression is associated with, or 0 if there + is no association or the QmlContext has been destroyed. +*/ +QmlContext *QmlExpression::context() const +{ + return d->ctxt; +} + +/*! + Returns the expression string. +*/ +QString QmlExpression::expression() const +{ + if (d->sse.isValid()) + return QLatin1String(d->sse.expression()); + else + return d->expression; +} + +/*! + Clear the expression. +*/ +void QmlExpression::clearExpression() +{ + setExpression(QString()); +} + +/*! + Set the expression to \a expression. +*/ +void QmlExpression::setExpression(const QString &expression) +{ + if (d->sseData) { + d->sse.deleteScriptState(d->sseData); + d->sseData = 0; + } + + delete d->proxy; d->proxy = 0; + + d->expression = expression; + + d->sse.clear(); +} + +/*! + Called by QmlExpression each time the expression value changes from the + last time it was evaluated. The expression must have been evaluated at + least once (by calling QmlExpression::value()) before this callback will + be made. + + The default implementation does nothing. +*/ +void QmlExpression::valueChanged() +{ +} + +QVariant QmlExpressionPrivate::evalSSE(QmlBasicScript::CacheState &cacheState) +{ +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer<QFxPerf::BindValueSSE> perfsse; +#endif + + QmlContextPrivate *ctxtPriv = ctxt->d_func(); + if (me) + ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount , me); + + if (!sseData) + sseData = sse.newScriptState(); + QVariant rv = sse.run(ctxt, sseData, &cacheState); + + if (me) + ctxtPriv->defaultObjects.removeAt(ctxtPriv->highPriorityCount); + + return rv; +} + +QVariant QmlExpressionPrivate::evalQtScript() +{ +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer<QFxPerf::BindValueQt> perfqt; +#endif + + QmlContextPrivate *ctxtPriv = ctxt->d_func(); + QmlEngine *engine = ctxt->engine(); + + if (me) + ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount, me); + + QScriptEngine *scriptEngine = engine->scriptEngine(); + QScriptValueList oldScopeChain = + scriptEngine->currentContext()->scopeChain(); + + for (int i = 0; i < oldScopeChain.size(); ++i) + scriptEngine->currentContext()->popScope(); + for (int i = ctxtPriv->scopeChain.size() - 1; i > -1; --i) + scriptEngine->currentContext()->pushScope(ctxtPriv->scopeChain.at(i)); + + QScriptValue svalue = + scriptEngine->evaluate(expression, fileName.toString(), line); + + if (scriptEngine->hasUncaughtException()) { + if (scriptEngine->uncaughtException().isError()){ + QScriptValue exception = scriptEngine->uncaughtException(); + QLatin1String fileNameProp("fileName"); + if (!exception.property(fileNameProp).toString().isEmpty()){ + qWarning() << exception.property(fileNameProp).toString() + << scriptEngine->uncaughtExceptionLineNumber() + << exception.toString(); + } else { + qWarning() << exception.toString(); + } + } + } + + if (me) + ctxtPriv->defaultObjects.removeAt(ctxtPriv->highPriorityCount); + + QVariant rv; + + if (svalue.isArray()) { + int length = svalue.property(QLatin1String("length")).toInt32(); + if (length && svalue.property(0).isObject()) { + QList<QObject *> list; + for (int ii = 0; ii < length; ++ii) { + QScriptValue arrayItem = svalue.property(ii); + QObject *d = + qvariant_cast<QObject *>(arrayItem.data().toVariant()); + if (d) { + list << d; + } else { + list << 0; + } + } + rv = QVariant::fromValue(list); + } + } else if (svalue.isObject() && + !svalue.isNumber() && + !svalue.isString() && + !svalue.isDate() && + !svalue.isError() && + !svalue.isFunction() && + !svalue.isNull() && + !svalue.isQMetaObject() && + !svalue.isQObject() && + !svalue.isRegExp()) { + QScriptValue objValue = svalue.data(); + if (objValue.isValid()) { + QVariant var = objValue.toVariant(); + if (var.userType() >= (int)QVariant::UserType && + QmlMetaType::isObject(var.userType())) + rv = var; + } + } + if (rv.isNull()) + rv = svalue.toVariant(); + + for (int i = 0; i < ctxtPriv->scopeChain.size(); ++i) + scriptEngine->currentContext()->popScope(); + for (int i = oldScopeChain.size() - 1; i > -1; --i) + scriptEngine->currentContext()->pushScope(oldScopeChain.at(i)); + + return rv; +} + +/*! + Returns the value of the expression, or an invalid QVariant if the + expression is invalid or has an error. +*/ +QVariant QmlExpression::value() +{ + QVariant rv; + if (!d->ctxt || !engine() || (!d->sse.isValid() && d->expression.isEmpty())) + return rv; + +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer<QFxPerf::BindValue> perf; +#endif + + QmlBasicScript::CacheState cacheState = QmlBasicScript::Reset; + + QmlEnginePrivate *ep = engine()->d_func(); + QmlExpression *lastCurrentExpression = ep->currentExpression; + ep->currentExpression = this; + + if (d->sse.isValid()) { + rv = d->evalSSE(cacheState); + } else { + rv = d->evalQtScript(); + } + + ep->currentExpression = lastCurrentExpression; + + if (cacheState != QmlBasicScript::NoChange) { + if (cacheState != QmlBasicScript::Incremental && d->proxy) { + delete d->proxy; + d->proxy = 0; + } + + if (trackChange() && ep->capturedProperties.count()) { + if (!d->proxy) + d->proxy = new QmlExpressionBindProxy(this); + + static int changedIndex = -1; + if (changedIndex == -1) + changedIndex = QmlExpressionBindProxy::staticMetaObject.indexOfSlot("changed()"); + + if(qmlDebugger()) { + QmlExpressionLog log; + log.setTime(engine()->d_func()->getUniqueId()); + log.setExpression(expression()); + log.setResult(rv); + + for (int ii = 0; ii < ep->capturedProperties.count(); ++ii) { + const QmlEnginePrivate::CapturedProperty &prop = + ep->capturedProperties.at(ii); + + if (prop.notifyIndex != -1) { + QMetaObject::connect(prop.object, prop.notifyIndex, + d->proxy, changedIndex); + } else { + const QMetaObject *metaObj = prop.object->metaObject(); + QMetaProperty metaProp = + metaObj->property(prop.coreIndex); + + QString warn = QLatin1String("Expression depends on non-NOTIFYable property: ") + + QLatin1String(metaObj->className()) + + QLatin1String("::") + + QLatin1String(metaProp.name()); + log.addWarning(warn); + } + } + d->addLog(log); + + } else { + bool outputWarningHeader = false; + for (int ii = 0; ii < ep->capturedProperties.count(); ++ii) { + const QmlEnginePrivate::CapturedProperty &prop = + ep->capturedProperties.at(ii); + + if (prop.notifyIndex != -1) { + QMetaObject::connect(prop.object, prop.notifyIndex, + d->proxy, changedIndex); + } else { + if (!outputWarningHeader) { + outputWarningHeader = true; + qWarning() << "QmlExpression: Expression" << expression() << "depends on non-NOTIFYable properties:"; + } + + const QMetaObject *metaObj = prop.object->metaObject(); + QMetaProperty metaProp = + metaObj->property(prop.coreIndex); + + qWarning().nospace() << " " << metaObj->className() + << "::" << metaProp.name(); + } + } + } + } else { + QmlExpressionLog log; + log.setTime(engine()->d_func()->getUniqueId()); + log.setExpression(expression()); + log.setResult(rv); + d->addLog(log); + } + + } else { + if(qmlDebugger()) { + QmlExpressionLog log; + log.setTime(engine()->d_func()->getUniqueId()); + log.setExpression(expression()); + log.setResult(rv); + d->addLog(log); + } + } + + ep->capturedProperties.clear(); + + return rv; +} + +/*! + Returns true if the expression results in a constant value. + QmlExpression::value() must have been invoked at least once before the + return from this method is valid. + */ +bool QmlExpression::isConstant() const +{ + return d->proxy == 0; +} + +/*! + Returns true if the changes are tracked in the expression's value. +*/ +bool QmlExpression::trackChange() const +{ + return d->trackChange; +} + +/*! + Set whether changes are tracked in the expression's value to \a trackChange. + + If true, the QmlExpression will monitor properties involved in the + expression's evaluation, and call QmlExpression::valueChanged() if they have + changed. This allows an application to ensure that any value associated + with the result of the expression remains up to date. + + If false, the QmlExpression will not montitor properties involved in the + expression's evaluation, and QmlExpression::valueChanged() will never be + called. This is more efficient if an application wants a "one off" + evaluation of the expression. + + By default, trackChange is true. +*/ +void QmlExpression::setTrackChange(bool trackChange) +{ + d->trackChange = trackChange; +} + +/*! + Set the location of this expression to \a line of \a fileName. This information + is used by the script engine. +*/ +void QmlExpression::setSourceLocation(const QUrl &fileName, int line) +{ + d->fileName = fileName; + d->line = line; +} + +/*! + Returns the expression's scope object, if provided, otherwise 0. + + In addition to data provided by the expression's QmlContext, the scope + object's properties are also in scope during the expression's evaluation. +*/ +QObject *QmlExpression::scopeObject() const +{ + return d->me; +} + +/*! + \internal +*/ +quint32 QmlExpression::id() const +{ + return d->id; +} + +/*! + \class QmlExpression + \brief The QmlExpression class evaluates ECMAScript in a QML context. +*/ + +/*! + \class QmlExpressionObject + \brief The QmlExpressionObject class extends QmlExpression with signals and slots. + + To remain as lightweight as possible, QmlExpression does not inherit QObject + and consequently cannot use signals or slots. For the cases where this is + more convenient in an application, QmlExpressionObject can be used instead. + + QmlExpressionObject behaves identically to QmlExpression, except that the + QmlExpressionObject::value() method is a slot, and the + QmlExpressionObject::valueChanged() callback is a signal. +*/ +/*! + Create a QmlExpression with the specified \a parent. + + As the expression will not have an associated QmlContext, this will be a + null expression object and its value will always be an invalid QVariant. +*/ +QmlExpressionObject::QmlExpressionObject(QObject *parent) +: QObject(parent) +{ +} + +/*! + Create a QmlExpressionObject with the specified \a parent. + + The \a expression ECMAScript will be executed in the \a ctxt QmlContext. + If specified, the \a scope object's properties will also be in scope during + the expression's execution. +*/ +QmlExpressionObject::QmlExpressionObject(QmlContext *ctxt, const QString &expression, QObject *scope, QObject *parent) +: QObject(parent), QmlExpression(ctxt, expression, scope) +{ +} + +/*! \internal */ +QmlExpressionObject::QmlExpressionObject(QmlContext *ctxt, void *d, QmlRefCount *rc, QObject *me) +: QmlExpression(ctxt, d, rc, me) +{ +} + +/*! + Returns the value of the expression, or an invalid QVariant if the + expression is invalid or has an error. +*/ +QVariant QmlExpressionObject::value() +{ + return QmlExpression::value(); +} + +/*! + \fn void QmlExpressionObject::valueChanged() + + Emitted each time the expression value changes from the last time it was + evaluated. The expression must have been evaluated at least once (by + calling QmlExpressionObject::value()) before this signal will be emitted. +*/ + +void QmlExpressionPrivate::addLog(const QmlExpressionLog &l) +{ + if (!log) + log = new QList<QmlExpressionLog>(); + log->append(l); +} + +QmlExpressionLog::QmlExpressionLog() +{ +} + +QmlExpressionLog::QmlExpressionLog(const QmlExpressionLog &o) +: m_time(o.m_time), + m_expression(o.m_expression), + m_result(o.m_result), + m_warnings(o.m_warnings) +{ +} + +QmlExpressionLog::~QmlExpressionLog() +{ +} + +QmlExpressionLog &QmlExpressionLog::operator=(const QmlExpressionLog &o) +{ + m_time = o.m_time; + m_expression = o.m_expression; + m_result = o.m_result; + m_warnings = o.m_warnings; + return *this; +} + +void QmlExpressionLog::setTime(quint32 time) +{ + m_time = time; +} + +quint32 QmlExpressionLog::time() const +{ + return m_time; +} + +QString QmlExpressionLog::expression() const +{ + return m_expression; +} + +void QmlExpressionLog::setExpression(const QString &e) +{ + m_expression = e; +} + +QStringList QmlExpressionLog::warnings() const +{ + return m_warnings; +} + +void QmlExpressionLog::addWarning(const QString &w) +{ + m_warnings << w; +} + +QVariant QmlExpressionLog::result() const +{ + return m_result; +} + +void QmlExpressionLog::setResult(const QVariant &r) +{ + m_result = r; +} + + +QT_END_NAMESPACE + diff --git a/src/declarative/qml/qmlexpression.h b/src/declarative/qml/qmlexpression.h index 15d026a..3d8f8df 100644 --- a/src/declarative/qml/qmlexpression.h +++ b/src/declarative/qml/qmlexpression.h @@ -86,7 +86,7 @@ protected: virtual void valueChanged(); private: - friend class BindExpressionProxy; + friend class QmlExpressionBindProxy; friend class QmlDebugger; friend class QmlContext; QmlExpressionPrivate *d; @@ -109,7 +109,6 @@ Q_SIGNALS: void valueChanged(); }; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/fx/qfxcontentwrapper.h b/src/declarative/qml/qmlexpression_p.h index 898d695..5883125 100644 --- a/src/declarative/fx/qfxcontentwrapper.h +++ b/src/declarative/qml/qmlexpression_p.h @@ -39,52 +39,100 @@ ** ****************************************************************************/ -#ifndef QFXCONTENTWRAPPER_H -#define QFXCONTENTWRAPPER_H +#ifndef QMLEXPRESSION_P_H +#define QMLEXPRESSION_P_H -#include <QtDeclarative/qfxitem.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. +// - -QT_BEGIN_HEADER +#include "qmlbasicscript_p.h" +#include "qmlexpression.h" QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) -class QFxContentWrapperPrivate; -class Q_DECLARATIVE_EXPORT QFxContentWrapper : public QFxItem +class QmlExpression; +class QString; +class QmlExpressionLog; +class QmlExpressionBindProxy; +class QmlExpressionPrivate { - Q_OBJECT - - Q_PROPERTY(QList<QFxItem *>* content READ content DESIGNABLE false) - Q_CLASSINFO("DefaultProperty", "content") public: - QFxContentWrapper(QFxItem *parent=0); + QmlExpressionPrivate(QmlExpression *); + QmlExpressionPrivate(QmlExpression *, const QString &expr); + QmlExpressionPrivate(QmlExpression *, void *expr, QmlRefCount *rc); + ~QmlExpressionPrivate(); - QList<QFxItem *> *content(); + QmlExpression *q; + QmlContext *ctxt; + QString expression; + QmlBasicScript sse; + void *sseData; + QmlExpressionBindProxy *proxy; + QObject *me; + bool trackChange; -private: - void create(); - QFxItem *findContent(QList<QGraphicsItem *> &nodes); + QUrl fileName; + int line; + + quint32 id; + + void addLog(const QmlExpressionLog &); + QList<QmlExpressionLog> *log; -protected: - void componentComplete(); - QFxContentWrapper(QFxContentWrapperPrivate &dd, QFxItem *parent); + QVariant evalSSE(QmlBasicScript::CacheState &cacheState); + QVariant evalQtScript(); +}; + +class QmlExpressionBindProxy : public QObject +{ +Q_OBJECT +public: + QmlExpressionBindProxy(QmlExpression *be) + :e(be) { } private: - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxContentWrapper) + QmlExpression *e; + +private Q_SLOTS: + void changed() { e->valueChanged(); } }; -QML_DECLARE_TYPE(QFxContentWrapper) -class Q_DECLARATIVE_EXPORT QFxContent : public QFxItem +class QmlExpressionLog { - Q_OBJECT public: - QFxContent(QFxItem *parent=0) : QFxItem(parent) {} + QmlExpressionLog(); + QmlExpressionLog(const QmlExpressionLog &); + ~QmlExpressionLog(); + + QmlExpressionLog &operator=(const QmlExpressionLog &); + + void setTime(quint32); + quint32 time() const; + + QString expression() const; + void setExpression(const QString &); + + QStringList warnings() const; + void addWarning(const QString &); + + QVariant result() const; + void setResult(const QVariant &); + +private: + quint32 m_time; + QString m_expression; + QVariant m_result; + QStringList m_warnings; }; -QML_DECLARE_TYPE(QFxContent) QT_END_NAMESPACE -QT_END_HEADER - -#endif // QFXCONTENTWRAPPER_H +#endif // QMLEXPRESSION_P_H diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp index a618fe7..1647a12 100644 --- a/src/declarative/qml/qmlinstruction.cpp +++ b/src/declarative/qml/qmlinstruction.cpp @@ -44,6 +44,7 @@ #include <QDebug> QT_BEGIN_NAMESPACE + void QmlCompiledComponent::dump(QmlInstruction *instr, int idx) { QByteArray lineNumber = QByteArray::number(instr->line); diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index e3b0dfe..40f9a32 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -42,10 +42,21 @@ #ifndef QMLINSTRUCTION_P_H #define QMLINSTRUCTION_P_H -#include <QtDeclarative/qfxglobal.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 <QtDeclarative/qfxglobal.h> QT_BEGIN_NAMESPACE + class QmlCompiledComponent; class Q_DECLARATIVE_EXPORT QmlInstruction { @@ -170,6 +181,7 @@ public: struct { int data; int slotData; + int aliasData; } storeMeta; struct { int value; @@ -283,6 +295,6 @@ public: void dump(QmlCompiledComponent *); }; -#endif // QMLINSTRUCTION_P_H - QT_END_NAMESPACE + +#endif // QMLINSTRUCTION_P_H diff --git a/src/declarative/qml/qmllist.h b/src/declarative/qml/qmllist.h index cc13924..80c3138 100644 --- a/src/declarative/qml/qmllist.h +++ b/src/declarative/qml/qmllist.h @@ -119,7 +119,6 @@ class Qml_ProxyList_ ##ListName : public QmlList<ListType> \ friend class Qml_ProxyList_ ##ListName ; \ Qml_ProxyList_##ListName ListName; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 52036c2..e158adf 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -42,7 +42,7 @@ #include "qmlmetaproperty.h" #include "qmlmetaproperty_p.h" #include <qml.h> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <QStringList> #include <qmlbindablevalue.h> #include <qmlcontext.h> @@ -50,6 +50,7 @@ #include <math.h> #include <QtCore/qdebug.h> +Q_DECLARE_METATYPE(QList<QObject *>); QT_BEGIN_NAMESPACE @@ -242,15 +243,6 @@ void QmlMetaProperty::initProperty(QObject *obj, const QString &name) } if (!d->name.isEmpty()) d->type = Property; - - if (d->type == Invalid) { - int sig = findSignal(obj, name.toLatin1()); - if (sig != -1) { - d->signal = obj->metaObject()->method(sig); - d->type = Signal; - d->coreIdx = sig; - } - } } /*! @@ -283,7 +275,6 @@ QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other) \value Invalid The property is invalid. \value Property The property is a regular Qt property. \value SignalProperty The property is a signal property. - \value Signal The property is a signal. \value Default The property is the default property. \value Attached The property is an attached property. */ @@ -519,7 +510,7 @@ QMetaProperty QmlMetaProperty::property() const Returns the binding associated with this property, or 0 if no binding exists. */ -QmlBindableValue *QmlMetaProperty::binding() +QmlBindableValue *QmlMetaProperty::binding() const { if (!isProperty() || type() & Attached) return 0; @@ -537,24 +528,49 @@ QmlBindableValue *QmlMetaProperty::binding() return 0; } -/*! \internal */ -int QmlMetaProperty::findSignal(const QObject *obj, const char *name) +/*! + Set the binding associated with this property to \a binding. Returns + the existing binding (if any), otherwise 0. + + \a binding will be enabled, and the returned binding (if any) will be + disabled. +*/ +QmlBindableValue *QmlMetaProperty::setBinding(QmlBindableValue *binding) const { - const QMetaObject *mo = obj->metaObject(); - int methods = mo->methodCount(); - for (int ii = 0; ii < methods; ++ii) { - QMetaMethod method = mo->method(ii); - if (method.methodType() != QMetaMethod::Signal) - continue; + if (!isProperty() || type() & Attached) + return 0; - QByteArray methodName = method.signature(); - int idx = methodName.indexOf('('); - methodName = methodName.left(idx); + const QObjectList &children = object()->children(); + for (QObjectList::ConstIterator iter = children.begin(); + iter != children.end(); ++iter) { + QObject *child = *iter; + if (child->metaObject() == &QmlBindableValue::staticMetaObject) { + QmlBindableValue *v = static_cast<QmlBindableValue *>(child); + if (v->property() == *this && v->enabled()) { + + v->setEnabled(false); + + if (binding) { + binding->setParent(object()); + binding->setTarget(*this); + binding->setEnabled(true); + binding->forceUpdate(); + } + + return v; + + } + } + } - if (methodName == name) - return ii; + if (binding) { + binding->setParent(object()); + binding->setTarget(*this); + binding->setEnabled(true); + binding->forceUpdate(); } - return -1; + + return 0; } void QmlMetaPropertyPrivate::findSignalInt(QObject *obj, const QString &name) @@ -562,7 +578,7 @@ void QmlMetaPropertyPrivate::findSignalInt(QObject *obj, const QString &name) const QMetaObject *mo = obj->metaObject(); int methods = mo->methodCount(); - for (int ii = 0; ii < methods; ++ii) { + for (int ii = methods - 1; ii >= 0; --ii) { QMetaMethod method = mo->method(ii); QString methodName = QLatin1String(method.signature()); int idx = methodName.indexOf(QLatin1Char('(')); @@ -607,8 +623,6 @@ QVariant QmlMetaProperty::read() const return QVariant(); } -Q_DECLARE_METATYPE(QList<QObject *>); - void QmlMetaPropertyPrivate::writeSignalProperty(const QVariant &value) { QString expr = value.toString(); @@ -868,7 +882,8 @@ bool QmlMetaProperty::hasChangedNotifier() const */ bool QmlMetaProperty::needsChangedNotifier() const { - return type() & Property && !(type() & Attached); + return type() & Property && !(type() & Attached) && + !property().isConstant(); } /*! @@ -914,17 +929,6 @@ bool QmlMetaProperty::connectNotifier(QObject *dest, const char *slot) const } } -/*! \internal */ -void QmlMetaProperty::emitSignal() -{ - if (type() & Signal) { - if (d->signal.parameterTypes().isEmpty()) - d->object->metaObject()->activate(d->object, d->coreIdx, 0); - else - qWarning() << "QmlMetaProperty: Cannot emit signal with parameters"; - } -} - /*! Return the Qt metaobject index of the property. */ @@ -975,7 +979,7 @@ void QmlMetaProperty::restore(quint32 id, QObject *obj) d->name = QLatin1String(p.name()); d->propType = p.propertyType; d->coreIdx = id; - } else if (d->type & SignalProperty || d->type & Signal) { + } else if (d->type & SignalProperty) { d->signal = obj->metaObject()->method(id); d->coreIdx = id; } @@ -990,4 +994,34 @@ QMetaMethod QmlMetaProperty::method() const return d->signal; } +/*! + \internal + + Creates a QmlMetaProperty for the property \a name of \a obj. Unlike + the QmlMetaProperty(QObject*, QString) constructor, this static function + will correctly handle dot properties. +*/ +QmlMetaProperty QmlMetaProperty::createProperty(QObject *obj, const QString &name) +{ + QStringList path = name.split(QLatin1Char('.')); + + QObject *object = obj; + + for (int jj = 0; jj < path.count() - 1; ++jj) { + const QString &pathName = path.at(jj); + QmlMetaProperty prop(object, pathName); + QObject *objVal = QmlMetaType::toQObject(prop.read()); + if (!objVal) + return QmlMetaProperty(); + object = objVal; + } + + const QString &propName = path.last(); + QmlMetaProperty prop(object, propName); + if (!prop.isValid()) + return QmlMetaProperty(); + else + return prop; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index 9daef59..688c4fd 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -86,7 +86,6 @@ public: QVariant read() const; void write(const QVariant &) const; - void emitSignal(); bool hasChangedNotifier() const; bool needsChangedNotifier() const; @@ -101,7 +100,6 @@ public: enum Type { Invalid = 0x00, Property = 0x01, SignalProperty = 0x02, - Signal = 0x04, Default = 0x08, Attached = 0x10 }; @@ -123,8 +121,10 @@ public: QMetaProperty property() const; - QmlBindableValue *binding(); - static int findSignal(const QObject *, const char *); + QmlBindableValue *binding() const; + QmlBindableValue *setBinding(QmlBindableValue *) const; + + static QmlMetaProperty createProperty(QObject *, const QString &); int coreIndex() const; private: diff --git a/src/declarative/qml/qmlmetaproperty_p.h b/src/declarative/qml/qmlmetaproperty_p.h index 738bfec..69fd5c3 100644 --- a/src/declarative/qml/qmlmetaproperty_p.h +++ b/src/declarative/qml/qmlmetaproperty_p.h @@ -42,8 +42,21 @@ #ifndef QMLMETAPROPERTY_P_H #define QMLMETAPROPERTY_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 "qmlmetaproperty.h" +QT_BEGIN_NAMESPACE + class QmlContext; class QmlMetaPropertyPrivate { @@ -78,5 +91,6 @@ public: void writeValueProperty(const QVariant &); }; -#endif // QMLMETAPROPERTY_P_H +QT_END_NAMESPACE +#endif // QMLMETAPROPERTY_P_H diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 8ce8571..b15f711 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -59,7 +59,6 @@ #include <QtCore/qcryptographichash.h> #include <private/qmlcustomparser_p.h> -QT_BEGIN_NAMESPACE #ifdef QT_BOOTSTRAPPED # ifndef QT_NO_GEOM_VARIANT # define QT_NO_GEOM_VARIANT @@ -78,6 +77,8 @@ QT_BEGIN_NAMESPACE #endif #define NS(x) QT_PREPEND_NAMESPACE(x) +QT_BEGIN_NAMESPACE + struct QmlMetaTypeData { QList<QmlType *> types; diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index 5ad4a6e..8daab6a 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -48,7 +48,7 @@ #include <QRectF> #include <private/qmlvme_p.h> #include <qmlbindablevalue.h> -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <qml.h> #include "private/qmlcomponent_p.h" #include <qmlcomponent.h> @@ -113,7 +113,8 @@ QmlParser::Object::DynamicProperty::DynamicProperty(const DynamicProperty &o) : isDefaultProperty(o.isDefaultProperty), type(o.type), name(o.name), - defaultValue(o.defaultValue) + defaultValue(o.defaultValue), + range(o.range) { } @@ -122,7 +123,8 @@ QmlParser::Object::DynamicSignal::DynamicSignal() } QmlParser::Object::DynamicSignal::DynamicSignal(const DynamicSignal &o) -: name(o.name) +: name(o.name), parameterTypes(o.parameterTypes), + parameterNames(o.parameterNames) { } @@ -131,7 +133,7 @@ QmlParser::Object::DynamicSlot::DynamicSlot() } QmlParser::Object::DynamicSlot::DynamicSlot(const DynamicSlot &o) -: name(o.name), body(o.body) +: name(o.name), body(o.body), parameterNames(o.parameterNames) { } diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index a38ce69..7550870 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -42,6 +42,17 @@ #ifndef QMLPARSER_P_H #define QMLPARSER_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 <QtCore/QByteArray> #include <QtCore/QList> #include <QtCore/qstring.h> @@ -102,6 +113,8 @@ namespace QmlParser // QmlCompiledData::types array, or -1 if the object is a fetched // object. int type; + // The url of this object if it is an external type. Used by the DOM + QUrl url; // The name of this type QByteArray typeName; // The id assigned to the object (if any). @@ -131,18 +144,21 @@ namespace QmlParser DynamicProperty(); DynamicProperty(const DynamicProperty &); - enum Type { Variant, Int, Bool, Real, String, Url, Color, Date }; + enum Type { Variant, Int, Bool, Real, String, Url, Color, Date, Alias }; bool isDefaultProperty; Type type; QByteArray name; QmlParser::Property *defaultValue; + LocationRange range; }; struct DynamicSignal { DynamicSignal(); DynamicSignal(const DynamicSignal &); QByteArray name; + QList<QByteArray> parameterTypes; + QList<QByteArray> parameterNames; }; struct DynamicSlot { DynamicSlot(); @@ -150,6 +166,7 @@ namespace QmlParser QByteArray name; QString body; + QList<QByteArray> parameterNames; }; // The list of dynamic properties @@ -282,10 +299,11 @@ namespace QmlParser void dump(int = 0) const; }; } -Q_DECLARE_METATYPE(QmlParser::Variant) QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlParser::Variant) + QT_END_HEADER #endif // QMLPARSER_P_H diff --git a/src/declarative/qml/qmlparserstatus.h b/src/declarative/qml/qmlparserstatus.h index 7c2e141..4db6d8c 100644 --- a/src/declarative/qml/qmlparserstatus.h +++ b/src/declarative/qml/qmlparserstatus.h @@ -68,7 +68,6 @@ private: }; Q_DECLARE_INTERFACE(QmlParserStatus, "com.trolltech.qml.QmlParserStatus") - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index ed1304a..3d5fa61 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -394,10 +394,8 @@ int QmlPrivate::list_interface_op(QmlPrivate::ListOp op, int val, return 0; } - -#endif // QMLPRIVATE_H - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QMLPRIVATE_H diff --git a/src/declarative/qml/qmlpropertyvaluesource.cpp b/src/declarative/qml/qmlpropertyvaluesource.cpp index 18092c8..c6ff596 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.cpp +++ b/src/declarative/qml/qmlpropertyvaluesource.cpp @@ -42,8 +42,8 @@ #include "qmlpropertyvaluesource.h" #include "qml.h" - QT_BEGIN_NAMESPACE + /*! \class QmlPropertyValueSource \brief The QmlPropertyValueSource class is inherited by property value sources such as animations and bindings. diff --git a/src/declarative/qml/qmlpropertyvaluesource.h b/src/declarative/qml/qmlpropertyvaluesource.h index 9cef150..4e5f1c5 100644 --- a/src/declarative/qml/qmlpropertyvaluesource.h +++ b/src/declarative/qml/qmlpropertyvaluesource.h @@ -46,12 +46,12 @@ #include <QtDeclarative/qml.h> #include <QtCore/QObject> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QObjectPrivate; class QmlMetaProperty; class Q_DECLARATIVE_EXPORT QmlPropertyValueSource : public QObject @@ -69,11 +69,11 @@ protected: private: Q_DISABLE_COPY(QmlPropertyValueSource) }; -QML_DECLARE_TYPE(QmlPropertyValueSource) - -#endif // QMLPROPERTYVALUESOURCE_H - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlPropertyValueSource) + QT_END_HEADER + +#endif // QMLPROPERTYVALUESOURCE_H diff --git a/src/declarative/qml/qmlproxymetaobject.cpp b/src/declarative/qml/qmlproxymetaobject.cpp index 06d8a50..0baea31 100644 --- a/src/declarative/qml/qmlproxymetaobject.cpp +++ b/src/declarative/qml/qmlproxymetaobject.cpp @@ -41,8 +41,10 @@ #include "qmlproxymetaobject_p.h" +#include <QDebug> QT_BEGIN_NAMESPACE + QmlProxyMetaObject::QmlProxyMetaObject(QObject *obj, QList<ProxyData> *mList) : metaObjects(mList), proxies(0), parent(0), object(obj) { @@ -78,7 +80,6 @@ QmlProxyMetaObject::~QmlProxyMetaObject() proxies = 0; } -#include <QDebug> int QmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) { if ((c == QMetaObject::ReadProperty || diff --git a/src/declarative/qml/qmlproxymetaobject_p.h b/src/declarative/qml/qmlproxymetaobject_p.h index c0ce36e..736bd91 100644 --- a/src/declarative/qml/qmlproxymetaobject_p.h +++ b/src/declarative/qml/qmlproxymetaobject_p.h @@ -42,6 +42,17 @@ #ifndef QMLPROXYMETAOBJECT_P_H #define QMLPROXYMETAOBJECT_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 <QtCore/QMetaObject> #include <QtCore/QObject> #include <private/qmetaobjectbuilder_p.h> @@ -53,6 +64,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + class QmlProxyMetaObject : public QAbstractDynamicMetaObject { public: diff --git a/src/declarative/qml/qmlrefcount.cpp b/src/declarative/qml/qmlrefcount.cpp index 8f71f1b..6c409e1 100644 --- a/src/declarative/qml/qmlrefcount.cpp +++ b/src/declarative/qml/qmlrefcount.cpp @@ -41,6 +41,8 @@ #include "qmlrefcount_p.h" +QT_BEGIN_NAMESPACE + QmlRefCount::QmlRefCount() : refCount(1) { @@ -64,3 +66,5 @@ void QmlRefCount::release() delete this; } +QT_END_NAMESPACE + diff --git a/src/declarative/qml/qmlrefcount_p.h b/src/declarative/qml/qmlrefcount_p.h index 1355c86..a87d596 100644 --- a/src/declarative/qml/qmlrefcount_p.h +++ b/src/declarative/qml/qmlrefcount_p.h @@ -42,6 +42,17 @@ #ifndef QMLREFCOUNT_P_H #define QMLREFCOUNT_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 <QtCore/qglobal.h> QT_BEGIN_HEADER diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index fb7492d..d1ad540 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -55,7 +55,7 @@ #include <QCoreApplication> #include <QtDebug> -#include <qfxperf.h> +#include <private/qfxperf_p.h> QT_BEGIN_NAMESPACE @@ -178,8 +178,6 @@ protected: virtual bool visit(AST::UiArrayBinding *node); virtual bool visit(AST::UiSourceElement *node); - virtual bool visit(AST::ExpressionStatement *node); - void accept(AST::Node *node); QString asString(AST::UiQualifiedId *node) const; @@ -464,15 +462,26 @@ bool ProcessAST::visit(AST::UiProgram *node) // UiImport: T_IMPORT T_STRING_LITERAL ; bool ProcessAST::visit(AST::UiImport *node) { - QString fileName = node->fileName->asString(); - _parser->addNamespacePath(fileName); + QString uri; + QmlScriptParser::Import import; + + if (node->fileName) { + import.type = QmlScriptParser::Import::File; + uri = node->fileName->asString(); + _parser->addNamespacePath(uri); + } else { + import.type = QmlScriptParser::Import::Library; + uri = asString(node->importUri); + } AST::SourceLocation startLoc = node->importToken; AST::SourceLocation endLoc = node->semicolonToken; - QmlScriptParser::Import import; + if (node->importId) + import.as = node->importId->asString(); + import.location = location(startLoc, endLoc); - import.uri = fileName; + import.uri = uri; _parser->_imports << import; @@ -481,37 +490,67 @@ bool ProcessAST::visit(AST::UiImport *node) bool ProcessAST::visit(AST::UiPublicMember *node) { + const struct TypeNameToType { + const char *name; + Object::DynamicProperty::Type type; + const char *qtName; + } propTypeNameToTypes[] = { + { "int", Object::DynamicProperty::Int, "int" }, + { "bool", Object::DynamicProperty::Bool, "bool" }, + { "double", Object::DynamicProperty::Real, "double" }, + { "real", Object::DynamicProperty::Real, "qreal" }, + { "string", Object::DynamicProperty::String, "QString" }, + { "url", Object::DynamicProperty::Url, "QUrl" }, + { "color", Object::DynamicProperty::Color, "QColor" }, + { "date", Object::DynamicProperty::Date, "QDate" }, + { "var", Object::DynamicProperty::Variant, "QVariant" }, + { "variant", Object::DynamicProperty::Variant, "QVariant" } + }; + const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) / + sizeof(propTypeNameToTypes[0]); + if(node->type == AST::UiPublicMember::Signal) { const QString name = node->name->asString(); Object::DynamicSignal signal; signal.name = name.toUtf8(); + AST::UiParameterList *p = node->parameters; + while (p) { + const QString memberType = p->type->asString(); + const char *qtType = 0; + for(int ii = 0; !qtType && ii < propTypeNameToTypesCount; ++ii) { + if(QLatin1String(propTypeNameToTypes[ii].name) == memberType) + qtType = propTypeNameToTypes[ii].qtName; + } + + if (!qtType) { + QmlError error; + error.setDescription(QCoreApplication::translate("QmlParser","Expected parameter type")); + error.setLine(node->typeToken.startLine); + error.setColumn(node->typeToken.startColumn); + _parser->_errors << error; + return false; + } + + signal.parameterTypes << qtType; + signal.parameterNames << p->name->asString().toUtf8(); + p = p->finish(); + } + _stateStack.top().object->dynamicSignals << signal; } else { const QString memberType = node->memberType->asString(); const QString name = node->name->asString(); - const struct TypeNameToType { - const char *name; - Object::DynamicProperty::Type type; - } propTypeNameToTypes[] = { - { "int", Object::DynamicProperty::Int }, - { "bool", Object::DynamicProperty::Bool }, - { "double", Object::DynamicProperty::Real }, - { "real", Object::DynamicProperty::Real }, - { "string", Object::DynamicProperty::String }, - { "url", Object::DynamicProperty::Url }, - { "color", Object::DynamicProperty::Color }, - { "date", Object::DynamicProperty::Date }, - { "var", Object::DynamicProperty::Variant }, - { "variant", Object::DynamicProperty::Variant } - }; - const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) / - sizeof(propTypeNameToTypes[0]); - bool typeFound = false; Object::DynamicProperty::Type type; + + if (memberType == QLatin1String("alias")) { + type = Object::DynamicProperty::Alias; + typeFound = true; + } + for(int ii = 0; !typeFound && ii < propTypeNameToTypesCount; ++ii) { if(QLatin1String(propTypeNameToTypes[ii].name) == memberType) { type = propTypeNameToTypes[ii].type; @@ -532,6 +571,8 @@ bool ProcessAST::visit(AST::UiPublicMember *node) property.isDefaultProperty = node->isDefaultMember; property.type = type; property.name = name.toUtf8(); + property.range.offset = node->firstSourceLocation().offset; + property.range.length = node->semicolonToken.end() - property.range.offset; if (node->expression) { // default value property.defaultValue = new Property; @@ -643,14 +684,6 @@ bool ProcessAST::visit(AST::UiScriptBinding *node) return true; } -bool ProcessAST::visit(AST::ExpressionStatement *node) -{ - if (!node->semicolonToken.isValid()) - _parser->addAutomaticSemicolonOffset(node->semicolonToken.offset); - - return true; -} - static QList<int> collectCommas(AST::UiArrayMemberList *members) { QList<int> commas; @@ -701,20 +734,19 @@ bool ProcessAST::visit(AST::UiSourceElement *node) if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) { - if(funDecl->formals) { - QmlError error; - error.setDescription(QCoreApplication::translate("QmlParser","Slot declarations must be parameterless")); - error.setLine(funDecl->lparenToken.startLine); - error.setColumn(funDecl->lparenToken.startColumn); - _parser->_errors << error; - return false; + Object::DynamicSlot slot; + + AST::FormalParameterList *f = funDecl->formals; + while (f) { + slot.parameterNames << f->name->asString().toUtf8(); + f = f->finish(); } QString body = textAt(funDecl->lbraceToken, funDecl->rbraceToken); - Object::DynamicSlot slot; slot.name = funDecl->name->asString().toUtf8(); slot.body = body; obj->dynamicSlots << slot; + } else { QmlError error; error.setDescription(QCoreApplication::translate("QmlParser","QmlJS declaration outside Script element")); @@ -854,7 +886,6 @@ void QmlScriptParser::clear() _nameSpacePaths.clear(); _typeNames.clear(); _errors.clear(); - _automaticSemicolonOffsets.clear(); if (data) { delete data; @@ -886,5 +917,4 @@ void QmlScriptParser::addNamespacePath(const QString &path) _nameSpacePaths.insertMulti(QString(), path); } - QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index b057e2b..5e30914 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -41,13 +41,24 @@ #ifndef QMLSCRIPTPARSER_P_H #define QMLSCRIPTPARSER_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 <QtCore/QList> #include <QtCore/QUrl> #include <QtDeclarative/qmlerror.h> #include "qmlparser_p.h" - QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -61,9 +72,13 @@ public: class Import { public: - Import() {} + Import() : type(Library) {} + + enum Type { Library, File }; + Type type; QString uri; + QString as; QmlParser::LocationSpan location; }; @@ -82,9 +97,6 @@ public: QList<QmlError> errors() const; - QList<int> automaticSemicolonOffsets() const { return _automaticSemicolonOffsets; } - void addAutomaticSemicolonOffset(int offset) { _automaticSemicolonOffsets.append(offset); } - // ### private: int findOrCreateTypeId(const QString &name); void setTree(QmlParser::Object *tree); @@ -103,10 +115,10 @@ public: QStringList _typeNames; QString _scriptFile; QmlScriptParserJsASTData *data; - QList<int> _automaticSemicolonOffsets; }; QT_END_NAMESPACE + QT_END_HEADER #endif // QMLSCRIPTPARSER_P_H diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h index ed1f959..52426a7 100644 --- a/src/declarative/qml/qmlstringconverters_p.h +++ b/src/declarative/qml/qmlstringconverters_p.h @@ -42,6 +42,17 @@ #ifndef QMLSTRINGCONVERTERS_P_H #define QMLSTRINGCONVERTERS_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 <QtCore/qglobal.h> class QColor; class QPointF; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index a3ee4e5..a11caeb 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -40,14 +40,13 @@ ****************************************************************************/ #include "qmlvme_p.h" -#include <qfxperf.h> +#include <private/qfxperf_p.h> #include <private/qmlboundsignal_p.h> #include <private/qmlstringconverters_p.h> #include "private/qmetaobjectbuilder_p.h" #include "private/qmldeclarativedata_p.h" #include <qml.h> #include <private/qmlcustomparser_p.h> -#include <qperformancelog.h> #include <QStack> #include <QWidget> #include <private/qmlcompiledcomponent_p.h> @@ -240,7 +239,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp case QmlInstruction::StoreMetaObject: { QObject *target = stack.top(); - new QmlVMEMetaObject(target, synthesizedMetaObjects.at(instr.storeMeta.data), &comp->primitives, instr.storeMeta.slotData, comp); + new QmlVMEMetaObject(target, synthesizedMetaObjects.at(instr.storeMeta.data), &comp->primitives, instr.storeMeta.slotData, (const QmlVMEMetaData *)datas.at(instr.storeMeta.aliasData).constData(), comp); } break; @@ -564,7 +563,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp QmlMetaProperty mp(target, instr.assignBinding.property, (QmlMetaProperty::PropertyCategory)instr.assignBinding.category); - QmlBindableValue *bind = new QmlBindableValue((void *)datas.at(instr.assignBinding.value).constData(), comp, context, 0); + QmlBindableValue *bind = new QmlBindableValue((void *)datas.at(instr.assignBinding.value).constData(), comp, context, QmlContext::activeContext(), 0); bindValues.append(bind); QmlBindableValuePrivate *p = static_cast<QmlBindableValuePrivate *>(QObjectPrivate::get(bind)); @@ -584,7 +583,7 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledComp QmlMetaProperty mp(target, instr.assignBinding.property, (QmlMetaProperty::PropertyCategory)instr.assignBinding.category); - QmlBindableValue *bind = new QmlBindableValue(primitives.at(instr.assignBinding.value), context, false); + QmlBindableValue *bind = new QmlBindableValue(primitives.at(instr.assignBinding.value), context, QmlContext::activeContext()); bindValues.append(bind); QmlBindableValuePrivate *p = static_cast<QmlBindableValuePrivate *>(QObjectPrivate::get(bind)); diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h index 149c82c..2da7bb4 100644 --- a/src/declarative/qml/qmlvme_p.h +++ b/src/declarative/qml/qmlvme_p.h @@ -42,11 +42,23 @@ #ifndef QMLVME_P_H #define QMLVME_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 <QtCore/QString> #include <QtCore/QStack> #include <QtDeclarative/qmlerror.h> QT_BEGIN_NAMESPACE + class QObject; class QmlInstruction; class QmlCompiledComponent; @@ -70,4 +82,5 @@ private: }; QT_END_NAMESPACE + #endif // QMLVME_P_H diff --git a/src/declarative/qml/qmlvmemetaobject.cpp b/src/declarative/qml/qmlvmemetaobject.cpp index 4b2c64c..6d14689 100644 --- a/src/declarative/qml/qmlvmemetaobject.cpp +++ b/src/declarative/qml/qmlvmemetaobject.cpp @@ -47,15 +47,18 @@ #include <QtCore/qlist.h> #include <QtCore/qdebug.h> #include <qmlexpression.h> - +#include <private/qmlcontext_p.h> QT_BEGIN_NAMESPACE + QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj, const QMetaObject *other, QList<QString> *strData, int slotData, + const QmlVMEMetaData *meta, QmlRefCount *rc) -: object(obj), ref(rc), slotData(strData), slotDataIdx(slotData), parent(0) +: object(obj), ref(rc), metaData(meta), slotData(strData), + slotDataIdx(slotData), parent(0) { if (ref) ref->addref(); @@ -68,37 +71,18 @@ QmlVMEMetaObject::QmlVMEMetaObject(QObject *obj, parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject); op->metaObject = this; - baseProp = propertyOffset(); - baseSig = methodOffset(); - data = new QVariant[propertyCount() - baseProp]; - vTypes.resize(propertyCount() - baseProp); + propOffset = QAbstractDynamicMetaObject::propertyOffset(); + methodOffset = QAbstractDynamicMetaObject::methodOffset(); - // ### Optimize - for (int ii = baseProp; ii < propertyCount(); ++ii) { - QMetaProperty prop = property(ii); - if ((int)prop.type() != -1) { - data[ii - baseProp] = QVariant((QVariant::Type)prop.userType()); - } else { - vTypes.setBit(ii - baseProp, true); - } - } + data = new QVariant[metaData->propertyCount]; + aConnected.resize(metaData->aliasCount); - baseSlot = -1; - slotCount = 0; - for (int ii = baseSig; ii < methodCount(); ++ii) { - QMetaMethod m = method(ii); - if (m.methodType() == QMetaMethod::Slot) { - if (baseSlot == -1) - baseSlot = ii; - } else { - if (baseSlot != -1) { - slotCount = ii - baseSlot; - break; - } - } + // ### Optimize + for (int ii = 0; ii < metaData->propertyCount; ++ii) { + int t = (metaData->propertyData() + ii)->propertyType; + if (t != -1) + data[ii] = QVariant((QVariant::Type)t); } - if(baseSlot != -1 && !slotCount) - slotCount = methodCount() - baseSlot; } QmlVMEMetaObject::~QmlVMEMetaObject() @@ -110,78 +94,146 @@ QmlVMEMetaObject::~QmlVMEMetaObject() delete [] data; } -int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int id, void **a) +int QmlVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) { + int id = _id; if(c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) { - if (id >= baseProp) { - int propId = id - baseProp; - bool needActivate = false; - - if (vTypes.testBit(propId)) { - if (c == QMetaObject::ReadProperty) { - *reinterpret_cast<QVariant *>(a[0]) = data[propId]; - } else if (c == QMetaObject::WriteProperty) { - needActivate = - (data[propId] != *reinterpret_cast<QVariant *>(a[0])); - data[propId] = *reinterpret_cast<QVariant *>(a[0]); - } - } else { - if (c == QMetaObject::ReadProperty) { - switch(data[propId].type()) { - case QVariant::Int: - *reinterpret_cast<int *>(a[0]) = data[propId].toInt(); - break; - case QVariant::Bool: - *reinterpret_cast<bool *>(a[0]) = data[propId].toBool(); - break; - case QVariant::Double: - *reinterpret_cast<double *>(a[0]) = data[propId].toDouble(); - break; - case QVariant::String: - *reinterpret_cast<QString *>(a[0]) = data[propId].toString(); - break; - case QVariant::Url: - *reinterpret_cast<QUrl *>(a[0]) = data[propId].toUrl(); - break; - case QVariant::Color: - *reinterpret_cast<QColor *>(a[0]) = data[propId].value<QColor>(); - break; - case QVariant::Date: - *reinterpret_cast<QDate *>(a[0]) = data[propId].toDate(); - break; - default: - qFatal("Unknown type"); - break; + if (id >= propOffset) { + id -= propOffset; + + if (id < metaData->propertyCount) { + int t = (metaData->propertyData() + id)->propertyType; + bool needActivate = false; + + if (t == -1) { + + if (c == QMetaObject::ReadProperty) { + *reinterpret_cast<QVariant *>(a[0]) = data[id]; + } else if (c == QMetaObject::WriteProperty) { + needActivate = + (data[id] != *reinterpret_cast<QVariant *>(a[0])); + data[id] = *reinterpret_cast<QVariant *>(a[0]); + } + + } else { + + if (c == QMetaObject::ReadProperty) { + switch(t) { + case QVariant::Int: + *reinterpret_cast<int *>(a[0]) = data[id].toInt(); + break; + case QVariant::Bool: + *reinterpret_cast<bool *>(a[0]) = data[id].toBool(); + break; + case QVariant::Double: + *reinterpret_cast<double *>(a[0]) = data[id].toDouble(); + break; + case QVariant::String: + *reinterpret_cast<QString *>(a[0]) = data[id].toString(); + break; + case QVariant::Url: + *reinterpret_cast<QUrl *>(a[0]) = data[id].toUrl(); + break; + case QVariant::Color: + *reinterpret_cast<QColor *>(a[0]) = data[id].value<QColor>(); + break; + case QVariant::Date: + *reinterpret_cast<QDate *>(a[0]) = data[id].toDate(); + break; + default: + break; + } + + } else if (c == QMetaObject::WriteProperty) { + + QVariant value = QVariant((QVariant::Type)data[id].type(), a[0]); + needActivate = (data[id] != value); + data[id] = value; } - } else if (c == QMetaObject::WriteProperty) { - QVariant value = QVariant((QVariant::Type)data[propId].type(), a[0]); - needActivate = (data[propId] != value); - data[propId] = value; } + + if (c == QMetaObject::WriteProperty && needActivate) { + activate(object, methodOffset + id, 0); + } + + return -1; } - if (c == QMetaObject::WriteProperty && needActivate) { - activate(object, baseSig + propId, 0); + id -= metaData->propertyCount; + + if (id < metaData->aliasCount) { + + QmlContext *ctxt = qmlContext(object); + + if (!ctxt) return -1; + QmlVMEMetaData::AliasData *d = metaData->aliasData() + id; + QmlContextPrivate *ctxtPriv = + (QmlContextPrivate *)QObjectPrivate::get(ctxt); + + QObject *target = + *(QObject **)ctxtPriv->propertyValues[d->contextIdx].data(); + if (!target) return -1; + + if (c == QMetaObject::ReadProperty && !aConnected.testBit(id)) { + int sigIdx = methodOffset + id + metaData->propertyCount; + QMetaObject::connect(ctxt, d->contextIdx + ctxtPriv->notifyIndex, object, sigIdx); + + QMetaProperty prop = + target->metaObject()->property(d->propertyIdx); + if (prop.hasNotifySignal()) + QMetaObject::connect(target, prop.notifySignalIndex(), + object, sigIdx); + aConnected.setBit(id); + } + return QMetaObject::metacall(target, c, d->propertyIdx, a); + } + return -1; + + } - return id; - } } else if(c == QMetaObject::InvokeMetaMethod) { - if(id >= baseSlot && id < (baseSlot + slotCount)) { - int idx = id - baseSlot + slotDataIdx; - QmlContext *ctxt = qmlContext(object); - QmlExpression expr(ctxt, slotData->at(idx), object); - expr.setTrackChange(false); - expr.value(); - return id; + + if (id >= methodOffset) { + + id -= methodOffset; + int plainSignals = metaData->signalCount + metaData->propertyCount + + metaData->aliasCount; + if (id < plainSignals) { + QMetaObject::activate(object, _id, a); + return -1; + } + + id -= plainSignals; + + if (id < metaData->methodCount) { + QString code = slotData->at(id + slotDataIdx); + QmlContext *ctxt = qmlContext(object); + + if (0 == (metaData->methodData() + id)->parameterCount) { + QmlExpression expr(ctxt, code, object); + expr.setTrackChange(false); + expr.value(); + } else { + QmlContext newCtxt(ctxt); + QMetaMethod m = method(_id); + QList<QByteArray> names = m.parameterNames(); + for (int ii = 0; ii < names.count(); ++ii) + newCtxt.setContextProperty(names.at(ii), *(QVariant *)a[ii + 1]); + QmlExpression expr(&newCtxt, code, object); + expr.setTrackChange(false); + expr.value(); + } + } + return -1; } } if (parent) - return parent->metaCall(c, id, a); + return parent->metaCall(c, _id, a); else - return object->qt_metacall(c, id, a); + return object->qt_metacall(c, _id, a); } QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlvmemetaobject_p.h b/src/declarative/qml/qmlvmemetaobject_p.h index 17140ef..6421c3f 100644 --- a/src/declarative/qml/qmlvmemetaobject_p.h +++ b/src/declarative/qml/qmlvmemetaobject_p.h @@ -42,17 +42,62 @@ #ifndef QMLVMEMETAOBJECT_P_H #define QMLVMEMETAOBJECT_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 <QtDeclarative/qml.h> #include <QtCore/QMetaObject> #include <QtCore/QBitArray> #include <private/qobject_p.h> QT_BEGIN_NAMESPACE + +struct QmlVMEMetaData +{ + short propertyCount; + short aliasCount; + short signalCount; + short methodCount; + + struct AliasData { + int contextIdx; + int propertyIdx; + }; + + struct PropertyData { + int propertyType; + }; + + struct MethodData { + int parameterCount; + }; + + PropertyData *propertyData() const { + return (PropertyData *)(((const char *)this) + sizeof(QmlVMEMetaData)); + } + + AliasData *aliasData() const { + return (AliasData *)(propertyData() + propertyCount); + } + + MethodData *methodData() const { + return (MethodData *)(aliasData() + propertyCount); + } +}; + class QmlRefCount; class QmlVMEMetaObject : public QAbstractDynamicMetaObject { public: - QmlVMEMetaObject(QObject *, const QMetaObject *, QList<QString> *, int slotData, QmlRefCount * = 0); + QmlVMEMetaObject(QObject *, const QMetaObject *, QList<QString> *, int slotData, const QmlVMEMetaData *data, QmlRefCount * = 0); ~QmlVMEMetaObject(); protected: @@ -61,16 +106,21 @@ protected: private: QObject *object; QmlRefCount *ref; - int baseProp; - int baseSig; - int baseSlot; - int slotCount; + + const QmlVMEMetaData *metaData; + int propOffset; + int methodOffset; + QVariant *data; - QBitArray vTypes; + QBitArray aConnected; + QList<QString> *slotData; int slotDataIdx; + QAbstractDynamicMetaObject *parent; + }; QT_END_NAMESPACE + #endif // QMLVMEMETAOBJECT_P_H diff --git a/src/declarative/qml/qpodvector_p.h b/src/declarative/qml/qpodvector_p.h index 55c04e7..101c62d 100644 --- a/src/declarative/qml/qpodvector_p.h +++ b/src/declarative/qml/qpodvector_p.h @@ -42,6 +42,17 @@ #ifndef QPODVECTOR_P_H #define QPODVECTOR_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 <QtCore/qglobal.h> QT_BEGIN_NAMESPACE @@ -119,6 +130,7 @@ private: int m_capacity; T *m_data; }; + QT_END_NAMESPACE #endif diff --git a/src/declarative/qml/rewriter/rewriter.cpp b/src/declarative/qml/rewriter/rewriter.cpp index 2ce927c..ed45f16 100644 --- a/src/declarative/qml/rewriter/rewriter.cpp +++ b/src/declarative/qml/rewriter/rewriter.cpp @@ -83,14 +83,19 @@ void Rewriter::moveTextBefore(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc, const AST::SourceLocation &loc) { - textWriter.move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset); + move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset); } void Rewriter::moveTextAfter(const AST::SourceLocation &firstLoc, const AST::SourceLocation &lastLoc, const AST::SourceLocation &loc) { - textWriter.move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset + loc.length); + move(firstLoc.offset, lastLoc.offset + lastLoc.length - firstLoc.offset, loc.offset + loc.length); +} + +void Rewriter::move(int pos, int length, int to) +{ + textWriter.move(pos, length, to); } QT_END_NAMESPACE diff --git a/src/declarative/qml/rewriter/rewriter_p.h b/src/declarative/qml/rewriter/rewriter_p.h index fcb9ca5..44f3cce 100644 --- a/src/declarative/qml/rewriter/rewriter_p.h +++ b/src/declarative/qml/rewriter/rewriter_p.h @@ -121,7 +121,8 @@ public: // // low-level offset based API // - void replace(int offset, int length, const QString &text); + virtual void replace(int offset, int length, const QString &text); + virtual void move(int pos, int length, int to); void insertText(int offset, const QString &text); void removeText(int offset, int length); diff --git a/src/declarative/timeline/qmltimelinevalueproxy.h b/src/declarative/timeline/qmltimelinevalueproxy.h deleted file mode 100644 index 9ecdba1..0000000 --- a/src/declarative/timeline/qmltimelinevalueproxy.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, 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. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QMLTIMELINEVALUEPROXY_H -#define QMLTIMELINEVALUEPROXY_H - -#include <QtDeclarative/qmltimeline.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -template<class T> -class QmlTimeLineValueProxy : public QmlTimeLineValue -{ -public: - QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) - : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0) - { - Q_ASSERT(_class); - } - - QmlTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.) - : QmlTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func) - { - Q_ASSERT(_class); - } - - virtual void setValue(qreal v) - { - QmlTimeLineValue::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 - -QT_END_HEADER - -#endif//QMLTIMELINEVALUEPROXY_H diff --git a/src/declarative/timeline/timeline.pri b/src/declarative/timeline/timeline.pri deleted file mode 100644 index a7b3cb9..0000000 --- a/src/declarative/timeline/timeline.pri +++ /dev/null @@ -1,7 +0,0 @@ -SOURCES += \ - timeline/qmltimeline.cpp \ - -HEADERS += \ - timeline/qmltimeline.h \ - timeline/qmltimelinevalueproxy.h \ - diff --git a/src/declarative/util/qfxglobal.h b/src/declarative/util/qfxglobal.h index 1f3d561f..9b4aee1 100644 --- a/src/declarative/util/qfxglobal.h +++ b/src/declarative/util/qfxglobal.h @@ -45,7 +45,6 @@ #include <QtCore/qglobal.h> #include <QtCore/QObject> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -88,8 +87,8 @@ inline void QFx_setParent_noEvent(QObject *object, QObject *parent) static_cast<QFx_DerivedObject *>(object)->setParent_noEvent(parent); } - QT_END_NAMESPACE QT_END_HEADER + #endif // QFXGLOBAL_H diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp index e4f0c53..db56b37 100644 --- a/src/declarative/util/qfxperf.cpp +++ b/src/declarative/util/qfxperf.cpp @@ -39,10 +39,10 @@ ** ****************************************************************************/ -#include "qfxperf.h" - +#include "private/qfxperf_p.h" QT_BEGIN_NAMESPACE + Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(QmlParsing, "Compilation: QML Parsing") Q_DEFINE_PERFORMANCE_METRIC(Compilation, " QML Compilation") @@ -64,4 +64,5 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(QFxText_setText, " QFxText::setText") Q_DEFINE_PERFORMANCE_METRIC(AddScript, "QmlScript::addScriptToEngine") } + QT_END_NAMESPACE diff --git a/src/declarative/util/qfxperf.h b/src/declarative/util/qfxperf_p.h index 9fcf1d6..a1e38b7 100644 --- a/src/declarative/util/qfxperf.h +++ b/src/declarative/util/qfxperf_p.h @@ -38,17 +38,28 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef _QFXPERF_H_ -#define _QFXPERF_H_ +#ifndef QFXPERF_H +#define QFXPERF_H -#include "qperformancelog.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/qperformancelog_p.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) + Q_DECLARE_PERFORMANCE_LOG(QFxPerf) { Q_DECLARE_PERFORMANCE_METRIC(QmlParsing) @@ -73,9 +84,8 @@ Q_DECLARE_PERFORMANCE_LOG(QFxPerf) { Q_DECLARE_PERFORMANCE_METRIC(AddScript) } -#endif // _QFXPERF_H_ - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QFXPERF_H diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index 43c10bb..e8b324c 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -54,16 +54,16 @@ #include "qmlbindablevalue.h" #include "qml.h" #include "qfxitem.h" -#include "qperformancelog.h" -#include "qfxperf.h" +#include "private/qperformancelog_p.h" +#include "private/qfxperf_p.h" #include "qfxview.h" #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcontext.h> #include <QtDeclarative/qmldebugger.h> - QT_BEGIN_NAMESPACE + DEFINE_BOOL_CONFIG_OPTION(qmlDebugger, QML_DEBUGGER); static QVariant stringToPixmap(const QString &str) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 7df249e..ff070c1 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -45,6 +45,7 @@ #include "qfile.h" #include "qmlpropertyvaluesource.h" #include "qml.h" +#include "qmlinfo.h" #include "qmlanimation_p.h" #include "qmlbehaviour.h" #include <QParallelAnimationGroup> @@ -57,12 +58,6 @@ #include <private/qmlstringconverters_p.h> #include <private/qvariantanimation_p.h> -/* TODO: - Check for any memory leaks - easing should be a QEasingCurve-type property - All other XXXs -*/ - QT_BEGIN_NAMESPACE QEasingCurve stringToCurve(const QString &curve) @@ -85,18 +80,22 @@ QEasingCurve stringToCurve(const QString &curve) QString prop_str = easeName.mid(idx + 1, easeName.length() - 1 - idx - 1); normalizedCurve = easeName.left(idx); + if (!normalizedCurve.startsWith(QLatin1String("ease"))) { + qWarning("QEasingCurve: Easing function '%s' must start with 'ease'", + curve.toLatin1().constData()); + } props = prop_str.split(QLatin1Char(',')); } - normalizedCurve = normalizedCurve.mid(4); - //XXX optimize? - int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type"); - QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index); + if (normalizedCurve.startsWith(QLatin1String("ease"))) + normalizedCurve = normalizedCurve.mid(4); + + static int index = QEasingCurve::staticMetaObject.indexOfEnumerator("Type"); + static QMetaEnum me = QEasingCurve::staticMetaObject.enumerator(index); int value = me.keyToValue(normalizedCurve.toLatin1().constData()); if (value < 0) { - //XXX print line number qWarning("QEasingCurve: Unknown easing curve '%s'", curve.toLatin1().constData()); value = 0; @@ -123,7 +122,6 @@ QEasingCurve stringToCurve(const QString &curve) return easingCurve; } - //XXX optimize if (propName == QLatin1String("amplitude")) { easingCurve.setAmplitude(propValue); } else if (propName == QLatin1String("period")) { @@ -179,7 +177,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj \code Rect { width: 100; height: 100 - x: NumericAnimation { + x: NumberAnimation { running: MyMouse.pressed from: 0; to: 100 } @@ -192,7 +190,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj or not the animation is running. \code - NumericAnimation { id: MyAnimation } + NumberAnimation { id: MyAnimation } Text { text: MyAnimation.running ? "Animation is running" : "Animation is not running" } \endcode @@ -219,6 +217,21 @@ void QmlAbstractAnimationPrivate::commence() } } +//### make static? +QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str) +{ + Q_Q(QmlAbstractAnimation); + QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str); + if (!prop.isValid()) { + qmlInfo(q) << "Cannot animate non-existant property" << str; + return QmlMetaProperty(); + } else if (!prop.isWritable()) { + qmlInfo(q) << "Cannot animate read-only property" << str; + return QmlMetaProperty(); + } + return prop; +} + void QmlAbstractAnimation::setRunning(bool r) { Q_D(QmlAbstractAnimation); @@ -255,6 +268,44 @@ void QmlAbstractAnimation::setRunning(bool r) 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 QmlAbstractAnimation::isPaused() const +{ + Q_D(const QmlAbstractAnimation); + return d->paused; +} + +void QmlAbstractAnimation::setPaused(bool p) +{ + Q_D(QmlAbstractAnimation); + if (d->paused == p) + return; + + if (d->group) { + qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes"); + return; + } + + d->paused = p; + if (d->paused) + qtAnimation()->pause(); + else + qtAnimation()->resume(); + + emit pausedChanged(d->running); +} + void QmlAbstractAnimation::classBegin() { Q_D(QmlAbstractAnimation); @@ -311,7 +362,7 @@ void QmlAbstractAnimation::setFinishPlaying(bool f) \code Rect { - rotation: NumericAnimation { running: true; repeat: true; from: 0 to: 360 } + rotation: NumberAnimation { running: true; repeat: true; from: 0 to: 360 } } \endcode */ @@ -333,6 +384,16 @@ void QmlAbstractAnimation::setRepeat(bool r) emit repeatChanged(r); } +int QmlAbstractAnimation::currentTime() +{ + return qtAnimation()->currentTime(); +} + +void QmlAbstractAnimation::setCurrentTime(int time) +{ + qtAnimation()->setCurrentTime(time); +} + QmlAnimationGroup *QmlAbstractAnimation::group() const { Q_D(const QmlAbstractAnimation); @@ -380,7 +441,7 @@ void QmlAbstractAnimation::setTarget(QObject *o) d->target = o; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = QmlMetaProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName); } else { d->userProperty.invalidate(); } @@ -409,7 +470,7 @@ void QmlAbstractAnimation::setProperty(const QString &n) d->propertyName = n; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = QmlMetaProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName); } else { d->userProperty.invalidate(); } @@ -430,6 +491,30 @@ void QmlAbstractAnimation::start() } /*! + \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 QmlAbstractAnimation::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 QmlAbstractAnimation::resume() +{ + setPaused(false); +} + +/*! \qmlmethod Animation::stop() \brief Stops the animation. @@ -440,7 +525,7 @@ void QmlAbstractAnimation::start() no further influence on property values. In this example animation \code Rect { - x: NumericAnimation { from: 0; to: 100; duration: 500 } + x: NumberAnimation { from: 0; to: 100; duration: 500 } } \endcode was stopped at time 250ms, the \c x property will have a value of 50. @@ -478,7 +563,7 @@ void QmlAbstractAnimation::restart() its end. In the following example, \code Rect { - x: NumericAnimation { from: 0; to: 100; duration: 500 } + x: NumberAnimation { from: 0; to: 100; duration: 500 } } \endcode calling \c stop() at time 250ms will result in the \c x property having @@ -534,9 +619,9 @@ void QmlAbstractAnimation::timelineComplete() A 500ms animation sequence, with a 100ms pause between two animations: \code SequentialAnimation { - NumericAnimation { ... duration: 200 } + NumberAnimation { ... duration: 200 } PauseAnimation { duration: 100 } - NumericAnimation { ... duration: 200 } + NumberAnimation { ... duration: 200 } } \endcode */ @@ -604,15 +689,6 @@ void QmlPauseAnimation::setDuration(int duration) emit durationChanged(duration); } -void QmlPauseAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlPauseAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; -} - QAbstractAnimation *QmlPauseAnimation::qtAnimation() { Q_D(QmlPauseAnimation); @@ -621,16 +697,16 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() /*! \qmlclass ColorAnimation QmlColorAnimation - \inherits Animation + \inherits PropertyAnimation \brief The ColorAnimation allows you to animate color changes. \code ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 } \endcode - The default property animated is \c color, but like other animations, - this can be changed by setting \c property. The \c color property will - still animate. XXX is this a bug? + When used in a transition, ColorAnimation will by default animate + all properties of type color that are changing. If a property or properties + are explicity set for the animation, then those will be used instead. */ /*! \internal @@ -644,56 +720,19 @@ QAbstractAnimation *QmlPauseAnimation::qtAnimation() */ QmlColorAnimation::QmlColorAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlColorAnimationPrivate), parent) +: QmlPropertyAnimation(parent) { - Q_D(QmlColorAnimation); + Q_D(QmlPropertyAnimation); d->init(); + d->interpolatorType = QMetaType::QColor; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + d->defaultToInterpolatorType = true; } QmlColorAnimation::~QmlColorAnimation() { } -void QmlColorAnimationPrivate::init() -{ - Q_Q(QmlColorAnimation); - ca = new QmlTimeLineValueAnimator(q); - ca->setStartValue(QVariant(0.0f)); - ca->setEndValue(QVariant(1.0f)); -} - -/*! - \qmlproperty int ColorAnimation::duration - This property holds the duration of the color transition, in milliseconds. - - The default value is 250. -*/ -/*! - \property QmlColorAnimation::duration - \brief the duration of the transition, in milliseconds. - - The default value is 250. -*/ -int QmlColorAnimation::duration() const -{ - Q_D(const QmlColorAnimation); - return d->ca->duration(); -} - -void QmlColorAnimation::setDuration(int duration) -{ - if (duration < 0) { - qWarning("QmlColorAnimation: Cannot set a duration of < 0"); - return; - } - - Q_D(QmlColorAnimation); - if (d->ca->duration() == duration) - return; - d->ca->setDuration(duration); - emit durationChanged(duration); -} - /*! \qmlproperty color ColorAnimation::from This property holds the starting color. @@ -704,18 +743,13 @@ void QmlColorAnimation::setDuration(int duration) */ QColor QmlColorAnimation::from() const { - Q_D(const QmlColorAnimation); - return d->fromValue; + Q_D(const QmlPropertyAnimation); + return d->from.value<QColor>(); } void QmlColorAnimation::setFrom(const QColor &f) { - Q_D(QmlColorAnimation); - if (d->fromIsDefined && f == d->fromValue) - return; - d->fromValue = f; - d->fromIsDefined = f.isValid(); - emit fromChanged(f); + QmlPropertyAnimation::setFrom(f); } /*! @@ -728,202 +762,15 @@ void QmlColorAnimation::setFrom(const QColor &f) */ QColor QmlColorAnimation::to() const { - Q_D(const QmlColorAnimation); - return d->toValue; + Q_D(const QmlPropertyAnimation); + return d->to.value<QColor>(); } void QmlColorAnimation::setTo(const QColor &t) { - Q_D(QmlColorAnimation); - if (d->toIsDefined && t == d->toValue) - return; - d->toValue = t; - d->toIsDefined = t.isValid(); - emit toChanged(t); -} - -/*! - \qmlproperty string ColorAnimation::easing - This property holds the easing curve used for the transition. - - Each channel of the color is eased using the same easing curve. - See NumericAnimation::easing for a full discussion of easing, - and a list of available curves. -*/ -QString QmlColorAnimation::easing() const -{ - Q_D(const QmlColorAnimation); - return d->easing; -} - -void QmlColorAnimation::setEasing(const QString &e) -{ - Q_D(QmlColorAnimation); - if (d->easing == e) - return; - - d->easing = e; - d->ca->setEasingCurve(stringToCurve(d->easing)); - emit easingChanged(e); -} - -/*! - \qmlproperty list<Item> ColorAnimation::filter - This property holds the items selected to be affected by this animation (all if not set). - \sa exclude -*/ -QList<QObject *> *QmlColorAnimation::filter() -{ - Q_D(QmlColorAnimation); - return &d->filter; -} - -/*! - \qmlproperty list<Item> ColorAnimation::exclude - This property holds the items not to be affected by this animation. - \sa filter -*/ -QList<QObject *> *QmlColorAnimation::exclude() -{ - Q_D(QmlColorAnimation); - return &d->exclude; -} - -void QmlColorAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlColorAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - d->fromSourced = false; - d->value.QmlTimeLineValue::setValue(0.); - d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); - d->ca->setFromSourcedValue(&d->fromSourced); + QmlPropertyAnimation::setTo(t); } -QAbstractAnimation *QmlColorAnimation::qtAnimation() -{ - Q_D(QmlColorAnimation); - return d->ca; -} - -void QmlColorAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction) -{ - Q_D(QmlColorAnimation); - Q_UNUSED(direction); - - struct NTransitionData : public QmlTimeLineValue - { - QmlStateActions actions; - void write(QmlMetaProperty &property, const QVariant &color) - { - if (property.propertyType() == QVariant::Color) { - property.write(color); - } - } - - void setValue(qreal v) - { - QmlTimeLineValue::setValue(v); - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QColor to(action.toValue.value<QColor>()); - - if (v == 1.) { - write(action.property, to); - } else { - if (action.fromValue.isNull()) { - action.fromValue = action.property.read(); - if (action.fromValue.isNull()) - action.fromValue = QVariant(QColor()); - } - - QColor from(action.fromValue.value<QColor>()); - - QVariant newColor = QmlColorAnimationPrivate::colorInterpolator(&from, &to, v); - write(action.property, newColor); - } - } - } - }; - - //XXX should we get rid of this? - QStringList props; - props << QLatin1String("color"); - if (!d->propertyName.isEmpty() && !props.contains(d->propertyName)) - props.append(d->propertyName); - - NTransitionData *data = new NTransitionData; - - QSet<QObject *> objs; - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QObject *obj = action.property.object(); - QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { - objs.insert(obj); - Action myAction = action; - - if (d->fromIsDefined) { - myAction.fromValue = QVariant(d->fromValue); - } else { - myAction.fromValue = QVariant(); - } - if (d->toIsDefined) - myAction.toValue = QVariant(d->toValue); - - modified << action.property; - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } - - if (d->toValue.isValid() && target() && !objs.contains(target())) { - QObject *obj = target(); - for (int jj = 0; jj < props.count(); ++jj) { - Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); - - if (d->fromIsDefined) - myAction.fromValue = QVariant(d->fromValue); - - myAction.toValue = QVariant(d->toValue); - myAction.bv = 0; - myAction.event = 0; - data->actions << myAction; - } - } - - if (data->actions.count()) - d->ca->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); - else - delete data; -} - -QVariantAnimation::Interpolator QmlColorAnimationPrivate::colorInterpolator = 0; - -void QmlColorAnimationPrivate::valueChanged(qreal v) -{ - if (!fromSourced) { - if (!fromIsDefined) { - fromValue = qvariant_cast<QColor>(property.read()); - } - fromSourced = true; - } - - if (property.propertyType() == QVariant::Color) { - QVariant newColor = colorInterpolator(&fromValue, &toValue, v); - property.write(newColor); - } -} QML_DEFINE_TYPE(QmlColorAnimation,ColorAnimation) /*! @@ -1187,10 +1034,14 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QObject *obj = action.property.object(); QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName))) && + (!target() || target() == obj || (!same && target() == sObj))) { objs.insert(obj); Action myAction = action; @@ -1207,7 +1058,9 @@ void QmlSetPropertyAction::transition(QmlStateActions &actions, QObject *obj = target(); for (int jj = 0; jj < props.count(); ++jj) { Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); + myAction.property = d->createProperty(obj, props.at(jj)); + if (!myAction.property.isValid()) + continue; myAction.toValue = d->value; data->actions << myAction; } @@ -1249,7 +1102,7 @@ void QmlParentChangeActionPrivate::init() void QmlParentChangeActionPrivate::doAction() { - //XXX property.write(value); + //### property.write(value); } void QmlParentChangeAction::prepare(QmlMetaProperty &p) @@ -1261,7 +1114,7 @@ void QmlParentChangeAction::prepare(QmlMetaProperty &p) else d->property = d->userProperty; - //XXX + //### } QAbstractAnimation *QmlParentChangeAction::qtAnimation() @@ -1333,391 +1186,82 @@ void QmlParentChangeAction::transition(QmlStateActions &actions, QML_DEFINE_TYPE(QmlParentChangeAction,ParentChangeAction) /*! - \qmlclass NumericAnimation QmlNumericAnimation - \inherits Animation - \brief The NumericAnimation allows you to animate changes in properties of type qreal. + \qmlclass NumberAnimation QmlNumberAnimation + \inherits PropertyAnimation + \brief The NumberAnimation allows you to animate changes in properties of type qreal. Animate a set of properties over 200ms, from their values in the start state to their values in the end state of the transition: \code - NumericAnimation { properties: "x,y,scale"; duration: 200 } + NumberAnimation { properties: "x,y,scale"; duration: 200 } \endcode */ /*! \internal - \class QmlNumericAnimation + \class QmlNumberAnimation \ingroup group_animation \ingroup group_states - \brief The QmlNumericAnimation class allows you to animate changes in properties of type qreal. + \brief The QmlNumberAnimation class allows you to animate changes in properties of type qreal. - A QmlNumericAnimation object can be instantiated in Qml using the tag - \l{xmlNumericAnimation} {<NumericAnimation>}. + A QmlNumberAnimation object can be instantiated in Qml using the tag + \l{xmlNumberAnimation} {<NumberAnimation>}. */ -QmlNumericAnimation::QmlNumericAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlNumericAnimationPrivate), parent) +QmlNumberAnimation::QmlNumberAnimation(QObject *parent) +: QmlPropertyAnimation(parent) { - Q_D(QmlNumericAnimation); + Q_D(QmlPropertyAnimation); d->init(); + d->interpolatorType = QMetaType::QReal; + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); } -QmlNumericAnimation::~QmlNumericAnimation() -{ -} - -void QmlNumericAnimationPrivate::init() -{ - Q_Q(QmlNumericAnimation); - na = new QmlTimeLineValueAnimator(q); - na->setStartValue(QVariant(0.0f)); - na->setEndValue(QVariant(1.0f)); -} - -/*! - \qmlproperty int NumericAnimation::duration - This property holds the duration of the transition, in milliseconds. - - The default value is 250. -*/ -/*! - \property QmlNumericAnimation::duration - \brief the duration of the transition, in milliseconds. - - The default value is 250. -*/ -int QmlNumericAnimation::duration() const -{ - Q_D(const QmlNumericAnimation); - return d->na->duration(); -} - -void QmlNumericAnimation::setDuration(int duration) +QmlNumberAnimation::~QmlNumberAnimation() { - if (duration < 0) { - qWarning("QmlNumericAnimation: Cannot set a duration of < 0"); - return; - } - - Q_D(QmlNumericAnimation); - if (d->na->duration() == duration) - return; - d->na->setDuration(duration); - emit durationChanged(duration); } /*! - \qmlproperty real NumericAnimation::from + \qmlproperty real NumberAnimation::from This property holds the starting value. If not set, then the value defined in the start state of the transition. */ /*! - \property QmlNumericAnimation::from + \property QmlNumberAnimation::from \brief the starting value. */ -qreal QmlNumericAnimation::from() const +qreal QmlNumberAnimation::from() const { - Q_D(const QmlNumericAnimation); - return d->from; + Q_D(const QmlPropertyAnimation); + return d->from.toDouble(); } -void QmlNumericAnimation::setFrom(qreal f) +void QmlNumberAnimation::setFrom(qreal f) { - Q_D(QmlNumericAnimation); - if (!d->from.isNull && f == d->from) - return; - d->from = f; - emit fromChanged(f); + QmlPropertyAnimation::setFrom(f); } /*! - \qmlproperty real NumericAnimation::to + \qmlproperty real NumberAnimation::to This property holds the ending value. If not set, then the value defined in the end state of the transition. */ /*! - \property QmlNumericAnimation::to + \property QmlNumberAnimation::to \brief the ending value. */ -qreal QmlNumericAnimation::to() const +qreal QmlNumberAnimation::to() const { - Q_D(const QmlNumericAnimation); - return d->to; + Q_D(const QmlPropertyAnimation); + return d->to.toDouble(); } -void QmlNumericAnimation::setTo(qreal t) +void QmlNumberAnimation::setTo(qreal t) { - Q_D(QmlNumericAnimation); - if (!d->to.isNull && t == d->to) - return; - d->to = t; - emit toChanged(t); + QmlPropertyAnimation::setTo(t); } -/*! - \qmlproperty string NumericAnimation::easing - \brief the easing curve used for the transition. - - Available values are: - - \list - \i \e easeNone - Easing equation function for a simple linear tweening, with no easing. - \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity. - \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity. - \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity. - \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity. - \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity. - \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity. - \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity. - \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity. - \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity. - \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity. - \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity. - \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity. - \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity. - \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity. - \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. - \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. - \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration. - \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. - \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity. - \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. - \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity. - \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity. - \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration. - \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration. - \endlist -*/ - -/*! - \property QmlNumericAnimation::easing - This property holds the easing curve to use. - - \sa QEasingCurve -*/ -QString QmlNumericAnimation::easing() const -{ - Q_D(const QmlNumericAnimation); - return d->easing; -} - -void QmlNumericAnimation::setEasing(const QString &e) -{ - Q_D(QmlNumericAnimation); - if (d->easing == e) - return; - - d->easing = e; - d->na->setEasingCurve(stringToCurve(d->easing)); - emit easingChanged(e); -} - -/*! - \qmlproperty string NumericAnimation::properties - This property holds the properties this animation should be applied to. - - This is a comma-separated list of properties that should use - this animation when they change. -*/ -/*! - \property QmlNumericAnimation::properties - \brief the properties this animation should be applied to. - - properties holds a comma-separated list of properties that should use - this animation when they change. -*/ -QString QmlNumericAnimation::properties() const -{ - Q_D(const QmlNumericAnimation); - return d->properties; -} - -void QmlNumericAnimation::setProperties(const QString &prop) -{ - Q_D(QmlNumericAnimation); - if (d->properties == prop) - return; - - d->properties = prop; - emit propertiesChanged(prop); -} - -/*! - \qmlproperty list<Item> NumericAnimation::filter - This property holds the items selected to be affected by this animation (all if not set). - \sa exclude -*/ -QList<QObject *> *QmlNumericAnimation::filter() -{ - Q_D(QmlNumericAnimation); - return &d->filter; -} - -/*! - \qmlproperty list<Item> NumericAnimation::exclude - This property holds the items not to be affected by this animation. - \sa filter -*/ -QList<QObject *> *QmlNumericAnimation::exclude() -{ - Q_D(QmlNumericAnimation); - return &d->exclude; -} - -void QmlNumericAnimationPrivate::valueChanged(qreal r) -{ - if (!fromSourced) { - if (from.isNull) { - fromValue = qvariant_cast<qreal>(property.read()); - } else { - fromValue = from; - } - fromSourced = true; - } - - if (r == 1.) { - property.write(to.value); - } else { - qreal val = fromValue + (to-fromValue) * r; - property.write(val); - } -} - -void QmlNumericAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlNumericAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - d->fromSourced = false; - d->value.QmlTimeLineValue::setValue(0.); - d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); - d->na->setFromSourcedValue(&d->fromSourced); -} - -QAbstractAnimation *QmlNumericAnimation::qtAnimation() -{ - Q_D(QmlNumericAnimation); - return d->na; -} - -void QmlNumericAnimation::transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction) -{ - Q_D(QmlNumericAnimation); - Q_UNUSED(direction); - - struct NTransitionData : public QmlTimeLineValue - { - QmlStateActions actions; - void setValue(qreal v) - { - QmlTimeLineValue::setValue(v); - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QmlBehaviour::_ignore = true; - if (v == 1.) - action.property.write(action.toValue.toDouble()); - else { - if (action.fromValue.isNull()) { - action.fromValue = action.property.read(); - if (action.fromValue.isNull()) { - action.fromValue = QVariant(0.); - } - } - qreal start = action.fromValue.toDouble(); - qreal end = action.toValue.toDouble(); - qreal val = start + (end-start) * v; - action.property.write(val); - } - QmlBehaviour::_ignore = false; - } - } - }; - - 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.contains(d->propertyName)) - props.append(d->propertyName); - - if (d->userProperty.isValid() && props.isEmpty() && !target()) { - props.append(d->userProperty.value.name()); - d->target = d->userProperty.value.object(); - } - - NTransitionData *data = new NTransitionData; - - QSet<QObject *> objs; - for (int ii = 0; ii < actions.count(); ++ii) { - Action &action = actions[ii]; - - QObject *obj = action.property.object(); - QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { - objs.insert(obj); - Action myAction = action; - if (d->from.isValid()) { - myAction.fromValue = QVariant(d->from); - } else { - myAction.fromValue = QVariant(); - } - if (d->to.isValid()) - myAction.toValue = QVariant(d->to); - - modified << action.property; - - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } - - if (d->to.isValid() && target() && !objs.contains(target())) { - QObject *obj = target(); - for (int jj = 0; jj < props.count(); ++jj) { - Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); - - if (d->from.isValid()) - myAction.fromValue = QVariant(d->from); - - myAction.toValue = QVariant(d->to); - myAction.bv = 0; - myAction.event = 0; - data->actions << myAction; - } - } - - if (data->actions.count()) { - d->na->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); - } else { - delete data; - } -} - -QML_DEFINE_TYPE(QmlNumericAnimation,NumericAnimation) +QML_DEFINE_TYPE(QmlNumberAnimation,NumberAnimation) QmlAnimationGroup::QmlAnimationGroup(QObject *parent) : QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent) @@ -1746,8 +1290,8 @@ QmlList<QmlAbstractAnimation *> *QmlAnimationGroup::animations() \code SequentialAnimation { - NumericAnimation { target: MyItem; property: "x"; to: 100 } - NumericAnimation { target: MyItem; property: "x"; to: 0 } + NumberAnimation { target: MyItem; property: "x"; to: 100 } + NumberAnimation { target: MyItem; property: "x"; to: 0 } } \endcode @@ -1796,23 +1340,15 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, from = d->animations.count() - 1; } - //### needed for Behavior + //needed for Behavior if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) { for (int i = 0; i < d->animations.count(); ++i) d->animations.at(i)->setTarget(d->userProperty); } - //XXX removing and readding isn't ideal; we do it to get around the problem mentioned below. - for (int i = d->ag->animationCount()-1; i >= 0; --i) - d->ag->takeAnimationAt(i); - for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) { d->animations.at(ii)->transition(actions, modified, direction); - d->ag->addAnimation(d->animations.at(ii)->qtAnimation()); } - - //XXX changing direction means all the animations play in reverse, while we only want the ordering reversed. - //d->ag->setDirection(direction == Backward ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); } QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation) @@ -1829,8 +1365,8 @@ QML_DEFINE_TYPE(QmlSequentialAnimation,SequentialAnimation) \code ParallelAnimation { - NumericAnimation { target: MyItem; property: "x"; to: 100 } - NumericAnimation { target: MyItem; property: "y"; to: 100 } + NumberAnimation { target: MyItem; property: "x"; to: 100 } + NumberAnimation { target: MyItem; property: "y"; to: 100 } } \endcode @@ -1886,7 +1422,7 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, { Q_D(QmlAnimationGroup); - //### needed for Behavior + //needed for Behavior if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) { for (int i = 0; i < d->animations.count(); ++i) d->animations.at(i)->setTarget(d->userProperty); @@ -1899,20 +1435,12 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, QML_DEFINE_TYPE(QmlParallelAnimation,ParallelAnimation) -QVariant QmlVariantAnimationPrivate::interpolateVariant(const QVariant &from, const QVariant &to, qreal progress) -{ - if (from.userType() != to.userType()) - return QVariant(); - - QVariantAnimation::Interpolator interpolator = QVariantAnimationPrivate::getInterpolator(from.userType()); - return interpolator(from.constData(), to.constData(), progress); -} - //convert a variant from string type to another animatable type -void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Type type) +void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) { if (variant.type() != QVariant::String) { - variant.convert(type); + if ((uint)type < QVariant::UserType) + variant.convert((QVariant::Type)type); return; } @@ -1946,15 +1474,20 @@ void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Typ break; } default: - variant.convert(type); + if ((uint)type >= QVariant::UserType) { + QmlMetaType::StringConverter converter = QmlMetaType::customStringConverter(type); + if (converter) + variant = converter(variant.toString()); + } else + variant.convert((QVariant::Type)type); break; } } /*! - \qmlclass VariantAnimation QmlVariantAnimation + \qmlclass PropertyAnimation QmlPropertyAnimation \inherits Animation - \brief The VariantAnimation allows you to animate changes in properties of type QVariant. + \brief The PropertyAnimation allows you to animate property changes. Animate a size property over 200ms, from its current size to 20-by-20: \code @@ -1962,51 +1495,51 @@ void QmlVariantAnimationPrivate::convertVariant(QVariant &variant, QVariant::Typ \endcode */ -QmlVariantAnimation::QmlVariantAnimation(QObject *parent) -: QmlAbstractAnimation(*(new QmlVariantAnimationPrivate), parent) +QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent) +: QmlAbstractAnimation(*(new QmlPropertyAnimationPrivate), parent) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); d->init(); } -QmlVariantAnimation::~QmlVariantAnimation() +QmlPropertyAnimation::~QmlPropertyAnimation() { } -void QmlVariantAnimationPrivate::init() +void QmlPropertyAnimationPrivate::init() { - Q_Q(QmlVariantAnimation); + Q_Q(QmlPropertyAnimation); va = new QmlTimeLineValueAnimator(q); va->setStartValue(QVariant(0.0f)); va->setEndValue(QVariant(1.0f)); } /*! - \qmlproperty int VariantAnimation::duration + \qmlproperty int PropertyAnimation::duration This property holds the duration of the transition, in milliseconds. The default value is 250. */ /*! - \property QmlVariantAnimation::duration + \property QmlPropertyAnimation::duration \brief the duration of the transition, in milliseconds. The default value is 250. */ -int QmlVariantAnimation::duration() const +int QmlPropertyAnimation::duration() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->va->duration(); } -void QmlVariantAnimation::setDuration(int duration) +void QmlPropertyAnimation::setDuration(int duration) { if (duration < 0) { - qWarning("QmlVariantAnimation: Cannot set a duration of < 0"); + qWarning("QmlPropertyAnimation: Cannot set a duration of < 0"); return; } - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->va->duration() == duration) return; d->va->setDuration(duration); @@ -2014,23 +1547,23 @@ void QmlVariantAnimation::setDuration(int duration) } /*! - \qmlproperty real VariantAnimation::from + \qmlproperty real PropertyAnimation::from This property holds the starting value. If not set, then the value defined in the start state of the transition. */ /*! - \property QmlVariantAnimation::from + \property QmlPropertyAnimation::from \brief the starting value. */ -QVariant QmlVariantAnimation::from() const +QVariant QmlPropertyAnimation::from() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->from; } -void QmlVariantAnimation::setFrom(const QVariant &f) +void QmlPropertyAnimation::setFrom(const QVariant &f) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->fromIsDefined && f == d->from) return; d->from = f; @@ -2039,23 +1572,23 @@ void QmlVariantAnimation::setFrom(const QVariant &f) } /*! - \qmlproperty real VariantAnimation::to + \qmlproperty real PropertyAnimation::to This property holds the ending value. If not set, then the value defined in the end state of the transition. */ /*! - \property QmlVariantAnimation::to + \property QmlPropertyAnimation::to \brief the ending value. */ -QVariant QmlVariantAnimation::to() const +QVariant QmlPropertyAnimation::to() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->to; } -void QmlVariantAnimation::setTo(const QVariant &t) +void QmlPropertyAnimation::setTo(const QVariant &t) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->toIsDefined && t == d->to) return; d->to = t; @@ -2064,28 +1597,71 @@ void QmlVariantAnimation::setTo(const QVariant &t) } /*! - \qmlproperty string VariantAnimation::easing - This property holds the easing curve used for the transition. + \qmlproperty string PropertyAnimation::easing + \brief the easing curve used for the transition. + + Available values are: - See NumericAnimation::easing for a full discussion of easing, - and a list of available curves. + \list + \i \e easeNone - Easing equation function for a simple linear tweening, with no easing. + \i \e easeInQuad - Easing equation function for a quadratic (t^2) easing in: accelerating from zero velocity. + \i \e easeOutQuad - Easing equation function for a quadratic (t^2) easing out: decelerating to zero velocity. + \i \e easeInOutQuad - Easing equation function for a quadratic (t^2) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInQuad - Easing equation function for a quadratic (t^2) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInCubic - Easing equation function for a cubic (t^3) easing in: accelerating from zero velocity. + \i \e easeOutCubic - Easing equation function for a cubic (t^3) easing out: decelerating from zero velocity. + \i \e easeInOutCubic - Easing equation function for a cubic (t^3) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInCubic - Easing equation function for a cubic (t^3) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInQuart - Easing equation function for a quartic (t^4) easing in: accelerating from zero velocity. + \i \e easeOutQuart - Easing equation function for a quartic (t^4) easing out: decelerating from zero velocity. + \i \e easeInOutQuart - Easing equation function for a quartic (t^4) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInQuart - Easing equation function for a quartic (t^4) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInQuint - Easing equation function for a quintic (t^5) easing in: accelerating from zero velocity. + \i \e easeOutQuint - Easing equation function for a quintic (t^5) easing out: decelerating from zero velocity. + \i \e easeInOutQuint - Easing equation function for a quintic (t^5) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInQuint - Easing equation function for a quintic (t^5) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInSine - Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity. + \i \e easeOutSine - Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity. + \i \e easeInOutSine - Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInSine - Easing equation function for a sinusoidal (sin(t)) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInExpo - Easing equation function for an exponential (2^t) easing in: accelerating from zero velocity. + \i \e easeOutExpo - Easing equation function for an exponential (2^t) easing out: decelerating from zero velocity. + \i \e easeInOutExpo - Easing equation function for an exponential (2^t) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInExpo - Easing equation function for an exponential (2^t) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in: accelerating from zero velocity. + \i \e easeOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out: decelerating from zero velocity. + \i \e easeInOutCirc - Easing equation function for a circular (sqrt(1-t^2)) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInCirc - Easing equation function for a circular (sqrt(1-t^2)) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in: accelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. + \i \e easeOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out: decelerating from zero velocity. The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. + \i \e easeInOutElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInElastic - Easing equation function for an elastic (exponentially decaying sine wave) easing out/in: deceleration until halfway, then acceleration. + \i \e easeInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. + \i \e easeOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out: decelerating from zero velocity. + \i \e easeInOutBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInBack - Easing equation function for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. + \i \e easeOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out: decelerating from zero velocity. + \i \e easeInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in: accelerating from zero velocity. + \i \e easeInOutBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing in/out: acceleration until halfway, then deceleration. + \i \e easeOutInBounce - Easing equation function for a bounce (exponentially decaying parabolic bounce) easing out/in: deceleration until halfway, then acceleration. + \endlist */ /*! - \property QmlVariantAnimation::easing + \property QmlPropertyAnimation::easing \brief the easing curve to use. \sa QEasingCurve */ -QString QmlVariantAnimation::easing() const +QString QmlPropertyAnimation::easing() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->easing; } -void QmlVariantAnimation::setEasing(const QString &e) +void QmlPropertyAnimation::setEasing(const QString &e) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->easing == e) return; @@ -2095,28 +1671,28 @@ void QmlVariantAnimation::setEasing(const QString &e) } /*! - \qmlproperty string VariantAnimation::properties + \qmlproperty string PropertyAnimation::properties This property holds the properties this animation should be applied to. This is a comma-separated list of properties that should use this animation when they change. */ /*! - \property QmlVariantAnimation::properties + \property QmlPropertyAnimation::properties \brief the properties this animation should be applied to properties holds a copy separated list of properties that should use this animation when they change. */ -QString QmlVariantAnimation::properties() const +QString QmlPropertyAnimation::properties() const { - Q_D(const QmlVariantAnimation); + Q_D(const QmlPropertyAnimation); return d->properties; } -void QmlVariantAnimation::setProperties(const QString &prop) +void QmlPropertyAnimation::setProperties(const QString &prop) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->properties == prop) return; @@ -2125,32 +1701,34 @@ void QmlVariantAnimation::setProperties(const QString &prop) } /*! - \qmlproperty list<Item> VariantAnimation::filter + \qmlproperty list<Item> PropertyAnimation::filter This property holds the items selected to be affected by this animation (all if not set). \sa exclude */ -QList<QObject *> *QmlVariantAnimation::filter() +QList<QObject *> *QmlPropertyAnimation::filter() { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); return &d->filter; } /*! - \qmlproperty list<Item> VariantAnimation::exclude + \qmlproperty list<Item> PropertyAnimation::exclude This property holds the items not to be affected by this animation. \sa filter */ -QList<QObject *> *QmlVariantAnimation::exclude() +QList<QObject *> *QmlPropertyAnimation::exclude() { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); return &d->exclude; } -void QmlVariantAnimationPrivate::valueChanged(qreal r) +void QmlPropertyAnimationPrivate::valueChanged(qreal r) { if (!fromSourced) { if (!fromIsDefined) { from = property.read(); + convertVariant(from, interpolatorType ? interpolatorType : property.propertyType()); + //### check for invalid variant if using property type } fromSourced = true; } @@ -2158,28 +1736,34 @@ void QmlVariantAnimationPrivate::valueChanged(qreal r) if (r == 1.) { property.write(to); } else { - QVariant val = interpolateVariant(from, to, r); - property.write(val); + if (interpolator) + property.write(interpolator(from.constData(), to.constData(), r)); } } -QAbstractAnimation *QmlVariantAnimation::qtAnimation() +QAbstractAnimation *QmlPropertyAnimation::qtAnimation() { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); return d->va; } -void QmlVariantAnimation::prepare(QmlMetaProperty &p) +void QmlPropertyAnimation::prepare(QmlMetaProperty &p) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); if (d->userProperty.isNull) d->property = p; else d->property = d->userProperty; - d->convertVariant(d->to, (QVariant::Type)d->property.propertyType()); + int propType = d->property.propertyType(); + d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType); if (d->fromIsDefined) - d->convertVariant(d->from, (QVariant::Type)d->property.propertyType()); + d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : propType); + + if (!d->interpolatorType) { + //### check for invalid variants + d->interpolator = QVariantAnimationPrivate::getInterpolator(propType); + } d->fromSourced = false; d->value.QmlTimeLineValue::setValue(0.); @@ -2187,44 +1771,69 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p) d->va->setFromSourcedValue(&d->fromSourced); } -void QmlVariantAnimation::transition(QmlStateActions &actions, +void QmlPropertyAnimation::transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction) { - Q_D(QmlVariantAnimation); + Q_D(QmlPropertyAnimation); Q_UNUSED(direction); - struct NTransitionData : public QmlTimeLineValue + struct PropertyUpdater : public QmlTimeLineValue { QmlStateActions actions; + int interpolatorType; //for Number/ColorAnimation + int prevInterpolatorType; //for generic + QVariantAnimation::Interpolator interpolator; + bool reverse; void setValue(qreal v) { + if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 + v = 1 - v; QmlTimeLineValue::setValue(v); for (int ii = 0; ii < actions.count(); ++ii) { Action &action = actions[ii]; + QmlBehaviour::_ignore = true; if (v == 1.) action.property.write(action.toValue); else { if (action.fromValue.isNull()) { action.fromValue = action.property.read(); - /*if (action.fromValue.isNull()) - action.fromValue = QVariant(0.);*/ //XXX can we give a default value for any type? + if (interpolatorType) + QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); + } + if (!interpolatorType) { + int propType = action.property.propertyType(); + if (!prevInterpolatorType || prevInterpolatorType != propType) { + prevInterpolatorType = propType; + interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); + } } - QVariant val = QmlVariantAnimationPrivate::interpolateVariant(action.fromValue, action.toValue, v); - action.property.write(val); + if (interpolator) + action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v)); } + QmlBehaviour::_ignore = false; } } }; - QStringList props = d->properties.split(QLatin1Char(',')); + 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.contains(d->propertyName)) props.append(d->propertyName); - NTransitionData *data = new NTransitionData; + bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false; + + if (d->userProperty.isValid() && props.isEmpty() && !target()) { + props.append(d->userProperty.value.name()); + d->target = d->userProperty.value.object(); + } + + PropertyUpdater *data = new PropertyUpdater; + data->interpolatorType = d->interpolatorType; + data->interpolator = d->interpolator; + data->reverse = direction == Backward ? true : false; QSet<QObject *> objs; for (int ii = 0; ii < actions.count(); ++ii) { @@ -2232,10 +1841,15 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, QObject *obj = action.property.object(); QString propertyName = action.property.name(); - - if ((d->filter.isEmpty() || d->filter.contains(obj)) && - (!d->exclude.contains(obj)) && props.contains(propertyName) && - (!target() || target() == obj)) { + QObject *sObj = action.specifiedObject; + QString sPropertyName = action.specifiedProperty; + bool same = (obj == sObj); + + if ((d->filter.isEmpty() || d->filter.contains(obj) || (!same && d->filter.contains(sObj))) && + (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && + (props.contains(propertyName) || (!same && props.contains(sPropertyName)) + || (useType && action.property.propertyType() == d->interpolatorType)) && + (!target() || target() == obj || (!same && target() == sObj))) { objs.insert(obj); Action myAction = action; @@ -2247,8 +1861,8 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, if (d->toIsDefined) myAction.toValue = d->to; - d->convertVariant(myAction.fromValue, (QVariant::Type)myAction.property.propertyType()); - d->convertVariant(myAction.toValue, (QVariant::Type)myAction.property.propertyType()); + 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; @@ -2261,17 +1875,16 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, QObject *obj = target(); for (int jj = 0; jj < props.count(); ++jj) { Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); + myAction.property = d->createProperty(obj, props.at(jj)); + if (!myAction.property.isValid()) + continue; if (d->fromIsDefined) { - d->convertVariant(d->from, (QVariant::Type)myAction.property.propertyType()); + d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); myAction.fromValue = d->from; } - - d->convertVariant(d->to, (QVariant::Type)myAction.property.propertyType()); + d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); myAction.toValue = d->to; - myAction.bv = 0; - myAction.event = 0; data->actions << myAction; } } @@ -2283,7 +1896,6 @@ void QmlVariantAnimation::transition(QmlStateActions &actions, } } -//XXX whats the best name for this? (just Animation?) -QML_DEFINE_TYPE(QmlVariantAnimation,VariantAnimation) +QML_DEFINE_TYPE(QmlPropertyAnimation,PropertyAnimation) QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation.h b/src/declarative/util/qmlanimation.h index 5ab9dda..91c1898 100644 --- a/src/declarative/util/qmlanimation.h +++ b/src/declarative/util/qmlanimation.h @@ -65,6 +65,7 @@ class QmlAbstractAnimation : public QmlPropertyValueSource, public QmlParserStat Q_INTERFACES(QmlParserStatus) Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) + Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) Q_PROPERTY(bool finishPlaying READ finishPlaying WRITE setFinishPlaying NOTIFY finishPlayingChanged()) Q_PROPERTY(bool repeat READ repeat WRITE setRepeat NOTIFY repeatChanged) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) @@ -78,11 +79,16 @@ public: bool isRunning() const; void setRunning(bool); + bool isPaused() const; + void setPaused(bool); bool finishPlaying() const; void setFinishPlaying(bool); bool repeat() const; void setRepeat(bool); + int currentTime(); + void setCurrentTime(int); + QmlAnimationGroup *group() const; void setGroup(QmlAnimationGroup *); @@ -100,6 +106,7 @@ Q_SIGNALS: void started(); void completed(); void runningChanged(bool); + void pausedChanged(bool); void repeatChanged(bool); void targetChanged(QObject *, const QString &); void finishPlayingChanged(bool); @@ -107,6 +114,8 @@ Q_SIGNALS: public Q_SLOTS: void restart(); void start(); + void pause(); + void resume(); void stop(); void complete(); @@ -125,8 +134,6 @@ private Q_SLOTS: void timelineComplete(); }; -QML_DECLARE_TYPE(QmlAbstractAnimation) - class QmlPauseAnimationPrivate; class QmlPauseAnimation : public QmlAbstractAnimation { @@ -147,56 +154,7 @@ Q_SIGNALS: protected: virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlPauseAnimation) - -class QmlColorAnimationPrivate; -class QmlColorAnimation : public QmlAbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlColorAnimation) - Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged) - Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged) - Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) - Q_PROPERTY(QList<QObject *>* filter READ filter) - Q_PROPERTY(QList<QObject *>* exclude READ exclude) - -public: - QmlColorAnimation(QObject *parent=0); - virtual ~QmlColorAnimation(); - - int duration() const; - void setDuration(int); - - QColor from() const; - void setFrom(const QColor &); - - QColor to() const; - void setTo(const QColor &); - - QString easing() const; - void setEasing(const QString &); - - QList<QObject *> *filter(); - - QList<QObject *> *exclude(); - -protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); - -Q_SIGNALS: - void durationChanged(int); - void fromChanged(const QColor &); - void toChanged(const QColor &); - void easingChanged(const QString &); -}; -QML_DECLARE_TYPE(QmlColorAnimation) class QmlRunScriptActionPrivate; class QmlRunScriptAction : public QmlAbstractAnimation @@ -224,7 +182,6 @@ Q_SIGNALS: protected: virtual QAbstractAnimation *qtAnimation(); }; -QML_DECLARE_TYPE(QmlRunScriptAction) class QmlSetPropertyActionPrivate; class QmlSetPropertyAction : public QmlAbstractAnimation @@ -261,7 +218,6 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlSetPropertyAction) class QmlParentChangeActionPrivate; class QmlParentChangeAction : public QmlAbstractAnimation @@ -282,34 +238,33 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlParentChangeAction) -class QmlNumericAnimationPrivate; -class QmlNumericAnimation : public QmlAbstractAnimation +class QmlPropertyAnimationPrivate; +class QmlPropertyAnimation : public QmlAbstractAnimation { Q_OBJECT - Q_DECLARE_PRIVATE(QmlNumericAnimation) + Q_DECLARE_PRIVATE(QmlPropertyAnimation) Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) - Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) + Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) Q_PROPERTY(QList<QObject *>* filter READ filter) Q_PROPERTY(QList<QObject *>* exclude READ exclude) public: - QmlNumericAnimation(QObject *parent=0); - virtual ~QmlNumericAnimation(); + QmlPropertyAnimation(QObject *parent=0); + virtual ~QmlPropertyAnimation(); int duration() const; void setDuration(int); - qreal from() const; - void setFrom(qreal); + QVariant from() const; + void setFrom(const QVariant &); - qreal to() const; - void setTo(qreal); + QVariant to() const; + void setTo(const QVariant &); QString easing() const; void setEasing(const QString &); @@ -329,19 +284,48 @@ protected: Q_SIGNALS: void durationChanged(int); - void fromChanged(qreal); - void toChanged(qreal); + void fromChanged(QVariant); + void toChanged(QVariant); void easingChanged(const QString &); void propertiesChanged(const QString &); }; -QML_DECLARE_TYPE(QmlNumericAnimation) -#if 0 -class QmlDiscreteAnimation : public QmlAbstractAnimation +class QmlColorAnimation : public QmlPropertyAnimation { -Q_OBJECT + Q_OBJECT + Q_DECLARE_PRIVATE(QmlPropertyAnimation) + Q_PROPERTY(QColor from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(QColor to READ to WRITE setTo NOTIFY toChanged) + +public: + QmlColorAnimation(QObject *parent=0); + virtual ~QmlColorAnimation(); + + QColor from() const; + void setFrom(const QColor &); + + QColor to() const; + void setTo(const QColor &); +}; + +class QmlNumberAnimation : public QmlPropertyAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlPropertyAnimation) + + Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) + +public: + QmlNumberAnimation(QObject *parent=0); + virtual ~QmlNumberAnimation(); + + qreal from() const; + void setFrom(qreal); + + qreal to() const; + void setTo(qreal); }; -#endif class QmlAnimationGroupPrivate; class QmlAnimationGroup : public QmlAbstractAnimation @@ -375,7 +359,6 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlSequentialAnimation) class QmlParallelAnimation : public QmlAnimationGroup { @@ -393,62 +376,20 @@ protected: virtual QAbstractAnimation *qtAnimation(); virtual void prepare(QmlMetaProperty &); }; -QML_DECLARE_TYPE(QmlParallelAnimation) - -class QmlVariantAnimationPrivate; -class QmlVariantAnimation : public QmlAbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlVariantAnimation) - - 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(QString easing READ easing WRITE setEasing NOTIFY easingChanged) - Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList<QObject *>* filter READ filter) - Q_PROPERTY(QList<QObject *>* exclude READ exclude) - -public: - QmlVariantAnimation(QObject *parent=0); - virtual ~QmlVariantAnimation(); - - int duration() const; - void setDuration(int); - - QVariant from() const; - void setFrom(const QVariant &); - - QVariant to() const; - void setTo(const QVariant &); - - QString easing() const; - void setEasing(const QString &); - - QString properties() const; - void setProperties(const QString &); - - QList<QObject *> *filter(); - QList<QObject *> *exclude(); - -protected: - virtual void transition(QmlStateActions &actions, - QmlMetaProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); - -Q_SIGNALS: - void durationChanged(int); - void fromChanged(QVariant); - void toChanged(QVariant); - void easingChanged(const QString &); - void propertiesChanged(const QString &); -}; -QML_DECLARE_TYPE(QmlVariantAnimation) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlAbstractAnimation) +QML_DECLARE_TYPE(QmlPauseAnimation) +QML_DECLARE_TYPE(QmlRunScriptAction) +QML_DECLARE_TYPE(QmlSetPropertyAction) +QML_DECLARE_TYPE(QmlParentChangeAction) +QML_DECLARE_TYPE(QmlPropertyAnimation) +QML_DECLARE_TYPE(QmlColorAnimation) +QML_DECLARE_TYPE(QmlNumberAnimation) +QML_DECLARE_TYPE(QmlSequentialAnimation) +QML_DECLARE_TYPE(QmlParallelAnimation) + QT_END_HEADER #endif // QMLANIMATION_H diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index e5a7384..87d480f 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -42,6 +42,17 @@ #ifndef QMLANIMATION_P_H #define QMLANIMATION_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/qobject_p.h> #include <private/qmlnullablevalue_p.h> #include <private/qvariantanimation_p.h> @@ -52,7 +63,7 @@ #include <QtDeclarative/qmlanimation.h> #include <QtDeclarative/qml.h> #include <QtDeclarative/qmlcontext.h> -#include <QtDeclarative/qmltimelinevalueproxy.h> +#include <private/qmltimeline_p.h> QT_BEGIN_NAMESPACE @@ -172,11 +183,12 @@ class QmlAbstractAnimationPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlAbstractAnimation) public: QmlAbstractAnimationPrivate() - : running(false), finishPlaying(false), repeat(false), + : running(false), paused(false), finishPlaying(false), repeat(false), connectedTimeLine(false), componentComplete(true), startOnCompletion(false), target(0), group(0) {} bool running; + bool paused; bool finishPlaying; bool repeat; bool connectedTimeLine; @@ -192,6 +204,8 @@ public: QmlMetaProperty property; QmlAnimationGroup *group; + + QmlMetaProperty createProperty(QObject *obj, const QString &str); }; class QmlPauseAnimationPrivate : public QmlAbstractAnimationPrivate @@ -206,40 +220,6 @@ public: QPauseAnimation *pa; }; -class QmlColorAnimationPrivate : public QmlAbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QmlColorAnimation) -public: - QmlColorAnimationPrivate() - : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), - ca(0), value(this, &QmlColorAnimationPrivate::valueChanged) - { - if (!colorInterpolator) - colorInterpolator = QVariantAnimationPrivate::getInterpolator(QVariant::Color); - } - - void init(); - - QString easing; - - QColor fromValue; - QColor toValue; - - QList<QObject *> filter; - QList<QObject *> exclude; - - bool fromSourced; - bool fromIsDefined; - bool toIsDefined; - - QmlTimeLineValueAnimator *ca; - virtual void valueChanged(qreal); - - QmlTimeLineValueProxy<QmlColorAnimationPrivate> value; - - static QVariantAnimation::Interpolator colorInterpolator; -}; - class QmlRunScriptActionPrivate : public QmlAbstractAnimationPrivate { Q_DECLARE_PUBLIC(QmlRunScriptAction) @@ -294,32 +274,6 @@ public: QActionAnimation *cpa; }; -class QmlNumericAnimationPrivate : public QmlAbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QmlNumericAnimation) -public: - QmlNumericAnimationPrivate() - : QmlAbstractAnimationPrivate(), fromSourced(false), na(0), value(this, &QmlNumericAnimationPrivate::valueChanged) {} - - void init(); - - QmlNullableValue<qreal> from; - QmlNullableValue<qreal> to; - - QString easing; - - QString properties; - QList<QObject *> filter; - QList<QObject *> exclude; - - bool fromSourced; - qreal fromValue; - QmlTimeLineValueAnimator *na; - virtual void valueChanged(qreal); - - QmlTimeLineValueProxy<QmlNumericAnimationPrivate> value; -}; - class QmlAnimationGroupPrivate : public QmlAbstractAnimationPrivate { Q_DECLARE_PUBLIC(QmlAnimationGroup) @@ -359,13 +313,14 @@ public: QAnimationGroup *ag; }; -class QmlVariantAnimationPrivate : public QmlAbstractAnimationPrivate +class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate { - Q_DECLARE_PUBLIC(QmlVariantAnimation) + Q_DECLARE_PUBLIC(QmlPropertyAnimation) public: - QmlVariantAnimationPrivate() + QmlPropertyAnimationPrivate() : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), - va(0), value(this, &QmlVariantAnimationPrivate::valueChanged) {} + defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), + value(this, &QmlPropertyAnimationPrivate::valueChanged) {} void init(); @@ -381,16 +336,19 @@ public: bool fromSourced; bool fromIsDefined; bool toIsDefined; + bool defaultToInterpolatorType; + int interpolatorType; + QVariantAnimation::Interpolator interpolator; QmlTimeLineValueAnimator *va; virtual void valueChanged(qreal); - QmlTimeLineValueProxy<QmlVariantAnimationPrivate> value; + QmlTimeLineValueProxy<QmlPropertyAnimationPrivate> value; static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); - static void convertVariant(QVariant &variant, QVariant::Type type); + static void convertVariant(QVariant &variant, int type); }; -#endif // QMLANIMATION_P_H - QT_END_NAMESPACE + +#endif // QMLANIMATION_P_H diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index b45d07d..bb342bc 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -52,6 +52,7 @@ #include "qmlbind.h" QT_BEGIN_NAMESPACE + class QmlBindPrivate : public QObjectPrivate { public: diff --git a/src/declarative/util/qmlbind.h b/src/declarative/util/qmlbind.h index b7b77f2..731cdf8 100644 --- a/src/declarative/util/qmlbind.h +++ b/src/declarative/util/qmlbind.h @@ -82,10 +82,11 @@ public: private: void eval(); }; -QML_DECLARE_TYPE(QmlBind) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlBind) + QT_END_HEADER #endif diff --git a/src/declarative/util/qmlconnection.cpp b/src/declarative/util/qmlconnection.cpp index 6c7b158..95f4573 100644 --- a/src/declarative/util/qmlconnection.cpp +++ b/src/declarative/util/qmlconnection.cpp @@ -46,8 +46,8 @@ #include <QtDeclarative/qmlcontext.h> #include <QtCore/qdebug.h> - QT_BEGIN_NAMESPACE + class QmlConnectionPrivate : public QObjectPrivate { public: diff --git a/src/declarative/util/qmlconnection.h b/src/declarative/util/qmlconnection.h index d61659f..dcaac34 100644 --- a/src/declarative/util/qmlconnection.h +++ b/src/declarative/util/qmlconnection.h @@ -81,10 +81,11 @@ private: void connectIfValid(); void componentComplete(); }; -QML_DECLARE_TYPE(QmlConnection) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlConnection) + QT_END_HEADER #endif diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index d1ecac4..b8e6685 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -40,13 +40,14 @@ ****************************************************************************/ #include <limits.h> +#include <math.h> #include <QtCore/qdebug.h> #include "private/qobject_p.h" #include "qmlfollow.h" #include "private/qmlanimation_p.h" - QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QmlFollow,Follow) class QmlFollowPrivate : public QObjectPrivate @@ -55,7 +56,7 @@ class QmlFollowPrivate : public QObjectPrivate public: QmlFollowPrivate() : sourceValue(0), maxVelocity(0), lastTime(0) - , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), enabled(true), mode(Track), clock(this) {} + , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), modulus(0.0), enabled(true), mode(Track), clock(this) {} QmlMetaProperty property; qreal currentValue; @@ -68,6 +69,7 @@ public: qreal damping; qreal velocity; qreal epsilon; + qreal modulus; bool enabled; enum Mode { @@ -92,14 +94,25 @@ void QmlFollowPrivate::tick(int time) int elapsed = time - lastTime; if (!elapsed) return; + qreal srcVal = sourceValue; + if (modulus != 0.0) { + currentValue = fmod(currentValue, modulus); + srcVal = fmod(srcVal, modulus); + } if (mode == Spring) { - if (elapsed < 10) // capped at 100fps. + if (elapsed < 16) // capped at 62fps. return; // Real men solve the spring DEs using RK4. // We'll do something much simpler which gives a result that looks fine. - int count = (elapsed+5) / 10; + int count = (elapsed+8) / 16; for (int i = 0; i < count; ++i) { - qreal diff = sourceValue - currentValue; + qreal diff = srcVal - currentValue; + if (modulus != 0.0 && qAbs(diff) > modulus / 2) { + if (diff < 0) + diff += modulus; + else + diff -= modulus; + } velocity = velocity + spring * diff - damping * velocity; // The following line supports mass. Not sure its worth the extra divisions. // velocity = velocity + spring / mass * diff - damping / mass * velocity; @@ -110,25 +123,40 @@ void QmlFollowPrivate::tick(int time) else if (velocity < -maxVelocity) velocity = -maxVelocity; } - currentValue += velocity * 10.0 / 1000.0; + currentValue += velocity * 16.0 / 1000.0; + if (modulus != 0.0) { + currentValue = fmod(currentValue, modulus); + if (currentValue < 0.0) + currentValue += modulus; + } } - if (qAbs(velocity) < epsilon && qAbs(sourceValue - currentValue) < epsilon) { + if (qAbs(velocity) < epsilon && qAbs(srcVal - currentValue) < epsilon) { velocity = 0.0; - currentValue = sourceValue; + currentValue = srcVal; clock.stop(); } - lastTime = time - (elapsed - count * 10); + lastTime = time - (elapsed - count * 16); } else { qreal moveBy = elapsed * velocityms; - qreal diff = sourceValue - currentValue; + qreal diff = srcVal - currentValue; + if (modulus != 0.0 && qAbs(diff) > modulus / 2) { + if (diff < 0) + diff += modulus; + else + diff -= modulus; + } if (diff > 0) { currentValue += moveBy; + if (modulus != 0.0) + currentValue = fmod(currentValue, modulus); if (currentValue > sourceValue) { currentValue = sourceValue; clock.stop(); } } else { currentValue -= moveBy; + if (modulus != 0.0 && currentValue < 0.0) + currentValue = fmod(currentValue, modulus) + modulus; if (currentValue < sourceValue) { currentValue = sourceValue; clock.stop(); @@ -183,7 +211,7 @@ void QmlFollowPrivate::stop() y: SequentialAnimation { running: true repeat: true - NumericAnimation { + NumberAnimation { to: 200 easing: "easeOutBounce(amplitude:100)" duration: 2000 @@ -326,6 +354,25 @@ void QmlFollow::setEpsilon(qreal epsilon) } /*! + \qmlproperty qreal Follow::modulus + This property holds the modulus value. + + 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 QmlFollow::modulus() const +{ + Q_D(const QmlFollow); + return d->modulus; +} + +void QmlFollow::setModulus(qreal modulus) +{ + Q_D(QmlFollow); + d->modulus = modulus; +} + +/*! \qmlproperty qreal Follow::followValue The current value. */ diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlfollow.h index 72d6df5..07e15e9 100644 --- a/src/declarative/util/qmlfollow.h +++ b/src/declarative/util/qmlfollow.h @@ -64,8 +64,10 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QmlPropertyValueSource, 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) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) Q_PROPERTY(qreal followValue READ value NOTIFY valueChanged) + Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged) public: QmlFollow(QObject *parent=0); @@ -83,6 +85,8 @@ public: void setDamping(qreal damping); qreal epsilon() const; void setEpsilon(qreal epsilon); + qreal modulus() const; + void setModulus(qreal modulus); bool enabled() const; void setEnabled(bool enabled); @@ -92,10 +96,10 @@ Q_SIGNALS: void valueChanged(qreal); }; -QML_DECLARE_TYPE(QmlFollow) - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlFollow) + QT_END_HEADER #endif // QFXFOLLOW_H diff --git a/src/declarative/util/qmlfont.cpp b/src/declarative/util/qmlfont.cpp index c537a83..3075b82 100644 --- a/src/declarative/util/qmlfont.cpp +++ b/src/declarative/util/qmlfont.cpp @@ -43,8 +43,8 @@ #include "qfont.h" #include "qmlfont.h" - QT_BEGIN_NAMESPACE + class QmlFontPrivate : public QObjectPrivate { public: @@ -144,4 +144,5 @@ QFont QmlFont::font() const Q_D(const QmlFont); return d->font; } + QT_END_NAMESPACE diff --git a/src/declarative/util/qmlfont.h b/src/declarative/util/qmlfont.h index c4c86e2..e85b8d3 100644 --- a/src/declarative/util/qmlfont.h +++ b/src/declarative/util/qmlfont.h @@ -83,10 +83,11 @@ public: Q_SIGNALS: void updated(); }; -QML_DECLARE_TYPE(QmlFont) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlFont) + QT_END_HEADER #endif // QMLFONT_H diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index cc85661..f5f76b0 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -49,6 +49,8 @@ #include <qmlbindablevalue.h> #include "qmllistmodel.h" +Q_DECLARE_METATYPE(QListModelInterface *) + QT_BEGIN_NAMESPACE #define DATA_ROLE_ID 1 @@ -67,8 +69,6 @@ struct ListModelData ListInstruction *instructions() const { return (ListInstruction *)((char *)this + sizeof(ListModelData)); } }; -Q_DECLARE_METATYPE(QListModelInterface *) - /*! \qmlclass ListModel \brief The ListModel element defines a free-form list data source. @@ -169,31 +169,6 @@ Q_DECLARE_METATYPE(QListModelInterface *) */ -struct ModelNode; -class ListModel : public QListModelInterface -{ - Q_OBJECT -public: - ListModel(QObject *parent=0); - - virtual QList<int> roles() const; - virtual QString toString(int role) const; - Q_PROPERTY(int count READ count) - virtual int count() const; - virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const; - -private: - QVariant valueForNode(ModelNode *) const; - mutable QStringList roleStrings; - friend class ListModelParser; - friend struct ModelNode; - - void checkRoles() const; - void addRole(const QString &) const; - mutable bool _rolesOk; - ModelNode *_root; -}; - class ModelObject : public QObject { Q_OBJECT @@ -220,9 +195,9 @@ struct ModelNode QList<QVariant> values; QHash<QString, ModelNode *> properties; - ListModel *model() { + QmlListModel *model() { if (!modelCache) { - modelCache = new ListModel; + modelCache = new QmlListModel; modelCache->_root = this; } return modelCache; @@ -240,22 +215,25 @@ struct ModelNode return objectCache; } - ListModel *modelCache; + QmlListModel *modelCache; ModelObject *objectCache; }; -Q_DECLARE_METATYPE(ModelNode *) ModelObject::ModelObject(ModelNode *node) : _node(node), _haveProperties(false), _mo(new QmlOpenMetaObject(this)) { } -ListModel::ListModel(QObject *parent) +QmlListModel::QmlListModel(QObject *parent) : QListModelInterface(parent), _rolesOk(false), _root(0) { } -void ListModel::checkRoles() const +QmlListModel::~QmlListModel() +{ +} + +void QmlListModel::checkRoles() const { if (_rolesOk) return; @@ -271,13 +249,13 @@ void ListModel::checkRoles() const _rolesOk = true; } -void ListModel::addRole(const QString &role) const +void QmlListModel::addRole(const QString &role) const { if (!roleStrings.contains(role)) roleStrings << role; } -QList<int> ListModel::roles() const +QList<int> QmlListModel::roles() const { checkRoles(); QList<int> rv; @@ -286,7 +264,7 @@ QList<int> ListModel::roles() const return rv; } -QString ListModel::toString(int role) const +QString QmlListModel::toString(int role) const { checkRoles(); if (role < roleStrings.count()) @@ -295,7 +273,7 @@ QString ListModel::toString(int role) const return QString(); } -QVariant ListModel::valueForNode(ModelNode *node) const +QVariant QmlListModel::valueForNode(ModelNode *node) const { QObject *rv = 0; @@ -328,7 +306,7 @@ QVariant ListModel::valueForNode(ModelNode *node) const return QVariant(); } -QHash<int,QVariant> ListModel::data(int index, const QList<int> &roles) const +QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const { checkRoles(); QHash<int, QVariant> rv; @@ -353,13 +331,13 @@ QHash<int,QVariant> ListModel::data(int index, const QList<int> &roles) const return rv; } -int ListModel::count() const +int QmlListModel::count() const { if (!_root) return 0; return _root->values.count(); } -class ListModelParser : public QmlCustomParser +class QmlListModelParser : public QmlCustomParser { public: QByteArray compile(const QList<QmlCustomParserProperty> &, bool *ok); @@ -367,7 +345,7 @@ public: void setCustomData(QObject *, const QByteArray &); }; -bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data) +bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data) { QList<QVariant> values = prop.assignedValues(); for(int ii = 0; ii < values.count(); ++ii) { @@ -434,7 +412,7 @@ bool ListModelParser::compileProperty(const QmlCustomParserProperty &prop, QList return true; } -QByteArray ListModelParser::compile(const QList<QmlCustomParserProperty> &customProps, bool *ok) +QByteArray QmlListModelParser::compile(const QList<QmlCustomParserProperty> &customProps, bool *ok) { *ok = true; QList<ListInstruction> instr; @@ -471,9 +449,9 @@ QByteArray ListModelParser::compile(const QList<QmlCustomParserProperty> &custom return rv; } -void ListModelParser::setCustomData(QObject *obj, const QByteArray &d) +void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) { - ListModel *rv = static_cast<ListModel *>(obj); + QmlListModel *rv = static_cast<QmlListModel *>(obj); ModelNode *root = new ModelNode; rv->_root = root; @@ -519,16 +497,14 @@ void ListModelParser::setCustomData(QObject *obj, const QByteArray &d) } } -QML_DECLARE_TYPE(ListModel) -QML_DEFINE_CUSTOM_TYPE(ListModel, ListModel, ListModelParser) +QML_DEFINE_CUSTOM_TYPE(QmlListModel, ListModel, QmlListModelParser) // ### FIXME -class ListElement : public QObject +class QmlListElement : public QObject { Q_OBJECT }; -QML_DECLARE_TYPE(ListElement) -QML_DEFINE_TYPE(ListElement,ListElement) +QML_DEFINE_TYPE(QmlListElement,ListElement) static void dump(ModelNode *node, int ind) { @@ -567,4 +543,8 @@ ModelNode::~ModelNode() } QT_END_NAMESPACE + +Q_DECLARE_METATYPE(ModelNode *) +QML_DECLARE_TYPE(QmlListElement) + #include "qmllistmodel.moc" diff --git a/src/declarative/util/qmllistmodel.h b/src/declarative/util/qmllistmodel.h index ddf1e13..39edbe4 100644 --- a/src/declarative/util/qmllistmodel.h +++ b/src/declarative/util/qmllistmodel.h @@ -51,16 +51,43 @@ #include <QtDeclarative/qml.h> #include <QtDeclarative/qlistmodelinterface.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +struct ModelNode; +class QmlListModel : public QListModelInterface +{ + Q_OBJECT + Q_PROPERTY(int count READ count) + +public: + QmlListModel(QObject *parent=0); + ~QmlListModel(); + + virtual QList<int> roles() const; + virtual QString toString(int role) const; + virtual int count() const; + virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const; + +private: + QVariant valueForNode(ModelNode *) const; + mutable QStringList roleStrings; + friend class QmlListModelParser; + friend struct ModelNode; + + void checkRoles() const; + void addRole(const QString &) const; + mutable bool _rolesOk; + ModelNode *_root; +}; QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlListModel) + QT_END_HEADER #endif // QMLLISTMODEL_H diff --git a/src/declarative/util/qmlnullablevalue_p.h b/src/declarative/util/qmlnullablevalue_p.h index f16ddd6..6455642 100644 --- a/src/declarative/util/qmlnullablevalue_p.h +++ b/src/declarative/util/qmlnullablevalue_p.h @@ -42,6 +42,19 @@ #ifndef QMLNULLABLEVALUE_P_H #define QMLNULLABLEVALUE_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. +// + +QT_BEGIN_NAMESPACE + template<typename T> struct QmlNullableValue { @@ -63,5 +76,6 @@ struct QmlNullableValue T value; }; -#endif // QMLNULLABLEVALUE_P_H +QT_END_NAMESPACE +#endif // QMLNULLABLEVALUE_P_H diff --git a/src/declarative/util/qmlopenmetaobject.cpp b/src/declarative/util/qmlopenmetaobject.cpp index d0dd817..7305362 100644 --- a/src/declarative/util/qmlopenmetaobject.cpp +++ b/src/declarative/util/qmlopenmetaobject.cpp @@ -43,7 +43,6 @@ #include "private/qmetaobjectbuilder_p.h" #include <QDebug> - QT_BEGIN_NAMESPACE class QmlOpenMetaObjectPrivate diff --git a/src/declarative/util/qmlpackage.cpp b/src/declarative/util/qmlpackage.cpp index e527c1f..eec769e 100644 --- a/src/declarative/util/qmlpackage.cpp +++ b/src/declarative/util/qmlpackage.cpp @@ -42,8 +42,8 @@ #include "private/qobject_p.h" #include "qmlpackage.h" - QT_BEGIN_NAMESPACE + class QmlPackagePrivate : public QObjectPrivate { public: @@ -150,4 +150,5 @@ QmlPackageAttached *QmlPackage::qmlAttachedProperties(QObject *o) QML_DEFINE_TYPE(QmlPackage, Package) QT_END_NAMESPACE + #include "qmlpackage.moc" diff --git a/src/declarative/util/qmlpackage.h b/src/declarative/util/qmlpackage.h index 9f1d94f..9f7a623 100644 --- a/src/declarative/util/qmlpackage.h +++ b/src/declarative/util/qmlpackage.h @@ -77,10 +77,11 @@ public: static QmlPackageAttached *qmlAttachedProperties(QObject *); }; -QML_DECLARE_TYPE(QmlPackage) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlPackage) + QT_END_HEADER #endif // QMLPACKAGE_H diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index ab095b1..07cc1d5 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -55,7 +55,7 @@ #include <QNetworkReply> #include <QNetworkRequest> #include <QtDeclarative/qmlinfo.h> -#include <qfxperf.h> +#include <private/qfxperf_p.h> QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qmlscript.h b/src/declarative/util/qmlscript.h index 09ebc2c..4ba4f6b 100644 --- a/src/declarative/util/qmlscript.h +++ b/src/declarative/util/qmlscript.h @@ -47,6 +47,7 @@ #include <QtDeclarative/qml.h> QT_BEGIN_HEADER + QT_BEGIN_NAMESPACE QT_MODULE(Declarative) @@ -73,8 +74,11 @@ public: private Q_SLOTS: void replyFinished(); }; -QML_DECLARE_TYPE(QmlScript) QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlScript) + QT_END_HEADER + #endif diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index cb97ed9..6464e33 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -47,9 +47,10 @@ #include <private/qmlcustomparser_p.h> #include <private/qmlparser_p.h> #include <QtDeclarative/qmlexpression.h> - +#include <QtDeclarative/qmlbindablevalue.h> QT_BEGIN_NAMESPACE + /*! \qmlclass SetProperties QmlSetProperties \brief The SetProperties element describes new property values for a state. @@ -113,7 +114,8 @@ class QmlSetPropertiesPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlSetProperties) public: - QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true) {} + QmlSetPropertiesPrivate() : object(0), decoded(true), restore(true), + isExplicit(false) {} QObject *object; QByteArray data; @@ -121,6 +123,7 @@ public: void decode(); bool restore; + bool isExplicit; QList<QPair<QByteArray, QVariant> > properties; QList<QPair<QByteArray, QmlExpression *> > expressions; @@ -205,6 +208,7 @@ QmlSetPropertiesParser::compile(const QList<QmlCustomParserProperty> &props, void QmlSetPropertiesPrivate::decode() { + Q_Q(QmlSetProperties); if (decoded) return; @@ -221,7 +225,7 @@ void QmlSetPropertiesPrivate::decode() ds >> data; if (isScript) { - QmlExpression *expression = new QmlExpression(qmlContext(object), data.toString(), object); + QmlExpression *expression = new QmlExpression(qmlContext(q), data.toString(), object); expression->setTrackChange(false); expressions << qMakePair(name, expression); } else { @@ -278,39 +282,19 @@ void QmlSetProperties::setRestoreEntryValues(bool v) d->restore = v; } -QmlMetaProperty -QmlSetPropertiesPrivate::property(const QByteArray &property) +QmlMetaProperty +QmlSetPropertiesPrivate::property(const QByteArray &property) { Q_Q(QmlSetProperties); - QList<QByteArray> path = property.split('.'); - - QObject *obj = this->object; - - for (int jj = 0; jj < path.count() - 1; ++jj) { - const QByteArray &pathName = path.at(jj); - QmlMetaProperty prop(obj, QLatin1String(pathName)); - QObject *objVal = QmlMetaType::toQObject(prop.read()); - if (!objVal) { - qmlInfo(q) << obj->metaObject()->className() - << "has no object property named" << pathName; - return QmlMetaProperty(); - } - obj = objVal; - } - - const QByteArray &name = path.last(); - QmlMetaProperty prop(obj, QLatin1String(name)); + QmlMetaProperty prop = QmlMetaProperty::createProperty(object, QString::fromLatin1(property)); if (!prop.isValid()) { - qmlInfo(q) << obj->metaObject()->className() - << "has no property named" << name; + qmlInfo(q) << "Cannot assign to non-existant property" << property; return QmlMetaProperty(); } else if (!prop.isWritable()) { - qmlInfo(q) << obj->metaObject()->className() - << name << "is not writable, and cannot be set."; + qmlInfo(q) << "Cannot assign to read-only property" << property; return QmlMetaProperty(); - } else { - return prop; } + return prop; } QmlSetProperties::ActionList QmlSetProperties::actions() @@ -324,15 +308,12 @@ QmlSetProperties::ActionList QmlSetProperties::actions() for (int ii = 0; ii < d->properties.count(); ++ii) { QByteArray property = d->properties.at(ii).first; - QmlMetaProperty prop = d->property(property); - if (prop.isValid()) { - Action a; - a.restore = restoreEntryValues(); - a.property = prop; - a.fromValue = a.property.read(); - a.toValue = d->properties.at(ii).second; + Action a(d->object, QString::fromLatin1(property), + d->properties.at(ii).second); + if (a.property.isValid()) { + a.restore = restoreEntryValues(); list << a; } } @@ -347,16 +328,35 @@ QmlSetProperties::ActionList QmlSetProperties::actions() a.restore = restoreEntryValues(); a.property = prop; a.fromValue = a.property.read(); - a.toValue = d->expressions.at(ii).second->value(); + a.specifiedObject = d->object; + a.specifiedProperty = QString::fromLatin1(property); + + if (d->isExplicit) { + a.toValue = d->expressions.at(ii).second->value(); + } else { + a.toBinding = new QmlBindableValue(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); + a.toBinding->setTarget(prop); + } list << a; } - } return list; } +bool QmlSetProperties::isExplicit() const +{ + Q_D(const QmlSetProperties); + return d->isExplicit; +} + +void QmlSetProperties::setIsExplicit(bool e) +{ + Q_D(QmlSetProperties); + d->isExplicit = e; +} + QML_DEFINE_CUSTOM_TYPE(QmlSetProperties,SetProperties,QmlSetPropertiesParser) QT_END_NAMESPACE diff --git a/src/declarative/util/qmlsetproperties.h b/src/declarative/util/qmlsetproperties.h index da5fcf2..3632816 100644 --- a/src/declarative/util/qmlsetproperties.h +++ b/src/declarative/util/qmlsetproperties.h @@ -44,7 +44,6 @@ #include <QtDeclarative/qmlstateoperations.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -59,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QmlSetProperties : public QmlStateOperation 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: QmlSetProperties(); ~QmlSetProperties(); @@ -69,12 +69,16 @@ public: bool restoreEntryValues() const; void setRestoreEntryValues(bool); + bool isExplicit() const; + void setIsExplicit(bool); + virtual ActionList actions(); }; -QML_DECLARE_TYPE(QmlSetProperties) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlSetProperties) + QT_END_HEADER #endif // QMLSETPROPERTIES_H diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index abe8301..e3cff38 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -53,10 +53,23 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -Action::Action() : restore(true), bv(0), event(0), actionDone(false) +Action::Action() +: restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0), + specifiedObject(0) { } +Action::Action(QObject *target, const QString &propertyName, + const QVariant &value) +: restore(true), actionDone(false), toValue(value), fromBinding(0), + toBinding(0), event(0), specifiedObject(target), + specifiedProperty(propertyName) +{ + property = QmlMetaProperty::createProperty(target, propertyName); + if (property.isValid()) + fromValue = property.read(); +} + ActionEvent::~ActionEvent() { } @@ -108,6 +121,8 @@ QML_DEFINE_TYPE(QmlState,State) QmlState::QmlState(QObject *parent) : QObject(*(new QmlStatePrivate), parent) { + Q_D(QmlState); + d->transitionManager.setState(this); } QmlState::~QmlState() @@ -234,33 +249,9 @@ QmlState &QmlState::operator<<(QmlStateOperation *op) return *this; } -#if 0 -static void dump(const QmlStateOperation::ActionList &list) -{ - if (!QString(getenv("STATE_DEBUG")).isEmpty()) - return; - - for (int ii = 0; ii < list.count(); ++ii) { - const Action &action = list.at(ii); - qWarning() << action.property.object << action.property.name << action.toValue; - } -} -#endif - -void QmlStatePrivate::applyBindings() -{ - foreach(const Action &action, bindingsList) { - if (action.bv && !action.toBinding.isEmpty()) { - action.bv->setExpression(action.toBinding); - } - } -} - void QmlStatePrivate::complete() { Q_Q(QmlState); - //apply bindings (now that all transitions are complete) - applyBindings(); for (int ii = 0; ii < reverting.count(); ++ii) { for (int jj = 0; jj < revertList.count(); ++jj) { @@ -272,22 +263,19 @@ void QmlStatePrivate::complete() } reverting.clear(); - for (int ii = 0; ii < completeList.count(); ++ii) { - const QmlMetaProperty &prop = completeList.at(ii).property; - prop.write(completeList.at(ii).value); - } - - completeList.clear(); - transition = 0; emit q->completed(); } -QmlStateOperation::ActionList QmlStatePrivate::generateActionList(QmlStateGroup *group) const +// Generate a list of actions for this state. This includes coelescing state +// actions that this state "extends" +QmlStateOperation::ActionList +QmlStatePrivate::generateActionList(QmlStateGroup *group) const { QmlStateOperation::ActionList applyList; if (inState) return applyList; + // Prevent "extends" recursion inState = true; if (!extends.isEmpty()) { @@ -319,9 +307,15 @@ void QmlState::setStateGroup(QmlStateGroup *group) void QmlState::cancel() { Q_D(QmlState); - if (d->transition) { - d->transition->stop(); //XXX this could potentially trigger a complete in rare circumstances - d->transition = 0; + d->transitionManager.cancel(); +} + +void Action::deleteFromBinding() +{ + if (fromBinding) { + property.setBinding(0); + delete fromBinding; + fromBinding = 0; } } @@ -334,29 +328,56 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever revert->cancel(); d->revertList.clear(); d->reverting.clear(); - d->bindingsList.clear(); - if (revert) - d->revertList = static_cast<QmlStatePrivate*>(revert->d_ptr)->revertList; - QmlStateOperation::RevertActionList additionalReverts; + if (revert) { + QmlStatePrivate *revertPrivate = + static_cast<QmlStatePrivate*>(revert->d_ptr); + d->revertList = revertPrivate->revertList; + revertPrivate->revertList.clear(); + } + // List of actions caused by this state QmlStateOperation::ActionList applyList = d->generateActionList(group); + // List of actions that need to be reverted to roll back (just) this state + QmlStatePrivate::SimpleActionList additionalReverts; + // First add the reverse of all the applyList actions for (int ii = 0; ii < applyList.count(); ++ii) { - const Action &action = applyList.at(ii); - if (action.event || !action.restore) + Action &action = applyList[ii]; + + if (action.event) continue; + action.fromBinding = action.property.binding(); + bool found = false; - for (int jj = 0; !found && jj < d->revertList.count(); ++jj) { - if (d->revertList.at(jj).property == action.property) + int jj; + for (jj = 0; jj < d->revertList.count(); ++jj) { + if (d->revertList.at(jj).property == action.property) { found = true; + break; + } } + if (!found) { - RevertAction r(action); - additionalReverts << r; + 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 + SimpleAction r(action); + additionalReverts << r; + } + } else { + + if (!found || d->revertList.at(jj).binding != action.fromBinding) { + action.deleteFromBinding(); + } } } + + // 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; for (int jj = 0; !found && jj < applyList.count(); ++jj) { @@ -366,104 +387,35 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever } if (!found) { QVariant cur = d->revertList.at(ii).property.read(); + delete d->revertList.at(ii).property.setBinding(0); + Action a; a.property = d->revertList.at(ii).property; a.fromValue = cur; a.toValue = d->revertList.at(ii).value; a.toBinding = d->revertList.at(ii).binding; - if (!a.toBinding.isEmpty()) { - a.fromBinding = d->revertList.at(ii).bv->expression(); - a.bv = d->revertList.at(ii).bv; - } + a.specifiedObject = d->revertList.at(ii).specifiedObject; //### + a.specifiedProperty = d->revertList.at(ii).specifiedProperty; 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; - //apply all changes, and work out any ending positions for bindings - //then rewind all changes and proceed as normal - //### 4 foreach loops! - //////////////////////////////////////////////////////////////////// - foreach(const Action &action, applyList) { - if (stateChangeDebug()) - qWarning() << " Action:" << action.property.object() << action.property.name() << action.toValue; - - if (action.bv && !action.toBinding.isEmpty()) { - d->bindingsList << action; - action.bv->clearExpression(); - } - } - - if (!d->bindingsList.isEmpty()) { + // Output for debugging + if (stateChangeDebug()) { foreach(const Action &action, applyList) { - if (action.bv && !action.toBinding.isEmpty()) { - action.bv->setExpression(action.toBinding); - } else if (!action.event) { - action.property.write(action.toValue); - } - } - - for (int ii = 0; ii < applyList.size(); ++ii) { - Action *action = &applyList[ii]; - if (action->event) - continue; - - const QmlMetaProperty &prop = action->property; - if (action->bv && !action->toBinding.isEmpty()) { - action->toValue = prop.read(); - } - } - - foreach(const Action &action, applyList) { - if (action.event) - continue; - - if (action.bv && !action.toBinding.isEmpty()) - action.bv->clearExpression(); - action.property.write(action.fromValue); - } - } - //////////////////////////////////////////////////////////////////// - - QmlStateOperation::ActionList modList = applyList; - QList<QmlMetaProperty> touched; - d->completeList.clear(); - if (trans) { - d->transition = trans; - trans->prepare(modList, touched, this); - for (int ii = 0; ii < modList.count(); ++ii) { - const Action &action = modList.at(ii); - - if (action.event) { - if (action.actionDone) { - modList.removeAt(ii); - --ii; - } - } else { - if (action.toValue != action.fromValue) { - d->completeList << RevertAction(action, false); - } - - if (touched.contains(action.property)) { - modList.removeAt(ii); - --ii; - } - } + qWarning() << " Action:" << action.property.object() + << action.property.name() << action.toValue; } } - foreach(const Action &action, modList) { - if (action.event) - action.event->execute(); - else - action.property.write(action.toValue); - } - if (!trans) - d->applyBindings(); //### merge into above foreach? + d->transitionManager.transition(applyList, trans); } -QML_DEFINE_TYPE(QmlStateOperation,StateOperation) +QML_DEFINE_NOCREATE_TYPE(QmlStateOperation) QmlStateOperation::ActionList QmlStateOperation::actions() { return ActionList(); diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 0b8d82a..7532430 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -59,16 +59,23 @@ class Action { public: Action(); + Action(QObject *, const QString &, const QVariant &); + + bool restore:1; + bool actionDone:1; QmlMetaProperty property; - bool restore; QVariant fromValue; QVariant toValue; - QString fromBinding; - QString toBinding; - QmlBindableValue *bv; + + QmlBindableValue *fromBinding; + QmlBindableValue *toBinding; ActionEvent *event; - bool actionDone; + + QObject *specifiedObject; + QString specifiedProperty; + + void deleteFromBinding(); }; class ActionEvent @@ -79,28 +86,6 @@ public: virtual void execute(); }; -class RevertAction -{ -public: - RevertAction(const Action &a, bool from = true) : bv(0) - { - property = a.property; - if (from) { - value = a.fromValue; - binding = a.fromBinding; - } else { - value = a.toValue; - binding = a.toBinding; - } - bv = a.bv; - } - - QmlMetaProperty property; - QVariant value; - QString binding; - QmlBindableValue *bv; -}; - class QmlStateGroup; class Q_DECLARATIVE_EXPORT QmlStateOperation : public QObject { @@ -109,14 +94,12 @@ public: QmlStateOperation(QObject *parent = 0) : QObject(parent) {} typedef QList<Action> ActionList; - typedef QList<RevertAction> RevertActionList; virtual ActionList actions(); protected: QmlStateOperation(QObjectPrivate &dd, QObject *parent = 0); }; -QML_DECLARE_TYPE(QmlStateOperation) typedef QmlStateOperation::ActionList QmlStateActions; @@ -166,10 +149,12 @@ private: Q_DISABLE_COPY(QmlState) friend class QmlTransitionPrivate; }; -QML_DECLARE_TYPE(QmlState) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlStateOperation) +QML_DECLARE_TYPE(QmlState) + QT_END_HEADER #endif // QMLSTATE_H diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index da8fdcd..414ec08 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -42,34 +42,72 @@ #ifndef QMLSTATE_P_H #define QMLSTATE_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 <QtDeclarative/qmlstate.h> #include <private/qobject_p.h> #include <private/qmlanimation_p.h> +#include <private/qmltransitionmanager_p.h> QT_BEGIN_NAMESPACE +class SimpleAction +{ +public: + enum State { StartState, EndState }; + SimpleAction(const Action &a, State state = StartState) + { + property = a.property; + specifiedObject = a.specifiedObject; + specifiedProperty = a.specifiedProperty; + if (state == StartState) { + value = a.fromValue; + binding = property.binding(); + } else { + value = a.toValue; + binding = a.toBinding; + } + } + + QmlMetaProperty property; + QVariant value; + QmlBindableValue *binding; + QObject *specifiedObject; + QString specifiedProperty; +}; + class QmlStatePrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlState) public: QmlStatePrivate() - : when(0), transition(0), inState(false), group(0) {} + : when(0), inState(false), group(0) {} + + typedef QList<SimpleAction> SimpleActionList; QString name; QmlBindableValue *when; QmlConcreteList<QmlStateOperation *> operations; - QmlTransition *transition; - QmlStateOperation::RevertActionList revertList; + + QmlTransitionManager transitionManager; + + SimpleActionList revertList; QList<QmlMetaProperty> reverting; - QmlStateOperation::RevertActionList completeList; - QmlStateOperation::ActionList bindingsList; QString extends; mutable bool inState; QmlStateGroup *group; QmlStateOperation::ActionList generateActionList(QmlStateGroup *) const; - void applyBindings(); void complete(); }; diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 57ccd37..2b1cf7d 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -45,8 +45,8 @@ #include "qmltransition.h" #include <QtCore/qdebug.h> - QT_BEGIN_NAMESPACE + DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); QML_DEFINE_TYPE(QmlStateGroup,StateGroup) diff --git a/src/declarative/util/qmlstategroup.h b/src/declarative/util/qmlstategroup.h index 237b60e..a817bd0 100644 --- a/src/declarative/util/qmlstategroup.h +++ b/src/declarative/util/qmlstategroup.h @@ -85,10 +85,11 @@ private: friend class QmlState; void updateAutoState(); }; -QML_DECLARE_TYPE(QmlStateGroup) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlStateGroup) + QT_END_HEADER #endif // QMLSTATEGROUP_H diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 02b54f8..5bb2cb6 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -204,229 +204,4 @@ QmlRunScript::ActionList QmlRunScript::actions() return rv; } -/*! - \qmlclass SetProperty QmlSetProperty - \brief The SetProperty element describes a new property value or binding for a state. - - The code below changes the position of the Rect depending upon - the current state: - - \code - Rect { - id: myrect - width: 50 - height: 50 - color: "red" - } - - states: [ - State { - name: "Position1" - SetProperty { - target: myrect - property: "x" - value: 150 - } - SetProperty { - target: myrect - property: "y" - value: 50 - } - }, - State { - name: "Position2" - SetProperty { - target: myrect - property: "y" - value: 200 - } - } - ] - \endcode - - \sa SetProperties -*/ - -/*! - \internal - \class QmlSetProperty - \brief The QmlSetProperty class describes a new property value or binding for a state. - - \ingroup group_states - - \sa QmlSetProperties -*/ - -class QmlSetPropertyPrivate : public QObjectPrivate -{ -public: - QmlSetPropertyPrivate() : obj(0) {} - - QObject *obj; - QString prop; - QVariant value; - QString binding; -}; - -QML_DEFINE_TYPE(QmlSetProperty,SetProperty) - -QmlSetProperty::QmlSetProperty(QObject *parent) - : QmlStateOperation(*(new QmlSetPropertyPrivate), parent) -{ -} - -QmlSetProperty::~QmlSetProperty() -{ -} - -/*! - \qmlproperty Object SetProperty::target - This property holds the object the property to change belongs to -*/ - -/*! - \property QmlSetProperty::target - \brief the object the property to change belongs to -*/ -QObject *QmlSetProperty::object() -{ - Q_D(QmlSetProperty); - return d->obj; -} - -void QmlSetProperty::setObject(QObject *o) -{ - Q_D(QmlSetProperty); - d->obj = o; -} - -/*! - \qmlproperty string SetProperty::property - This property holds the name of the property to change -*/ - -/*! - \property QmlSetProperty::property - \brief the name of the property to change -*/ -QString QmlSetProperty::property() const -{ - Q_D(const QmlSetProperty); - return d->prop; -} - -void QmlSetProperty::setProperty(const QString &p) -{ - Q_D(QmlSetProperty); - d->prop = p; -} - -/*! - \qmlproperty variant SetProperty::value - This property holds the value to assign to the property - - You should set either a \c value or a \c binding, but not both. -*/ - -/*! - \property QmlSetProperty::value - \brief the value to assign to the property - - You should set either a value or a binding, not both. -*/ -QVariant QmlSetProperty::value() const -{ - Q_D(const QmlSetProperty); - return d->value; -} - -void QmlSetProperty::setValue(const QVariant &v) -{ - Q_D(QmlSetProperty); - d->value = v; -} - -/*! - \qmlproperty string SetProperty::binding - This property holds the binding to assign to the property - - You should set either a \c value or a \c binding, but not both. -*/ - -/*! - \property QmlSetProperty::binding - \brief the binding to assign to the property - - You should set either a value or a binding, not both. -*/ -QString QmlSetProperty::binding() const -{ - Q_D(const QmlSetProperty); - return d->binding; -} - -void QmlSetProperty::setBinding(const QString &binding) -{ - Q_D(QmlSetProperty); - d->binding = binding; -} - -QmlSetProperty::ActionList QmlSetProperty::actions() -{ - Q_D(QmlSetProperty); - if (!d->obj) - return ActionList(); - - QObject *obj = d->obj; - QString propName = d->prop; - - if (d->prop.contains(QLatin1Char('.'))) { //handle dot properties - QStringList str = d->prop.split(QLatin1Char('.')); - for (int ii = 0; ii < str.count()-1; ++ii) { - const QString &s = str.at(ii); - QmlMetaProperty prop(obj, s); - if (!prop.isValid()) { - qmlInfo(this) << obj->metaObject()->className() - << "has no property named" << s; - return ActionList(); - } - QVariant v = prop.read(); - obj = QmlMetaType::toQObject(v); - if (!obj) { - qmlInfo(this) << "Unable to coerce value property" - << s << "into a QObject"; - return ActionList(); - } - } - propName = str.last(); - } - - QmlMetaProperty prop(obj, propName); - if (!prop.isValid()) { - qmlInfo(this) << obj->metaObject()->className() - << "has no property named" << propName; - return ActionList(); - }else if (!prop.isWritable()){ - qmlInfo(this) << obj->metaObject()->className() << propName - << "is not a writable property and cannot be set."; - return ActionList(); - } - QVariant cur = prop.read(); - - Action a; - a.property = prop; - a.fromValue = cur; - a.toValue = d->value; - if (!d->binding.isEmpty()) { - QmlBindableValue *bv = prop.binding(); - if (bv) { - a.fromBinding = bv->expression(); - a.bv = bv; - } - } - a.toBinding = d->binding; - - return ActionList() << a; -} - QT_END_NAMESPACE diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h index c7a6d42..221373b 100644 --- a/src/declarative/util/qmlstateoperations.h +++ b/src/declarative/util/qmlstateoperations.h @@ -70,7 +70,6 @@ public: virtual ActionList actions(); }; -QML_DECLARE_TYPE(QmlParentChange) class QmlRunScriptPrivate; class Q_DECLARATIVE_EXPORT QmlRunScript : public QmlStateOperation, public ActionEvent @@ -95,38 +94,12 @@ public: virtual void execute(); }; -QML_DECLARE_TYPE(QmlRunScript) - -class QmlSetPropertyPrivate; -class Q_DECLARATIVE_EXPORT QmlSetProperty : public QmlStateOperation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlSetProperty) - - 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(QString binding READ binding WRITE setBinding) - -public: - QmlSetProperty(QObject *parent=0); - ~QmlSetProperty(); - - QObject *object(); - void setObject(QObject *); - QString property() const; - void setProperty(const QString &); - QVariant value() const; - void setValue(const QVariant &); - QString binding() const; - void setBinding(const QString&); - - virtual ActionList actions(); -}; -QML_DECLARE_TYPE(QmlSetProperty) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlParentChange) +QML_DECLARE_TYPE(QmlRunScript) + QT_END_HEADER #endif // QMLSTATEOPERATIONS_H diff --git a/src/declarative/timeline/qmltimeline.cpp b/src/declarative/util/qmltimeline.cpp index dcc8745..5ba310d 100644 --- a/src/declarative/timeline/qmltimeline.cpp +++ b/src/declarative/util/qmltimeline.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "qmltimeline.h" +#include "qmltimeline_p.h" #include <QDebug> #include <QMutex> #include <QThread> diff --git a/src/declarative/timeline/qmltimeline.h b/src/declarative/util/qmltimeline_p.h index 627ec79..abed80a 100644 --- a/src/declarative/timeline/qmltimeline.h +++ b/src/declarative/util/qmltimeline_p.h @@ -42,16 +42,23 @@ #ifndef QMLTIMELINE_H #define QMLTIMELINE_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 <QtCore/QObject> #include <QtCore/QAbstractAnimation> #include <QtDeclarative/qfxglobal.h> -QT_BEGIN_HEADER - QT_BEGIN_NAMESPACE -QT_MODULE(Declarative) - class QEasingCurve; class QmlTimeLineValue; class QmlTimeLineEvent; @@ -183,8 +190,35 @@ private: QmlTimeLineObject *d2; }; -QT_END_NAMESPACE +template<class T> +class QmlTimeLineValueProxy : public QmlTimeLineValue +{ +public: + QmlTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) + : QmlTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0) + { + Q_ASSERT(_class); + } + + QmlTimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.) + : QmlTimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func) + { + Q_ASSERT(_class); + } + + virtual void setValue(qreal v) + { + QmlTimeLineValue::setValue(v); + if (_setFunctionReal) (_class->*_setFunctionReal)(v); + else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v); + } -QT_END_HEADER +private: + T *_class; + void (T::*_setFunctionReal)(qreal); + void (T::*_setFunctionInt)(int); +}; + +QT_END_NAMESPACE #endif diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index 5931075..d793c7d 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -46,6 +46,7 @@ #include "qmlstateoperations.h" #include "qmlanimation.h" #include "qmlanimation_p.h" +#include "qmltransitionmanager_p.h" #include <QParallelAnimationGroup> QT_BEGIN_NAMESPACE @@ -92,7 +93,7 @@ public: bool reversed; bool reversible; ParallelAnimationWrapper *group; - QmlState *endState; + QmlTransitionManager *endState; void init() { @@ -103,7 +104,7 @@ public: void complete() { - endState->d_func()->complete(); + endState->complete(); } class AnimationList : public QmlConcreteList<QmlAbstractAnimation *> @@ -161,7 +162,7 @@ void QmlTransition::setReversed(bool r) void QmlTransition::prepare(QmlStateOperation::ActionList &actions, QList<QmlMetaProperty> &after, - QmlState *endState) + QmlTransitionManager *endState) { Q_D(QmlTransition); @@ -176,6 +177,7 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, } d->endState = endState; + d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); d->group->start(); } diff --git a/src/declarative/util/qmltransition.h b/src/declarative/util/qmltransition.h index 4462b4c..8ccb0ec 100644 --- a/src/declarative/util/qmltransition.h +++ b/src/declarative/util/qmltransition.h @@ -55,6 +55,7 @@ QT_MODULE(Declarative) class QmlAbstractAnimation; class QmlTransitionPrivate; +class QmlTransitionManager; class Q_DECLARATIVE_EXPORT QmlTransition : public QObject { Q_OBJECT @@ -83,15 +84,16 @@ public: void prepare(QmlStateOperation::ActionList &actions, QList<QmlMetaProperty> &after, - QmlState *endState); + QmlTransitionManager *end); void setReversed(bool r); void stop(); }; -QML_DECLARE_TYPE(QmlTransition) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlTransition) + QT_END_HEADER #endif // QMLTRANSITION_H diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp new file mode 100644 index 0000000..5e86b73 --- /dev/null +++ b/src/declarative/util/qmltransitionmanager.cpp @@ -0,0 +1,225 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtDeclarative/qmlbindablevalue.h> +#include <private/qmltransitionmanager_p.h> +#include <private/qmlstate_p.h> + +QT_BEGIN_NAMESPACE + +class QmlTransitionManagerPrivate +{ +public: + QmlTransitionManagerPrivate() + : state(0), transition(0) {} + + void applyBindings(); + typedef QList<SimpleAction> SimpleActionList; + QmlState *state; + QmlTransition *transition; + QmlStateOperation::ActionList bindingsList; + SimpleActionList completeList; +}; + +QmlTransitionManager::QmlTransitionManager() +: d(new QmlTransitionManagerPrivate) +{ +} + +void QmlTransitionManager::setState(QmlState *s) +{ + d->state = s; +} + +QmlTransitionManager::~QmlTransitionManager() +{ + delete d; d = 0; +} + +void QmlTransitionManager::complete() +{ + d->applyBindings(); + + for (int ii = 0; ii < d->completeList.count(); ++ii) { + const QmlMetaProperty &prop = d->completeList.at(ii).property; + prop.write(d->completeList.at(ii).value); + } + + d->completeList.clear(); + + if (d->state) + static_cast<QmlStatePrivate*>(QObjectPrivate::get(d->state))->complete(); +} + +void QmlTransitionManagerPrivate::applyBindings() +{ + foreach(const Action &action, bindingsList) { + if (action.toBinding) { + action.property.setBinding(action.toBinding); + action.toBinding->forceUpdate(); + } + } + + bindingsList.clear(); +} + +void QmlTransitionManager::transition(const QList<Action> &list, + QmlTransition *transition) +{ + cancel(); + + QmlStateOperation::ActionList applyList = list; + // Determine which actions are binding changes. + foreach(const Action &action, applyList) { + if (action.toBinding) { + d->bindingsList << action; + if (action.fromBinding) + action.property.setBinding(0); // Disable current binding + } else if (action.fromBinding) { + action.property.setBinding(0); // Disable current binding + } + } + + // 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 + foreach(const Action &action, applyList) { + if (action.toBinding) { + action.property.setBinding(action.toBinding); + action.toBinding->forceUpdate(); + } else if (!action.event) { + action.property.write(action.toValue); + } + } + + // Read all the end values for binding changes + for (int ii = 0; ii < applyList.size(); ++ii) { + Action *action = &applyList[ii]; + if (action->event) + continue; + + const QmlMetaProperty &prop = action->property; + if (action->toBinding) + action->toValue = prop.read(); + } + + // Revert back to the original values + foreach(const Action &action, applyList) { + if (action.event) + continue; + + if (action.toBinding) + action.property.setBinding(0); + + action.property.write(action.fromValue); + } + } + + if (transition) { + QList<QmlMetaProperty> 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 Action &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 << + SimpleAction(action, SimpleAction::EndState); + + applyList.removeAt(ii); + --ii; + } + + } + } + } + + // Any actions remaining have not been handled by the transition and should + // be applied immediately. We skip applying transitions, as they are all + // applied at the end in applyBindings() to avoid any nastiness mid + // transition + foreach(const Action &action, applyList) { + if (action.event) { + action.event->execute(); + } else { + action.property.write(action.toValue); + } + } + if (!transition) + d->applyBindings(); //### merge into above foreach? + +} + +void QmlTransitionManager::cancel() +{ + if (d->transition) { + // ### this could potentially trigger a complete in rare circumstances + d->transition->stop(); + d->transition = 0; + } + + d->bindingsList.clear(); + d->completeList.clear(); + +} + +QT_END_NAMESPACE diff --git a/src/declarative/fx/qfxcontentwrapper_p.h b/src/declarative/util/qmltransitionmanager_p.h index a75fa1e..74a3950 100644 --- a/src/declarative/fx/qfxcontentwrapper_p.h +++ b/src/declarative/util/qmltransitionmanager_p.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QFXCONTENTWRAPPER_P_H -#define QFXCONTENTWRAPPER_P_H +#ifndef QMLTRANSITIONMANAGER_P_H +#define QMLTRANSITIONMANAGER_P_H // // W A R N I N G @@ -53,19 +53,33 @@ // We mean it. // -#include "qfxitem_p.h" -#include "qfxcontentwrapper.h" - +#include <QtDeclarative/qmlstateoperations.h> QT_BEGIN_NAMESPACE -class QFxContentWrapperPrivate : public QFxItemPrivate + +class QmlStatePrivate; +class QmlTransitionManagerPrivate; +class QmlTransitionManager { - Q_DECLARE_PUBLIC(QFxContentWrapper) public: - QFxContentWrapperPrivate() { } + QmlTransitionManager(); + ~QmlTransitionManager(); + + void transition(const QList<Action> &, QmlTransition *transition); + + void cancel(); - QList<QFxItem *> _content; +private: + Q_DISABLE_COPY(QmlTransitionManager); + QmlTransitionManagerPrivate *d; + + void complete(); + void setState(QmlState *); + + friend class QmlState; + friend class QmlTransitionPrivate; }; QT_END_NAMESPACE -#endif // QFXCONTENTWRAPPER_P_H + +#endif // QMLTRANSITIONMANAGER_P_H diff --git a/src/declarative/util/qperformancelog.cpp b/src/declarative/util/qperformancelog.cpp index 8065f9d..8e11997 100644 --- a/src/declarative/util/qperformancelog.cpp +++ b/src/declarative/util/qperformancelog.cpp @@ -39,10 +39,11 @@ ** ****************************************************************************/ -#include "qperformancelog.h" +#include "qperformancelog_p.h" #include <QHash> #include <QDebug> +QT_BEGIN_NAMESPACE #ifdef Q_ENABLE_PERFORMANCE_LOG @@ -175,3 +176,5 @@ void QPerformanceLog::clear() } #endif // Q_ENABLE_PERFORMANCE_LOG + +QT_END_NAMESPACE diff --git a/src/declarative/util/qperformancelog.h b/src/declarative/util/qperformancelog_p.h index 3203685..6655a8d 100644 --- a/src/declarative/util/qperformancelog.h +++ b/src/declarative/util/qperformancelog_p.h @@ -43,6 +43,9 @@ #define QPERFORMANCELOG_H #include <QtCore/qdatetime.h> + +QT_BEGIN_NAMESPACE + namespace QPerformanceLog { Q_DECLARATIVE_EXPORT void displayData(); @@ -133,4 +136,6 @@ namespace QPerformanceLog #endif // Q_ENABLE_PERFORMANCE_LOG +QT_END_NAMESPACE + #endif // QPERFORMANCELOG_H diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri index 030a44e..aae10af 100644 --- a/src/declarative/util/util.pri +++ b/src/declarative/util/util.pri @@ -6,44 +6,42 @@ SOURCES += \ util/qmlpackage.cpp \ util/qmlscript.cpp \ util/qmlanimation.cpp \ - util/qmlbehaviour.cpp \ util/qmlfont.cpp \ util/qmlfollow.cpp \ util/qmlstate.cpp\ + util/qmltransitionmanager.cpp \ util/qmlstateoperations.cpp \ util/qmlsetproperties.cpp \ util/qmlstategroup.cpp \ util/qmltransition.cpp \ - util/qbindablemap.cpp \ - util/qmldatetimeformatter.cpp \ util/qmllistmodel.cpp\ util/qmllistaccessor.cpp \ util/qmlopenmetaobject.cpp \ + util/qmltimeline.cpp \ util/qmlbind.cpp HEADERS += \ util/qfxview.h \ - util/qfxperf.h \ + util/qfxperf_p.h \ util/qfxglobal.h \ - util/qperformancelog.h \ + util/qperformancelog_p.h \ util/qmlconnection.h \ util/qmlpackage.h \ util/qmlscript.h \ util/qmlanimation.h \ util/qmlanimation_p.h \ - util/qmlbehaviour.h \ util/qmlfont.h \ util/qmlfollow.h \ util/qmlstate.h\ util/qmlstateoperations.h \ util/qmlsetproperties.h \ util/qmlstate_p.h\ + util/qmltransitionmanager_p.h \ util/qmlstategroup.h \ util/qmltransition.h \ - util/qbindablemap.h \ - util/qmldatetimeformatter.h \ util/qmllistmodel.h\ util/qmllistaccessor.h \ util/qmlopenmetaobject.h \ util/qmlnullablevalue_p.h \ + util/qmltimeline_p.h \ util/qmlbind.h diff --git a/src/declarative/widgets/graphicslayouts.h b/src/declarative/widgets/graphicslayouts.h index 303f749..ab8ad90 100644 --- a/src/declarative/widgets/graphicslayouts.h +++ b/src/declarative/widgets/graphicslayouts.h @@ -52,9 +52,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) - class QGraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem { Q_OBJECT @@ -64,7 +61,6 @@ public: virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; }; -QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) //TODO: // -content margins @@ -120,7 +116,6 @@ private: ChildList _children; }; -QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) //TODO: // -content margins @@ -181,10 +176,15 @@ private: ChildList _children; }; -QML_DECLARE_TYPE(QGraphicsGridLayoutObject) - -#endif // GRAPHICSLAYOUTS_H QT_END_NAMESPACE +QML_DECLARE_INTERFACE(QGraphicsLayoutItem) +QML_DECLARE_INTERFACE(QGraphicsLayout) +QML_DECLARE_TYPE(QGraphicsLinearLayoutStretchItemObject) +QML_DECLARE_TYPE(QGraphicsLinearLayoutObject) +QML_DECLARE_TYPE(QGraphicsGridLayoutObject) + QT_END_HEADER + +#endif // GRAPHICSLAYOUTS_H diff --git a/src/declarative/widgets/graphicswidgets.cpp b/src/declarative/widgets/graphicswidgets.cpp index 86509f5..e7d01e3 100644 --- a/src/declarative/widgets/graphicswidgets.cpp +++ b/src/declarative/widgets/graphicswidgets.cpp @@ -168,6 +168,6 @@ QML_DEFINE_EXTENDED_TYPE(QGraphicsWidget,QGraphicsWidget,QGraphicsWidgetDeclarat QML_DEFINE_INTERFACE(QGraphicsItem) -#include "graphicswidgets.moc" - QT_END_NAMESPACE + +#include "graphicswidgets.moc" diff --git a/src/declarative/widgets/graphicswidgets.h b/src/declarative/widgets/graphicswidgets.h index e29f1d6..8147400 100644 --- a/src/declarative/widgets/graphicswidgets.h +++ b/src/declarative/widgets/graphicswidgets.h @@ -48,13 +48,15 @@ #include <QtGui/QGraphicsWidget> #include <QtGui/QGraphicsItem> -QT_BEGIN_NAMESPACE +QT_BEGIN_HEADER + +QT_MODULE(Declarative) QML_DECLARE_TYPE(QGraphicsView) QML_DECLARE_TYPE_HASMETATYPE(QGraphicsScene) QML_DECLARE_TYPE(QGraphicsWidget) QML_DECLARE_INTERFACE_HASMETATYPE(QGraphicsItem) -QT_END_NAMESPACE +QT_END_HEADER #endif // GRAPHICSWIDGETS_H |